Commit 201d9923 authored by baxibaba's avatar baxibaba

feat: 更新商品库

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