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
4ff4d225
Commit
4ff4d225
authored
Mar 26, 2023
by
陈万宝
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更新商品库
parent
1a4aa07b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
32 deletions
+37
-32
AddRepertoryModal.jsx
src/pages/ServiceGoods/components/AddRepertoryModal.jsx
+5
-13
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+32
-19
No files found.
src/pages/ServiceGoods/components/AddRepertoryModal.jsx
View file @
4ff4d225
...
...
@@ -16,7 +16,6 @@ const AddRepertoryModal = (props, ref) => {
});
const
{
modifiedInventory
,
intactData
,
repertoryModel
}
=
props
;
console
.
log
(
'
repertoryModel
'
,
repertoryModel
);
const
{
type
,
idx
,
item
}
=
repertoryModel
;
useImperativeHandle
(
ref
,
()
=>
({
// changeVal 就是暴露给父组件的方法
...
...
@@ -26,14 +25,12 @@ const AddRepertoryModal = (props, ref) => {
}));
// 自动补全
const
onChangeAutoStock
=
e
=>
{
console
.
log
(
'
onChangeAutoStock
'
);
form
.
setFieldsValue
({
autoStock
:
e
?
1
:
0
,
});
};
// 勾选库存设置
const
onChangeSetRepertory
=
e
=>
{
console
.
log
(
'
form
'
,
form
);
setRepertoryState
(
`
${
e
.
target
.
value
}
`
);
if
(
+
e
.
target
.
value
===
0
)
{
form
.
setFieldsValue
({
...
...
@@ -57,25 +54,23 @@ const AddRepertoryModal = (props, ref) => {
};
const
getFormValues
=
debounce
(()
=>
{
const
values
=
form
.
getFieldsValue
();
console
.
log
(
'
values========
'
,
values
);
},
400
);
const
handleOk
=
async
()
=>
{
const
values
=
await
form
.
validateFields
();
values
.
autoStock
=
values
.
autoStock
?
1
:
0
;
// 回调库存
modifiedInventory
(
type
,
idx
,
values
);
//
setConfirmLoading(true);
//
setTimeout(() => {
//
setOpenRepertory(false);
//
setConfirmLoading(false);
// }, 2
000);
setConfirmLoading
(
true
);
setTimeout
(()
=>
{
setOpenRepertory
(
false
);
setConfirmLoading
(
false
);
},
1
000
);
};
const
handleCancel
=
()
=>
{
setOpenRepertory
(
false
);
};
useEffect
(()
=>
{
console
.
log
(
'
333
'
,
repertoryModel
);
if
(
item
?.
serviceItem
)
{
const
{
productStock
=
1
,
autoStock
=
0
,
maxStock
=
2
}
=
item
?.
serviceItem
;
const
params
=
{
...
...
@@ -83,11 +78,8 @@ const AddRepertoryModal = (props, ref) => {
autoStock
:
+
autoStock
===
1
,
maxStock
,
};
console
.
log
(
'
params=====
'
,
params
);
switch
(
type
)
{
case
'
all
'
:
// 统一设置
console
.
log
(
'
params
'
,
params
);
form
.
setFieldsValue
(
params
);
break
;
case
'
multi
'
:
// 多规格设置
...
...
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
4ff4d225
...
...
@@ -128,6 +128,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
multiSpu
=
[];
// 单库存spu
let
singularSpu
=
[];
// 多库存spu
const
saleTimesTemp
=
[];
let
initIndex
=
0
;
if
(
saleTimes
.
length
)
{
saleTimes
.
forEach
(
item
=>
{
const
startTime
=
item
?
moment
(
item
[
0
]).
format
(
format
)
:
''
;
...
...
@@ -166,12 +167,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
};
singularSpecList
[
0
].
specs
=
[
specs
];
singularSpu
=
[{
...
temp
,
specs
:
[
specs
]
}];
console
.
log
(
'
2222
'
,
singularSpu
);
setSingularSpu
(
singularSpu
);
}
// 多规格
if
(
+
repertoryType
===
2
)
{
console
.
log
(
'
222
'
);
if
(
name
)
{
if
(
weight
.
length
)
{
weight
.
forEach
((
item
,
weightIndex
)
=>
{
...
...
@@ -194,32 +193,42 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if
(
specsItem
.
specs
.
length
>
1
)
{
specsItem
.
specs
.
forEach
((
itm
,
idx
)
=>
{
const
params
=
{
...
temp
,
initIndex
,
...
JSON
.
parse
(
JSON
.
stringify
(
temp
)),
...
intactData
?.
items
[
initIndex
],
specs
:
[
{
...
item
},
{
...
specsItem
.
specs
[
idx
],
specGroupName
:
specsItem
.
specGroupName
},
],
};
multiSpu
.
push
(
params
);
// 处理spu
initIndex
++
;
});
}
else
{
const
params
=
{
...
temp
,
initIndex
,
...
JSON
.
parse
(
JSON
.
stringify
(
temp
)),
...
intactData
?.
items
[
initIndex
],
specs
:
[
{
...
item
},
{
...
specsItem
.
specs
[
0
],
specGroupName
:
specsItem
.
specGroupName
},
],
};
multiSpu
.
push
(
params
);
// 处理spu
initIndex
++
;
}
});
isFirstLoops
=
false
;
}
else
{
const
params
=
{
...
temp
,
initIndex
,
...
JSON
.
parse
(
JSON
.
stringify
(
temp
)),
...
intactData
?.
items
[
initIndex
],
specs
:
[{
...
item
}],
};
multiSpu
.
push
(
params
);
// 处理spu
initIndex
++
;
}
});
}
...
...
@@ -228,7 +237,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setMultiSpu
(
multiSpu
);
}
// +repertoryType === 1 单规格 2多规格
const
intactData
=
{
const
intactData
Temp
=
{
type
:
5
,
// 外卖类型
...
infoMation
,
label
:
label
&&
label
.
toString
(),
...
...
@@ -237,15 +246,15 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
detailImageList
,
singleDelivery
,
specList
:
+
repertoryType
===
1
?
singularSpecList
:
multiSpecList
,
// 单库存和多库存specList
items
:
+
repertoryType
===
1
?
singularSpu
:
multiSpu
,
items
:
+
repertoryType
===
1
?
singularSpu
:
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
))
,
categoryId
:
(
infoMation
?.
categoryId
&&
infoMation
?.
categoryId
.
slice
(
infoMation
.
categoryId
.
length
-
1
)
).
toString
(),
storageRackIds
:
[
1633015955205664770
],
};
console
.
log
(
'
intactData======>
'
,
intactData
);
setIntactData
(
intactData
);
return
intactData
;
setIntactData
(
intactData
Temp
);
return
false
;
};
const
onChange
=
()
=>
{};
...
...
@@ -259,26 +268,30 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
takeawayData
=
localStorage
.
get
(
localAutoSaveKey
);
console
.
log
(
'
takeawayData
'
,
takeawayData
);
setTakeawayData
(
takeawayData
);
console
.
log
(
"
3333
"
,
isCalcTakeaway
);
takeawayCalc
(
takeawayData
);
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
);
console
.
log
(
'
index===2222
'
,
+
idx
,
intactData
);
const
temp
=
{
...
intactData
};
setIntactData
(
temp
);
}
}
if
(
type
===
'
all
'
)
{
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
);
}
...
...
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