Commit 5855a8a1 authored by wzy's avatar wzy

fix: 关联供应商回显修改

parent 9282289c
......@@ -25,10 +25,10 @@ function useGetDetailCommon<T extends GetProductGoodsGetGoodsProcessDetailRespon
const [vendor, setVendor] = useState('')
const getVentor = (vt) => {
getMemberAbilityMaintenanceCreateMterielPage().then(res => {
getMemberAbilityMaintenanceCreateMterielPage({ memberGlobalMqId: vt }).then(res => {
if (res.code === 1000) {
const val = res.data.data?.find(v => v.memberGlobalMqId === vt)
setVendor(val?.name)
setVendor(res.data.data?.[0]?.name)
}
})
}
......@@ -85,7 +85,7 @@ function useGetDetailCommon<T extends GetProductGoodsGetGoodsProcessDetailRespon
const basicInfoList = useMemo(() => {
const show_ = getAuth()?.memberRoleType === RoleEnum.Purchaser;
if (initialValue && !vendor && show_) {
if (initialValue && !vendor && show_ && initialValue?.vendorMemberGlobalMQID) {
getVentor(initialValue?.vendorMemberGlobalMQID)
}
const basicInfoList_ = [
......
......@@ -51,9 +51,9 @@ export const fetchCategoryData = async () => {
}
}
export const fetchBrand = async (name?: string) => {
export const fetchBrand = async () => {
try {
const { data, code } = await getProductSelectGetAllSelectBrand({name});
const { data, code } = await getProductSelectGetAllSelectBrand();
if (code === 1000) {
return data;
}
......@@ -62,9 +62,9 @@ export const fetchBrand = async (name?: string) => {
return EMPTY_ARRAY
}
}
export const fetchVendor = async (name?: string) => {
export const fetchVendor = async (param?: Object) => {
try {
const { data, code } = await getMemberAbilityMaintenanceCreateMterielPage({name});
const { data, code } = await getMemberAbilityMaintenanceCreateMterielPage(param);
if (code === 1000) {
return data.data;
}
......
......@@ -95,6 +95,31 @@ const MaterialAdd: React.FC<IProps> = (props) => {
})
}, [])
const searchFn = (fn, key: string, key_val: string, param?, enum_ = []) => {
if (timer) {
clearTimeout(timer)
timer = null
}
timer = setTimeout(() => {
fn(param).then(data => {
formActions.setFieldState(key, state => {
state.props.enum = [
...enum_,
...data.map((item) => ({
label: item['name'],
value: item[key_val]
}))
];
state.originData = [
...enum_, ...data
];
})
})
}, 300);
}
const handleVendor = async (name?) => {
searchFn(fetchVendor, 'vendor', 'memberGlobalMqId', { name })
}
useEffect(() => {
if (!formatInitialValue) {
return
......@@ -117,13 +142,23 @@ const MaterialAdd: React.FC<IProps> = (props) => {
})
}
setVendor({
vendorMemberId: formatInitialValue.vendorMemberId,
vendorMemberRoleId: formatInitialValue.vendorMemberRoleId,
vendorMemberGlobalMQID: formatInitialValue.vendorMemberGlobalMQID,
vendorName: formatInitialValue.vendorName,
})
if (formatInitialValue.vendorMemberGlobalMQID) {
formActions.getFieldState('vendor', state => {
const enum_ = state.props.enum
if (enum_.length) {
const find_ = enum_.findIndex(val => val.memberGlobalMqId === formatInitialValue.vendorMemberGlobalMQID)
if (find_ === -1) {
searchFn(fetchVendor, 'vendor', 'memberGlobalMqId', { memberGlobalMqId: formatInitialValue.vendorMemberGlobalMQID }, enum_)
}
}
})
setVendor({
vendorMemberId: formatInitialValue.vendorMemberId,
vendorMemberRoleId: formatInitialValue.vendorMemberRoleId,
vendorMemberGlobalMQID: formatInitialValue.vendorMemberGlobalMQID,
vendorName: formatInitialValue.vendorName,
})
}
// if (!isAdd && !isEdit) {
// /* 最小单位(包) */
// if (formatInitialValue?.miniUnit) {
......@@ -507,29 +542,6 @@ const MaterialAdd: React.FC<IProps> = (props) => {
});
}
};
const searchFn = (fn, key: string, key_val: string, name?: string) => {
if (timer) {
clearTimeout(timer)
timer = null
}
timer = setTimeout(() => {
fn(name).then(data => {
formActions.setFieldState(key, state => {
state.props.enum = data.map((item) => ({
label: item['name'],
value: item[key_val]
}));
state.originData = data;
})
})
}, 300);
}
const handleBrand = async (name?: string) => {
searchFn(fetchBrand, 'brand', 'id', name)
}
const handleVendor = async (name?: string) => {
searchFn(fetchVendor, 'vendor', 'memberGlobalMqId', name)
}
return (
<AnchorPage
title={renderTitle()}
......@@ -570,7 +582,6 @@ const MaterialAdd: React.FC<IProps> = (props) => {
// className={styles.startText}
startText: <span>发货地</span>,
limitDecimalPoint,
handleBrand,
handleVendor
}}
effects={($, actions) => {
......
......@@ -373,7 +373,6 @@ const brand = {
'x-component-props': {
allowClear: true,
showSearch: true,
onSearch: '{{handleBrand}}',
optionFilterProp: 'children',
filterOption: (input, option) => (option!.children as unknown as string).toLowerCase().includes(input.toLowerCase())
},
......
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