Commit 201d9923 authored by baxibaba's avatar baxibaba

feat: 更新商品库

parent 184bb8b8
......@@ -245,6 +245,15 @@
.specsBetween {
display: flex;
flex-flow: row nowrap;
:global {
.ant-form-item-label{
overflow:inherit;
}
.ant-col-sm-3{
max-width: fit-content;
}
}
}
.specRepertory {
background-color: #319bfe;
......
......@@ -101,6 +101,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const takeawayCalc = takeawayData => {
// 商品基本信息编辑商品名称
const { infoMation: name, infoMation, takeawayItem } = takeawayData;
console.log('infoMation========', infoMation);
// weight 份量 specs规格 生成sku规则 weight * specs
const {
specs = [],
......@@ -120,9 +121,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
singleDelivery,
saleTimeType,
autoStock = 0,
categoryId,
skuList,
id,
categoryId,
} = takeawayItem;
console.log('id', id, skuList);
const singularSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 单规格
......@@ -163,8 +164,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
salePrice,
maxStock,
quantity,
// unit: (unit && unit?.length && unit?.splice(unit?.length - 1)[0]) || unit,
unit,
unit: (Array.isArray(unit) && unit?.length && unit?.splice(unit?.length - 1)[0]) || unit,
productStock,
specGroupName: '份量',
};
......@@ -261,8 +261,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
// debugger
setMultiSpu(multiSpu);
}
console.log('categoryId', categoryId);
// +repertoryType === 1 单规格 2多规格
const intactDataTemp = {
...takeawayItem,
id,
type: 5, // 外卖类型
...infoMation,
......@@ -277,7 +279,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
(
infoMation?.categoryId &&
infoMation?.categoryId?.slice(infoMation?.categoryId?.length - 1)
)?.toString() || categoryId,
)?.toString() ||
(Array.isArray(categoryId) && categoryId?.slice(categoryId?.length - 1)?.toString()),
};
setIntactData(intactDataTemp);
......@@ -310,6 +313,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
// 设置库存
const modifiedInventory = (type, idx, values) => {
const { productStock, maxStock, autoStock } = values;
console.log('type', type);
if (type === 'multi') {
multiSpu.map(item => {
if (item.unique === idx) {
......@@ -325,17 +329,29 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setMultiSpu(temp);
}
if (type === 'all') {
if (intactData?.items.length) {
intactData?.items.forEach(item => {
item.serviceItem.productStock = productStock;
item.serviceItem.autoStock = autoStock;
item.serviceItem.maxStock = maxStock;
return item;
});
const temp = { ...intactData };
setIntactData(temp);
}
multiSpu.map(item => {
item.serviceItem.productStock = productStock;
item.serviceItem.autoStock = autoStock;
item.serviceItem.maxStock = maxStock;
return item;
});
let temp = JSON.parse(JSON.stringify(multiSpu));
tempMultiSpu.push(...temp);
setTempMultiSpu(tempMultiSpu);
setMultiSpu(multiSpu);
// if (intactData?.items.length) {
// intactData?.items.forEach(item => {
// item.serviceItem.productStock = productStock;
// item.serviceItem.autoStock = autoStock;
// item.serviceItem.maxStock = maxStock;
// return item;
// });
// const temp = { ...intactData };
// setIntactData(temp);
// }
}
console.log('=========', multiSpu, tempMultiSpu);
getFormValues();
return false;
};
......@@ -482,7 +498,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}
}, [customer.isEdit, editData]);
useEffect(() => {
// setIntactData(intactData);
setIntactData(intactData);
}, [intactData]);
useEffect(() => {
init();
......@@ -734,7 +750,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
</Form.Item>
<div className={styles.rowWarp}>
{singularSpu.length > 0 &&
takeawayData?.infoMation?.name &&
(takeawayData?.infoMation?.name || takeawayData.takeawayItem.name) &&
singularSpu.map((item, index) => (
<div className={styles.specsBetween}>
<Form.Item label={calcLabelName(intactData, item, 'singular')}>
......
......@@ -207,6 +207,7 @@ const ServiceGoods = options => {
setPageLoading(true);
const sendAsyncHttpRequest = isEdit ? merchantProductEdit : merchantProductAdd;
const addResponse = await sendAsyncHttpRequest(sendData);
debugger;
if (addResponse.data) {
message.success(`${isEdit ? '修改' : '添加'}成功!`);
localStorage.remove(localAutoSaveKey);
......
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