Commit f7678690 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复商品可以重复选择的问题

parent 9a13a004
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-26 19:31:37
* @LastEditTime: 2021-02-19 17:42:55
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
......@@ -317,6 +317,7 @@ export const useBusinessEffects = (context, actions) => {
// 关联单据改变
onFieldValueChange$('orderNo').subscribe(fieldState => {
const invoicesTypeIdVal = getFieldValue('invoicesTypeId');
const invoicesDetailsRequestsValue = getFieldValue('invoicesDetailsRequests');
const first = fieldState.value && fieldState.value[0];
// 设置单据公用的数据相关
......@@ -352,6 +353,7 @@ export const useBusinessEffects = (context, actions) => {
const goodOptions = res.data.map(item => ({
label: item.productName,
value: item.id,
disabled: !!invoicesDetailsRequestsValue.find(val => val.product === item.id),
}));
setFieldState('invoicesDetailsRequests.*.product', state => {
FormPath.setIn(state, 'originAsyncData', res.data);
......@@ -381,6 +383,7 @@ export const useBusinessEffects = (context, actions) => {
const goodOptions = details.map(item => ({
label: `${item.productName}${item.orderNo ? '---' + item.orderNo : ''}`,
value: item.id,
disabled: !!invoicesDetailsRequestsValue.find(val => val.product === item.id),
}));
setFieldState('invoicesDetailsRequests.*.product', state => {
FormPath.setIn(state, 'originAsyncData', details.map(item => ({
......@@ -414,6 +417,7 @@ export const useBusinessEffects = (context, actions) => {
const goodOptions = details.map(item => ({
label: `${item.productName}${item.orderNo ? '---订单号:' + item.orderNo : ''}`,
value: item.id,
disabled: !!invoicesDetailsRequestsValue.find(val => val.product === item.id),
}));
setFieldState('invoicesDetailsRequests.*.product', state => {
FormPath.setIn(state, 'originAsyncData', details);
......@@ -450,6 +454,7 @@ export const useBusinessEffects = (context, actions) => {
const goodOptions = data.map(item => ({
label: `${item.productName}---订单号:${item.orderNo}`,
value: item.orderRecordId,
disabled: !!invoicesDetailsRequestsValue.find(val => val.product === item.orderRecordId),
}));
setFieldState('invoicesDetailsRequests.*.product', state => {
FormPath.setIn(state, 'originAsyncData', data.map(item => ({
......@@ -486,6 +491,7 @@ export const useBusinessEffects = (context, actions) => {
const goodOptions = data.map(item => ({
label: `${item.productName}---订单号:${item.orderNo}`,
value: item.orderRecordId,
disabled: !!invoicesDetailsRequestsValue.find(val => val.product === item.orderRecordId),
}));
setFieldState('invoicesDetailsRequests.*.product', state => {
FormPath.setIn(state, 'originAsyncData', data.map(item => ({
......@@ -523,11 +529,15 @@ export const useBusinessEffects = (context, actions) => {
setFieldValue('transport', '');
setFieldValue('deliveryType', null);
}
// 已选的数据需要禁用掉,不可以重复选择
setFieldState('invoicesDetailsRequests.*.product', state => {
state.props.enum = state.props.enum.map((item) => ({...item, disabled: !!value.find(val => val.product === item.value)}));
});
});
// 关联明细 商品下拉框 联动商品ID、单价
onFieldInputChange$('invoicesDetailsRequests.*.product').subscribe(fieldState => {
const { name, originAsyncData, value } = fieldState;
const { name, originAsyncData, value, props } = fieldState;
const current = originAsyncData.find(item => item.id === value);
const invoicesTypeIdVal = getFieldValue('invoicesTypeId');
......@@ -767,7 +777,6 @@ export const useBusinessEffects = (context, actions) => {
};
}
);
});
// 关联明细 商品数量 联动计算商品金额
......
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