Commit 3529ed15 authored by leimo's avatar leimo

Merge branch '220418-fix' into 'v2-220418'

fix: 进销存物料组相关问题 See merge request linkseeks-design/pro-platform!264
parents e212c7ae 0206fff1
......@@ -5,14 +5,14 @@
*/
import React, { useEffect, useState } from 'react'
import AnchorPage, { AnchorsItem } from '@/components/AnchorPage'
import { history, useLocation } from 'umi'
import { history } from 'umi'
import { Circulation, ConfirmDeliveryPlan, DeliveryNoticeDetaitlsAnchors, Purchaser, SubmitDeliveryPlan, Supplier, BaseInfo as base_Info, NoticeNo, BuyerLabel, NoticeSummary, ExternalState, ShippingInfo, DeliveryDate, DeliveryTime, ReceivingAddress, DeliveryList, ExternalRoamRecord, } from '../../constants'
import BaseInfo from '@/components/BaseInfo/BaseInfo'
import StandardTable from '@/components/StandardTable'
import { Steps, Table, Tag } from 'antd'
import { DeliveryMaterialsTableColumn, ExternalRoamRecordTableColumn } from '../../constants/page-table-column'
import { getOrderDeliveryNoticeOrderDetail, getOrderDeliveryNoticeOrderDetailPage, getOrderDeliveryNoticeOrderDeliveryHistory } from '@/services/OrderNewV2Api'
import { ORDER_TYPE, TAG_STATUS_COLOR, OUTER_STATUS, STATUS_NAME } from '../../constants/deliveryNotice'
import { STATUS_NAME } from '../../constants/deliveryNotice'
const DeliveryNoticeManagementAwaitSRMDetails: React.FC = () => {
......
......@@ -8,6 +8,11 @@
import { useBusinessEffects } from './useBusinessEffects';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { getProductInvoicesTypeAll, getProductWarehouseAll } from '@/services/ProductV2Api';
import { getProductMaterialGroupTree } from "@/services/ProductV2Api"
import { createFormActions, FormEffectHooks, FormPath } from "@formily/antd"
const { onFormMount$ } = FormEffectHooks
const EMPTY_ARRAY = []
// 获取单据类型
const fetchInvoicesType = (): Promise<any[]> => {
......@@ -43,3 +48,31 @@ export const createEffects = (context, actions) => {
useAsyncSelect('invoicesTypeId', fetchInvoicesType, ['name', 'id']);
useAsyncSelect('warehouseId', fetchInventory, ['name', 'id']);
};
export const useAsyncCascader = async (name, service: () => Promise<any[]>) => {
const { setFieldState } = createFormActions()
onFormMount$().subscribe(() => {
service().then(res => {
setFieldState(name, state => {
FormPath.setIn(state, 'props.x-component-props.options', res)
})
}).catch(err => {
setFieldState(name, state => {
FormPath.setIn(state, 'props.x-component-props.options', [])
})
})
})
}
export const fetchTreeData = async () => {
try {
const { data, code } = await getProductMaterialGroupTree({ rootNodeId: '0' });
if (code === 1000) {
return data;
}
return EMPTY_ARRAY
} catch {
return EMPTY_ARRAY
}
}
import React, { useState, useEffect } from 'react';
import { Button, Card, Spin } from 'antd';
import { Button, Card, Spin, Cascader } from 'antd';
import { DeleteOutlined } from '@ant-design/icons';
import { Radio, ArrayTable } from '@formily/antd-components';
import { getIntl, history, Prompt } from 'umi';
......@@ -23,7 +23,7 @@ import CustomCategorySearch from '@/components/NiceForm/components/CustomCategor
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { addBillSchema, goodsSearchSchema } from './schema';
import { createEffects } from './effects';
import { createEffects, useAsyncCascader, fetchTreeData } from './effects';
import EllipsisText from '../EllipsisText';
const intl = getIntl();
......@@ -215,6 +215,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
goodsNo: item.code,
goodsName: item.name,
goodsGroup: item.materialGroup?.name,
materialGroupId: item.materialGroup?.id,
specifications: item.type,
category: item.customerCategory?.name || '',
brand: item.brand?.name || '',
......@@ -236,8 +237,11 @@ const BillsForm: React.FC<BillsFormProps> = ({
// 获取货品列表
const fetchProductList = async params => {
const materialGroupId = params.materialGroupId ? params.materialGroupId[params.materialGroupId.length - 1] : undefined
const res = await getProductGoodsGetGoodsList({
...params,
materialGroupId,
ids: [99]
});
if (res.code === 1000) {
return res.data;
......@@ -343,8 +347,10 @@ const BillsForm: React.FC<BillsFormProps> = ({
Submit,
SearchSelect,
CustomCategorySearch,
Cascader
},
effects: ($, actions) => {
useAsyncCascader('materialGroupId', fetchTreeData)
useStateFilterSearchLinkageEffect(
$,
actions,
......
......@@ -21,6 +21,8 @@ import {
} from '@/constants/commodity';
import { PATTERN_MAPS } from '@/constants/regExp';
import { getIntl } from 'umi';
import { getProductSelectGetSelectBrand, getProductSelectGetSelectCustomerCategory } from '@/services/ProductV2Api'
const intl = getIntl();
const orderDetailSchema: ISchema = {
type: 'object',
......@@ -307,6 +309,9 @@ export const addBillSchema: ISchema = {
invoicesCount: {
type: 'string',
title: intl.formatMessage({id: 'stockSellStorage.danjushuliang'}),
'x-props': {
width: 150,
},
'x-component-props': {
allowClear: true,
style: {
......@@ -687,36 +692,62 @@ export const goodsSearchSchema: ISchema = {
allowClear: true,
},
},
// customerCategoryId: {
// type: 'string',
// 'x-component': 'CustomCategorySearch',
// 'x-component-props': {
// placeholder: intl.formatMessage({id: 'stockSellStorage.pinlei'}),
// showSearch: true,
// notFoundContent: null,
// dataoption: [],
// fieldNames: { label: 'title', value: 'id', children: 'children' },
// },
// },
customerCategoryId: {
type: 'string',
'x-component': 'CustomCategorySearch',
'x-component-props': {
placeholder: intl.formatMessage({id: 'stockSellStorage.pinlei'}),
showSearch: true,
notFoundContent: null,
dataoption: [],
fieldNames: { label: 'title', value: 'id', children: 'children' },
},
"x-component": 'SearchSelect',
"x-component-props": {
placeholder: intl.formatMessage({ id: 'detail.purchase.message28' }),
className: 'fixed-ant-selected-down', // 该类强制将显示的下拉框出现在select下, 只有这里出现问题, ??
fetchSearch: getProductSelectGetSelectCustomerCategory,
style: {
width: 160
}
}
},
brandId: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: intl.formatMessage({id: 'stockSellStorage.pinpai'}),
allowClear: true,
},
"x-component": 'SearchSelect',
"x-component-props": {
placeholder: intl.formatMessage({ id: 'detail.purchase.message31' }),
fetchSearch: getProductSelectGetSelectBrand,
style: {
width: 160
}
}
},
materialGroupId: {
type: 'string',
'x-component': 'CustomCategorySearch',
'x-component': 'Cascader',
'x-component-props': {
placeholder: intl.formatMessage({ id: 'commodity.goods.schema.goodsSchema.goodsGroupId' }),
showSearch: true,
notFoundContent: null,
dataoption: [],
placeholder: '物料组',
allowClear: true,
fieldNames: { label: 'title', value: 'id', children: 'children' },
style: { width: '150px' },
showSearch: true
},
},
// materialGroupId: {
// type: 'string',
// 'x-component': 'CustomCategorySearch',
// 'x-component-props': {
// placeholder: intl.formatMessage({ id: 'commodity.goods.schema.goodsSchema.goodsGroupId' }),
// showSearch: true,
// notFoundContent: null,
// dataoption: [],
// fieldNames: { label: 'title', value: 'id', children: 'children' },
// },
// },
submit: {
'x-component': 'Submit',
'x-mega-props': {
......
import React, { useState, useEffect, useRef } from 'react';
import { getIntl, history } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Input, Card, Space, Modal, Button, message } from 'antd';
import { Cascader, Card, Space, Modal, Button, message } from 'antd';
import { SettingOutlined } from '@ant-design/icons';
import StandardTable from '@/components/StandardTable';
import { ColumnType } from 'antd/lib/table/interface';
import EyePreview from '@/components/EyePreview';
import NiceForm from '@/components/NiceForm';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import {
getProductInventoryList,
getProductMaterialGroupTree,
getProductWarehouseAll,
postProductInventorySafetyBatchUpdate,
} from '@/services/ProductV2Api';
......@@ -20,6 +21,7 @@ import { inventorySchema, safetyModalSchema } from './schema';
import styles from './index.less';
import { AuthUrl } from '@/components/AuthButton/AuthUrl';
import AuthButton from '@/components/AuthButton';
const { onFormMount$ } = FormEffectHooks
const formActions = createFormActions();
const modalFormActions = createFormActions();
......@@ -40,6 +42,22 @@ const Inventory: React.FC<{}> = () => {
}
};
const useAsyncCascader = async (name, service: () => Promise<any[]>) => {
const { setFieldState } = createFormActions()
onFormMount$().subscribe(() => {
service().then(res => {
setFieldState(name, state => {
FormPath.setIn(state, 'props.x-component-props.options', res)
})
}).catch(err => {
setFieldState(name, state => {
FormPath.setIn(state, 'props.x-component-props.options', [])
})
})
})
}
const columns: ColumnType<any>[] = [
{
title: intl.formatMessage({ id: 'stockSellStorage.huohao' }),
......@@ -120,8 +138,9 @@ const Inventory: React.FC<{}> = () => {
];
const fetchListData = (params: any) => {
const materialGroupId = params.materialGroupId ? params.materialGroupId[params.materialGroupId.length - 1] : undefined
return new Promise((resolve, reject) => {
getProductInventoryList(params)
getProductInventoryList({ ...params, materialGroupId })
.then(res => {
if (res.code === 1000) {
resolve(res.data);
......@@ -143,6 +162,18 @@ const Inventory: React.FC<{}> = () => {
return [];
};
const fetchTreeData = async () => {
try {
const { data, code } = await getProductMaterialGroupTree({ rootNodeId: '0' });
if (code === 1000) {
return data;
}
return []
} catch {
return []
}
}
// 修改安全库存
const handleSubmit = async values => {
setConfirmLoading(true);
......@@ -203,6 +234,7 @@ const Inventory: React.FC<{}> = () => {
expressionScope={{
controllerBtns,
}}
components={{ Cascader }}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
......@@ -211,6 +243,7 @@ const Inventory: React.FC<{}> = () => {
FORM_FILTER_PATH,
);
useAsyncSelect('warehouseId', fetchInventory);
useAsyncCascader('materialGroupId', fetchTreeData)
}}
schema={inventorySchema}
/>
......
......@@ -87,12 +87,24 @@ export const inventorySchema: ISchema = {
warehouseId: {
type: 'string',
'x-component-props': {
style: { width: '150px' },
placeholder: intl.formatMessage({
id: 'stockSellStorage.cangku',
}),
},
enum: [],
},
materialGroupId: {
type: 'string',
'x-component': 'Cascader',
'x-component-props': {
placeholder: '物料组',
allowClear: true,
fieldNames: { label: 'title', value: 'id', children: 'children' },
style: { width: '150px' },
showSearch: true
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment