Commit df6c07b0 authored by 李腾's avatar 李腾

feat: 完善多物流发货新增编辑逻辑

parent ef633c31
const isProduction = process.env.NODE_ENV === 'production';
const isPre = process.env.PRE_ENV === 'pre';
const environment = 'sc';
const environment = 'sc1';
const envAPi = {
api: `https://security-${environment}.liangkebang.net`, //'https://security-xyqb.liangkebang.net',
kdspOpApi: `https://sc-merchant-api-${environment}.liangkebang.net`,
kdspApi: `http://192.168.68.87:7002`,
kdspApi: `https://sc-merchant-api-${environment}.liangkebang.net`,
goodsApi: `https://sc-merchant-api-${environment}.liangkebang.net`,
querysApi: `https://sc-merchant-api-${environment}.liangkebang.net`,
prologueDomain: `https://mall-${environment}.liangkebang.net`,
......
......@@ -72,7 +72,7 @@ const FormComponent = (props, ref) => {
skuInfoList: [{ validator: onCheckSkuInfoList }],
expressCompanyCode: [{ required: true, message: '请选择物流公司' }],
expressNo: [{ required: true, message: '请填写物流单号' }],
serialNumber: [{ required: true, message: '请填写序列号' }],
// serialNumber: [{ required: true, message: '请填写序列号' }],
};
useImperativeHandle(ref, () => ({
......@@ -180,6 +180,7 @@ const UpdateStatusModal = (props, ref) => {
const [confirmLoading, setConfirmLoading] = useState(false);
const [record, setRecord] = useState();
const [oldPackageList, setOldPackageList] = useState();
const [actionRef, setActionRef] = useState();
// 提交前处理数据结构将skuNo的值从[skuNo]=>skuNo
const onFilterParams = packageList => {
......@@ -206,27 +207,54 @@ const UpdateStatusModal = (props, ref) => {
});
};
const open = item => {
const open = (item, tableRef) => {
setActionRef(tableRef);
setVisible(true);
setOldPackageList(JSON.parse(JSON.stringify(item.packageList)));
setRecord(item);
};
const onCancel = () => {
setVisible(false);
setConfirmLoading(false);
formRef.current.form.resetFields();
setRecord(null);
setConfirmLoading(false);
setVisible(false);
};
const onOk = async () => {
formRef.current.form.validateFields().then(async values => {
const packageList = onFilterParams(values.packageList);
// oldPackageList.forEach((item, index) => {
// if (JSON.stringify(item) !== JSON.stringify(packageList[index])) {
// packageList[index].preExpressCompanyCode = item.expressCompanyCode;
// packageList[index].preExpressCompanyName = item.expressCompanyName;
// packageList[index].preExpressNo = item.expressNo;
// }
// });
// 对比修改差异
oldPackageList.forEach((item, index) => {
if (JSON.stringify(item) !== JSON.stringify(packageList[index])) {
const updateAttr = () => {
packageList[index].preExpressCompanyCode = item.expressCompanyCode;
packageList[index].preExpressCompanyName = item.expressCompanyName;
packageList[index].preExpressNo = item.expressNo;
};
// eslint-disable-next-line no-restricted-syntax
for (const key in item) {
if (typeof item[key] !== 'object' && item[key] !== packageList[index][key]) {
console.log('修改了物流信息');
updateAttr();
break;
} else if (
typeof item[key] === 'object' &&
JSON.stringify(item[key]) !== JSON.stringify(packageList[index][key])
) {
console.log('修改了选择的商品');
updateAttr();
break;
}
}
});
......@@ -236,13 +264,12 @@ const UpdateStatusModal = (props, ref) => {
};
console.log('params', params);
const res = await apiDeliveriesAdd(params);
console.log('res>>', res);
if (res.code === '0000' && res.businessCode === '0000') {
notification.success({
message: '提交成功',
});
onCancel();
actionRef.current.reload();
}
});
};
......@@ -260,10 +287,12 @@ const UpdateStatusModal = (props, ref) => {
onOk,
};
return (
return visible ? (
<Modal {...modalProps}>
{record ? <FormWarpper ref={formRef} record={record} companys={companys} /> : ''}
</Modal>
) : (
''
);
};
......
......@@ -421,10 +421,13 @@ const TableList = props => {
orderNo: record.orderNo,
});
multiLogisticsModalRef.current.open({
...record,
packageList: res.data.packageList || [],
});
multiLogisticsModalRef.current.open(
{
...record,
packageList: res.data.packageList || [],
},
actionRef,
);
}}
>
{props.type === 2 ? '更新物流信息' : '填写物流信息'}
......
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