Commit e3c3c17b authored by 陈万宝's avatar 陈万宝

feat: 更新时间问题

parent 5d4359f5
...@@ -215,8 +215,12 @@ ...@@ -215,8 +215,12 @@
.ant-form-item-control-input-content { .ant-form-item-control-input-content {
display: flex; display: flex;
} }
.ant-form-text {
display: flex;
justify-content: center;
align-items: center;
}
} }
} }
.itemInline { .itemInline {
:global { :global {
......
...@@ -195,94 +195,94 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -195,94 +195,94 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
// 多规格 // 多规格
if (+repertoryType === 2) { if (+repertoryType === 2) {
// if (name || editData.name) { // if (name || editData.name) {
if (weight.length) { if (weight.length) {
let tempSku = []; let tempSku = [];
multiSpecList[0].specs = weight; // 处理specList multiSpecList[0].specs = weight; // 处理specList
if (specs.length) { if (specs.length) {
specs.forEach((specsItem, specsIndex) => { specs.forEach((specsItem, specsIndex) => {
if (specsItem && !specsItem.generateSku) { if (specsItem && !specsItem.generateSku) {
specsItem.generateSku = 1; specsItem.generateSku = 1;
} }
if (specsItem.specGroupName) { if (specsItem.specGroupName) {
specsItem?.specs?.forEach(itm => { specsItem?.specs?.forEach(itm => {
itm.specGroupName = specsItem.specGroupName; itm.specGroupName = specsItem.specGroupName;
}); });
} }
multiSpecList.push(specsItem); multiSpecList.push(specsItem);
});
}
const sepcx = specs.map(item => item.specs);
sepcx.map(item => {
item.unit = '';
return item
});
// 生成 specs 规格sku
tempSku = [[...weight], ...sepcx].reduce(
(x, y) => {
const arr = [];
x.forEach(x => y.forEach(y => arr.push(x.concat([y]))));
return arr;
},
[[]],
);
console.log('multiSpu1111', multiSpu);
multiSpu = tempSku.map((item, index) => {
const obj = {};
obj.salePrice = salePrice;
obj.productStock = productStock;
obj.list = list;
obj.id = multiSpu?.[index]?.id || ''
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) {
if (multiSpecList[idx].specGroupName) {
item[idx].specGroupName = multiSpecList[idx].specGroupName;
}
}
});
obj.specs = [...item];
return obj;
}); });
} }
const sepcx = specs.map(item => item.specs);
multiSpu.map(item => { sepcx.map(item => {
item.salePrice = 0; item.unit = '';
item.unique = item?.specs return item;
.map(itm => { });
if (itm?.unit) { // 生成 specs 规格sku
itm.unit = tempSku = [[...weight], ...sepcx].reduce(
itm?.unit && (x, y) => {
(Array.isArray(itm?.unit) ? itm?.unit.slice(itm?.unit.length - 1)[0] : itm?.unit); const arr = [];
} x.forEach(x => y.forEach(y => arr.push(x.concat([y]))));
if (itm?.unit && peopleUnits.includes(itm.unit)) { return arr;
delete itm.quantity; },
} [[]],
if (itm?.specName) { );
return itm.specName; console.log('multiSpu1111', multiSpu);
multiSpu = tempSku.map((item, index) => {
const obj = {};
obj.salePrice = salePrice;
obj.productStock = productStock;
obj.list = list;
obj.id = multiSpu?.[index]?.id || '';
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) {
if (multiSpecList[idx].specGroupName) {
item[idx].specGroupName = multiSpecList[idx].specGroupName;
} }
}) }
.toString(); });
obj.specs = [...item];
return obj;
}); });
}
console.log('multiSpu', multiSpu); multiSpu.map(item => {
if (tempMultiSpu.length) { item.salePrice = 0;
multiSpu.forEach((item, index) => { item.unique = item?.specs
tempMultiSpu.forEach((itm, idx) => { .map(itm => {
if (item.unique === itm.unique) { if (itm?.unit) {
item.serviceItem = objectComparison(item.serviceItem, itm); itm.unit =
} itm?.unit &&
}); (Array.isArray(itm?.unit) ? itm?.unit.slice(itm?.unit.length - 1)[0] : itm?.unit);
}
if (itm?.unit && peopleUnits.includes(itm.unit)) {
delete itm.quantity;
}
if (itm?.specName) {
return itm.specName;
}
})
.toString();
});
console.log('multiSpu', multiSpu);
if (tempMultiSpu.length) {
multiSpu.forEach((item, index) => {
tempMultiSpu.forEach((itm, idx) => {
if (item.unique === itm.unique) {
item.serviceItem = objectComparison(item.serviceItem, itm);
}
}); });
} });
}
console.log(multiSpu, 'multiSpumultiSpu'); console.log(multiSpu, 'multiSpumultiSpu');
setMultiSpu(JSON.parse(JSON.stringify(multiSpu))); setMultiSpu(JSON.parse(JSON.stringify(multiSpu)));
// } // }
} }
// +repertoryType === 1 单规格 2多规格 // +repertoryType === 1 单规格 2多规格
...@@ -730,15 +730,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -730,15 +730,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
) : null} ) : null}
</Form.Item> </Form.Item>
))} ))}
<Form.Item> <Form.Item>
<Button {fields.length < 5 ? (
type="dashed" <Button
onClick={() => add()} type="dashed"
style={{ width: '60%' }} onClick={() => add()}
icon={<PlusOutlined />} style={{ width: '60%' }}
> icon={<PlusOutlined />}
新增售卖时段 >
</Button> 新增售卖时段
</Button>
) : null}
</Form.Item> </Form.Item>
</> </>
)} )}
...@@ -787,12 +790,21 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -787,12 +790,21 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
{repertoryType === '1' && ( {repertoryType === '1' && (
<> <>
<Form.Item label="份量" className={styles.required}> <Form.Item label="份量" className={styles.required}>
{form.getFieldValue(['unit']) &&
Array.isArray(form.getFieldValue(['unit'])) &&
weightUnits.includes(
form
.getFieldValue(['unit'])
.slice(1)
.toString(),
) && <span className="ant-form-text"> 约</span>}
<Form.Item <Form.Item
// noStyle // noStyle
shouldUpdate={(prevValues, curValues) => false} shouldUpdate={(prevValues, curValues) => false}
> >
{form => { {form => {
let unit = form.getFieldValue('unit') || ''; let unit = form.getFieldValue('unit') || '';
console.log('unit', unit);
unit = unit =
(unit && (Array.isArray(unit) && unit?.length && unit?.slice(1).toString())) || (unit && (Array.isArray(unit) && unit?.length && unit?.slice(1).toString())) ||
unit; unit;
...@@ -1222,7 +1234,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -1222,7 +1234,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}} }}
shape="round" shape="round"
> >
统一设置库存 统一设置库存
</Button> </Button>
<div className={styles.rowWarp}> <div className={styles.rowWarp}>
{multiSpu.length > 0 && {multiSpu.length > 0 &&
......
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