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
30a4c555
Commit
30a4c555
authored
Jan 16, 2022
by
beisir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 有一级没二级情况生成数据
parent
fe92a03d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
3 deletions
+41
-3
index.jsx
src/pages/GoodsManage/createModal/index.jsx
+11
-1
mixin.jsx
src/pages/GoodsManage/createModal/mixin.jsx
+30
-2
No files found.
src/pages/GoodsManage/createModal/index.jsx
View file @
30a4c555
...
...
@@ -447,7 +447,7 @@ class goodsManage extends Component {
const
isSecondSame
=
specValidate
(
second
,
initData
.
secondSpecList
,
initData
.
id
);
if
(
isFirstSame
)
first
.
pop
();
if
(
isSecondSame
)
second
.
pop
();
cons
t
colorKeys
=
isEdit
le
t
colorKeys
=
isEdit
?
initData
.
firstSpecList
.
concat
(
first
||
this
.
state
.
initForm
.
first
||
[])
:
first
||
this
.
state
.
initForm
.
first
||
[];
...
...
@@ -474,6 +474,15 @@ class goodsManage extends Component {
const
brandListArray
=
productType
===
2
?
brandList
:
normalBrandList
;
dataInit
(
this
.
state
.
editData
);
const
filterOption
=
(
input
,
op
)
=>
op
.
props
.
children
.
includes
(
input
);
// ---------------------驳回编辑规格时候,过滤掉colors中为null的数据---------------------
if
(
isEdit
)
{
if
(
!
initData
.
editData
[
0
]?.
firstSpec
&&
!
initData
.
editData
[
0
]?.
secondSpec
)
{
if
(
colorKeys
.
length
>
1
)
{
colorKeys
=
colorKeys
.
filter
(
item
=>
item
!==
'
null
'
);
}
}
}
return
(
<
Modal
title=
{
initData
.
id
?
'
修改商品
'
:
'
新增商品
'
}
...
...
@@ -806,6 +815,7 @@ class goodsManage extends Component {
colorKeys
.
map
(
color
=>
{
if
(
JSON
.
stringify
(
color
)
===
'
{}
'
)
return
[];
if
((
color
!==
null
&&
!
color
)
||
(
color
&&
!
color
.
trim
()))
return
[];
// if (initData.)
{}
return
[
<
Row
>
<
Col
span=
{
1
}
>
...
...
src/pages/GoodsManage/createModal/mixin.jsx
View file @
30a4c555
...
...
@@ -81,6 +81,7 @@ export function createNewList(first, second, firstSpecId, secondSpecId) {
}
export
function
createEditData
(
values
,
initData
)
{
console
.
log
(
values
);
let
list
=
null
;
const
first
=
values
.
first
?.
filter
(
item
=>
item
&&
!
item
.
match
(
/^
[
]
*$/
))
||
[];
const
second
=
...
...
@@ -110,7 +111,9 @@ export function createEditData(values, initData) {
const
list2
=
second
.
length
?
createNewList
(
newFirst
,
second
,
values
.
firstSpecId
,
values
.
secondSpecId
)
:
[];
// console.log('list1===========>', list1);
// console.log('list2===========>', list2);
console
.
log
(
'
initData===========>
'
,
initData
);
// 初次添加规格时没有选择规格,添加一条没有规格的商品,被驳回之后编辑时选择规格之后需要重新创建
// 编辑时回显时的id需要给重新创建的数据第一条加上 回显的id
if
(
!
initData
.
editData
[
0
]?.
firstSpec
&&
!
initData
.
editData
[
0
]?.
secondSpec
)
{
...
...
@@ -118,6 +121,32 @@ export function createEditData(values, initData) {
// 这种情况出现时items中只有一条数据
// 第一次无规格时,重新生成的数据,必须保留第一条数据的id是items里面第一条数据的id
list
[
0
].
id
=
initData
.
editData
[
0
].
id
;
}
else
if
(
initData
.
editData
[
0
]?.
firstSpec
&&
!
initData
.
editData
[
0
]?.
secondSpec
)
{
console
.
log
(
'
只有一级规格================>
'
);
console
.
log
(
first
);
console
.
log
(
second
);
list
=
createNewList
(
[...
initData
.
firstSpecList
,
...
first
],
second
,
values
.
firstSpecId
,
values
.
secondSpecId
,
);
// const editObject = initData.editData.concat(list1).reduce((itemObject, item) => {
// itemObject[item.firstSpecValue] = item;
// return itemObject;
// }, {});
// const newList = createNewList([...initData.firstSpecList, ...first], second, values.firstSpecId, values.secondSpecId);
// list = newList.map(item => {
// console.log(initData.firstSpecList, item.firstSpecValue, editObject);
// if (Object.keys(editObject).includes(item.firstSpecValue)) {
// item = Object.assign({}, editObject[item.firstSpecValue], item);
// delete editObject[item.firstSpecValue];
// console.log('============>拼装', editObject, editObject[item.firstSpecValue]);
// }
// return item;
// });
console
.
log
(
list
);
}
else
{
list
=
sortBy
(
initData
.
editData
.
concat
(
list1
.
concat
(
list2
)),
item
=>
item
.
firstSpecValue
);
}
...
...
@@ -147,7 +176,6 @@ export function validateSpuInfo(values, initData, editData, productType) {
notification
.
warning
({
message
:
'
请完善表格:
'
,
description
:
checkString
,
duration
:
null
,
});
return
true
;
}
...
...
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