Commit ce59da78 authored by XieZhiXiong's avatar XieZhiXiong

单据明细不需要展示的字段都放到一个字段里边

parent 11091e49
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-11-24 17:17:13
* @LastEditTime: 2020-11-25 16:29:06
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
......@@ -525,7 +525,6 @@ export const useBusinessEffects = (context, actions) => {
});
});
break;
break;
}
// 加工发货单
......@@ -618,14 +617,6 @@ export const useBusinessEffects = (context, actions) => {
);
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.productName`
}),
state => {
state.value = '';
}
);
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.price`
}),
state => {
......@@ -648,15 +639,6 @@ export const useBusinessEffects = (context, actions) => {
state.value = null;
}
);
// 配送方式,一个单据只能有一个配送方式
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.deliveryType`
}),
state => {
state.value = undefined;
}
);
const invoicesDetailsRequestsValue = getFieldValue('invoicesDetailsRequests');
......@@ -668,22 +650,13 @@ export const useBusinessEffects = (context, actions) => {
setFieldValue('deliveryType', null);
}
// 加工发货单
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.orderNo`
}),
state => {
state.value = '';
}
);
// 加工发货单
// 额外的数据
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.id`
return `invoicesDetailsRequests.${$1}.extraData`
}),
state => {
state.value = '';
state.value = {};
}
);
}
......@@ -702,14 +675,6 @@ export const useBusinessEffects = (context, actions) => {
);
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.productName`
}),
state => {
state.value = current.productName;
}
);
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.price`
}),
state => {
......@@ -732,31 +697,25 @@ export const useBusinessEffects = (context, actions) => {
state.value = current.price ? `¥${(current.purchaseCount * current.price).toFixed(2)}` : null;
}
);
// 配送方式,一个单据只能有一个配送方式
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.deliveryType`
}),
state => {
state.value = current.logistics && current.logistics.deliveryType ? current.logistics.deliveryType : undefined;
}
);
// 加工发货单
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.orderNo`
}),
state => {
state.value = current.orderNo;
}
);
// 加工发货单
// 额外的数据
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.id`
return `invoicesDetailsRequests.${$1}.extraData`
}),
state => {
state.value = current.id;
state.value = {
productName: current.productName,
deliveryType:
// 配送方式,一个单据只能有一个配送方式
current.logistics && current.logistics.deliveryType ?
current.logistics.deliveryType :
undefined
,
id: current.id, // 加工发货单需要,明细id
orderNo: current.orderNo, // 加工发货单需要,订单编号
processNum: current.processNum, // 加工发货单需要,加工数量
};
}
);
......@@ -771,7 +730,7 @@ export const useBusinessEffects = (context, actions) => {
state => {
if (
current.logistics &&
invoicesDetailsRequestsValue.some(item => item.deliveryType && item.deliveryType !== current.logistics.deliveryType)
invoicesDetailsRequestsValue.some(item => item.extraData.deliveryType !== current.logistics.deliveryType)
) {
state.errors = '商品配送方式不一致,请保持一次性';
} else {
......@@ -784,7 +743,7 @@ export const useBusinessEffects = (context, actions) => {
if (
current.logistics &&
current.logistics.deliveryType &&
invoicesDetailsRequestsValue.every(item => item.deliveryType === current.logistics.deliveryType)
invoicesDetailsRequestsValue.every(item => item.extraData.deliveryType === current.logistics.deliveryType)
) {
setFieldValue('transport', DELIVERY_TYPE[current.logistics.deliveryType]);
setFieldValue('deliveryType', current.logistics.deliveryType);
......
......@@ -451,7 +451,6 @@ const BillsForm: React.FC<BillsFormProps> = ({
const newInvoicesDetailsRequests = invoicesDetailsRequests.map(({
product,
productCount,
deliveryType,
...rest
}) => ({
productCount: +productCount,
......@@ -459,6 +458,8 @@ const BillsForm: React.FC<BillsFormProps> = ({
}));
const newTransactionTime = transactionTime ? moment(transactionTime).valueOf() : null;
console.log('value', value);
setSubmitLoading(true);
switch (invoicesTypeId) {
// 采购入库单
......@@ -472,10 +473,24 @@ const BillsForm: React.FC<BillsFormProps> = ({
orderNo: orderNo[0].orderNo,
relevanceInvoicesId: orderNo[0].id,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => ({
...item,
itemNmae: item.itemName,
})),
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => {
const {
extraData: {
id,
orderNo,
deliveryType,
...extraRest
},
itemName,
amount,
...rest
} = item;
return {
...rest,
...extraRest,
itemNmae: itemName,
};
}),
supplyMembersName: memberName,
})
.then(res => {
......@@ -500,10 +515,24 @@ const BillsForm: React.FC<BillsFormProps> = ({
inventoryId: rest.inventoryId,
inventoryRole: rest.inventoryRole,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => ({
...item,
itemNmae: item.itemName,
})),
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => {
const {
extraData: {
id,
orderNo,
deliveryType,
...extraRest
},
itemName,
amount,
...rest
} = item;
return {
...rest,
...extraRest,
itemNmae: itemName,
};
}),
})
.then(res => {
if (res.code !== 1000) {
......@@ -531,10 +560,24 @@ const BillsForm: React.FC<BillsFormProps> = ({
orderNo: orderNo[0].orderNo,
relevanceInvoicesId: orderNo[0].id,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => ({
...item,
itemNmae: item.itemName,
})),
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => {
const {
extraData: {
id,
orderNo,
deliveryType,
...extraRest
},
itemName,
amount,
...rest
} = item;
return {
...rest,
...extraRest,
itemNmae: itemName,
};
}),
createMemberName: memberName,
})
.then(res => {
......@@ -559,10 +602,24 @@ const BillsForm: React.FC<BillsFormProps> = ({
inventoryId: rest.inventoryId,
inventoryRole: rest.inventoryRole,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => ({
...item,
itemNmae: item.itemName,
})),
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => {
const {
extraData: {
id,
orderNo,
deliveryType,
...extraRest
},
itemName,
amount,
...rest
} = item;
return {
...rest,
...extraRest,
itemNmae: itemName,
};
}),
})
.then(res => {
if (res.code !== 1000) {
......@@ -591,11 +648,21 @@ const BillsForm: React.FC<BillsFormProps> = ({
warehouseRole: rest.inventoryRole,
storageSummary: rest.invoicesAbstract,
storageTime: newTransactionTime,
storageDetailsDTOList: newInvoicesDetailsRequests.map(item => ({
...item,
produceNoticeOrderDetailId: item.id,
storageCount: item.productCount,
})),
storageDetailsDTOList: newInvoicesDetailsRequests.map(item => {
const {
extraData = {},
amount,
productCount,
...rest
} = item;
return {
...rest,
produceNoticeOrderDetailId: extraData.id,
orderNo: extraData.orderNo,
processNum: extraData.processNum,
storageCount: productCount,
};
}),
})
.then(res => {
if (res.code !== 1000) {
......@@ -630,11 +697,21 @@ const BillsForm: React.FC<BillsFormProps> = ({
warehouseRole: rest.inventoryRole,
invoiceSummary: rest.invoicesAbstract,
invoiceTime: newTransactionTime,
invoiceDetailsDTOList: newInvoicesDetailsRequests.map(item => ({
...item,
produceNoticeOrderDetailId: item.id,
shipmentQuantity: item.productCount,
})),
invoiceDetailsDTOList: newInvoicesDetailsRequests.map(item => {
const {
extraData = {},
amount,
productCount,
...rest
} = item;
return {
...item,
produceNoticeOrderDetailId: extraData.id,
orderNo: extraData.orderNo,
processNum: extraData.processNum,
shipmentQuantity: productCount,
};
}),
})
.then(res => {
if (res.code !== 1000) {
......
......@@ -498,23 +498,8 @@ export const addBillSchema: ISchema = {
title: '金额',
'x-component': 'Text',
},
// 不用于展示,只收集值
productName: {
type: 'string',
display: false,
},
// 配送方式,不用于展示,只收集值
deliveryType: {
type: 'string',
display: false,
},
// 明细 商品记录id(加工发货单需要),不用于展示,只收集值
id: {
type: 'string',
display: false,
},
// 订单号(加工发货单需要),不用于展示,只收集值
orderNo: {
// 额外的数据,用于收集不需要展示的数据
extraData: {
type: 'string',
display: false,
},
......
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