Commit ec597dfc authored by 武广's avatar 武广

fix: 修改规格ID丢失问题

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