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
shenshaokai
jinfa-platform
Commits
e8c20cc3
Commit
e8c20cc3
authored
May 10, 2021
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 处理新增商品直接点图片上传页面异常问题
parent
cae4295a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
23 deletions
+27
-23
productImageForm.tsx
...s/commodity/products/addProductsItem/productImageForm.tsx
+27
-23
No files found.
src/pages/commodity/products/addProductsItem/productImageForm.tsx
View file @
e8c20cc3
...
@@ -13,7 +13,7 @@ import { inject, observer } from 'mobx-react'
...
@@ -13,7 +13,7 @@ import { inject, observer } from 'mobx-react'
import
{
store
}
from
'@/store'
import
{
store
}
from
'@/store'
const
ProductImageForm
:
React
.
FC
<
{}
>
=
(
props
)
=>
{
const
ProductImageForm
:
React
.
FC
<
{}
>
=
(
props
)
=>
{
const
[
defaultChecked
,
setDefaultChecked
]
=
useState
(
-
1
)
const
[
defaultChecked
,
setDefaultChecked
]
=
useState
(
-
1
)
const
[
priceAttributeParamsByRender
,
setPriceAttributeParamsByRender
]
=
useState
<
any
[]
>
([])
const
[
priceAttributeParamsByRender
,
setPriceAttributeParamsByRender
]
=
useState
<
any
[]
>
([])
const
[
commonImageList
,
setCommonImageList
]
=
useState
<
any
>
([])
const
[
commonImageList
,
setCommonImageList
]
=
useState
<
any
>
([])
const
[
previewVisible
,
setPreviewVisible
]
=
useState
(
false
)
const
[
previewVisible
,
setPreviewVisible
]
=
useState
(
false
)
...
@@ -30,13 +30,13 @@ const ProductImageForm: React.FC<{}> = (props) => {
...
@@ -30,13 +30,13 @@ const ProductImageForm: React.FC<{}> = (props) => {
const
editRowIndexRef
=
useRef
<
number
>
(
0
)
const
editRowIndexRef
=
useRef
<
number
>
(
0
)
const
{
ProductStore
}
=
store
const
{
ProductStore
}
=
store
const
{
const
{
priceAttributeParams
,
priceAttributeParams
,
productInfoByEdit
,
productInfoByEdit
,
setProductAttributeAndImageParams
,
setProductAttributeAndImageParams
,
setIsAllAttributePic
,
setIsAllAttributePic
,
selectCategoryId
,
selectCategoryId
,
tabClickItem
tabClickItem
}
=
ProductStore
}
=
ProductStore
// 再次点击tab 选中置为0
// 再次点击tab 选中置为0
...
@@ -209,17 +209,22 @@ const ProductImageForm: React.FC<{}> = (props) => {
...
@@ -209,17 +209,22 @@ const ProductImageForm: React.FC<{}> = (props) => {
uploadFileSelectRef
.
current
=
{}
uploadFileSelectRef
.
current
=
{}
}
}
setCommonImageList
(
fileList
)
setCommonImageList
(
fileList
)
// @5.10 commodityPic字段异常 表明前面商品信息未完善 使用trycatch捕获
_priceAttributeParams
[
index
||
editRowIndexRef
.
current
].
commodityPic
=
fileList
try
{
if
(
!
file
?.
status
&&
file
?.
status
!==
'done'
){
_priceAttributeParams
[
index
||
editRowIndexRef
.
current
].
commodityPic
=
fileList
let
ttt
=
_priceAttributeParams
[
index
||
editRowIndexRef
.
current
].
commodityPic
.
filter
(
_
=>
_
.
status
===
'done'
)
if
(
!
file
?.
status
&&
file
?.
status
!==
'done'
){
_priceAttributeParams
[
index
||
editRowIndexRef
.
current
].
commodityPic
=
ttt
let
ttt
=
_priceAttributeParams
[
index
||
editRowIndexRef
.
current
].
commodityPic
.
filter
(
_
=>
_
.
status
===
'done'
)
setCommonImageList
(
ttt
)
_priceAttributeParams
[
index
||
editRowIndexRef
.
current
].
commodityPic
=
ttt
setCommonImageList
(
ttt
)
}
setPriceAttributeParamsByRender
(
_priceAttributeParams
)
setProductAttributeAndImageParams
(
_priceAttributeParams
)
// 保留上传的数据在页面状态 用于处理前面价格变动后不重新更新图片数据
setMaintainImageData
(
_priceAttributeParams
.
map
(
item
=>
item
.
commodityPic
))
}
catch
(
error
)
{
console
.
log
(
error
)
// message.error('请先完善前面商品相关信息')
}
}
setPriceAttributeParamsByRender
(
_priceAttributeParams
)
setProductAttributeAndImageParams
(
_priceAttributeParams
)
// 保留上传的数据在页面状态 用于处理前面价格变动后不重新更新图片数据
setMaintainImageData
(
_priceAttributeParams
.
map
(
item
=>
item
.
commodityPic
))
}
}
const
onChangeSetImageType
=
(
e
)
=>
{
const
onChangeSetImageType
=
(
e
)
=>
{
...
@@ -261,10 +266,10 @@ const ProductImageForm: React.FC<{}> = (props) => {
...
@@ -261,10 +266,10 @@ const ProductImageForm: React.FC<{}> = (props) => {
<
span
>
所有属性共用
<
i
style=
{
{
color
:
'red'
}
}
>
*
</
i
></
span
>
<
span
>
所有属性共用
<
i
style=
{
{
color
:
'red'
}
}
>
*
</
i
></
span
>
</
li
>
</
li
>
}
}
{
!
setImageType
&&
{
!
setImageType
&&
priceAttributeParamsByRender
?.
length
>
0
&&
priceAttributeParamsByRender
.
map
(
priceAttributeParamsByRender
?.
length
>
0
&&
priceAttributeParamsByRender
.
map
(
(
item
,
index
)
=>
{
(
item
,
index
)
=>
{
return
Array
.
isArray
(
item
.
attributeAndValueList
)
&&
return
Array
.
isArray
(
item
.
attributeAndValueList
)
&&
<
li
key=
{
index
}
className=
{
defaultChecked
==
index
?
styles
.
activedLi
:
""
}
onClick=
{
()
=>
clickItemTab
(
index
)
}
>
<
li
key=
{
index
}
className=
{
defaultChecked
==
index
?
styles
.
activedLi
:
""
}
onClick=
{
()
=>
clickItemTab
(
index
)
}
>
<
span
>
<
span
>
{
{
...
@@ -281,7 +286,7 @@ const ProductImageForm: React.FC<{}> = (props) => {
...
@@ -281,7 +286,7 @@ const ProductImageForm: React.FC<{}> = (props) => {
<
Col
span=
{
20
}
style=
{
{
padding
:
24
}
}
id=
"uploadBox"
>
<
Col
span=
{
20
}
style=
{
{
padding
:
24
}
}
id=
"uploadBox"
>
{
{
!
setImageType
?
!
setImageType
?
(
priceAttributeParamsByRender
?.
length
>
0
&&
priceAttributeParamsByRender
[
0
]?.
attributeAndValueList
?.
length
!=
0
?
priceAttributeParamsByRender
.
map
((
item
,
index
)
=>
(
priceAttributeParamsByRender
?.
length
>
0
&&
priceAttributeParamsByRender
[
0
]?.
attributeAndValueList
?.
length
!=
0
?
priceAttributeParamsByRender
.
map
((
item
,
index
)
=>
<
div
key=
{
index
+
100
}
style=
{
defaultChecked
==
index
?
{
display
:
'block'
}
:
{
display
:
'none'
}
}
>
<
div
key=
{
index
+
100
}
style=
{
defaultChecked
==
index
?
{
display
:
'block'
}
:
{
display
:
'none'
}
}
>
<
div
className=
{
styles
.
pictureCardBox
}
>
<
div
className=
{
styles
.
pictureCardBox
}
>
<
div
className=
"clearfix"
>
<
div
className=
"clearfix"
>
...
@@ -364,4 +369,4 @@ const ProductImageForm: React.FC<{}> = (props) => {
...
@@ -364,4 +369,4 @@ const ProductImageForm: React.FC<{}> = (props) => {
</
div
>)
</
div
>)
}
}
export
default
observer
(
ProductImageForm
)
export
default
observer
(
ProductImageForm
)
\ 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