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
b6c7b7b9
Commit
b6c7b7b9
authored
Mar 31, 2023
by
陈万宝
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更新商品
parent
7953b2af
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
71 deletions
+139
-71
index.jsx
src/pages/GoodsManage/index.jsx
+1
-1
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+119
-70
utils.js
src/pages/ServiceGoods/utils.js
+19
-0
No files found.
src/pages/GoodsManage/index.jsx
View file @
b6c7b7b9
...
...
@@ -62,7 +62,7 @@ class goodsManage extends Component {
auditRow
:
{},
// 查看审核信息使用
isVisibleDraft
:
false
,
// 显示隐藏草稿箱
isEditDraft
:
false
,
// 是否编辑草稿
productType
:
1
,
// 商品类型
productType
:
5
,
// 商品类型
takeAway
:
{},
// 弹窗外卖商品参数
searchValue
:
{},
// 搜索条件
refresh
:
''
,
// 外卖刷新
...
...
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
b6c7b7b9
...
...
@@ -37,7 +37,7 @@ import styles from '../common.less';
import
AddRepertoryModal
from
'
./AddRepertoryModal
'
;
import
AddMultiSpecModal
from
'
./AddMultiSpecModal
'
;
import
{
apiTagList
,
apiUnits
}
from
'
../service
'
;
import
{
localAutoSaveKey
}
from
'
../utils
'
;
import
{
localAutoSaveKey
,
calcDescartes
}
from
'
../utils
'
;
import
localStorage
from
'
@/utils/localStorage
'
;
const
createInitValues
=
()
=>
({
...
...
@@ -101,8 +101,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
{
infoMation
:
name
,
infoMation
,
takeawayItem
}
=
takeawayData
;
// weight 份量 specs规格 生成sku规则 weight * specs
const
{
specs
=
tempSpecs
,
weight
=
tempWeight
,
specs
=
[]
,
weight
=
[]
,
description
,
detailImageList
,
list
,
...
...
@@ -122,6 +122,20 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
id
,
categoryId
,
}
=
takeawayItem
;
console
.
log
(
"
weight
"
,
weight
);
console
.
log
(
"
sepcx
"
,
specs
)
// const sepcx = specs.map(item => item.specs)
// let sku = [[...weight],...sepcx].reduce((x,y) =>{
// let arr = [];
// x.forEach(x => y.forEach(y => arr.push(x.concat([y]))))
// return arr;
// },[[]])
const
singularSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 单规格
const
multiSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 多规格
// const multiSpu = customer.isEdit ? skuList:[]; // 多库存spu、
...
...
@@ -172,81 +186,114 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
singularSpu
=
[{
...
temp
,
specs
:
[
specs
]
}];
setSingularSpu
(
singularSpu
);
}
console
.
log
(
"
weight
"
,
weight
,
repertoryType
,
weight
.
length
);
// 多规格
if
(
+
repertoryType
===
2
)
{
if
(
name
||
editData
.
name
)
{
//
if (name || editData.name) {
if
(
weight
.
length
)
{
weight
.
forEach
((
item
,
weightIndex
)
=>
{
if
(
item
?.
unit
&&
item
?.
unit
.
length
)
{
item
.
unit
=
item
?.
unit
&&
(
Array
.
isArray
(
item
?.
unit
)
?
item
.
unit
.
slice
(
item
.
unit
.
length
-
1
)[
0
]
:
item
.
unit
);
}
if
(
item
&&
!
item
.
specGroupName
)
{
item
.
specGroupName
=
'
份量
'
;
}
if
(
item
&&
!
item
.
generateSku
)
{
item
.
generateSku
=
1
;
multiSpecList
[
0
].
specs
=
weight
;
// 处理specList
if
(
specs
.
length
){
specs
.
forEach
((
specsItem
,
specsIndex
)
=>
{
if
(
specsItem
&&
!
specsItem
.
generateSku
)
{
specsItem
.
generateSku
=
1
;
}
multiSpecList
.
push
(
specsItem
)
})
}
multiSpecList
[
0
].
specs
=
weight
;
// 处理specList
// 循环一次 插入规则列表
let
isFirstLoops
=
true
;
console
.
log
(
"
multiSpecList
"
,
multiSpecList
);
if
(
specs
.
length
)
{
specs
.
forEach
((
specsItem
,
specsIndex
)
=>
{
if
(
specsItem
&&
!
specsItem
.
generateSku
)
{
specsItem
.
generateSku
=
1
;
}
if
(
isFirstLoops
&&
multiSpecList
.
length
<
specs
.
length
+
1
)
{
multiSpecList
.
push
(
specsItem
);
// 处理specList
}
if
(
specsItem
.
specs
.
length
>
1
)
{
specsItem
.
specs
.
forEach
((
itm
,
idx
)
=>
{
const
params
=
{
initIndex
,
unique
:
`
${
item
.
specName
}
-
${
specsItem
.
specGroupName
}
-
${
specsItem
.
specs
[
idx
].
specName
}
`
,
...
JSON
.
parse
(
JSON
.
stringify
(
temp
)),
// ...intactData?.items[initIndex],
specs
:
[
{
...
item
},
{
...
specsItem
.
specs
[
idx
],
specGroupName
:
specsItem
.
specGroupName
},
],
};
multiSpu
.
push
(
params
);
// 处理spu
initIndex
++
;
});
}
else
{
const
params
=
{
initIndex
,
unique
:
`
${
item
.
specName
}
-
${
specsItem
.
specGroupName
}
-
${
specsItem
.
specs
[
0
].
specName
}
`
,
...
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
=
{
initIndex
,
unique
:
`
${
item
?.
specName
}
`,
...JSON.parse(JSON.stringify(temp)),
// ...intactData?.items[initIndex],
specs: [{ ...item }],
};
multiSpu.push(params); // 处理spu
initIndex++;
}
});
// const sepcx = specs.map(item => item.specs)
// let sku = [[...weight],...sepcx].reduce((x,y) =>{
// let arr = [];
// x.forEach(x => y.forEach(y => arr.push(x.concat([y]))))
// return arr;
// },[[]])
let
result
=
[]
weight
.
forEach
(
item
=>
{
console
.
log
(
"
item
"
,
item
);
specs
.
forEach
((
itm
,
idx
)
=>
{
console
.
log
(
"
itm
"
,
itm
);
itm
.
specs
.
forEach
((
it
,
idx
)
=>
{
result
.
push
({...
temp
,
specs
:[
item
,
specs
[
idx
],
it
]})
})
})
})
console
.
log
(
result
,
"
result
"
)
// weight.forEach((item, weightIndex) => {
// if (item?.unit && item?.unit.length) {
// item.unit =
// item?.unit &&
// (Array.isArray(item?.unit) ? item.unit.slice(item.unit.length - 1)[0] : item.unit);
// }
// if (item && !item.specGroupName) {
// item.specGroupName = '份量';
// }
// if (item && !item.generateSku) {
// item.generateSku = 1;
// }
// multiSpecList[0].specs = weight; // 处理specList
// // 循环一次 插入规则列表
// let isFirstLoops = true;
// if (specs.length) {
// specs.forEach((specsItem, specsIndex) => {
// if (specsItem && !specsItem.generateSku) {
// specsItem.generateSku = 1;
// }
// if (isFirstLoops && multiSpecList.length < specs.length + 1) {
// multiSpecList.push(specsItem); // 处理specList
// }
// if (specsItem.specs.length > 1) {
// specsItem.specs.forEach((itm, idx) => {
// const params = {
// initIndex,
// unique: `${item.specName}-${specsItem.specGroupName}-${specsItem.specs[idx].specName}`,
// ...JSON.parse(JSON.stringify(temp)),
// // ...intactData?.items[initIndex],
// specs: [
// { ...item },
// { ...specsItem.specs[idx], specGroupName: specsItem.specGroupName },
// ],
// };
// multiSpu.push(params); // 处理spu
// initIndex++;
// });
// } else {
// const params = {
// initIndex,
// unique: `${item.specName}-${specsItem.specGroupName}-${specsItem.specs[0].specName}`,
// ...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 = {
// initIndex,
// unique: `${item?.specName}`,
// ...JSON.parse(JSON.stringify(temp)),
// // ...intactData?.items[initIndex],
// specs: [{ ...item }],
// };
// multiSpu.push(params); // 处理spu
// initIndex++;
// }
// });
}
}
//
}
console
.
log
(
"
multiSpu
"
,
multiSpu
);
if
(
tempMultiSpu
.
length
)
{
multiSpu
.
forEach
((
item
,
index
)
=>
{
tempMultiSpu
.
forEach
((
itm
,
idx
)
=>
{
...
...
@@ -257,6 +304,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
});
});
}
// let weight= form.getFieldValue('weight')
console
.
log
(
"
weight
"
,
weight
);
console
.
log
(
multiSpu
,
tempMultiSpu
,
'
multiSpumultiSpu
'
);
setMultiSpu
(
multiSpu
);
}
...
...
src/pages/ServiceGoods/utils.js
View file @
b6c7b7b9
...
...
@@ -317,3 +317,22 @@ export const onAutoSaveValue = (e, isClear) => {
localStorage.set(localAutoSaveKey, Object.assign({ type: 1 }, info, e));
}
};
export const calcDescartes = (array) => {
console.log(array,"array");
if (array.length < 2) return array[0] || [];
return [].reduce.call(array, function (col, set) {
var res = [];
col.forEach(function (c) {
set.forEach(function (s) {
var t = [].concat(Array.isArray(c) ? c : [c]);
t.push(s);
res.push(t);
})
});
return res;
});
}
\ No newline at end of file
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