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
linweijiong
jinfa-platform
Commits
1f43df86
Commit
1f43df86
authored
Oct 23, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 处理新增商品提交异常、处理新增商品再次变动价格图片清空问题
parent
b0ba0430
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
basicInfoForm.tsx
...ages/commodity/products/addProductsItem/basicInfoForm.tsx
+4
-2
productImageForm.tsx
...s/commodity/products/addProductsItem/productImageForm.tsx
+9
-12
No files found.
src/pages/commodity/products/addProductsItem/basicInfoForm.tsx
View file @
1f43df86
...
...
@@ -195,6 +195,8 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
})
callback
()
}
}
else
{
callback
()
}
}
catch
(
err
)
{
callback
(
err
)
...
...
@@ -323,8 +325,8 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
<
Select
mode=
"tags"
placeholder=
"请输入并选择商品卖点"
//
maxTagCount={3}
//
maxTagTextLength={8}
maxTagCount=
{
3
}
maxTagTextLength=
{
8
}
tagRender=
{
tagRender
}
/>
</
Form
.
Item
>
...
...
src/pages/commodity/products/addProductsItem/productImageForm.tsx
View file @
1f43df86
...
...
@@ -20,6 +20,8 @@ const ProductImageForm: React.FC<{}> = (props) => {
const
[
previewImage
,
setPreviewImage
]
=
useState
(
''
)
const
[
previewTitle
,
setPreviewTitle
]
=
useState
(
''
)
const
[
setImageType
,
setSetImageType
]
=
useState
<
boolean
>
(
true
)
// 处理新增二次变更价格保留图片数据
const
[
maintainImageData
,
setMaintainImageData
]
=
useState
<
any
>
([])
const
[
openFileDialogFlag
,
setOpenFileDialogFlag
]
=
useState
<
boolean
>
(
false
)
const
flagRef
=
useRef
<
boolean
>
(
false
)
...
...
@@ -60,10 +62,8 @@ const ProductImageForm: React.FC<{}> = (props) => {
useEffect
(()
=>
{
if
(
priceAttributeParams
.
length
>
0
){
// console.log(priceAttributeParams, '对比')
constructImageListByRender
(
priceAttributeParams
)
}
else
if
(
history
.
location
.
query
?.
id
){
// 不点击前面 直接进入图片tab
// console.log(productInfoByEdit.unitPriceAndPicList, '对比')
constructImageListByRender
(
productInfoByEdit
.
unitPriceAndPicList
)
}
},[
priceAttributeParams
])
...
...
@@ -78,7 +78,6 @@ const ProductImageForm: React.FC<{}> = (props) => {
_priceAttributeParams
=
priceAttributeParams
.
map
((
_item
,
_index
)
=>
{
// 为图片字符串数组手动添加 uid 和 status
// console.log(_item, '_____')
// 查询编辑详情中属性值id相匹配的图片
let
_pic
=
null
let
_priceAndPicList
=
productInfoByEdit
.
unitPriceAndPicList
...
...
@@ -100,9 +99,11 @@ const ProductImageForm: React.FC<{}> = (props) => {
return
_obj
})
}
else
{
_priceAttributeParams
=
priceAttributeParams
.
map
(
_item
=>
{
_priceAttributeParams
=
priceAttributeParams
.
map
(
(
_item
,
_i
)
=>
{
let
_obj
=
{...
_item
}
_obj
.
commodityPic
=
[]
// ****这里 新增情况下 价格属性参数变动引起constructImageListByRender数据构建 []会清空之前已经上传的图片
// _obj.commodityPic = []
_obj
.
commodityPic
=
maintainImageData
[
_i
]
||
[]
return
_obj
})
}
...
...
@@ -110,7 +111,6 @@ const ProductImageForm: React.FC<{}> = (props) => {
clickItemTab
(
0
)
setPriceAttributeParamsByRender
(
_priceAttributeParams
)
setProductAttributeAndImageParams
(
_priceAttributeParams
)
// console.log(_priceAttributeParams, priceAttributeParams, '_p')
// 初始化若是按所有属性共用做显示处理
if
(
setImageType
&&
_priceAttributeParams
.
length
>
0
){
setCommonImageList
(
_priceAttributeParams
[
0
].
commodityPic
)
...
...
@@ -118,7 +118,6 @@ const ProductImageForm: React.FC<{}> = (props) => {
}
const
clickItemTab
=
(
_index
:
number
)
=>
{
// console.log(_index, '点击项')
setDefaultChecked
(
_index
)
}
...
...
@@ -184,14 +183,12 @@ const ProductImageForm: React.FC<{}> = (props) => {
const
handleChange
=
({
file
,
fileList
},
index
)
=>
{
let
_priceAttributeParams
=
[...
priceAttributeParamsByRender
]
// console.log(fileList, file, index, editRowIndexRef, '响应')
// console.log(uploadFileSelectRef.current)
const
selectUuid
=
uploadFileSelectRef
.
current
.
uid
if
(
selectUuid
)
{
// 点了图片编辑
const
editPicIndex
=
fileList
.
findIndex
(
v
=>
v
.
uid
===
selectUuid
)
// console.log(editPicIndex)
fileList
.
splice
(
editPicIndex
,
1
,
file
)
if
(
fileList
.
length
>
1
)
{
fileList
.
pop
()
...
...
@@ -200,7 +197,6 @@ const ProductImageForm: React.FC<{}> = (props) => {
}
setCommonImageList
(
fileList
)
// console.log(index||editRowIndexRef.current, fileList, '132456')
_priceAttributeParams
[
index
||
editRowIndexRef
.
current
].
commodityPic
=
fileList
if
(
!
file
?.
status
&&
file
?.
status
!==
'done'
){
let
ttt
=
_priceAttributeParams
[
index
||
editRowIndexRef
.
current
].
commodityPic
.
filter
(
_
=>
_
.
status
===
'done'
)
...
...
@@ -209,6 +205,8 @@ const ProductImageForm: React.FC<{}> = (props) => {
}
setPriceAttributeParamsByRender
(
_priceAttributeParams
)
setProductAttributeAndImageParams
(
_priceAttributeParams
)
// 保留上传的数据在页面状态 用于处理前面价格变动后不重新更新图片数据
setMaintainImageData
(
_priceAttributeParams
.
map
(
item
=>
item
.
commodityPic
))
}
const
onChangeSetImageType
=
(
e
)
=>
{
...
...
@@ -226,7 +224,6 @@ const ProductImageForm: React.FC<{}> = (props) => {
}
const
handlefileEdit
=
(
file
,
index
)
=>
{
// console.log(file, index)
const
uploadEle
=
document
.
querySelector
(
`#uploadEle
${
index
}
`
)
as
any
uploadFileSelectRef
.
current
=
(
file
)
editRowIndexRef
.
current
=
index
...
...
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