Commit 5da7897d authored by baxibaba's avatar baxibaba

feat: 更新商品库

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