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
de7c8405
Commit
de7c8405
authored
Sep 28, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:商品编辑切换品类清空数据、交易规则商城选项归类
parent
74d91f01
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
27 deletions
+73
-27
addProducts.tsx
src/pages/commodity/products/addProducts.tsx
+39
-13
basicInfoForm.tsx
...ages/commodity/products/addProductsItem/basicInfoForm.tsx
+10
-8
priceAttributeForm.tsx
...commodity/products/addProductsItem/priceAttributeForm.tsx
+2
-2
productAttributeForm.tsx
...mmodity/products/addProductsItem/productAttributeForm.tsx
+1
-2
productImageForm.tsx
...s/commodity/products/addProductsItem/productImageForm.tsx
+1
-1
index.tsx
src/pages/transaction/transactionRules/schema/index.tsx
+1
-1
index.ts
src/store/product/index.ts
+19
-0
No files found.
src/pages/commodity/products/addProducts.tsx
View file @
de7c8405
...
...
@@ -34,8 +34,7 @@ const AddProducts: React.FC<{}> = (props) => {
const
[
isDisableSaveBtn
,
setIsDisableSaveBtn
]
=
useState
<
boolean
>
(
false
)
const
[
currentTemplateName
,
setCurrentTemplateName
]
=
useState
<
string
>
()
let
[
formRefs
,
setFormRefs
]
=
useState
([])
//子form的ref数组
const
[
forceRenderRef
,
setForceRenderRef
]
=
useState
<
boolean
>
(
false
)
// 编辑情况下 是否强制渲染后面的 tabpane
const
isFirstRender
=
useRef
<
boolean
>
(
true
)
// 编辑情况下 是否是初始切换品类
const
clearPartRef
=
useRef
<
number
>
(
1
)
const
{
ProductStore
}
=
store
const
{
...
...
@@ -50,6 +49,8 @@ const AddProducts: React.FC<{}> = (props) => {
setProductInfoByEdit
,
isAllAttributePic
,
productInfoByEdit
,
selectCategoryId
,
clearPartData
}
=
ProductStore
useEffect
(()
=>
{
...
...
@@ -60,21 +61,35 @@ const AddProducts: React.FC<{}> = (props) => {
const
makeRequest
=
async
()
=>
{
const
productRes
=
await
PublicApi
.
getProductCommodityGetCommodity
({
id
:
id
})
const
{
data
}
=
productRes
setProductInfoByEdit
(
data
)
// setProductInfoByEdit(data) // *** 仅保存需要的数据 ***
setProductInfoByEdit
({
name
:
data
.
name
,
brand
:
data
.
brand
,
customerCategory
:
data
.
customerCategory
,
slogan
:
data
.
slogan
,
sellingPoint
:
data
.
sellingPoint
,
commodityAreaList
:
data
.
commodityAreaList
,
isUpdateAttribute
:
data
.
isUpdateAttribute
,
unitId
:
data
.
unitId
,
unitName
:
data
.
unitName
,
minOrder
:
data
.
minOrder
,
isMemberPrice
:
data
.
isMemberPrice
,
priceType
:
data
.
priceType
,
commodityAttributeList
:
data
.
commodityAttributeList
,
unitPriceAndPicList
:
data
.
unitPriceAndPicList
,
isAllAttributePic
:
data
.
isAllAttributePic
,
commodityRemark
:
data
.
commodityRemark
,
logistics
:
data
.
logistics
,
isInvoice
:
data
.
isInvoice
,
marks
:
data
.
marks
,
packing
:
data
.
packing
,
afterService
:
data
.
afterService
})
setProductName
(
data
?.
name
)
const
attributeRes
=
await
PublicApi
.
getProductCustomerGetCustomerCategoryById
({
id
:
data
?.
customerCategory
?.
id
+
''
})
setAttributeLists
(
attributeRes
.
data
?.
customerAttributeList
)
// return productRes.code
}
makeRequest
()
// .then(v => {
// if(v === 1000){
// if(!isFirstRender)
// setForceRenderRef(true)
// else
// isFirstRender.current = false
// }
// })
}
return
()
=>
{
...
...
@@ -82,6 +97,18 @@ const AddProducts: React.FC<{}> = (props) => {
}
},
[])
useEffect
(()
=>
{
console
.
log
(
111111
,
clearPartRef
.
current
)
if
(
history
.
location
.
query
?.
id
&&
clearPartRef
.
current
===
3
){
// 编辑商品切换品类 清空部分数据
clearPartData
()
}
else
{
clearPartRef
.
current
++
}
},
[
selectCategoryId
])
// useEffect(() => {
// renderTemplate(currentTemplateName)
// }, [currentTemplateName])
...
...
@@ -331,7 +358,6 @@ const AddProducts: React.FC<{}> = (props) => {
<
ProductImageForm
/>
</
TabPane
>
<
TabPane
tab=
"商品描述"
key=
"6"
>
{
/* <ProductDescFormDefualt /> */
}
{
renderTemplate
()
}
...
...
src/pages/commodity/products/addProductsItem/basicInfoForm.tsx
View file @
de7c8405
...
...
@@ -59,8 +59,8 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
const
[
customerCategoryTree
,
setCustomerCategoryTree
]
=
useState
<
GetProductCustomerGetCustomerCategoryTreeResponse
>
()
const
[
proviceOptions
,
setProviceOptions
]
=
useState
<
GetManageAreaAllResponse
>
()
const
[
showCategory
,
setShowCategory
]
=
useState
(
null
)
const
[
areaParams
,
setAreaParams
]
=
useState
<
AreaParams
>
()
const
[
isUpdateAttribute
,
setIsUpdateAttribute
]
=
useState
<
boolean
>
(
true
)
const
{
ProductStore
}
=
store
const
{
setAreaOption
,
...
...
@@ -69,9 +69,12 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
setAttributeLists
,
setProductName
,
setSelectCategoryId
,
setSelectBrandId
}
=
ProductStore
setSelectBrandId
,
}
=
ProductStore
useEffect
(()
=>
{
onRef
(
basicFormRef
)
// 获取品类树
PublicApi
.
getProductCustomerGetCustomerCategoryTree
().
then
(
res
=>
{
if
(
res
.
code
===
1000
){
...
...
@@ -98,20 +101,20 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
setAreaOption
(
arr
)
}
})
onRef
(
basicFormRef
)
},
[])
},
[])
useEffect
(()
=>
{
console
.
log
(
'basic'
)
const
{
id
}
=
history
.
location
.
query
if
(
id
&&
getBasicFormParamsByEdit
?.
name
){
handleBrandSearch
(
getBasicFormParamsByEdit
.
brandName
)
onCustomerCategoryChange
(
getBasicFormParamsByEdit
.
customerCategoryId
)
basicForm
.
setFieldsValue
(
getBasicFormParamsByEdit
)
setSelectCategoryId
(
getBasicFormParamsByEdit
.
customerCategoryId
)
setSelectBrandId
(
getBasicFormParamsByEdit
.
brandId
)
setIsUpdateAttribute
(
productInfoByEdit
.
isUpdateAttribute
)
}
},
[
productInfoByEdit
,
getBasicFormParamsByEdit
])
},
[
getBasicFormParamsByEdit
])
const
handleBrandSearch
=
(
value
?:
any
)
=>
{
PublicApi
.
getProductSelectGetSelectBrand
({
name
:
value
||
''
}).
then
(
res
=>
{
...
...
@@ -164,8 +167,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
areaParams
.
cityName
=
selected
[
1
].
name
areaParams
.
cityCode
=
selected
[
1
].
code
}
setAreaParams
(
areaParams
)
console
.
log
(
value
,
selected
,
areaParams
,
'area'
)
// console.log(value, selected, areaParams, 'area')
}
const
onChangeName
=
(
value
:
any
)
=>
{
...
...
src/pages/commodity/products/addProductsItem/priceAttributeForm.tsx
View file @
de7c8405
...
...
@@ -64,7 +64,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
setTableDataSource
,
clearData
,
setPriceAttributeParams
,
productInfoByEdit
,
productInfoByEdit
,
getPriceAttributeFormParamsByEdit
,
selectCategoryId
,
}
=
ProductStore
...
...
@@ -288,7 +288,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
Array
.
isArray
(
_rowArr
)
?
_rowArr
.
map
((
__rowArr
,
index
)
=>
{
_tempObj
[
_attributeNameArr
[
index
]]
=
__rowArr
})
:
_tempObj
[
_attributeNameArr
[
i
]
||
_attributeNameArr
[
0
]]
=
_rowArr
// 当一项变动的时候 找_attributeNameArr可能会找不到 找不到的情况下置为索引0的那项
if
(
productInfoByEdit
?.
id
){
if
(
history
.
location
.
query
?.
id
){
// 编辑的时候,先指定数据中的货品id,如果是重新组合的不存在id就使用选择的货品中的第一个,如果没有置为0;同理,不存在单价就置为{}
_tempObj
[
'对应货品'
]
=
productInfoByEdit
.
unitPriceAndPicList
[
i
]?.
goods
?.
id
||
selectedGoods
[
0
]?.
id
||
0
_tempObj
[
'单价'
]
=
productInfoByEdit
.
unitPriceAndPicList
[
i
]?.
unitPrice
||
{}
...
...
src/pages/commodity/products/addProductsItem/productAttributeForm.tsx
View file @
de7c8405
...
...
@@ -151,9 +151,8 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
const
renderTabPanchildren
=
(
attrItem
:
any
)
=>
{
let
_isPrice
=
null
let
_isUpdateAttribute
=
null
let
_isEdit
=
productInfoByEdit
?.
id
let
_isDisabled
=
false
if
(
_isEdit
){
if
(
history
.
location
.
query
?.
id
){
_isPrice
=
attrItem
.
isPrice
_isUpdateAttribute
=
productInfoByEdit
.
isUpdateAttribute
_isDisabled
=
_isPrice
&&
!
_isUpdateAttribute
...
...
src/pages/commodity/products/addProductsItem/productImageForm.tsx
View file @
de7c8405
...
...
@@ -54,7 +54,7 @@ const ProductImageForm: React.FC<{}> = (props) => {
/* 直接进入商品图片编辑的时候 参数为空数组 但是没有价格属性的时候 也可能为空数组 区别在于是否有url id */
const
constructImageListByRender
=
(
priceAttributeParams
?:
any
)
=>
{
let
_priceAttributeParams
:
any
=
[]
if
(
productInfoByEdit
?.
id
){
// id判断是否新增还是编辑
if
(
history
.
location
.
query
?.
id
){
// id判断是否新增还是编辑
// setSetImageType(productInfoByEdit.isAllAttributePic)
setIsAllAttributePic
(
productInfoByEdit
.
isAllAttributePic
)
...
...
src/pages/transaction/transactionRules/schema/index.tsx
View file @
de7c8405
...
...
@@ -125,7 +125,7 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
"type"
:
"array:number"
,
"x-component"
:
'CardCheckBox'
,
"x-component-props"
:
{
dataSource
:
GlobalConfig
.
web
.
shopInfo
,
dataSource
:
GlobalConfig
.
web
.
shopInfo
.
sort
((
a
,
b
)
=>
a
.
type
-
b
.
type
)
,
type
:
'radio'
// CardCheckBox 单选模式
},
"title"
:
"适用商城"
,
...
...
src/store/product/index.ts
View file @
de7c8405
...
...
@@ -139,6 +139,25 @@ class ProductStore implements IProductModule {
this
.
selectBrandId
=
null
;
}
// 编辑时 品类变更 清空部分数据
@
action
.
bound
public
clearPartData
(
data
?:
any
[])
{
this
.
productInfoByEdit
.
unitId
=
null
;
this
.
productInfoByEdit
.
unitName
=
null
;
this
.
productInfoByEdit
.
minOrder
=
null
;
this
.
productInfoByEdit
.
isMemberPrice
=
false
;
this
.
productInfoByEdit
.
priceType
=
1
;
this
.
productInfoByEdit
.
commodityAttributeList
=
[];
this
.
productInfoByEdit
.
unitPriceAndPicList
=
[];
this
.
productInfoByEdit
.
isAllAttributePic
=
true
;
this
.
productInfoByEdit
.
commodityRemark
=
{};
this
.
productInfoByEdit
.
logistics
=
{
deliveryType
:
1
,
carriageType
:
1
};
this
.
productInfoByEdit
.
isInvoice
=
null
;
this
.
productInfoByEdit
.
marks
=
null
;
this
.
productInfoByEdit
.
packing
=
null
;
this
.
productInfoByEdit
.
afterService
=
null
;
}
@
action
.
bound
public
setPriceAttributeParams
<
T
>
(
datas
:
T
[])
{
this
.
priceAttributeParams
=
datas
...
...
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