Commit ec597dfc authored by 武广's avatar 武广

fix: 修改规格ID丢失问题

parent 28edaf68
...@@ -231,6 +231,24 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -231,6 +231,24 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const [tableData, setTableData] = useState([]); const [tableData, setTableData] = useState([]);
const [mergeTable, setMergeTable] = useState(false); const [mergeTable, setMergeTable] = useState(false);
const insertSpecID = items => {
const sids = items.filter(item => item.id);
if (sids.length !== skuList.length) {
let i = 0;
const ids = skuList.reduce((prev, cur) => {
if (!sids.includes(cur.id)) {
prev.push(cur.id);
}
return prev;
}, []);
items.forEach(item => {
if (!item.id && i < ids.length) {
item.id = ids[i++];
}
});
}
};
const onCheck = async () => { const onCheck = async () => {
try { try {
let setMealContent = ''; let setMealContent = '';
...@@ -238,6 +256,14 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -238,6 +256,14 @@ const FormPriceOrStock = forwardRef((props, ref) => {
setMealContent = await packageRef.current.onCheck(); setMealContent = await packageRef.current.onCheck();
} }
const values = await form.validateFields(); const values = await form.validateFields();
if (!values.firstSpecValue || !values.firstSpecValue.length) {
values.firstSpecId = null;
values.firstSpec = '';
}
if (!values.secondSpecValue || !values.secondSpecValue.length) {
values.secondSpecId = null;
values.secondSpec = '';
}
const items = await editRef.current.onCheck(); const items = await editRef.current.onCheck();
if (customer.isCard && !setMealContent) { if (customer.isCard && !setMealContent) {
notification.open({ notification.open({
...@@ -247,6 +273,9 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -247,6 +273,9 @@ const FormPriceOrStock = forwardRef((props, ref) => {
return null; return null;
} }
if (items) { if (items) {
if (customer.isEdit && skuList.length) {
insertSpecID(items);
}
const obj = { ...values, items, temp: 'infoSpecData' }; const obj = { ...values, items, temp: 'infoSpecData' };
customer.isCard && setMealContent && (obj.setMealContent = setMealContent); customer.isCard && setMealContent && (obj.setMealContent = setMealContent);
return obj; return obj;
...@@ -288,8 +317,10 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -288,8 +317,10 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const cleanValues = { const cleanValues = {
firstValues: cleanArray(values.firstSpecValue || []), firstValues: cleanArray(values.firstSpecValue || []),
secondValues: cleanArray(values.secondSpecValue || []), secondValues: cleanArray(values.secondSpecValue || []),
firstSpecId: values.firstSpecId, firstSpecId:
secondSpecId: values.secondSpecId, values.firstSpecValue && values.firstSpecValue.length ? values.firstSpecId : null,
secondSpecId:
values.secondSpecValue && values.secondSpecValue.length ? values.secondSpecId : null,
}; };
const { inIdList: fisrtInIdList, noIdList: fisrtNoIdList } = filterSkuNotIdList( const { inIdList: fisrtInIdList, noIdList: fisrtNoIdList } = filterSkuNotIdList(
...@@ -325,9 +356,8 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -325,9 +356,8 @@ const FormPriceOrStock = forwardRef((props, ref) => {
}; };
const batchChange = () => { const batchChange = () => {
const batchItem = form.getFieldValue('batchItem'); const values = form.getFieldsValue();
const bacthFirst = form.getFieldValue('bacthFirst'); const { batchItem, bacthFirst, bacthSecon } = values;
const bacthSecon = form.getFieldValue('bacthSecon');
const resetObject = batchTableSourceData({ batchItem, tableData, bacthSecon, bacthFirst }); const resetObject = batchTableSourceData({ batchItem, tableData, bacthSecon, bacthFirst });
setTableData(resetObject); setTableData(resetObject);
}; };
...@@ -335,6 +365,8 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -335,6 +365,8 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const onSpecificationEvent = async () => { const onSpecificationEvent = async () => {
try { try {
const values = await form.validateFields(); const values = await form.validateFields();
console.log('values :>> ', values);
console.log('cleanArray(values.secondSpecValue) :>> ', cleanArray(values.secondSpecValue));
const cleanValues = { const cleanValues = {
firstSpec: values.firstSpec, firstSpec: values.firstSpec,
firstSpecId: values.firstSpecId, firstSpecId: values.firstSpecId,
......
...@@ -165,7 +165,7 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -165,7 +165,7 @@ const FormRuleVPictures = forwardRef((props, ref) => {
]} ]}
> >
<UploadImage <UploadImage
multiple={false} multiple={!customer.isCard}
maxWidth={customer.isCard ? 0 : 1200} maxWidth={customer.isCard ? 0 : 1200}
maxHeight={customer.isCard ? 0 : 1200} maxHeight={customer.isCard ? 0 : 1200}
superTips="公共滑动图尺寸不可大于 1200*1200" superTips="公共滑动图尺寸不可大于 1200*1200"
......
...@@ -141,6 +141,7 @@ const ServiceGoods = options => { ...@@ -141,6 +141,7 @@ const ServiceGoods = options => {
const submitEvent = async () => { const submitEvent = async () => {
const checkPromiseList = clearCurrent(checkFormList).map(({ current }) => current.onCheck()); const checkPromiseList = clearCurrent(checkFormList).map(({ current }) => current.onCheck());
const resuslt = await Promise.all(checkPromiseList); const resuslt = await Promise.all(checkPromiseList);
console.log('resuslt :>> ', resuslt);
if (!resuslt.includes(null)) { if (!resuslt.includes(null)) {
const params = resuslt.reduce((origin, item) => { const params = resuslt.reduce((origin, item) => {
const { temp, ...other } = item; const { temp, ...other } = item;
......
...@@ -224,6 +224,8 @@ export const createSkuListData = (first, second, firstSpecId, secondSpecId, skuL ...@@ -224,6 +224,8 @@ export const createSkuListData = (first, second, firstSpecId, secondSpecId, skuL
copy.secondSpecValue = sec.secondSpecValue; copy.secondSpecValue = sec.secondSpecValue;
list.push(copy); list.push(copy);
}); });
} else if (skuList && skuList.length) {
list.push(...skuList);
} else { } else {
// 缺少一级和二级规格时生成的编辑表格 // 缺少一级和二级规格时生成的编辑表格
list.push(skuItem); list.push(skuItem);
......
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