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
f48b3497
Commit
f48b3497
authored
Sep 23, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:商品/渠道商品积分/现货类型符号文字显示异常
parent
825d6118
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
87 additions
and
56 deletions
+87
-56
setPrice.tsx
src/pages/commodity/products/addChannelItem/setPrice.tsx
+1
-1
priceAttributeForm.tsx
...commodity/products/addProductsItem/priceAttributeForm.tsx
+12
-8
modifyDirectChannel.tsx
src/pages/commodity/products/modifyDirectChannel.tsx
+18
-18
viewDirectChannel.tsx
src/pages/commodity/products/viewDirectChannel.tsx
+1
-1
viewProducts.tsx
src/pages/commodity/products/viewProducts.tsx
+7
-7
addRule.tsx
src/pages/transaction/transactionRules/addRule.tsx
+5
-4
RuleSetting.tsx
...s/transaction/transactionRules/components/RuleSetting.tsx
+40
-6
index.tsx
src/pages/transaction/transactionRules/effects/index.tsx
+2
-10
index.tsx
src/pages/transaction/transactionRules/schema/index.tsx
+1
-1
No files found.
src/pages/commodity/products/addChannelItem/setPrice.tsx
View file @
f48b3497
...
...
@@ -138,7 +138,7 @@ const SetPrice:React.FC<IProps> = (props) => {
render
:
(
text
,
record
)
=>
{
if
(
!
text
||
JSON
.
stringify
(
text
)
===
'{}'
)
return
null
return
Object
.
keys
(
text
).
map
((
v
,
i
)
=>
{
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
¥
{
text
[
v
]
}
</
span
></
span
><
br
/></>
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
{
priceType
===
3
?
''
:
'¥'
}
{
text
[
v
]
}
</
span
></
span
><
br
/></>
})
}
})
...
...
src/pages/commodity/products/addProductsItem/priceAttributeForm.tsx
View file @
f48b3497
...
...
@@ -43,7 +43,8 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
const
updateFlag
=
useRef
(
true
)
// 是否第一次构建
const
[
priceForm
]
=
Form
.
useForm
()
const
[
setPriceForm
]
=
Form
.
useForm
()
const
[
planPrice
,
setPlanPrice
]
=
useState
(
1
)
//商品定价类型
const
[
planPrice
,
setPlanPrice
]
=
useState
(
1
)
//商品定价类型 ref替代
// const priceTypeRef = useRef<number>(1)
const
[
unitData
,
setUnitData
]
=
useState
<
any
>
([])
const
[
unitValue
,
setUnitValue
]
=
useState
(
undefined
)
const
[
setPriceModal
,
setSetPriceModal
]
=
useState
(
false
)
...
...
@@ -76,8 +77,9 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
onRef
(
priceFormRef
)
if
(
history
.
location
.
query
?.
id
){
// 编辑情况下 用于判断价格类型和显示单位
setPlanPrice
(
productInfoByEdit
?.
priceType
)
// priceTypeRef.current = productInfoByEdit?.priceType
handleUnitSearch
(
getPriceAttributeFormParamsByEdit
.
unitName
)
setMinOrderNumber
(
productInfoByEdit
?.
minOrder
)
// 先设置最小起订数 便于后续价格校验
setMinOrderNumber
(
productInfoByEdit
?.
minOrder
)
}
return
()
=>
{
console
.
log
(
'价格属性组件卸载'
)
...
...
@@ -87,8 +89,8 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
useEffect
(()
=>
{
constructedCallback
()
console
.
log
(
productSelectAttribute
,
'productSelectAttribute'
)
},[
productName
,
selectedGoods
,
productSelectAttribute
,
planPrice
])
//
console.log(productSelectAttribute, 'productSelectAttribute')
},[
productName
,
selectedGoods
,
productSelectAttribute
,
planPrice
])
/* 生成建表所需要的属性 属性值等数组数据 */
const
generateNeedData
=
(
hasAttribute
:
IProductSelectAttribute
[])
=>
{
...
...
@@ -225,7 +227,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
}
}
if
(
_attributeNameArr
?.
length
>
0
){
// ?*9.12*
if
(
_attributeNameArr
?.
length
>
0
){
_attributeNameArr
.
map
(
_attr
=>
{
_col
.
push
({
title
:
_attr
,
...
...
@@ -243,7 +245,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let
_priceRange
=
_tableDataSource
[
record
[
'索引'
]][
"单价"
]
if
(
!
_priceRange
||
JSON
.
stringify
(
_priceRange
)
===
'{}'
)
return
null
return
Object
.
keys
(
_priceRange
).
map
((
v
,
i
)
=>
{
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
¥
{
_priceRange
[
v
]
}
</
span
></
span
><
br
/></>
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
{
planPrice
===
3
?
''
:
'¥'
}
{
_priceRange
[
v
]
}
</
span
></
span
><
br
/></>
})
}
})
...
...
@@ -277,7 +279,6 @@ 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
){
// 编辑的时候,先指定数据中的货品id,如果是重新组合的不存在id就使用选择的货品中的第一个,如果没有置为0;同理,不存在单价就置为{}
_tempObj
[
'对应货品'
]
=
productInfoByEdit
.
unitPriceAndPicList
[
i
]?.
goods
?.
id
||
selectedGoods
[
0
]?.
id
||
0
...
...
@@ -293,15 +294,17 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let
_tempObj
:
any
=
{
索引
:
0
,
商品名称
:
productName
}
_tempObj
[
'对应货品'
]
=
selectedGoods
.
length
>
0
?
selectedGoods
[
0
].
id
:
0
// 编辑情况下 对应货品id和单价 特殊处理
_tempObj
[
'单价'
]
=
productInfoByEdit
?.
unitPriceAndPicList
[
0
]?.
unitPrice
||
{}
_tableData
.
push
(
_tempObj
)
}
// console.log(_tableData, '_tableData') // 只有一项 变动情况下表格数据的key获取不到
_tableDataSource
=
_tableData
// 有前面tab变动引起的二次构建 需要清空价格数据
if
(
updateFlag
.
current
){
// *****bug编辑积分商品(非现货价格)会导致价格类型变动引发重复渲染*****
updateFlag
.
current
=
false
}
else
{
// ***** 编辑情况下且是积分商品 不做清空单价处理*****
if
(
!
(
productInfoByEdit
?.
id
&&
planPrice
===
3
))
_tableDataSource
.
map
(
item
=>
item
[
'单价'
]
=
{})
}
setTableDataSource
(
productName
?
_tableDataSource
:
[])
// 通过商品名称来判断是否显示表格数据
...
...
@@ -406,6 +409,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
setPriceForm
.
resetFields
()
setLadderPrice
(
false
)
setPlanPrice
(
v
.
target
.
value
)
// priceTypeRef.current = v.target.value
}
const
setPriceOk
=
()
=>
{
...
...
src/pages/commodity/products/modifyDirectChannel.tsx
View file @
f48b3497
...
...
@@ -41,7 +41,6 @@ const ModifyDirectChannel:React.FC<{}> = () => {
const
[
visibleAddSpec
,
setVisibleAddSpec
]
=
useState
(
false
)
const
[
channelDetails
,
setChannelDetails
]
=
useState
<
any
>
()
const
[
priceType
,
setPriceType
]
=
useState
<
any
>
()
const
[
specColumn
,
setSpecColumn
]
=
useState
<
any
[]
>
([])
const
[
specTableData
,
setSpecTableData
]
=
useState
<
any
[]
>
([])
const
[
originTableData
,
setOriginTableData
]
=
useState
<
any
[]
>
([])
...
...
@@ -56,6 +55,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
const
[
submitParams
,
setSubmitParams
]
=
useState
<
any
>
()
const
flagRef
=
useRef
(
false
)
// 价格数据是否被模态框替换
const
priceTypeRef
=
useRef
<
number
>
()
useEffect
(()
=>
{
...
...
@@ -66,9 +66,9 @@ const ModifyDirectChannel:React.FC<{}> = () => {
const
{
data
}
=
res
if
(
res
.
code
===
1000
){
setChannelDetails
(
data
)
setPriceType
(
data
.
channelCommodity
.
commodity
.
priceType
)
priceTypeRef
.
current
=
data
.
channelCommodity
.
commodity
.
priceType
formPrice
.
setFieldsValue
({
isMemberPrice
:
data
?.
isMemberPrice
})
structureTable
(
data
.
unitPriceAndPicList
,
data
.
channelCommodity
.
commodity
.
name
,
true
)
// 初始已有规格
structureTable
(
data
.
unitPriceAndPicList
,
data
.
channelCommodity
.
commodity
,
true
)
// 初始已有规格
}
})
},
[])
...
...
@@ -97,8 +97,8 @@ const ModifyDirectChannel:React.FC<{}> = () => {
}
/** name<string>商品名称 noModal<boolean>不执行规格modla的操作 */
const
structureTable
=
(
data
:
any
,
name
?:
string
,
noModal
?:
boolean
)
=>
{
console
.
log
(
data
,
'structureTableData'
)
const
structureTable
=
(
data
:
any
,
commodity
?:
any
,
noModal
?:
boolean
)
=>
{
console
.
log
(
data
,
'structureTableData'
)
// 构建规格弹框table 列columns
let
col
:
any
=
[]
let
temp
:
any
=
[]
...
...
@@ -134,13 +134,13 @@ const ModifyDirectChannel:React.FC<{}> = () => {
},
...
temp
,
{
title
:
priceType
===
3
?
'积分'
:
'单价'
,
title
:
priceType
Ref
.
current
===
3
?
'积分'
:
'单价'
,
dataIndex
:
'单价'
,
key
:
'单价'
,
render
:
(
text
,
record
)
=>
{
if
(
!
text
||
JSON
.
stringify
(
text
)
===
'{}'
)
return
null
return
Object
.
keys
(
text
).
map
((
v
,
i
)
=>
{
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
¥
{
text
[
v
]
}
</
span
></
span
><
br
/></>
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
{
priceTypeRef
.
current
===
3
?
''
:
'¥'
}
{
text
[
v
]
}
</
span
></
span
><
br
/></>
})
}
})
...
...
@@ -156,7 +156,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
"id"
:
item
.
id
,
// 行数据id
"goodsId"
:
item
.
goods
?.
id
||
''
,
// 货品ID 可能为null
"索引"
:
index
,
"商品名称"
:
name
||
channelDetails
?.
channelCommodity
?.
commodity
?.
name
,
"商品名称"
:
commodity
?.
name
||
channelDetails
?.
channelCommodity
?.
commodity
?.
name
,
"对应货品"
:
item
.
goods
?.
name
||
''
,
...
temp
,
"单价"
:
item
.
unitPrice
...
...
@@ -186,7 +186,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
render
:
(
text
:
any
,
record
:
any
)
=>
{
return
(
<>
<
Button
type=
'link'
onClick=
{
()
=>
clickSetPrice
(
record
)
}
>
{
priceType
===
3
?
'设置积分'
:
'设置价格'
}
</
Button
>
<
Button
type=
'link'
onClick=
{
()
=>
clickSetPrice
(
record
)
}
>
{
priceType
Ref
.
current
===
3
?
'设置积分'
:
'设置价格'
}
</
Button
>
{
channelDetails
.
status
!==
6
&&
<
Button
type=
'link'
onClick=
{
()
=>
clickDelete
(
record
)
}
>
删除
</
Button
>
}
</>
)
...
...
@@ -407,14 +407,14 @@ const ModifyDirectChannel:React.FC<{}> = () => {
<
PlusOutlined
/>
选择商品规格
</
Button
>
{
priceTableData
.
length
>
0
&&
priceType
!=
2
&&
priceTableData
.
length
>
0
&&
priceType
Ref
.
current
!=
2
&&
<
Button
type=
"text"
style=
{
{
float
:
'right'
}
}
onClick=
{
clickBatchSetPrice
}
>
<
SettingOutlined
/>
{
priceType
===
3
?
'批量设置积分'
:
'批量设置价格'
}
{
priceType
Ref
.
current
===
3
?
'批量设置积分'
:
'批量设置价格'
}
</
Button
>
}
<
Table
rowKey=
"id"
dataSource=
{
priceTableData
}
columns=
{
priceColumn
}
style=
{
{
clear
:
'both'
}
}
/>
...
...
@@ -423,7 +423,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
</
Card
>
<
Modal
title=
{
priceType
===
3
?
(
isBatchSetting
?
'批量设置积分'
:
'设置积分'
)
:
(
isBatchSetting
?
'批量设置价格'
:
'设置价格'
)
}
title=
{
priceType
Ref
.
current
===
3
?
(
isBatchSetting
?
'批量设置积分'
:
'设置积分'
)
:
(
isBatchSetting
?
'批量设置价格'
:
'设置价格'
)
}
visible=
{
modifyModal
}
onOk=
{
handlePriceOk
}
onCancel=
{
()
=>
setModifyModal
(
false
)
}
...
...
@@ -437,7 +437,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
initialValues=
{
{
ladderPrice
:
false
}
}
>
{
priceType
!==
3
&&
priceType
Ref
.
current
!==
3
&&
<
Form
.
Item
label=
""
name=
"ladderPrice"
...
...
@@ -561,21 +561,21 @@ const ModifyDirectChannel:React.FC<{}> = () => {
}
}
</
Form
.
List
>
</
Form
.
Item
>
:
<
Form
.
Item
label=
{
priceType
===
3
?
"所需积分"
:
"单价"
}
label=
{
priceType
Ref
.
current
===
3
?
"所需积分"
:
"单价"
}
name=
"uniquePrice"
rules=
{
[
{
required
:
true
,
type
:
'number'
,
message
:
priceType
===
3
?
'请输入积分!'
:
'请输入价格!'
message
:
priceType
Ref
.
current
===
3
?
'请输入积分!'
:
'请输入价格!'
},
{
pattern
:
priceType
!==
3
?
/^
\d
+
(\.\d
{1,4}
)?
$/
:
/^
[
1-9
]\d
*$/
,
message
:
priceType
!==
3
?
'小数点后仅限四位'
:
'请正确输入积分'
,
pattern
:
priceType
Ref
.
current
!==
3
?
/^
\d
+
(\.\d
{1,4}
)?
$/
:
/^
[
1-9
]\d
*$/
,
message
:
priceType
Ref
.
current
!==
3
?
'小数点后仅限四位'
:
'请正确输入积分'
,
}
]
}
>
<
InputNumber
min=
{
0
}
style=
{
{
width
:
'100%'
}
}
placeholder=
{
priceType
===
3
?
"请输入积分"
:
"请输入价格"
}
/>
<
InputNumber
min=
{
0
}
style=
{
{
width
:
'100%'
}
}
placeholder=
{
priceType
Ref
.
current
===
3
?
"请输入积分"
:
"请输入价格"
}
/>
</
Form
.
Item
>
}
</
Form
>
...
...
src/pages/commodity/products/viewDirectChannel.tsx
View file @
f48b3497
...
...
@@ -69,7 +69,7 @@ const ViewDriectChannel: React.FC<{}> = () => {
render
:
(
text
,
record
)
=>
{
if
(
!
text
||
JSON
.
stringify
(
text
)
===
'{}'
)
return
null
return
Object
.
keys
(
text
).
map
((
v
,
i
)
=>
{
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
¥
{
text
[
v
]
}
</
span
></
span
><
br
/></>
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
{
commodity
.
priceType
===
3
?
''
:
'¥'
}
{
text
[
v
]
}
</
span
></
span
><
br
/></>
})
}
})
...
...
src/pages/commodity/products/viewProducts.tsx
View file @
f48b3497
...
...
@@ -55,7 +55,7 @@ const viewProducts: React.FC<{}> = () => {
console
.
log
(
data
,
'data'
)
setPorductDetail
(
data
)
renderDataByTab
(
data
)
constructTableData
(
data
.
name
,
data
.
unitPriceAndPicList
)
constructTableData
(
data
,
data
.
unitPriceAndPicList
)
if
(
data
.
status
===
1
)
setFixStep
(
0
)
else
if
(
data
.
status
===
2
)
setFixStep
(
1
)
else
if
(
data
.
status
===
3
)
setFixStep
(
2
)
...
...
@@ -94,6 +94,7 @@ const viewProducts: React.FC<{}> = () => {
title
:
'序号'
,
dataIndex
:
'memberRoleId'
,
key
:
'memberRoleId'
,
render
:
(
t
,
c
,
i
)
=>
i
+
1
},
{
title
:
'角色'
,
...
...
@@ -239,9 +240,9 @@ const viewProducts: React.FC<{}> = () => {
}
/* 构建表格数据 */
const
constructTableData
=
(
product
Name
:
string
,
unitPriceAndPicList
:
GetProductCommodityGetCommodityResponse
[
"unitPriceAndPicList"
])
=>
{
const
constructTableData
=
(
product
:
any
,
unitPriceAndPicList
:
GetProductCommodityGetCommodityResponse
[
"unitPriceAndPicList"
])
=>
{
// 构建列
console
.
log
(
product
Name
,
unitPriceAndPicList
,
'构建列'
)
console
.
log
(
product
,
unitPriceAndPicList
,
'构建列'
)
let
_col
=
[];
let
col_productName
=
{
title
:
'商品名称'
,
dataIndex
:
'商品名称'
,
key
:
'索引'
}
_col
.
push
(
col_productName
)
...
...
@@ -272,13 +273,13 @@ const viewProducts: React.FC<{}> = () => {
}
}
_col
.
push
({
title
:
product
Detail
?.
priceType
===
3
?
'所需积分'
:
'单价(元)'
,
title
:
product
?.
priceType
===
3
?
'所需积分'
:
'单价(元)'
,
dataIndex
:
'单价'
,
key
:
'单价'
,
render
:
(
text
,
record
)
=>
{
if
(
JSON
.
stringify
(
text
)
===
'{}'
)
return
null
return
Object
.
keys
(
text
).
map
((
v
,
i
)
=>
{
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
¥
{
text
[
v
]
}
</
span
></
span
><
br
/></>
return
<><
span
key=
{
i
}
>
{
v
===
'0-0'
?
''
:
`${v}:`
}
<
span
style=
{
{
color
:
'red'
}
}
>
{
product
?.
priceType
===
3
?
''
:
'¥'
}
{
text
[
v
]
}
</
span
></
span
><
br
/></>
})
}
})
...
...
@@ -291,7 +292,6 @@ const viewProducts: React.FC<{}> = () => {
let
_imageArrByImageRender
:
any
[]
=
[]
_tableData
=
unitPriceAndPicList
.
map
((
item
,
index
)
=>
{
_imageArrByImageRender
.
push
(
item
.
commodityPic
)
console
.
log
(
item
)
let
attrArrayWithObj
=
item
.
attributeAndValueList
.
map
(
_item
=>
{
let
_temp
=
{}
_temp
[
_item
.
customerAttribute
.
name
]
=
_item
.
customerAttributeValue
.
value
...
...
@@ -304,7 +304,7 @@ const viewProducts: React.FC<{}> = () => {
_attributeArrByImageRender
.
push
(
attrWithObj
)
let
temp
=
{
"索引"
:
index
,
"商品名称"
:
product
N
ame
,
"商品名称"
:
product
.
n
ame
,
"对应货品"
:
item
.
goods
?.
code
+
'/'
+
item
.
goods
?.
name
+
'/'
+
item
.
goods
?.
type
,
...
attrWithObj
,
"单价"
:
item
.
unitPrice
,
...
...
src/pages/transaction/transactionRules/addRule.tsx
View file @
f48b3497
...
...
@@ -28,10 +28,11 @@ const AddRule:React.FC<{}> = (props) => {
values
.
products
=
values
.
products
.
map
(
item
=>
({
productId
:
item
.
id
,
productName
:
item
.
name
,
category
:
item
.
customerCategoryName
,
productPrice
:
item
.
priceType
,
brand
:
item
.
brandName
}))
values
.
isElectronicContract
=
values
.
isElectronicContract
?
1
:
0
const
params
=
omit
(
values
,
[
'state'
])
// 移除不需要的字段
await
PublicApi
.
postOrderTradingRulesAdd
(
params
)
setTimeout
(()
=>
{
history
.
goBack
(
-
1
)
},
1000
)
console
.
log
(
params
,
'params'
)
// await PublicApi.postOrderTradingRulesAdd(params)
// setTimeout(() => {
// history.goBack(-1)
// }, 1000)
}
return
(
...
...
src/pages/transaction/transactionRules/components/RuleSetting.tsx
View file @
f48b3497
import
React
,
{
useState
}
from
'react'
import
React
,
{
use
Effect
,
use
State
}
from
'react'
import
{
usePageStatus
,
PageStatus
}
from
'@/hooks/usePageStatus'
import
{
useInitValue
}
from
'@/formSchema/effects/useInitValue'
import
EyePreview
from
'@/components/EyePreview'
...
...
@@ -33,6 +33,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const
{
addSchemaAction
,
schema
,
formSubmit
,
onFieldChange
=
()
=>
{}
}
=
props
const
[
visibleChannelRroduct
,
setVisibleChannelRroduct
]
=
useState
(
false
)
const
[
productRowSelection
,
productRowCtl
]
=
useRowSelectionTable
({
customKey
:
'id'
})
const
[
productsLength
,
setProductsLength
]
=
useState
(
0
)
const
[
initValue
,
setInitialValue
]
=
useState
({});
const
{
id
,
...
...
@@ -40,9 +42,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
pageStatus
}
=
usePageStatus
()
const
initValue
=
useInitValue
(
PublicApi
.
getOrderTradingRulesDetails
)
useUnitPreview
(
initValue
,
addSchemaAction
)
const
fetchProductList
=
async
(
params
)
=>
{
const
shopIds
=
addSchemaAction
.
getFieldValue
(
'shopIds'
)
if
(
shopIds
.
length
){
...
...
@@ -63,7 +62,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
// table删除商品
const
handleDeleteTable
=
(
id
)
=>
{
const
value
=
addSchemaAction
.
getFieldValue
(
'products'
)
addSchemaAction
.
setFieldValue
(
'products'
,
findItemAndDelete
(
value
,
id
,
'productId'
))
addSchemaAction
.
setFieldValue
(
'products'
,
findItemAndDelete
(
value
,
id
))
}
const
handleAddProductBtn
=
()
=>
{
...
...
@@ -73,7 +72,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
// return false
// }
const
checkBoxs
=
addSchemaAction
.
getFieldValue
(
'products'
)
productRowCtl
.
setSelectedRowKeys
(
checkBoxs
.
map
(
v
=>
v
.
productI
d
))
productRowCtl
.
setSelectedRowKeys
(
checkBoxs
.
map
(
v
=>
v
.
i
d
))
productRowCtl
.
setSelectRow
(
checkBoxs
)
setVisibleChannelRroduct
(
true
)
}
...
...
@@ -131,6 +130,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
// 商品添加弹窗控制
const
handleOkAddProduct
=
async
()
=>
{
setVisibleChannelRroduct
(
false
)
setProductsLength
(
productRowCtl
.
selectRow
.
length
);
addSchemaAction
.
setFieldValue
(
'products'
,
productRowCtl
.
selectRow
)
}
...
...
@@ -238,6 +238,38 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
}
}
useEffect
(()
=>
{
async
function
getInitValue
()
{
const
{
data
}
=
await
PublicApi
.
getOrderTradingRulesDetails
({
id
:
id
});
if
(
data
.
isTacitlyApprove
===
2
)
{
const
res
=
await
getBindingProducts
({
id
:
id
.
toString
(),
current
:
'1'
,
pageSize
:
'10'
});
addSchemaAction
.
setFieldState
(
'products'
,
(
state
)
=>
{
state
.
value
=
res
.
data
})
setProductsLength
(
res
.
totalCount
);
}
addSchemaAction
.
setFieldValue
(
'isElectronicContract'
,
data
?.
isElectronicContract
?
true
:
false
)
addSchemaAction
.
setFieldValue
(
'isTacitlyApprove'
,
data
?.
isTacitlyApprove
)
setInitialValue
(
data
)
}
if
(
id
!=
''
)
{
getInitValue
();
}
},
[
id
])
// 拿到绑定的商品
const
getBindingProducts
=
async
({
id
=
'1'
,
current
=
'1'
,
pageSize
=
'10'
})
=>
{
const
res
=
await
PublicApi
.
getOrderTradingRulesProductList
({
tradingRulesId
:
id
,
current
,
pageSize
});
return
res
.
data
}
const
paginationChange
=
async
(
page
:
number
,
size
:
number
)
=>
{
if
(
id
!==
''
)
{
const
result
=
await
getBindingProducts
({
id
,
current
:
page
.
toString
(),
pageSize
:
size
.
toString
()})
addSchemaAction
.
setFieldValue
(
'products'
,
result
.
data
)
}
}
return
(
<>
<
NiceForm
...
...
@@ -247,6 +279,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
expressionScope=
{
{
tableColumns
,
tableAddButton
,
paginationChange
,
productsLength
}
}
components=
{
{
SelectProcesss
,
...
...
src/pages/transaction/transactionRules/effects/index.tsx
View file @
f48b3497
...
...
@@ -22,15 +22,6 @@ export const createAddContractTemplateEffect = (context: ISchemaFormActions) =>
export
const
useUnitPreview
=
(
initValue
,
context
)
=>
{
useEffect
(()
=>
{
context
.
setFieldValue
(
'isElectronicContract'
,
initValue
?.
isElectronicContract
?
true
:
false
)
// console.log(initValue, 'init')
// if (initValue) {
// context.setFieldState('inventory', state => {
// if (!state.props['x-props']) {
// state.props['x-props'] = {}
// }
// state.props['x-props'].addonAfter = <div style={{marginLeft: 4}}>{initValue.unit}</div>
// })
// context.setFieldValue('itemNo', initValue.itemNo)
// }
context
.
setFieldValue
(
'isTacitlyApprove'
,
initValue
?.
isTacitlyApprove
)
},
[
initValue
])
}
\ No newline at end of file
src/pages/transaction/transactionRules/schema/index.tsx
View file @
f48b3497
...
...
@@ -173,7 +173,7 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
type
:
'array:number'
,
"x-component"
:
'MultTable'
,
"x-component-props"
:
{
rowKey
:
'
productI
d'
,
rowKey
:
'
i
d'
,
columns
:
"{{tableColumns}}"
,
prefix
:
"{{tableAddButton}}"
}
...
...
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