Commit 62d4be57 authored by baxibaba's avatar baxibaba

feat: 更新多规格商品

parent e61c50de
......@@ -156,19 +156,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
autoStock, // 弹框设置---自动补足
},
};
let serviceItem = {
description, // 商品描述
maxStock, // 最大库存
productStock,
minPurchaseNum, // 最少购买
saleTimeType, // 售卖时间
singleDelivery, // 单点不送
list, // 是否列出 1 是 0 否(外卖商品必填)
label, // 商品标签id
saleDates, // 可售日期 1-8
saleTimes: saleTimesTemp, // 可售日期 时间段
autoStock, // 弹框设置---自动补足
};
// 单规格
if (+repertoryType === 1) {
......@@ -189,6 +176,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if (+repertoryType === 2) {
if (name || editData.name) {
if (weight.length) {
let tempSku = [];
multiSpecList[0].specs = weight; // 处理specList
if (specs.length) {
specs.forEach((specsItem, specsIndex) => {
......@@ -203,7 +191,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
item.unit = '';
});
// 生成 specs 规格sku
let tempSku = [[...weight], ...sepcx].reduce(
tempSku = [[...weight], ...sepcx].reduce(
(x, y) => {
let arr = [];
x.forEach(x => y.forEach(y => arr.push(x.concat([y]))));
......@@ -211,13 +199,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
},
[[]],
);
console.log('multiSpu1111', multiSpu);
multiSpu = tempSku.map((item, index) => {
let obj = {};
obj.salePrice = salePrice;
obj.productStock = productStock;
obj.list = list;
obj.serviceItem = { ...serviceItem };
obj.serviceItem = {
...temp.serviceItem,
productStock: multiSpu?.[index]?.serviceItem?.productStock || productStock,
maxStock: multiSpu?.[index]?.serviceItem?.maxStock || maxStock,
autoStock: multiSpu?.[index]?.serviceItem?.autoStock || autoStock,
};
obj.unique = '';
multiSpecList.forEach((itm, idx) => {
if (item[idx] && !item[idx]?.specGroupName) {
......@@ -446,7 +439,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
let lastName = '';
const tempName = `${editData?.name || ''}`;
// const tempSpecName = `${item?.specs[0]?.specName || ''}`;
const tempQuantity = `${item.specs[0]?.quantity ? '(' : ''} ${item.specs[0]?.quantity || ''}`;
const tempQuantity = `${+item.specs[0]?.quantity > 0 ? '(' : ''} ${item.specs[0]?.quantity ||
''}`;
const tempUnit = `${item.specs[0]?.unit || ''} ${item.specs[0]?.unit ? ')' : ''}`;
// const tempSecondSpecName = `${item.specs[1]?.specName || ''}`;
// const isShow = tempQuantity && tempUnit && '+';
......@@ -589,7 +583,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}
form.setFieldsValue({ productRefShopId: editData.shopId });
onCardSuccessImageList(editData?.detailImageList);
getFormValues();
}
}
}, [customer.isEdit, editData]);
......@@ -599,6 +592,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
useEffect(() => {
init();
}, []);
useEffect(() => {
getFormValues();
}, [repertoryType]);
return (
<>
<Form
......
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