Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
陈智峰
jinfa-platform
Commits
2451c572
Commit
2451c572
authored
Nov 04, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:处理新增商品仅填写某些选项卡后点击保存的错误提示
parent
aa850a8d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
14 deletions
+26
-14
addProducts.tsx
src/pages/commodity/products/addProducts.tsx
+26
-14
No files found.
src/pages/commodity/products/addProducts.tsx
View file @
2451c572
...
...
@@ -154,12 +154,11 @@ const AddProducts: React.FC<{}> = (props) => {
_itme
.
customerAttribute
=
{
id
:
_itme
.
customerAttributeId
}
delete
_itme
.
attributeName
delete
_itme
.
isPrice
// delete _itme.customerAttributeId
})
let
_bacsicForm
=
{
...
values
[
0
]
}
if
(
values
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
values
.
length
;
i
++
)
{
// 过滤出物流
form
// 过滤出物流
表单
if
(
values
[
i
].
deliveryType
)
{
_bacsicForm
=
{
...
_bacsicForm
,
logistics
:
{
...
values
[
i
]
}
}
}
else
{
...
...
@@ -168,7 +167,7 @@ const AddProducts: React.FC<{}> = (props) => {
}
}
_bacsicForm
.
customerCategoryId
=
_bacsicForm
.
customerCategoryId
[
_bacsicForm
.
customerCategoryId
.
length
-
1
]
// 移除描述中的[]
// 移除描述中的
空数组
[]
let
_productDescription
=
{
...
productDescription
}
for
(
let
i
in
_productDescription
){
if
(
_productDescription
[
i
]?.
length
===
0
){
...
...
@@ -245,25 +244,24 @@ const AddProducts: React.FC<{}> = (props) => {
return
e
}
_params
.
unitPriceAndPicList
=
_productAttributeAndImageParams
}
else
{
// 编辑 没有点击商品图片
}
else
{
// 编辑时没有点击商品图片(新增没有点击也就没有数据)
if
(
productInfoByEdit
){
_params
.
unitPriceAndPicList
=
productInfoByEdit
.
unitPriceAndPicList
if
(
clickTabIndex
.
indexOf
(
"4"
)
!==
-
1
)
{
// 没有点击图片单单修改了商品价格 取原有的图片和新的价格合成
// 没有点击图片单单修改了商品价格 取原有的图片和新的价格合成
if
(
clickTabIndex
.
indexOf
(
"4"
)
!==
-
1
)
{
_params
.
unitPriceAndPicList
=
priceAttributeParams
.
map
((
item
,
index
)
=>
{
return
{
goods
:
{
id
:
item
.
goodsId
},
attributeAndValueList
:
item
.
attributeAndValueList
,
// .map(_item => {
// return {
// customerAttribute: { id: _item.customerAttributeId },
// customerAttributeValue: { id: _item.id, value: _item.value }
// }
// }),
unitPrice
:
item
.
unitPrice
,
commodityPic
:
productInfoByEdit
.
unitPriceAndPicList
[
index
].
commodityPic
}
})
}
}
}
if
(
productInfoByEdit
){
//(新增没有点击也就没有数据)
if
(
clickTabIndex
.
indexOf
(
"3"
)
===
-
1
)
// 商品属性
_params
.
commodityAttributeList
=
productInfoByEdit
.
commodityAttributeList
if
(
clickTabIndex
.
indexOf
(
"4"
)
===
-
1
)
{
// 价格属性
...
...
@@ -283,16 +281,30 @@ const AddProducts: React.FC<{}> = (props) => {
_params
.
packing
=
productInfoByEdit
.
packing
_params
.
afterService
=
productInfoByEdit
.
afterService
}
}
// 校验属性单位重量是否提供发票
try
{
if
(
!
_params
.
commodityAttributeList
.
length
&&
!
_params
?.
unitId
&&
typeof
(
_params
.
isInvoice
)
!==
'boolean'
&&
!
_params
?.
logistics
?.
weight
){
throw
new
Error
(
'请完善商品其他信息!'
)
}
}
catch
(
e
)
{
return
e
}
// 校验价格
try
{
if
(
_params
.
unitPriceAndPicList
){
let
hasPriceArray
=
_params
.
unitPriceAndPicList
.
map
(
item
=>
item
.
unitPrice
)
hasPriceArray
.
map
(
item
=>
{
if
(
JSON
.
stringify
(
item
)
===
'{}'
&&
_params
.
priceType
!==
2
)
// 除价格需要询问类型 其他都需要校验价格或积分
throw
new
Error
(
_params
.
priceType
===
1
?
'商品价格为必填项!'
:
'商品积分为必填项!'
)
})
}
}
catch
(
e
)
{
return
e
}
// 移除混入的id数字类的键值项
let
numberKeys
=
Object
.
keys
(
_params
).
map
(
_
=>
Number
(
_
)).
filter
(
Boolean
)
if
(
numberKeys
.
length
>
0
)
...
...
@@ -310,20 +322,20 @@ const AddProducts: React.FC<{}> = (props) => {
}).
then
(
e
=>
{
if
(
e
)
{
setIsDisableSaveBtn
(
false
)
message
.
error
(
e
.
message
)
message
.
error
(
e
.
message
||
'请完善商品其他信息!'
)
}
console
.
log
(
e
,
'e'
)
}).
catch
(
error
=>
{
console
.
log
(
error
,
'_error'
)
setIsDisableSaveBtn
(
false
)
if
(
error
.
messge
)
message
.
error
(
error
.
message
)
message
.
error
(
error
.
message
||
'请完善商品其他信息!'
)
else
message
.
error
(
error
.
errorFields
[
0
].
errors
.
toString
())
})
}
catch
(
e
)
{
setIsDisableSaveBtn
(
false
)
message
.
error
(
e
.
message
)
message
.
error
(
e
.
message
||
'请完善商品其他信息!'
)
console
.
log
(
e
,
'error'
)
}
...
...
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