Commit 5f5b8adb authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复不能选择相同货品+商品判断错误的问题

parent fea5dab6
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47 * @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-02-19 20:24:47 * @LastEditTime: 2021-03-02 14:30:30
* @Description: 联动逻辑相关 * @Description: 联动逻辑相关
*/ */
import { Modal, message } from 'antd'; import { Modal, message } from 'antd';
...@@ -531,17 +531,14 @@ export const useBusinessEffects = (context, actions) => { ...@@ -531,17 +531,14 @@ export const useBusinessEffects = (context, actions) => {
const current = originAsyncData.find(item => item.id === value); const current = originAsyncData.find(item => item.id === value);
const invoicesTypeIdVal = getFieldValue('invoicesTypeId'); const invoicesTypeIdVal = getFieldValue('invoicesTypeId');
const invoicesDetailsRequestsValue = getFieldValue('invoicesDetailsRequests'); const invoicesDetailsRequestsValue = getFieldValue('invoicesDetailsRequests');
const itemIndex = name.match(/\d/)[0];
const itemNoValue = getFieldValue(FormPath.transform(name, /\d/, $1 => { const itemNoValue = getFieldValue(FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.itemNo` return `invoicesDetailsRequests.${$1}.itemNo`
})); }));
// 这里判断是否货品 跟 商品 都已经选择过了,不可重复选择 // 这里判断是否货品 跟 商品 都已经选择过了,不可重复选择
const sameGood = invoicesDetailsRequestsValue.find(item => item.itemNo === itemNoValue); const sameGood = invoicesDetailsRequestsValue.find((item, index) => index !== +itemIndex && item.itemNo === itemNoValue && item.product === value);
if ( if (sameGood) {
invoicesDetailsRequestsValue.length > 1 &&
sameGood &&
sameGood.product === value
) {
message.warning('存在相同货号+商品的组合,请重新选择'); message.warning('存在相同货号+商品的组合,请重新选择');
setTimeout(() => { setTimeout(() => {
setFieldState( setFieldState(
...@@ -640,6 +637,30 @@ export const useBusinessEffects = (context, actions) => { ...@@ -640,6 +637,30 @@ export const useBusinessEffects = (context, actions) => {
} }
); );
// 额外的数据
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.extraData`
}),
state => {
state.value = {
productName: current.productName,
deliveryType:
// 配送方式,一个单据只能有一个配送方式
current.logistics && current.logistics.deliveryType ?
current.logistics.deliveryType :
undefined
,
id: current.id, // 加工发货单需要,明细id
processNum: current.processNum, // 加工发货单需要,加工数量
orderNo: current.orderNo, // 订单编号
goodsCount: current.purchaseCount, // 采购数量
price: current.processPrice, // 加工发货、入库单需要,加工单价
totalPrice: current.processTotalPrice, // 加工发货、入库单需要,加工总价
};
}
);
switch (invoicesTypeIdVal) { switch (invoicesTypeIdVal) {
// 采购入库单、销售发货单 // 采购入库单、销售发货单
case DOC_TYPE_PURCHASE_RECEIPT: case DOC_TYPE_PURCHASE_RECEIPT:
...@@ -674,7 +695,7 @@ export const useBusinessEffects = (context, actions) => { ...@@ -674,7 +695,7 @@ export const useBusinessEffects = (context, actions) => {
state => { state => {
if ( if (
current.logistics && current.logistics &&
invoicesDetailsRequestsValue.some(item => item.extraData.deliveryType !== current.logistics.deliveryType) invoicesDetailsRequestsValue.some(item => item.extraData && item.extraData.deliveryType !== current.logistics.deliveryType)
) { ) {
state.errors = '商品配送方式不一致,请保持一次性'; state.errors = '商品配送方式不一致,请保持一次性';
} else { } else {
...@@ -687,7 +708,7 @@ export const useBusinessEffects = (context, actions) => { ...@@ -687,7 +708,7 @@ export const useBusinessEffects = (context, actions) => {
if ( if (
current.logistics && current.logistics &&
current.logistics.deliveryType && current.logistics.deliveryType &&
invoicesDetailsRequestsValue.every(item => item.extraData.deliveryType === current.logistics.deliveryType) invoicesDetailsRequestsValue.every(item => item.extraData && item.extraData.deliveryType === current.logistics.deliveryType)
) { ) {
setFieldValue('transport', DELIVERY_TYPE[current.logistics.deliveryType]); setFieldValue('transport', DELIVERY_TYPE[current.logistics.deliveryType]);
setFieldValue('deliveryType', current.logistics.deliveryType); setFieldValue('deliveryType', current.logistics.deliveryType);
...@@ -768,30 +789,6 @@ export const useBusinessEffects = (context, actions) => { ...@@ -768,30 +789,6 @@ export const useBusinessEffects = (context, actions) => {
break; break;
} }
} }
// 额外的数据
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.extraData`
}),
state => {
state.value = {
productName: current.productName,
deliveryType:
// 配送方式,一个单据只能有一个配送方式
current.logistics && current.logistics.deliveryType ?
current.logistics.deliveryType :
undefined
,
id: current.id, // 加工发货单需要,明细id
processNum: current.processNum, // 加工发货单需要,加工数量
orderNo: current.orderNo, // 订单编号
goodsCount: current.purchaseCount, // 采购数量
price: current.processPrice, // 加工发货、入库单需要,加工单价
totalPrice: current.processTotalPrice, // 加工发货、入库单需要,加工总价
};
}
);
}); });
// 关联明细 商品数量 联动计算商品金额 // 关联明细 商品数量 联动计算商品金额
......
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