Commit 5da7897d authored by baxibaba's avatar baxibaba

feat: 更新商品库

parent cae5a4dd
......@@ -102,6 +102,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
};
const getFormValues = debounce(() => {
const values = form.getFieldsValue();
console.log('infoMation', values);
props.onValuesChange({ infoMation: values });
}, 400);
// 查询shopIds
......@@ -173,7 +174,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
{ required: true, min: 2, message: '请输入最少两个字符的商品名称', whitespace: true },
]}
>
<Input placeholder="请输入商品名称" disabled={customer.isDisabled || isEditTakeaway} />
<Input placeholder="请输入商品名称" disabled={customer.isDisabled} />
</Form.Item>
</Popover>
{customer.isTakeawayService && (
......
......@@ -128,7 +128,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
id,
categoryId,
} = takeawayItem;
console.log('skuList====', skuList);
console.log('skuList====', infoMation, takeawayItem, skuList);
const singularSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 单规格
const multiSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 多规格
// const multiSpu = customer.isEdit ? skuList:[]; // 多库存spu、
......@@ -178,7 +178,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
singularSpu = [{ ...temp, specs: [specs] }];
setSingularSpu(singularSpu);
}
console.log('weight', weight);
// 多规格
if (+repertoryType === 2) {
if (name || editData.name) {
......@@ -253,23 +252,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
});
}
}
if (tempMultiSpu.length) {
multiSpu.forEach((item, index) => {
tempMultiSpu.forEach((itm, idx) => {
console.log("itm",itm);
if (item.unique === itm.unique) {
item.serviceItem = objectComparison(item.serviceItem, itm);
item.id = itm.id
item.id = itm.id;
}
});
});
}
console.log('multiSpu=====11', tempMultiSpu);
console.log('multiSpu=====22', multiSpu);
// debugger
console.log('multiSpu', multiSpu);
// debugger;
console.log(multiSpu, tempMultiSpu, 'multiSpumultiSpu');
setMultiSpu(multiSpu);
}
// +repertoryType === 1 单规格 2多规格
......@@ -302,16 +296,14 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
let {
serviceItem: { maxStock, autoStock, productStock },
} = itm;
let params = { maxStock, autoStock, productStock };
let params = { maxStock, autoStock, productStock: productStock || itm.productStock };
let temp = { ...item, ...params };
return temp;
};
const onChange = () => {};
const onDealFinish = values => {
console.log('Received values of form:', values);
};
const getFormValues = debounce(() => {
const values = form.getFieldsValue();
console.log('values', values);
props.onValuesChange({ takeawayItem: JSON.parse(JSON.stringify(values)) });
const takeawayData = customer.isEdit
? { takeawayItem: Object.assign({}, editData, values) }
......@@ -397,10 +389,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
);
// 切换库存
const onChangeRepertory = e => {
if (e) {
setRepertoryType(`${e.target.value} `);
}
setRepertoryType(2);
setRepertoryType(`${e.target.value}`);
};
// 勾选库存设置
const onChangeSetRepertory = e => {
......@@ -452,7 +441,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const tempUnit = `${item.specs[0]?.unit || ''})`;
const tempSecondSpecName = `${item.specs[1]?.specName || ''}`;
const isShow = tempQuantity && tempUnit && '+';
return `${tempName} ${tempSpecName} ${tempQuantity} ${isShow} ${tempUnit} ${tempSecondSpecName}`;
return `${tempName} ${tempSpecName} ${tempQuantity} ${isShow} ${tempUnit} ${tempSecondSpecName}`;
};
const init = async () => {
if (!tagList.length) {
......@@ -471,7 +460,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if (customer.isEdit || customer.isUseCache) {
if (!editData) return;
let { label, firstCategoryId, secondCategoryId, thirdCategoryId, id } = editData;
editData.label = +label;
editData.label = label.split(',');
if (editData?.skuList.length) {
editData.minPurchaseNum = editData?.skuList[0]?.serviceItem.minPurchaseNum;
// 单规格
......@@ -531,15 +520,14 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const tempMultiSpu = editData?.skuList.map(item => {
if (item) {
let weightIdx = item.specs.findIndex(itm => itm.specGroupName === '份量');
console.log("weightIdx",weightIdx);
console.log('weightIdx', weightIdx);
let specsIdx = item.specs.findIndex(itm => itm.specGroupName !== '份量');
console.log("specsIdx",specsIdx);
console.log('specsIdx', specsIdx);
item.unique = `${item.specs[weightIdx]?.specName}-${item.specs[specsIdx]?.specGroupName}-${item.specs[specsIdx]?.specName}`;
}
return item;
});
setTempMultiSpu(tempMultiSpu || []);
debugger
}
form.setFieldsValue({ productRefShopId: editData.shopId });
......@@ -937,12 +925,14 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
<div>添加规格(如加料、甜度、辣度等)</div>
<Form.List
name="specs"
initialValue={[
{
specGroupName: '1',
specs: [],
},
]}
initialValue={
[
// {
// specGroupName: '',
// specs: [],
// },
]
}
>
{(specsFields, { add, remove }) => (
<>
......
......@@ -86,7 +86,7 @@ const ServiceGoods = options => {
const resetForm = () => clearCurrent(checkFormList).forEach(({ current }) => current.reset());
const onValuesChange = e => {
// console.log('e======', e, !isEdit, visibleCacheEdit);
console.log('e======', e, !isEdit, visibleCacheEdit);
if (!isEdit) {
if (visibleCacheEdit) {
setVisibleCacheEdit(false);
......@@ -207,6 +207,8 @@ 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