Commit d881618b authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复单据明细多选旧数据丢失的问题

parent 398a3b70
......@@ -5,6 +5,7 @@ import { DeleteOutlined } from '@ant-design/icons';
import { Radio, ArrayTable } from '@formily/antd-components';
import { history, Prompt } from 'umi';
import moment from 'moment';
import { findLastIndex } from 'lodash';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined, PlusOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
......@@ -426,11 +427,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
const value = [];
values.forEach(item => {
const existing = preValues.find(val => val.id === item.id);
const atom =
existing ?
existing :
{
const atom = {
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
......@@ -449,7 +446,10 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
};
value.push(atom);
});
addSchemaAction.setFieldValue('replaceGoodsList', value);
const concated = [...value, ...preValues];
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index).reverse();
addSchemaAction.setFieldValue('replaceGoodsList', newData);
};
const handleGoodsChange = values => {
......
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