Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
merchant-manage-ui
Commits
1a4aa07b
Commit
1a4aa07b
authored
Mar 26, 2023
by
陈万宝
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更新商品规格
parent
00a538e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
153 additions
and
90 deletions
+153
-90
env.config.js
config/env.config.js
+1
-1
AddRepertoryModal.jsx
src/pages/ServiceGoods/components/AddRepertoryModal.jsx
+12
-13
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+140
-76
No files found.
config/env.config.js
View file @
1a4aa07b
const
isProduction
=
process
.
env
.
NODE_ENV
===
'
production
'
;
const
isPre
=
process
.
env
.
PRE_ENV
===
'
pre
'
;
const
environment
=
'
xyqb
'
;
const
environment
=
'
sc1
'
;
const
envAPi
=
{
api
:
`https://security-
${
environment
}
.liangkebang.net`
,
//'https://security-xyqb.liangkebang.net',
kdspOpApi
:
`https://sc-merchant-api-
${
environment
}
.liangkebang.net`
,
...
...
src/pages/ServiceGoods/components/AddRepertoryModal.jsx
View file @
1a4aa07b
...
...
@@ -16,6 +16,8 @@ const AddRepertoryModal = (props, ref) => {
});
const
{
modifiedInventory
,
intactData
,
repertoryModel
}
=
props
;
console
.
log
(
'
repertoryModel
'
,
repertoryModel
);
const
{
type
,
idx
,
item
}
=
repertoryModel
;
useImperativeHandle
(
ref
,
()
=>
({
// changeVal 就是暴露给父组件的方法
setOpenRepertory
:
newVal
=>
{
...
...
@@ -59,10 +61,9 @@ const AddRepertoryModal = (props, ref) => {
},
400
);
const
handleOk
=
async
()
=>
{
const
values
=
await
form
.
validateFields
();
console
.
log
(
'
values
'
,
values
);
values
.
autoStock
=
values
.
autoStock
?
1
:
0
;
// 回调库存
modifiedInventory
(
values
);
modifiedInventory
(
type
,
idx
,
values
);
// setConfirmLoading(true);
// setTimeout(() => {
// setOpenRepertory(false);
...
...
@@ -74,10 +75,9 @@ const AddRepertoryModal = (props, ref) => {
setOpenRepertory
(
false
);
};
useEffect
(()
=>
{
console
.
log
(
'
open
'
,
openRepertory
,
intactData
?.
items
,
repertoryModel
);
if
(
intactData
?.
items
?.
length
)
{
const
{
productStock
,
serviceItem
}
=
intactData
?.
items
[
0
];
const
{
autoStock
,
maxStock
}
=
serviceItem
;
console
.
log
(
'
333
'
,
repertoryModel
);
if
(
item
?.
serviceItem
)
{
const
{
productStock
=
1
,
autoStock
=
0
,
maxStock
=
2
}
=
item
?.
serviceItem
;
const
params
=
{
productStock
,
autoStock
:
+
autoStock
===
1
,
...
...
@@ -85,24 +85,23 @@ const AddRepertoryModal = (props, ref) => {
};
console
.
log
(
'
params=====
'
,
params
);
switch
(
repertoryModel
)
{
switch
(
type
)
{
case
'
all
'
:
// 统一设置
console
.
log
(
'
params
'
,
params
);
form
.
setFieldsValue
(
params
);
form
.
setFieldsValue
({
autoStock
:
true
});
break
;
case
'
mlti
'
:
// 多规格设置
setInitialValues
(
params
);
case
'
m
u
lti
'
:
// 多规格设置
form
.
setFieldsValue
(
params
);
break
;
case
'
singular
'
:
// 单规格设置
setInitialValues
(
params
);
// setInitialValues(params);
form
.
setFieldsValue
(
params
);
break
;
default
:
break
;
}
}
},
[
openRepertory
,
i
ntactData
]);
},
[
openRepertory
,
i
tem
]);
return
(
<>
{
openRepertory
&&
(
...
...
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
1a4aa07b
/* eslint-disable react/no-array-index-key */
/* eslint-disable no-shadow */
import
React
,
{
useContext
,
...
...
@@ -43,7 +44,7 @@ const createInitValues = () => ({
description
:
''
,
// 商品描述
detailImageList
:
[],
// 商品图片
stock
:
'
1
'
,
// 库存类型
saleTimeType
:
1
,
// 售卖时间
saleTimeType
:
0
,
// 售卖时间
singleDelivery
:
0
,
// 单点不送
list
:
1
,
// 列出商品
});
...
...
@@ -71,11 +72,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
[
takeawayData
,
setTakeawayData
]
=
useState
({});
// const [multiSpecList, setMultiSpecList] = useState([]);
// const [singularSpecList, setSingularSpecList] = useState([]);
const
[
mltiSpu
,
setMultiSpu
]
=
useState
([]);
const
[
m
u
ltiSpu
,
setMultiSpu
]
=
useState
([]);
const
[
singularSpu
,
setSingularSpu
]
=
useState
([]);
const
[
intactData
,
setIntactData
]
=
useState
({});
const
[
repertoryState
,
setRepertoryState
]
=
useState
(
''
);
const
[
repertoryModel
,
setRepertoryModel
]
=
useState
(
''
);
const
[
repertoryModel
,
setRepertoryModel
]
=
useState
(
{}
);
const
initialDealValue
=
[
{
specGroupName
:
''
,
...
...
@@ -101,7 +102,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
};
const
takeawayCalc
=
takeawayData
=>
{
// 商品基本信息编辑商品名称
const
{
infoMation
:
name
,
infoMation
,
takeawayItem
,
saleTimeType
}
=
takeawayData
;
const
{
infoMation
:
name
,
infoMation
,
takeawayItem
}
=
takeawayData
;
// weight 份量 specs规格 生成sku规则 weight * specs
const
{
specs
=
[],
...
...
@@ -109,44 +110,63 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
description
,
detailImageList
,
list
,
minPurchaseNum
,
minPurchaseNum
=
0
,
saleDates
,
maxStock
,
saleTimes
,
maxStock
=
0
,
saleTimes
=
[]
,
label
,
unit
,
unit
=
[]
,
quantity
,
productStock
,
productStock
=
0
,
salePrice
,
singleDelivery
,
saleTimeType
,
autoStock
=
0
,
}
=
takeawayItem
;
const
singularSpecList
=
[{
specGroupName
:
'
份量
'
,
specs
:
[]
}];
// 单规格
const
multiSpecList
=
[{
specGroupName
:
'
份量
'
,
specs
:
[]
}];
// 多规格
const
singularSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 单规格
const
multiSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 多规格
const
multiSpu
=
[];
// 单库存spu
let
singularSpu
=
[];
// 多库存spu
const
saleTimesTemp
=
[];
if
(
saleTimes
.
length
)
{
saleTimes
.
forEach
(
item
=>
{
const
startTime
=
item
?
moment
(
item
[
0
]).
format
(
format
)
:
''
;
const
endTime
=
item
?
moment
(
item
[
1
]).
format
(
format
)
:
''
;
saleTimesTemp
.
push
({
startTime
,
endTime
});
});
}
const
temp
=
{
salePrice
:
0
,
productStock
:
0
,
salePrice
:
salePrice
||
0
,
productStock
,
list
:
1
,
serviceItem
:
{
description
,
// 商品描述
maxStock
,
// 最大库存
productStock
,
minPurchaseNum
,
// 最少购买
saleTimeType
,
// 售卖时间
singleDelivery
,
// 单点不送
list
,
// 是否列出 1 是 0 否(外卖商品必填)
label
,
// 商品标签id
saleDates
,
// 可售日期 1-8
saleTimes
,
autoStock
:
0
,
// 弹框设置---自动补足
saleTimes
:
saleTimesTemp
,
// 可售日期 时间段
autoStock
,
// 弹框设置---自动补足
},
};
// 单规格
if
(
+
repertoryType
===
1
)
{
const
specs
=
{
maxStock
,
quantity
,
unit
:
unit
.
splice
(
unit
.
length
-
1
)[
0
],
productStock
};
const
specs
=
{
salePrice
,
maxStock
,
quantity
,
unit
:
(
unit
&&
unit
.
splice
(
unit
.
length
-
1
)[
0
])
||
''
,
productStock
,
specGroupName
:
'
份量
'
,
};
singularSpecList
[
0
].
specs
=
[
specs
];
singularSpu
=
[{
...
temp
,
specs
:
[
specs
]
}];
console
.
log
(
'
2222
'
,
singularSpu
);
setSingularSpu
(
singularSpu
);
}
// 多规格
...
...
@@ -156,31 +176,41 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if
(
weight
.
length
)
{
weight
.
forEach
((
item
,
weightIndex
)
=>
{
console
.
log
(
'
eee====
'
,
item
);
if
(
item
.
unit
&&
item
.
unit
.
length
)
{
if
(
item
?
.
unit
&&
item
.
unit
.
length
)
{
item
.
unit
=
item
.
unit
.
slice
(
item
.
unit
.
length
-
1
).
toString
();
}
multiSpecList
[
0
].
specs
=
weight
;
item
.
specGroupName
=
'
份量
'
;
item
.
generateSku
=
1
;
multiSpecList
[
0
].
specs
=
weight
;
// 处理specList
// 循环一次 插入规则列表
let
isFirstLoops
=
true
;
if
(
specs
.
length
)
{
specs
.
forEach
((
specsItem
,
specsIndex
)
=>
{
specsItem
.
generateSku
=
1
;
if
(
isFirstLoops
&&
multiSpecList
.
length
<
specs
.
length
+
1
)
{
multiSpecList
.
push
(
specsItem
);
multiSpecList
.
push
(
specsItem
);
// 处理specList
}
if
(
specsItem
.
specs
.
length
>
1
)
{
specsItem
.
specs
.
forEach
((
itm
,
idx
)
=>
{
const
params
=
{
...
temp
,
specs
:
[{
...
item
},
{
...
specsItem
.
specs
[
idx
]
}],
specs
:
[
{
...
item
},
{
...
specsItem
.
specs
[
idx
],
specGroupName
:
specsItem
.
specGroupName
},
],
};
multiSpu
.
push
(
params
);
multiSpu
.
push
(
params
);
// 处理spu
});
}
else
{
const
params
=
{
...
temp
,
specs
:
[{
...
item
},
{
...
specsItem
.
specs
[
0
]
}],
specs
:
[
{
...
item
},
{
...
specsItem
.
specs
[
0
],
specGroupName
:
specsItem
.
specGroupName
},
],
};
multiSpu
.
push
(
params
);
multiSpu
.
push
(
params
);
// 处理spu
}
});
isFirstLoops
=
false
;
...
...
@@ -189,44 +219,35 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
temp
,
specs
:
[{
...
item
}],
};
multiSpu
.
push
(
params
);
multiSpu
.
push
(
params
);
// 处理spu
}
});
}
}
console
.
log
(
'
multiSpu
'
,
multiSpu
);
setMultiSpu
(
multiSpu
);
}
// +repertoryType === 1 单规格 2多规格
const
intactData
=
{
type
:
5
,
// 外卖类型
...
infoMation
,
label
,
label
:
label
&&
label
.
toString
()
,
list
,
description
,
detailImageList
,
singleDelivery
,
specList
:
+
repertoryType
===
1
?
singularSpecList
:
multiSpecList
,
// 单库存和多库存specList
items
:
+
repertoryType
===
1
?
singularSpu
:
multiSpu
,
categoryId
:
infoMation
.
categoryId
.
slice
(
infoMation
.
categoryId
.
length
-
1
),
categoryId
:
(
infoMation
?.
categoryId
&&
infoMation
?.
categoryId
.
slice
(
infoMation
.
categoryId
.
length
-
1
)
).
toString
(),
storageRackIds
:
[
1633015955205664770
],
};
console
.
log
(
'
intactData======>
'
,
intactData
);
setIntactData
(
intactData
);
return
intactData
;
};
// 设置库存
const
modifiedInventory
=
params
=>
{
const
{
productStock
,
maxStock
,
autoStock
}
=
params
;
if
(
intactData
?.
items
.
length
)
{
intactData
.
items
.
forEach
(
item
=>
{
item
.
productStock
=
productStock
;
item
.
serviceItem
.
autoStock
=
autoStock
;
item
.
serviceItem
.
maxStock
=
maxStock
;
});
console
.
log
(
'
intactData
'
,
intactData
);
setIntactData
(
intactData
);
}
return
false
;
};
const
onChange
=
()
=>
{};
const
onDealFinish
=
values
=>
{
console
.
log
(
'
Received values of form:
'
,
values
);
...
...
@@ -238,9 +259,33 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
takeawayData
=
localStorage
.
get
(
localAutoSaveKey
);
console
.
log
(
'
takeawayData
'
,
takeawayData
);
setTakeawayData
(
takeawayData
);
takeawayCalc
(
takeawayData
);
console
.
log
(
"
3333
"
,
isCalcTakeaway
);
takeawayCalc
(
takeawayData
);
},
400
);
// 设置库存
const
modifiedInventory
=
(
type
,
idx
,
values
)
=>
{
console
.
log
(
"
isCalcTakeaway
"
,
isCalcTakeaway
);
const
{
productStock
,
maxStock
,
autoStock
}
=
values
;
if
(
type
===
'
multi
'
)
{
if
(
intactData
?.
items
.
length
)
{
// intactData.items[index].serviceItem.productStock = productStock
// intactData.items[index].serviceItem.autoStock = autoStock
// intactData.items[index].serviceItem.maxStock = maxStock
intactData
.
items
[
+
idx
].
serviceItem
.
productStock
=
productStock
;
intactData
.
items
[
+
idx
].
serviceItem
.
autoStock
=
autoStock
;
intactData
.
items
[
+
idx
].
serviceItem
.
maxStock
=
maxStock
;
// intactData.items[1].serviceItem.productStock = 2
// intactData.items[1].serviceItem.autoStock = 0
// intactData.items[1].serviceItem.maxStock = 2
console
.
log
(
'
index===
'
,
+
idx
,
intactData
);
const
temp
=
{
...
intactData
};
setIntactData
(
temp
);
}
}
return
false
;
};
const
fileterBrandOptions
=
(
input
,
options
)
=>
options
.
children
.
includes
(
input
);
const
filterCategoryOptions
=
(
inputValue
,
path
)
=>
...
...
@@ -309,6 +354,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
productStock
:
maxStock
,
});
}
getFormValues
();
};
// 最大库存设置
const
onChangeMaxStock
=
e
=>
{
...
...
@@ -325,21 +371,22 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
};
// 自动补全
const
onChangeAutoStock
=
e
=>
{
console
.
log
(
'
e=======
'
,
e
);
form
.
setFieldsValue
({
autoStock
:
e
?
1
:
0
,
});
};
// 显示加入库存弹框
const
showAddRepertoryModal
=
params
=>
{
const
showAddRepertoryModal
=
(
type
,
idx
,
item
)
=>
{
AddRepertoryRef
.
current
.
setOpenRepertory
(
true
);
setRepertoryModel
(
params
);
setRepertoryModel
(
{
type
,
idx
,
item
}
);
};
const
onFinish
=
values
=>
{
console
.
log
(
'
Received values of form:
'
,
values
);
};
// 拼接sku 名称
const
calcLabelName
=
(
takeaway
Data
,
item
)
=>
{
const
tempName
=
`
${
takeawayData
?.
infoMation
?.
name
||
''
}
`;
const
calcLabelName
=
(
intact
Data
,
item
)
=>
{
const
tempName
=
`
${
intactData
?.
name
||
''
}
`;
const tempSpecName = `
$
{
item
?.
specs
[
0
]?.
specName
||
''
}
`;
const tempQuantity = `
(
$
{
item
.
specs
[
0
]?.
quantity
||
''
}
`;
const tempUnit = `
$
{
item
.
specs
[
0
]?.
unit
||
''
})
`;
...
...
@@ -365,7 +412,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setInitValue({ ...editData });
}
}, [customer.isEdit, customer.isUseCache, editData]);
useEffect(() => {
setIntactData(intactData);
}, [intactData]);
useEffect(() => {
init();
}, []);
...
...
@@ -416,11 +465,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
// rules={[{ type: 'array', required: true, message: '请输入售卖时间!' }]}
>
<Radio.Group onChange={onChangeTime}>
<Radio value={
1
}>全时段</Radio>
<Radio value={
2
}>自定义售卖时间</Radio>
<Radio value={
0
}>全时段</Radio>
<Radio value={
1
}>自定义售卖时间</Radio>
</Radio.Group>
</Form.Item>
{timeType ===
2
&& (
{timeType ===
1
&& (
<>
<Form.Item name="saleDates" label="售卖时期(可多选)">
<Checkbox.Group>
...
...
@@ -473,6 +522,22 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
defaultPickerValue={[startTime, endTime]}
format={format}
onChange={onChange}
showTime={{
format: 'HH:mm',
defaultValue: [moment('00:00', 'HH:mm'), moment('00:00', 'HH:mm')],
hideDisabledOptions: true,
}}
disabledTime={() => ({
disabledMinutes: () => {
const result = [];
for (let i = 1; i < 60; i++) {
if (i !== 30) {
result.push(i);
}
}
return result;
},
})}
/>
</Form.Item>
{fields.length > 1 ? (
...
...
@@ -499,12 +564,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
</Form.Item>
</>
)}
{/* <AddSellTimeModal
ref={addSellTimeRef}
saleDates={saleDates}
setSaleDates={setSaleDates}
></AddSellTimeModal> */}
<Form.Item
name="label"
label="商品标签"
...
...
@@ -627,35 +686,36 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
onChange={onChangeMaxStock}
/>
</Form.Item>
<Form.Item name="autoStock" label="自动补足">
<Form.Item name="autoStock" label="自动补足"
valuePropName="checked"
>
<Switch
checkedChildren="开启"
unCheckedChildren="关闭"
// defaultUnChecked
onChange={onChangeAutoStock}
/>
<div className={styles.textStyle}>修改成功后,原库存将被替换,请谨慎操作!</div>
</Form.Item>
<div className={styles.rowWarp}>
{
/* {
singularSpu.length > 0 &&
{singularSpu.length > 0 &&
takeawayData?.infoMation?.name &&
singularSpu.map((item, index) => (
<div className={styles.specsBetween}>
<Form.Item label={calcLabelName(
takeawayData, item
)}>
<Form.Item label={calcLabelName(
intactData, item, 'singular'
)}>
<div className={styles.specsBetween}>
<span className={styles.repertoryLimit}>1/1</span>
<div
<span className={styles.repertoryLimit}>
{item?.specs[0]?.productStock}/{item?.specs[0]?.maxStock}
</span>
{/* <div
className={styles.specRepertory}
onClick={() => {
showAddRepertoryModal('singular'); // 单规格库存
showAddRepertoryModal('singular'
, index
); // 单规格库存
}}
>
设置库存
</div>
</div>
*/}
</div>
</Form.Item>
</div>
))}
*/}
))}
</div>
</>
)}
...
...
@@ -694,7 +754,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
onClick={() => remove(field.name)}
/>
) : null} */}
<Form.List name="weight">
<Form.List name="weight"
initialValue={[{}]}
>
{(weightFields, { add: weightAdd, remove: weightRemove }) => (
<>
{weightFields.map(weightField => (
...
...
@@ -917,6 +977,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
)}
</Form.List>
</Form.Item>
<div className={styles.textStyle}>修改成功后,原库存将被替换,请谨慎操作!</div>
<Form.Item
name="receptionVolume"
label="多规格库存"
...
...
@@ -933,27 +995,29 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
>
统一设置置库存
</Button>
{/*
<div className={styles.rowWarp}>
{mltiSpu.length > 0 &&
takeawayData?.infoMation
?.name &&
mltiSpu.map((item, inde
x) => (
<div className={styles.specsBetween}>
<Form.Item label={calcLabelName(
takeaway
Data, item)}>
<div className={styles.rowWarp}>
{m
u
ltiSpu.length > 0 &&
intactData
?.name &&
intactData?.items?.map((item, id
x) => (
<div
key={idx}
className={styles.specsBetween}>
<Form.Item label={calcLabelName(
intact
Data, item)}>
<div className={styles.specsBetween}>
<span className={styles.repertoryLimit}>1/1</span>
<span className={styles.repertoryLimit}>
{item?.serviceItem?.productStock}/{item?.serviceItem?.maxStock}
</span>
<div
className={styles.specRepertory}
onClick={() => {
showAddRepertoryModal('m
lti'
); // 多个库存
showAddRepertoryModal('m
ulti', `
$
{
idx
}
`, item
); // 多个库存
}}
>
设置库存
设置库存
{idx}
</div>
</div>
</Form.Item>
</div>
))}
</div>
*/}
</div>
</Form.Item>
</>
)}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment