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
e61c50de
Commit
e61c50de
authored
Apr 02, 2023
by
baxibaba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更新显示框
parent
f5fe20b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
14 deletions
+46
-14
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+46
-14
No files found.
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
e61c50de
...
...
@@ -78,6 +78,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
[
tempWeight
,
setTempWeight
]
=
useState
([]);
const
[
tempSpecs
,
setTempSpecs
]
=
useState
([]);
const
[
weightUnits
,
setWeightUnits
]
=
useState
([]);
const
[
peopleUnits
,
setPeopleUnits
]
=
useState
([]);
// 自定义加入菜单
const
showModal
=
()
=>
{
...
...
@@ -198,6 +199,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
});
}
const
sepcx
=
specs
.
map
(
item
=>
item
.
specs
);
sepcx
.
map
(
item
=>
{
item
.
unit
=
''
;
});
// 生成 specs 规格sku
let
tempSku
=
[[...
weight
],
...
sepcx
].
reduce
(
(
x
,
y
)
=>
{
...
...
@@ -230,18 +234,25 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
item
.
salePrice
=
0
;
item
.
unique
=
item
?.
specs
.
map
(
itm
=>
{
itm
.
unit
=
itm
.
unit
&&
(
Array
.
isArray
(
itm
?.
unit
)
?
itm
.
unit
.
slice
(
itm
.
unit
.
length
-
1
)[
0
]
:
itm
.
unit
);
if
(
itm
.
unit
)
{
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
)
=>
{
console
.
log
(
'
item===
'
,
item
);
tempMultiSpu
.
forEach
((
itm
,
idx
)
=>
{
if
(
item
.
unique
===
itm
.
unique
)
{
item
.
serviceItem
=
objectComparison
(
item
.
serviceItem
,
itm
);
...
...
@@ -249,6 +260,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
});
});
}
console
.
log
(
multiSpu
,
'
multiSpumultiSpu
'
);
setMultiSpu
(
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
)));
}
}
...
...
@@ -288,6 +301,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
onChange
=
()
=>
{};
const
getFormValues
=
debounce
(()
=>
{
const
values
=
form
.
getFieldsValue
();
console
.
log
(
values
,
'
values===
'
);
props
.
onValuesChange
({
takeawayItem
:
JSON
.
parse
(
JSON
.
stringify
(
values
))
});
const
takeawayData
=
customer
.
isEdit
?
{
takeawayItem
:
Object
.
assign
({},
editData
,
values
)
}
...
...
@@ -452,10 +466,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if (!unitsList.length) {
const res = await apiUnits();
setUnitsList(res.data || []);
let temp = res.data.filter(item => item.name === '准确重量单位');
if (temp.length && temp[0]?.children) {
const tempWeightName = temp[0]?.children.map(item => item.name);
let tempWeight = res.data.filter(item => item.name === '准确重量单位');
let tempPeople = res.data.filter(item => item.name === '适用人数');
if (tempWeight.length && tempWeight[0]?.children) {
const tempWeightName = tempWeight[0]?.children.map(item => item.name);
sessionStorage.setItem('weightUnits', JSON.stringify(tempWeightName || []));
setWeightUnits(tempWeightName);
}
if (tempPeople.length && tempPeople[0]?.children) {
const tempPeopleName = tempPeople[0]?.children.map(item => item.name);
sessionStorage.setItem('peopleUnits', JSON.stringify(tempPeopleName || []));
setPeopleUnits(tempPeopleName);
}
}
setTempMultiSpu([]);
...
...
@@ -870,7 +892,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
<Form.List name="weight" initialValue={[{}]}>
{(weightFields, { add: weightAdd, remove: weightRemove }) => (
<>
{weightFields.map(
weightField
=> (
{weightFields.map(
(weightField, index)
=> (
<Space key={weightField.key} align="baseline" className={styles.conBg}>
<Form.Item
{...weightField}
...
...
@@ -884,25 +906,35 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
>
<Input style={{ width: '200px' }} placeholder="名称" />
</Form.Item>
{weightUnits.includes(form.getFieldValue(['weight'])?.[index]?.unit) && (
<span className="ant-form-text"> 约</span>
)}
<Form.Item
style={{
display:
peopleUnits.includes(form.getFieldValue(['weight'])?.[index]?.unit) &&
'none',
}}
{...weightField}
name={[weightField.name, 'quantity']}
rules={[
{
required: true,
required: peopleUnits.includes(
form.getFieldValue(['weight'])?.[index]?.unit,
)
? false
: true,
message: '份量',
},
]}
>
<InputNumber
style={{ width: '
20
0px' }}
style={{ width: '
12
0px' }}
max={999999999}
min={0}
placeholder="约 份量(数字)"
/>
</Form.Item>
<span className="ant-form-text"> 约</span>
<Form.Item
{...weightField}
name={[weightField.name, 'unit']}
...
...
@@ -941,7 +973,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
max={999999999}
min={0}
precision={2}
style={{ width: '
20
0px' }}
style={{ width: '
12
0px' }}
placeholder="销售价(元)"
/>
</Form.Item>
...
...
@@ -959,7 +991,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
max={999999999}
min={0}
precision={2}
style={{ width: '
20
0px' }}
style={{ width: '
12
0px' }}
placeholder="活动价(元)"
/>
</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