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
36782629
Commit
36782629
authored
Mar 27, 2023
by
陈万宝
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更新商品添加
parent
4ff4d225
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
37 deletions
+84
-37
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+84
-37
No files found.
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
36782629
...
@@ -77,6 +77,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -77,6 +77,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
[
intactData
,
setIntactData
]
=
useState
({});
const
[
intactData
,
setIntactData
]
=
useState
({});
const
[
repertoryState
,
setRepertoryState
]
=
useState
(
''
);
const
[
repertoryState
,
setRepertoryState
]
=
useState
(
''
);
const
[
repertoryModel
,
setRepertoryModel
]
=
useState
({});
const
[
repertoryModel
,
setRepertoryModel
]
=
useState
({});
const
[
tempMultiSpu
,
setTempMultiSpu
]
=
useState
([]);
const
initialDealValue
=
[
const
initialDealValue
=
[
{
{
specGroupName
:
''
,
specGroupName
:
''
,
...
@@ -125,8 +126,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -125,8 +126,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}
=
takeawayItem
;
}
=
takeawayItem
;
const
singularSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 单规格
const
singularSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 单规格
const
multiSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 多规格
const
multiSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 多规格
const
multiSpu
=
[];
//
单库存spu
const
multiSpu
=
[];
//
多库存spu、
let
singularSpu
=
[];
//
多
库存spu
let
singularSpu
=
[];
//
单
库存spu
const
saleTimesTemp
=
[];
const
saleTimesTemp
=
[];
let
initIndex
=
0
;
let
initIndex
=
0
;
if
(
saleTimes
.
length
)
{
if
(
saleTimes
.
length
)
{
...
@@ -172,21 +173,28 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -172,21 +173,28 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
// 多规格
// 多规格
if
(
+
repertoryType
===
2
)
{
if
(
+
repertoryType
===
2
)
{
if
(
name
)
{
if
(
name
)
{
console
.
log
(
'
weight
'
,
weight
);
if
(
weight
.
length
)
{
if
(
weight
.
length
)
{
weight
.
forEach
((
item
,
weightIndex
)
=>
{
weight
.
forEach
((
item
,
weightIndex
)
=>
{
console
.
log
(
'
eee====
'
,
item
);
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
();
item
.
unit
=
item
.
unit
.
slice
(
item
.
unit
.
length
-
1
).
toString
();
}
}
item
.
specGroupName
=
'
份量
'
;
if
(
item
&&
!
item
.
specGroupName
)
{
item
.
generateSku
=
1
;
item
.
specGroupName
=
'
份量
'
;
}
if
(
item
&&
!
item
.
generateSku
)
{
item
.
generateSku
=
1
;
}
multiSpecList
[
0
].
specs
=
weight
;
// 处理specList
multiSpecList
[
0
].
specs
=
weight
;
// 处理specList
// 循环一次 插入规则列表
// 循环一次 插入规则列表
let
isFirstLoops
=
true
;
let
isFirstLoops
=
true
;
if
(
specs
.
length
)
{
if
(
specs
.
length
)
{
specs
.
forEach
((
specsItem
,
specsIndex
)
=>
{
specs
.
forEach
((
specsItem
,
specsIndex
)
=>
{
specsItem
.
generateSku
=
1
;
if
(
specsItem
&&
!
specsItem
.
generateSku
)
{
specsItem
.
generateSku
=
1
;
}
if
(
isFirstLoops
&&
multiSpecList
.
length
<
specs
.
length
+
1
)
{
if
(
isFirstLoops
&&
multiSpecList
.
length
<
specs
.
length
+
1
)
{
multiSpecList
.
push
(
specsItem
);
// 处理specList
multiSpecList
.
push
(
specsItem
);
// 处理specList
}
}
...
@@ -194,8 +202,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -194,8 +202,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
specsItem
.
specs
.
forEach
((
itm
,
idx
)
=>
{
specsItem
.
specs
.
forEach
((
itm
,
idx
)
=>
{
const
params
=
{
const
params
=
{
initIndex
,
initIndex
,
unique
:
`
${
item
.
specName
}
-
${
specsItem
.
specGroupName
}
-
${
specsItem
.
specs
[
idx
].
specName
}
`
,
...
JSON
.
parse
(
JSON
.
stringify
(
temp
)),
...
JSON
.
parse
(
JSON
.
stringify
(
temp
)),
...
intactData
?.
items
[
initIndex
],
//
...intactData?.items[initIndex],
specs
:
[
specs
:
[
{
...
item
},
{
...
item
},
{
...
specsItem
.
specs
[
idx
],
specGroupName
:
specsItem
.
specGroupName
},
{
...
specsItem
.
specs
[
idx
],
specGroupName
:
specsItem
.
specGroupName
},
...
@@ -208,8 +217,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -208,8 +217,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}
else
{
}
else
{
const
params
=
{
const
params
=
{
initIndex
,
initIndex
,
unique
:
`
${
item
.
specName
}
-
${
specsItem
.
specGroupName
}
-
${
specsItem
.
specs
[
0
].
specName
}
`
,
...
JSON
.
parse
(
JSON
.
stringify
(
temp
)),
...
JSON
.
parse
(
JSON
.
stringify
(
temp
)),
...
intactData
?.
items
[
initIndex
],
//
...intactData?.items[initIndex],
specs
:
[
specs
:
[
{
...
item
},
{
...
item
},
{
...
specsItem
.
specs
[
0
],
specGroupName
:
specsItem
.
specGroupName
},
{
...
specsItem
.
specs
[
0
],
specGroupName
:
specsItem
.
specGroupName
},
...
@@ -223,8 +233,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -223,8 +233,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}
else
{
}
else
{
const
params
=
{
const
params
=
{
initIndex
,
initIndex
,
unique
:
`
${
item
?.
specName
}
`,
...JSON.parse(JSON.stringify(temp)),
...JSON.parse(JSON.stringify(temp)),
...
intactData
?.
items
[
initIndex
],
//
...intactData?.items[initIndex],
specs: [{ ...item }],
specs: [{ ...item }],
};
};
multiSpu.push(params); // 处理spu
multiSpu.push(params); // 处理spu
...
@@ -233,9 +244,25 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -233,9 +244,25 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
});
});
}
}
}
}
console
.
log
(
'
multiSpu
'
,
multiSpu
);
// console.log('multiSpu', multiSpu);
console.log("multiSpu===1111",multiSpu);
if(tempMultiSpu.length){
multiSpu.forEach((item,index)=>{
tempMultiSpu.forEach((itm,idx)=>{
if(item.unique === itm.unique ){
item.serviceItem = itm.serviceItem
}
})
})
}
// debugger
console.log("multiSpu===2222",multiSpu);
setMultiSpu(multiSpu);
setMultiSpu(multiSpu);
}
}
// debugger
// +repertoryType === 1 单规格 2多规格
// +repertoryType === 1 单规格 2多规格
const intactDataTemp = {
const intactDataTemp = {
type: 5, // 外卖类型
type: 5, // 外卖类型
...
@@ -250,11 +277,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -250,11 +277,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
categoryId: (
categoryId: (
infoMation?.categoryId && infoMation?.categoryId.slice(infoMation.categoryId.length - 1)
infoMation?.categoryId && infoMation?.categoryId.slice(infoMation.categoryId.length - 1)
).toString(),
).toString(),
storageRackIds
:
[
1633015955205664770
],
// storageRackIds:infoMation?.storageRackIds ? infoMation?.storageRackIds:[
],
};
};
console.log('intactData======>', intactData);
console.log('intactData======>', intactData);
setIntactData(intactDataTemp);
setIntactData(intactDataTemp);
return
false
;
return
intactData
;
};
};
const onChange = () => {};
const onChange = () => {};
...
@@ -275,14 +302,28 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -275,14 +302,28 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const modifiedInventory = (type, idx, values) => {
const modifiedInventory = (type, idx, values) => {
const { productStock, maxStock, autoStock } = values;
const { productStock, maxStock, autoStock } = values;
if (type === 'multi') {
if (type === 'multi') {
if
(
intactData
?.
items
.
length
)
{
multiSpu.map(item => {
intactData
.
items
[
+
idx
].
serviceItem
.
productStock
=
productStock
;
if (item.unique === idx) {
intactData
.
items
[
+
idx
].
serviceItem
.
autoStock
=
autoStock
;
item.serviceItem.productStock = productStock;
intactData
.
items
[
+
idx
].
serviceItem
.
maxStock
=
maxStock
;
item.serviceItem.autoStock = autoStock;
console
.
log
(
'
index===2222
'
,
+
idx
,
intactData
);
item.serviceItem.maxStock = maxStock;
const
temp
=
{
...
intactData
};
}
setIntactData
(
temp
);
return item;
}
});
let temp = JSON.parse(JSON.stringify(multiSpu))
tempMultiSpu.push(...temp)
setTempMultiSpu(tempMultiSpu)
setMultiSpu(temp);
console.log('33333========>', multiSpu,tempMultiSpu);
// if (intactData?.items.length) {
// intactData.items[+idx].serviceItem.productStock = productStock;
// intactData.items[+idx].serviceItem.autoStock = autoStock;
// intactData.items[+idx].serviceItem.maxStock = maxStock;
// console.log('index===2222', +idx, intactData);
// const temp = { ...intactData };
// setIntactData(temp);
// }
}
}
if (type === 'all') {
if (type === 'all') {
if (intactData?.items.length) {
if (intactData?.items.length) {
...
@@ -1010,25 +1051,31 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -1010,25 +1051,31 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
</Button>
</Button>
<div className={styles.rowWarp}>
<div className={styles.rowWarp}>
{multiSpu.length > 0 &&
{multiSpu.length > 0 &&
intactData?.name &&
multiSpu?.map((item, idx) => (
intactData?.items?.map((item, idx) => (
<>
<div key={idx} className={styles.specsBetween}>
{item.unique && (
<Form.Item label={calcLabelName(intactData, item)}>
<>
<div className={styles.specsBetween}>
<div key={idx} className={styles.specsBetween}>
<span className={styles.repertoryLimit}>
<Form.Item label={calcLabelName(intactData, item)}>
{item?.serviceItem?.productStock}/{item?.serviceItem?.maxStock}
<div className={styles.specsBetween}>
</span>
<span className={styles.repertoryLimit}>
<div
{item?.serviceItem?.productStock}/
className={styles.specRepertory}
{item?.serviceItem?.maxStock}
onClick={() => {
</span>
showAddRepertoryModal('multi', `
$
{
idx
}
`, item); // 多个库存
<div
}}
className={styles.specRepertory}
>
onClick={() => {
设置库存{idx}
showAddRepertoryModal('multi', `
$
{
item
.
unique
}
`, item); // 多个库存
}}
>
设置库存{item.unique}
</div>
</div>
</Form.Item>
</div>
</div>
</
div
>
</>
</Form.Item>
)}
</
div
>
</>
))}
))}
</div>
</div>
</Form.Item>
</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