Commit 89b1531e authored by xiexiuxing's avatar xiexiuxing

代码优化

parent cea42e18
......@@ -90,27 +90,26 @@ const IncreaseRequisition: React.FC<{}> = () => {
const _orderProductRequests = procurementRenderField(data)
addSchemaAction.setFieldState('deliveryAddressId', state => {
state.props.isDefaultAddress = false;
state.visible = data.deliveryMethod == 1 ? true : false;
state.visible = data.deliveryMethod == 1 && data.deliveryType != 1 ? true : false;
});
addSchemaAction.setFieldState('deliveryAddress', state => {
state.visible = data.deliveryMethod != 1 ? true : false;
state.visible = data.deliveryMethod != 1 || data.deliveryType == 1 ? true : false;
});
if (data.deliveryType) {
if (data.deliveryMethod == 1) {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList.map(item => { return { ...item, disabled: false } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
if (data.deliveryMethod === 1) {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList.map(item => { return { ...item, disabled: item.disabled = item.deliveryTypeName == '直送客户' ? false : true } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
console.log(deliveryTypeListRef.current.deliveryTypeList)
}
if (data.deliveryMethod == 2) {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList.map(item => { return { ...item, disabled: item.disabled = item.deliveryTypeName == '直送客户' ? true : false } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
}
addSchemaAction.setFieldState('deliveryType', state => {
state.visible = true;
});
setdeliveryType(data.deliveryType)
}
if (data.deliveryMethod == 2) {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList.map(item => { return { ...item, disabled: item.disabled = item.deliveryTypeName == '直送客户' ? true : false } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
}
addSchemaAction.setFieldState('deliveryType', state => {
state.visible = true;
});
setdeliveryType(data.deliveryType)
rowvendorMemberInfoRef.current = {
memberId: data.vendorMemberId,
roleId: data.vendorRoleId,
......@@ -214,18 +213,34 @@ const IncreaseRequisition: React.FC<{}> = () => {
const handleOrderMember = () => {
memberRef.current.setVisible(true)
}
// 配送方式
const changeDeliveryType = (e) => {
addSchemaAction.setFieldValue('deliveryType', e.target.value)
setdeliveryType(e.target.value)
const Address = addSchemaAction.getFieldState('deliveryAddressId')
console.log(Address)
const name = Address.value.name ? Address.value.name : Address.value.receiverName;
const addres = Address.value.fullAddress ? Address.value.fullAddress : Address.value.streetName + Address.value.address + Address.value.phone;
console.log(addres, name)
if (Address.value) {
addSchemaAction.setFieldState('deliveryAddress', state => {
state.visible = true;
state.value = name + Address.value.provinceName + Address.value.cityName + Address.value.districtName + addres
});
addSchemaAction.setFieldState('deliveryAddressId', state => {
state.visible = false;
});
}
}
// 自定义组建
const RadioNode = () => {
const value = deliveryTypeList.filter((item) => !item.disabled);
return (
// defaultValue={id ? deliveryType : value ? value.deliveryType : ''}
<Radio.Group onChange={changeDeliveryType} defaultValue={id ? deliveryType : value.length ? value[0].deliveryType : ''}>
<Radio.Group onChange={changeDeliveryType} value={deliveryType} defaultValue={id ? deliveryType : ''}>
<div className={styles.RadioMian}>
{
deliveryTypeList.map((item) => (
......@@ -357,9 +372,8 @@ const IncreaseRequisition: React.FC<{}> = () => {
dataIndex: 'goodsName',
render: (text, record, index) => {
let goodsName = id || text ? enclosureRef.current.list.find(item => item.label === text) : ''
console.log(goodsName)
return (
<Select style={{ width: 230 }} defaultValue={id || goodsName ? goodsName.label : ''} onChange={(value) => handleFirstChange(value, index)}>
<Select style={{ width: 230 }} defaultValue={id || goodsName ? goodsName?.label : ''} onChange={(value) => handleFirstChange(value, index)}>
{
Object.keys(enclosureRef.current).length && enclosureRef.current.list.map((item: any) => {
return (
......@@ -388,6 +402,48 @@ const IncreaseRequisition: React.FC<{}> = () => {
}, 500)
}
const onChangeAddress = (res) => {
if (res.values[1]?.title === "物流") {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList.map(item => { return { ...item, disabled: item.disabled = item.deliveryTypeName == '直送客户' ? false : true } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
addSchemaAction.setFieldState('deliveryAddress', state => {
state.visible = false;
});
setdeliveryType('')
addSchemaAction.setFieldValue('deliveryType', "")
addSchemaAction.setFieldState('deliveryAddressId', state => {
state.visible = true;
});
addSchemaAction.setFieldState('deliveryType', state => {
state.visible = true;
});
return;
} if (res.values[1]?.title === "自提") {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList.map(item => { return { ...item, disabled: item.disabled = item.deliveryTypeName == '直送客户' ? true : false } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
addSchemaAction.setFieldState('deliveryType', state => {
state.visible = true;
});
addSchemaAction.setFieldValue('deliveryType', "")
addSchemaAction.setFieldValue('deliveryAddressId', "")
addSchemaAction.setFieldState('deliveryAddressId', state => {
state.visible = false;
});
setdeliveryType('')
return;
} if (res.values[1]?.title === "无需配送") {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList && deliveryTypeListRef.current?.deliveryTypeList.map(item => { return { ...item, disabled: true } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
addSchemaAction.setFieldState('deliveryAddress', state => {
state.visible = false;
});
addSchemaAction.setFieldState('deliveryAddressId', state => {
state.visible = false;
});
setdeliveryType('')
addSchemaAction.setFieldValue('deliveryType', "")
}
}
return (<div className={styles['mian']}>
<FormDetailContext.Provider value={providerValue}>
<FormDetailHeader
......@@ -428,42 +484,7 @@ const IncreaseRequisition: React.FC<{}> = () => {
formContext.useAttachmentChangeForContext(ctx)
$('onFieldChange', 'deliveryMethod').subscribe(res => {
if (res.values[1]?.title === "物流") {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList.map(item => { return { ...item, disabled: item.disabled = item.deliveryTypeName == '直送客户' ? false : true } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
addSchemaAction.setFieldState('deliveryAddress', state => {
state.visible = false;
});
addSchemaAction.setFieldValue('deliveryType', "")
addSchemaAction.setFieldState('deliveryAddressId', state => {
state.visible = true;
});
addSchemaAction.setFieldState('deliveryType', state => {
state.visible = true;
});
} if (res.values[1]?.title === "自提") {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList.map(item => { return { ...item, disabled: item.disabled = item.deliveryTypeName == '直送客户' ? true : false } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
addSchemaAction.setFieldState('deliveryType', state => {
state.visible = true;
});
addSchemaAction.setFieldValue('deliveryType', "")
addSchemaAction.setFieldValue('deliveryAddressId', "")
addSchemaAction.setFieldState('deliveryAddressId', state => {
state.visible = false;
});
} if (res.values[1]?.title === "无需配送") {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList && deliveryTypeListRef.current?.deliveryTypeList.map(item => { return { ...item, disabled: true } })
setdeliveryTypeList(deliveryTypeListRef.current.deliveryTypeList)
addSchemaAction.setFieldState('deliveryAddress', state => {
state.visible = true;
});
addSchemaAction.setFieldState('deliveryAddressId', state => {
state.visible = false;
});
addSchemaAction.setFieldValue('deliveryType', "")
}
onChangeAddress(res)
})
}}
......
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