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
6095ba76
Commit
6095ba76
authored
Mar 23, 2023
by
陈万宝
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更新商品字段
parent
6f9f4424
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
435 additions
and
285 deletions
+435
-285
common.less
src/pages/ServiceGoods/common.less
+4
-5
AddRepertoryModal.jsx
src/pages/ServiceGoods/components/AddRepertoryModal.jsx
+92
-26
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+339
-254
No files found.
src/pages/ServiceGoods/common.less
View file @
6095ba76
...
...
@@ -221,7 +221,7 @@
}
.ant-form-item {
margin-bottom: 0;
margin-left:
2
0px;
margin-left:
4
0px;
}
}
}
...
...
@@ -253,7 +253,7 @@
line-height: 20px;
text-align: center;
margin: 0 10px;
padding:0 8px;
padding:
0 8px;
border-radius: 8px;
}
.repertoryLimit {
...
...
@@ -276,7 +276,7 @@
}
}
.conBg {
background:
#f8f8f8
;
background:
#f8f8f8
;
min-width: 100%;
width: fit-content;
:global {
...
...
@@ -299,6 +299,5 @@
.rowWarp {
display: flex;
flex-flow: row wrap;
background:#f8f8f8 ;
background: #f8f8f8;
}
src/pages/ServiceGoods/components/AddRepertoryModal.jsx
View file @
6095ba76
...
...
@@ -2,40 +2,98 @@ import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle } f
import
{
Button
,
Modal
,
Radio
,
Form
,
InputNumber
,
Switch
}
from
'
antd
'
;
import
styles
from
'
../common.less
'
;
import
{
ENUM_SET_REPERTORY
}
from
'
../config
'
;
import
{
debounce
}
from
'
@/utils/utils
'
;
const
AddRepertoryModal
=
(
props
,
ref
)
=>
{
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
modalText
,
setModalText
]
=
useState
(
'
Content of the modal
'
);
const
[
openRepertory
,
setOpenRepertory
]
=
useState
(
false
);
const
[
form
]
=
Form
.
useForm
();
const
[
repertoryState
,
setRepertoryState
]
=
useState
(
''
);
const
[
initialValues
,
setInitialValues
]
=
useState
({
productStock
:
0
,
maxStock
:
0
,
autoStock
:
0
,
});
// const {
// open,
// setOpen,
// } = props;
const
{
modifiedInventory
,
intactData
,
repertoryModel
}
=
props
;
useImperativeHandle
(
ref
,
()
=>
({
// changeVal 就是暴露给父组件的方法
setOpenRepertory
:
newVal
=>
{
setOpenRepertory
(
newVal
);
},
}));
const
onChange3
=
()
=>
{};
const
handleOk
=
()
=>
{
setModalText
(
'
The modal will be closed after two seconds
'
);
setConfirmLoading
(
true
);
setTimeout
(()
=>
{
setOpenRepertory
(
false
);
setConfirmLoading
(
false
);
},
2000
);
// 自动补全
const
onChangeAutoStock
=
e
=>
{
form
.
setFieldsValue
({
autoStock
:
e
?
1
:
0
,
});
};
// 勾选库存设置
const
onChangeSetRepertory
=
e
=>
{
console
.
log
(
'
form
'
,
form
);
setRepertoryState
(
`
${
e
.
target
.
value
}
`
);
if
(
+
e
.
target
.
value
===
0
)
{
form
.
setFieldsValue
({
productStock
:
0
,
});
}
else
{
const
{
maxStock
}
=
form
.
getFieldsValue
([
'
maxStock
'
]);
form
.
setFieldsValue
({
productStock
:
maxStock
,
});
}
};
// 最大库存设置
const
onChangeMaxStock
=
e
=>
{
// 已经勾选最大库存 自动更新剩余库存
if
(
+
repertoryState
===
1
)
{
form
.
setFieldsValue
({
productStock
:
e
,
});
}
};
const
getFormValues
=
debounce
(()
=>
{
const
values
=
form
.
getFieldsValue
();
console
.
log
(
'
values========
'
,
values
);
},
400
);
const
handleOk
=
async
()
=>
{
const
values
=
await
form
.
validateFields
();
console
.
log
(
'
values
'
,
values
);
// 回调库存
modifiedInventory
(
values
);
// setConfirmLoading(true);
// setTimeout(() => {
// setOpenRepertory(false);
// setConfirmLoading(false);
// }, 2000);
};
const
handleCancel
=
()
=>
{
console
.
log
(
'
Clicked cancel button
'
);
setOpenRepertory
(
false
);
};
useEffect
(()
=>
{
console
.
log
(
'
open
'
,
openRepertory
);
},
[
openRepertory
]);
const
{
productStock
,
serviceItem
}
=
intactData
?.
items
;
const
{
autoStock
,
maxStock
}
=
serviceItem
;
const
params
=
{
productStock
,
autoStock
,
maxStock
,
};
switch
(
repertoryModel
)
{
case
'
all
'
:
// 统一设置
setInitialValues
(
params
);
break
;
case
'
mlti
'
:
// 多规格设置
setInitialValues
(
params
);
break
;
case
'
singular
'
:
// 单规格设置
setInitialValues
(
params
);
break
;
default
:
break
;
}
},
[
openRepertory
,
intactData
]);
return
(
<>
{
openRepertory
&&
(
...
...
@@ -46,10 +104,10 @@ const AddRepertoryModal = (props, ref) => {
confirmLoading=
{
confirmLoading
}
onCancel=
{
handleCancel
}
>
<
Form
>
<
Form
form=
{
form
}
initialValues=
{
initialValues
}
onValuesChange=
{
getFormValues
}
>
<
Form
.
Item
className=
{
styles
.
itemInlineModal
}
>
<
Form
.
Item
name=
"
receptionVolume
"
name=
"
productStock
"
label=
"剩余库存"
style=
{
{
display
:
'
flex
'
,
...
...
@@ -58,28 +116,36 @@ const AddRepertoryModal = (props, ref) => {
rules=
{
[{
required
:
true
,
message
:
'
请填写剩余库存
'
}]
}
>
<
InputNumber
min=
{
1
}
min=
{
0
}
style=
{
{
width
:
200
,
display
:
'
inline-block
'
}
}
placeholder=
"请输入"
/>
</
Form
.
Item
>
<
Form
.
Item
name=
"limitPurchase"
style=
{
{
width
:
200
,
display
:
'
inline-block
'
}
}
>
<
Radio
.
Group
options=
{
ENUM_SET_REPERTORY
}
onChange=
{
onChange3
}
value=
{
1
}
/>
<
Form
.
Item
style=
{
{
width
:
200
,
display
:
'
inline-block
'
}
}
>
<
Radio
.
Group
value=
{
repertoryState
}
onChange=
{
onChangeSetRepertory
}
>
<
Radio
.
Button
value=
"0"
>
清空
</
Radio
.
Button
>
<
Radio
.
Button
value=
"1"
>
最大
</
Radio
.
Button
>
</
Radio
.
Group
>
</
Form
.
Item
>
</
Form
.
Item
>
<
Form
.
Item
name=
"
receptionVolume
"
name=
"
maxStock
"
label=
"最大库存"
rules=
{
[{
required
:
true
,
message
:
'
请填写最大库存
'
}]
}
>
<
InputNumber
min=
{
1
}
style=
{
{
width
:
200
}
}
placeholder=
"请输入"
/>
<
InputNumber
min=
{
0
}
style=
{
{
width
:
200
}
}
placeholder=
"请输入"
onChange=
{
onChangeMaxStock
}
/>
</
Form
.
Item
>
<
Form
.
Item
name=
"
receptionVolume
"
label=
"自动补足"
>
<
Form
.
Item
name=
"
autoStock
"
label=
"自动补足"
>
<
Switch
checkedChildren=
"开启"
unCheckedChildren=
"关闭"
defaultChecked
onChange=
{
onChange
3
}
//
defaultChecked
onChange=
{
onChange
AutoStock
}
/>
</
Form
.
Item
>
<
div
className=
{
styles
.
textStyle
}
>
修改成功后,原库存将被替换,请谨慎操作!
</
div
>
...
...
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
6095ba76
...
...
@@ -69,10 +69,13 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
[
tagList
,
setTagList
]
=
useState
([]);
const
[
unitsList
,
setUnitsList
]
=
useState
([]);
const
[
takeawayData
,
setTakeawayData
]
=
useState
({});
const
[
specList
,
setSpecList
]
=
useState
([]);
const
[
takeawaySku
,
setTakeawaySku
]
=
useState
([]);
// const [multiSpecList, setMultiSpecList] = useState([]);
// const [singularSpecList, setSingularSpecList] = useState([]);
const
[
mltiSpu
,
setMultiSpu
]
=
useState
([]);
const
[
singularSpu
,
setSingularSpu
]
=
useState
([]);
const
[
intactData
,
setIntactData
]
=
useState
({});
const
[
repertoryState
,
setRepertoryState
]
=
useState
(
''
);
const
[
repertoryModel
,
setRepertoryModel
]
=
useState
(
''
);
const
initialDealValue
=
[
{
specGroupName
:
''
,
...
...
@@ -90,7 +93,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
return
{
...
values
,
temp
:
'
takeawayItem
'
,
limitPurchase
:
values
.
limitPurchase
?
1
:
0
,
intactData
,
};
}
catch
(
errorInfo
)
{
return
null
;
...
...
@@ -98,7 +101,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
};
const
takeawayCalc
=
takeawayData
=>
{
// 商品基本信息编辑商品名称
const
{
infoMation
:
name
,
takeawayItem
,
saleTimeType
,
singleDelivery
}
=
takeawayData
;
const
{
infoMation
:
name
,
infoMation
,
takeawayItem
,
saleTimeType
}
=
takeawayData
;
// weight 份量 specs规格 生成sku规则 weight * specs
const
{
specs
=
[],
...
...
@@ -111,68 +114,112 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
maxStock
,
saleTimes
,
label
,
unit
,
quantity
,
productStock
,
singleDelivery
,
}
=
takeawayItem
;
const
takeawaySkuTemp
=
[];
const
takeawaySpecList
=
[{
specGroupName
:
'
份量
'
,
specs
:
[]
}]
console
.
log
(
'
takeawayData
'
,
takeawayData
);
if
(
name
)
{
const
temp
=
{
salePrice
:
1
,
productStock
:
2
,
list
:
1
,
serviceItem
:
{
description
,
// 商品描述
maxStock
,
// 最大库存
minPurchaseNum
,
// 最少购买
saleTimeType
,
// 售卖时间
singleDelivery
,
// 单点不送
list
,
// 是否列出 1 是 0 否(外卖商品必填)
label
,
// 商品标签id
saleDates
,
// 可售日期 1-8
saleTimes
,
autoStock
:
''
,
// 弹框设置---自动补足
},
}
if
(
weight
.
length
)
{
weight
.
forEach
((
item
,
weightIndex
)
=>
{
takeawaySpecList
[
0
].
specs
=
weight
// 循环一次 插入规则列表
let
isFirstLoops
=
true
if
(
specs
.
length
)
{
specs
.
forEach
((
specsItem
,
specsIndex
)
=>
{
if
(
isFirstLoops
)
{
takeawaySpecList
.
push
(
specsItem
)
}
if
(
specsItem
.
specs
.
length
>
1
)
{
specsItem
.
specs
.
forEach
((
itm
,
idx
)
=>
{
const
singularSpecList
=
[{
specGroupName
:
'
份量
'
,
specs
:
[]
}];
// 单规格
const
multiSpecList
=
[{
specGroupName
:
'
份量
'
,
specs
:
[]
}];
// 多规格
const
multiSpu
=
[];
// 单库存spu
let
singularSpu
=
[];
// 多库存spu
const
temp
=
{
salePrice
:
1
,
productStock
:
2
,
list
:
1
,
serviceItem
:
{
description
,
// 商品描述
maxStock
,
// 最大库存
minPurchaseNum
,
// 最少购买
saleTimeType
,
// 售卖时间
singleDelivery
,
// 单点不送
list
,
// 是否列出 1 是 0 否(外卖商品必填)
label
,
// 商品标签id
saleDates
,
// 可售日期 1-8
saleTimes
,
autoStock
:
''
,
// 弹框设置---自动补足
},
};
// 单规格
if
(
+
repertoryType
===
1
)
{
const
sepcs
=
{
maxStock
,
quantity
,
unit
,
productStock
};
singularSpecList
[
0
].
specs
=
[
sepcs
];
singularSpu
=
[{
...
temp
,
sepcs
:
[
sepcs
]
}];
setSingularSpu
(
singularSpu
);
}
// 多规格
if
(
+
repertoryType
===
2
)
{
console
.
log
(
'
222
'
);
if
(
name
)
{
if
(
weight
.
length
)
{
weight
.
forEach
((
item
,
weightIndex
)
=>
{
multiSpecList
[
0
].
specs
=
weight
;
// 循环一次 插入规则列表
let
isFirstLoops
=
true
;
if
(
specs
.
length
)
{
specs
.
forEach
((
specsItem
,
specsIndex
)
=>
{
if
(
isFirstLoops
&&
multiSpecList
.
length
<
specs
.
length
+
1
)
{
multiSpecList
.
push
(
specsItem
);
}
if
(
specsItem
.
specs
.
length
>
1
)
{
specsItem
.
specs
.
forEach
((
itm
,
idx
)
=>
{
const
params
=
{
...
temp
,
specs
:
[{
...
item
},
{
...
specsItem
.
specs
[
idx
]
}],
};
multiSpu
.
push
(
params
);
});
}
else
{
const
params
=
{
...
temp
,
specs
:
[{
...
item
},
{
...
specsItem
.
specs
[
idx
]
}],
specs
:
[{
...
item
},
{
...
specsItem
.
specs
[
0
]
}],
};
takeawaySkuTemp
.
push
(
params
);
});
}
else
{
const
params
=
{
multiSpu
.
push
(
params
);
}
});
isFirstLoops
=
false
;
}
else
{
const
params
=
{
...
temp
,
specs
:
[{
...
item
},
{
...
specsItem
.
specs
[
0
]
}],
};
takeawaySkuTemp
.
push
(
params
);
}
isFirstLoops
=
false
});
}
else
{
const
params
=
{
...
temp
,
specs
:
[{
...
item
}],
};
takeawaySkuTemp
.
push
(
params
);
}
});
specs
:
[{
...
item
}],
};
multiSpu
.
push
(
params
);
}
});
}
}
setMultiSpu
(
multiSpu
);
}
// +repertoryType === 1 单规格 2多规格
const
intactData
=
{
type
:
5
,
// 外卖类型
...
infoMation
,
label
,
list
,
description
,
detailImageList
,
singleDelivery
,
specList
:
+
repertoryType
===
1
?
singularSpecList
:
multiSpecList
,
// 单库存和多库存specList
items
:
+
repertoryType
===
1
?
singularSpu
:
multiSpu
,
};
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
;
});
setIntactData
(
intactData
);
}
console
.
log
(
'
takeawaySkuTemp
'
,
takeawaySkuTemp
,
takeawaySpecList
);
setTakeawaySku
(
takeawaySkuTemp
);
setSpecList
(
takeawaySpecList
)
return
false
;
};
const
onChange
=
()
=>
{};
const
onDealFinish
=
values
=>
{
...
...
@@ -249,12 +296,12 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if
(
+
e
.
target
.
value
===
0
)
{
form
.
setFieldsValue
({
productStock
:
0
,
})
})
;
}
else
{
const
{
maxStock
}
=
form
.
getFieldsValue
([
'
maxStock
'
])
const
{
maxStock
}
=
form
.
getFieldsValue
([
'
maxStock
'
])
;
form
.
setFieldsValue
({
productStock
:
maxStock
,
})
})
;
}
};
// 最大库存设置
...
...
@@ -263,23 +310,27 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if
(
+
repertoryState
===
1
)
{
form
.
setFieldsValue
({
productStock
:
e
,
})
})
;
}
}
}
;
// 切换时间
const
onChangeTime
=
e
=>
{
setTimeType
(
e
.
target
.
value
);
};
// 自动补全
const
onChangeAutoStock
=
e
=>
{
setTimeType
(
e
.
target
.
value
);
form
.
setFieldsValue
({
autoStock
:
e
?
1
:
0
,
});
};
// 显示加入库存弹框
const
showAddRepertoryModal
=
()
=>
{
const
showAddRepertoryModal
=
params
=>
{
AddRepertoryRef
.
current
.
setOpenRepertory
(
true
);
setRepertoryModel
(
params
);
};
const
onFinish
=
values
=>
{
console
.
log
(
'
Received values of form:
'
,
values
);
};
// const onFinish = values => {
// console.log('Received values of form:', values);
// };
// 拼接sku 名称
const
calcLabelName
=
(
takeawayData
,
item
)
=>
{
const
tempName
=
`
${
takeawayData
?.
infoMation
?.
name
||
''
}
`;
...
...
@@ -287,7 +338,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const tempQuantity = `
(
$
{
item
.
specs
[
0
]?.
quantity
||
''
}
`;
const tempUnit = `
$
{
item
.
specs
[
0
]?.
unit
||
''
})
`;
const tempSecondSpecName = `
$
{
item
.
specs
[
1
]?.
specName
||
''
}
`;
const isShow = tempQuantity && tempUnit && '+'
const isShow = tempQuantity && tempUnit && '+'
;
return `
$
{
tempName
}
$
{
tempSpecName
}
$
{
tempQuantity
}
$
{
isShow
}
$
{
tempUnit
}
$
{
tempSecondSpecName
}
`;
};
const init = async () => {
...
...
@@ -478,41 +529,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
</Radio.Group>
</Form.Item>
<Title title="规格信息" />
<Form.Item label="份量" className={styles.required}>
<Form.Item
name="quantity"
style={{
display: 'inline-block',
}}
rules={[{ required: true, message: '请输入分量' }]}
>
<InputNumber min={1} style={{ width: 200 }} placeholder="请输入数字" />
</Form.Item>
<Form.Item
name="unit"
rules={[{ type: 'array', required: true, message: '请选择单位' }]}
style={{
display: 'inline-block',
margin: '0 8px',
}}
>
<Cascader
placeholder="请选择单位"
disabled={customer.isEdit && customer.isNormal}
showSearch={{ filter: filterCategoryOptions }}
fieldNames={{ label: 'name', value: 'id', children: 'children' }}
onChange={props.onCategoryChange}
options={unitsList}
/>
</Form.Item>
</Form.Item>
<Form.Item
name="salePrice"
label="销售价格"
rules={[{ required: true, message: '请输入销售价格' }]}
>
<InputNumber min={0} style={{ width: 200 }} placeholder="元" />
</Form.Item>
{/* <Form.Item label="限购" name="limitPurchase" valuePropName="checked">
<Checkbox onChange={() => radioChangeEvent('limitPurchase')}>
...
...
@@ -535,6 +551,41 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
{repertoryType === '1' && (
<>
<Form.Item label="份量" className={styles.required}>
<Form.Item
name="quantity"
style={{
display: 'inline-block',
}}
rules={[{ required: true, message: '请输入分量' }]}
>
<InputNumber min={1} style={{ width: 200 }} placeholder="请输入数字" />
</Form.Item>
{/* <Form.Item
name="unit"
rules={[{ type: 'array', required: true, message: '请选择单位' }]}
style={{
display: 'inline-block',
margin: '0 8px',
}}
>
<Cascader
placeholder="请选择单位"
disabled={customer.isEdit && customer.isNormal}
showSearch={{ filter: filterCategoryOptions }}
fieldNames={{ label: 'name', value: 'id', children: 'children' }}
onChange={props.onCategoryChange}
options={unitsList}
/>
</Form.Item> */}
</Form.Item>
<Form.Item
name="salePrice"
label="销售价格"
rules={[{ required: true, message: '请输入销售价格' }]}
>
<InputNumber min={0} style={{ width: 200 }} placeholder="元" />
</Form.Item>
<Form.Item className={styles.itemInline}>
<Form.Item
name="productStock"
...
...
@@ -551,12 +602,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
placeholder="请输入"
/>
</Form.Item>
<Form.Item name="limitPurchase" style={{ width: 200, display: 'inline-block' }}>
<Radio.Group
options={ENUM_SET_REPERTORY}
onChange={onChangeSetRepertory}
value={1}
/>
<Form.Item style={{ width: 200, display: 'inline-block' }}>
<Radio.Group value={repertoryState} onChange={onChangeSetRepertory}>
<Radio.Button value="0">清空</Radio.Button>
<Radio.Button value="1">最大</Radio.Button>
</Radio.Group>
</Form.Item>
</Form.Item>
<Form.Item
...
...
@@ -564,7 +614,12 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
label="最大库存"
rules={[{ required: true, message: '请填写最大库存' }]}
>
<InputNumber min={0} style={{ width: 200 }} placeholder="请输入" onChange={onChangeMaxStock} />
<InputNumber
min={0}
style={{ width: 200 }}
placeholder="请输入"
onChange={onChangeMaxStock}
/>
</Form.Item>
<Form.Item name="autoStock" label="自动补足">
<Switch
...
...
@@ -575,6 +630,27 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
/>
<div className={styles.textStyle}>修改成功后,原库存将被替换,请谨慎操作!</div>
</Form.Item>
<div className={styles.rowWarp}>
{singularSpu.length > 0 &&
takeawayData?.infoMation?.name &&
singularSpu.map((item, index) => (
<div className={styles.specsBetween}>
<Form.Item label={calcLabelName(takeawayData, item)}>
<div className={styles.specsBetween}>
<span className={styles.repertoryLimit}>1/1</span>
<div
className={styles.specRepertory}
onClick={() => {
showAddRepertoryModal('singular'); // 单规格库存
}}
>
设置库存
</div>
</div>
</Form.Item>
</div>
))}
</div>
</>
)}
{repertoryType === '2' && (
...
...
@@ -728,154 +804,163 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
)}
</Form.List> */}
</Form.Item>
<Form.Item>
<div>添加规格(如加料、甜度、辣度等)</div>
<Form.List name="specs">
{(specsFields, { add, remove }) => (
<>
{specsFields.map((field, index) => (
<Form.Item key={field.key} className={styles.conBg}>
<Form.Item
{...field}
validateTrigger={['onChange', 'onBlur']}
name={[field.name, 'specGroupName']}
rules={[
{
required: true,
whitespace: true,
message: '请输入规格名称',
},
]}
noStyle
>
<Input placeholder="规格名称" className={styles.nameWidth} />
</Form.Item>
{specsFields.length > 1 ? (
<MinusCircleOutlined
className="dynamic-delete-button"
onClick={() => remove(field.name)}
/>
) : null}
<Form.List
{...field}
name={[field.name, 'specs']}
initialValue={[
{
specName: '',
salePrice: '',
},
]}
>
{(specsInfoFields, { add: specsAdd, remove: specsRemove }) => (
<>
{specsInfoFields.map(specsInfofield => (
<Space key={specsInfofield.key} align="baseline">
<Form.Item
{...specsInfofield}
name={[specsInfofield.name, 'specName']}
rules={[
{
required: true,
message: '请输入加价名称',
},
]}
>
<Input style={{ width: '200px' }} placeholder="加价名称" />
</Form.Item>
<Form.Item
{...specsInfofield}
name={[specsInfofield.name, 'salePrice']}
rules={[
{
required: true,
message: '请输入加价金额(元)',
},
]}
>
<InputNumber
style={{ width: '200px' }}
placeholder="加价名称金额(元)"
/>
</Form.Item>
{takeawayData?.takeawayItem?.weight?.length > 0 && (
<>
<Form.Item>
<div>添加规格(如加料、甜度、辣度等)</div>
<Form.List name="specs">
{(specsFields, { add, remove }) => (
<>
{specsFields.map((field, index) => (
<Form.Item key={field.key} className={styles.conBg}>
<Form.Item
{...field}
validateTrigger={['onChange', 'onBlur']}
name={[field.name, 'specGroupName']}
rules={[
{
required: true,
whitespace: true,
message: '请输入规格名称',
},
]}
noStyle
>
<Input placeholder="规格名称" className={styles.nameWidth} />
</Form.Item>
{specsFields.length > 1 ? (
<MinusCircleOutlined
className="dynamic-delete-button"
onClick={() => remove(field.name)}
/>
) : null}
<Form.List
{...field}
name={[field.name, 'specs']}
initialValue={[
{
specName: '',
salePrice: '',
},
]}
>
{(specsInfoFields, { add: specsAdd, remove: specsRemove }) => (
<>
{specsInfoFields.map(specsInfofield => (
<Space key={specsInfofield.key} align="baseline">
<Form.Item
{...specsInfofield}
name={[specsInfofield.name, 'specName']}
rules={[
{
required: true,
message: '请输入加价名称',
},
]}
>
<Input style={{ width: '200px' }} placeholder="加价名称" />
</Form.Item>
<Form.Item
{...specsInfofield}
name={[specsInfofield.name, 'salePrice']}
rules={[
{
required: true,
message: '请输入加价金额(元)',
},
]}
>
<InputNumber
style={{ width: '200px' }}
placeholder="加价名称金额(元)"
/>
</Form.Item>
<MinusCircleOutlined
onClick={() => specsRemove(specsInfofield.name)}
/>
</Space>
))}
<Form.Item>
<Button
type="dashed"
onClick={() => specsAdd()}
block
style={{ width: '400px' }}
icon={<PlusOutlined />}
>
新增加价
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form.Item>
))}
<Form.Item>
<Button
type="primary"
onClick={() => add()}
style={{ width: '400px' }}
icon={<PlusOutlined />}
>
新增规格
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form.Item>
<Form.Item
name="receptionVolume"
label="多规格库存"
className={styles.multiSpecification}
>
<Button
size="small"
danger
style={{ marginBottom: '10px' }}
onClick={() => {
showAddRepertoryModal(true);
}}
shape="round"
>
统一设置置库存
</Button>
<div className={styles.rowWarp}>
{takeawaySku.length > 0 &&
takeawayData?.infoMation?.name &&
takeawaySku.map((item, index) => (
<div className={styles.specsBetween}>
<Form.Item label={calcLabelName(takeawayData, item)}>
<div className={styles.specsBetween}>
<span className={styles.repertoryLimit}>1/1</span>
<div
className={styles.specRepertory}
onClick={() => {
showAddRepertoryModal(true);
}}
<MinusCircleOutlined
onClick={() => specsRemove(specsInfofield.name)}
/>
</Space>
))}
<Form.Item>
<Button
type="dashed"
onClick={() => specsAdd()}
block
style={{ width: '400px' }}
icon={<PlusOutlined />}
>
新增加价
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form.Item>
))}
<Form.Item>
<Button
type="primary"
onClick={() => add()}
style={{ width: '400px' }}
icon={<PlusOutlined />}
>
设置库存
</div>
新增规格
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form.Item>
<Form.Item
name="receptionVolume"
label="多规格库存"
className={styles.multiSpecification}
>
<Button
size="small"
danger
style={{ marginBottom: '10px' }}
onClick={() => {
showAddRepertoryModal('all'); // 统一库存
}}
shape="round"
>
统一设置置库存
</Button>
<div className={styles.rowWarp}>
{mltiSpu.length > 0 &&
takeawayData?.infoMation?.name &&
mltiSpu.map((item, index) => (
<div className={styles.specsBetween}>
<Form.Item label={calcLabelName(takeawayData, item)}>
<div className={styles.specsBetween}>
<span className={styles.repertoryLimit}>1/1</span>
<div
className={styles.specRepertory}
onClick={() => {
showAddRepertoryModal('mlti'); // 多个库存
}}
>
设置库存
</div>
</div>
</Form.Item>
</div>
</Form.Item>
</div>
))}
</
div
>
</Form.Item>
))}
</div>
</Form.Item>
</>
)}
</>
)}
</Form>
{/* 加入库存 */}
<AddRepertoryModal ref={AddRepertoryRef} />
<AddRepertoryModal
ref={AddRepertoryRef}
modifiedInventory={modifiedInventory}
intactData={intactData}
repertoryModel={repertoryModel}
/>
{/* 加入多规格 */}
<AddMultiSpecModal ref={AddMultiSpecRef} />
</>
...
...
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