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
aa5fab19
Commit
aa5fab19
authored
Jan 28, 2021
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:处理价格策略的一些问题
parent
c3ce66d1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
126 additions
and
73 deletions
+126
-73
index.ts
src/constants/index.ts
+1
-1
index.tsx
src/pages/priceManage/effect/index.tsx
+25
-23
PriceModal.tsx
src/pages/priceManage/priceStrategy/component/PriceModal.tsx
+3
-1
PriceSetting.tsx
...ages/priceManage/priceStrategy/component/PriceSetting.tsx
+86
-46
index.tsx
src/pages/priceManage/priceStrategy/index.tsx
+7
-1
index.tsx
src/pages/priceManage/schema/index.tsx
+4
-1
No files found.
src/constants/index.ts
View file @
aa5fab19
...
...
@@ -1037,7 +1037,7 @@ export const PurchaseOrderInsideWorkStateTexts = {
2
:
'待审核订单(一级)'
,
3
:
'待审核订单(二级)'
,
4
:
'待提交订单'
,
5
:
'
待确认电子合同
'
,
5
:
'
审核通过
'
,
6
:
'提交审核订单不通过(一级)'
,
7
:
'提交审核订单不通过(二级)'
,
8
:
'待支付订单'
,
...
...
src/pages/priceManage/effect/index.tsx
View file @
aa5fab19
...
...
@@ -5,6 +5,7 @@ import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import
{
columnsUnitProduct
}
from
'../constant'
;
import
{
GlobalConfig
}
from
'@/global/config'
;
const
{
onFieldValueChange$
}
=
FormEffectHooks
import
{
PageStatus
}
from
'@/hooks/usePageStatus'
// 高级筛选schema中用于输入搜索品牌的Effect
...
...
@@ -32,13 +33,15 @@ export const searchCustomerCategoryOptionEffect = (context: any, fieldName: stri
// 构建设置价格 table 所需要的data和columns
export
const
constructTableData
=
(
data
:
any
,
ctx
:
ISchemaFormActions
|
ISchemaFormAsyncActions
)
=>
{
export
const
constructTableData
=
(
data
:
any
,
ctx
:
ISchemaFormActions
|
ISchemaFormAsyncActions
,
pageStatus
:
any
)
=>
{
// 预先对阶梯价格排序
data
=
data
.
map
(
item
=>
{
let
tempUnit
:
any
=
{}
Object
.
keys
(
item
.
unitPrice
).
sort
().
forEach
(
function
(
key
)
{
tempUnit
[
key
]
=
item
.
unitPrice
[
key
]
})
if
(
item
.
unitPrice
)
{
Object
.
keys
(
item
.
unitPrice
).
sort
().
forEach
(
function
(
key
)
{
tempUnit
[
key
]
=
item
.
unitPrice
[
key
]
})
}
return
{
...
item
,
unitPrice
:
tempUnit
...
...
@@ -48,7 +51,9 @@ export const constructTableData = (data: any, ctx: ISchemaFormActions | ISchemaF
let
col
:
any
=
[...
columnsUnitProduct
]
let
temp
:
any
=
[]
data
[
0
].
attributeAndValueList
.
map
(
_item
=>
{
// 兼容编辑价格策略 新增使用data 编辑使用data[0].commodityUnitPrice
let
_data_column
=
pageStatus
===
PageStatus
.
ADD
?
data
[
0
]
:
data
[
0
][
"commodityUnitPrice"
]
_data_column
.
attributeAndValueList
.
map
(
_item
=>
{
temp
.
push
({
title
:
_item
.
customerAttribute
.
name
,
dataIndex
:
[
_item
.
customerAttribute
.
name
,
'value'
],
key
:
_item
.
customerAttribute
.
name
})
})
...
...
@@ -71,20 +76,26 @@ export const constructTableData = (data: any, ctx: ISchemaFormActions | ISchemaF
}
})
// 兼容编辑价格策略 新增使用data 编辑使用data -> item -> commodityUnitPrice
let
_tableData
:
any
=
[]
data
.
map
((
item
,
index
)
=>
{
let
temp
:
any
=
{}
item
.
attributeAndValueList
.
map
(
_item
=>
{
temp
[
_item
.
customerAttribute
.
name
]
=
{
value
:
_item
.
customerAttributeValue
.
value
,
vId
:
_item
.
customerAttributeValue
.
id
,
id
:
_item
.
customerAttribute
.
id
}
let
_item_differ
=
pageStatus
===
PageStatus
.
ADD
?
item
:
item
[
"commodityUnitPrice"
]
console
.
log
(
_item_differ
,
'_item_differ'
)
_item_differ
.
attributeAndValueList
.
map
(
_item
=>
{
temp
[
_item
.
customerAttribute
.
name
]
=
{
value
:
_item
.
customerAttributeValue
.
value
,
vId
:
_item
.
customerAttributeValue
.
id
,
id
:
_item
.
customerAttribute
.
id
}
})
_tableData
.
push
({
"id"
:
item
.
id
,
"id"
:
_item_differ
.
id
,
"索引"
:
index
,
"货品ID"
:
item
.
goods
?.
id
||
''
,
"货品ID"
:
_item_differ
.
goods
?.
id
||
''
,
"商品名称"
:
ctx
.
getFieldValue
(
"productName"
),
"对应货品"
:
item
.
goods
?.
name
||
''
,
"对应货品"
:
_item_differ
.
goods
?.
name
||
''
,
...
temp
,
"单价"
:
item
.
unitPrice
})
...
...
@@ -144,20 +155,11 @@ export const transformDataForNiceForm = (value: any, ctx: ISchemaFormActions | I
let
shopInfo
=
GlobalConfig
.
web
.
shopInfo
.
filter
(
item
=>
item
[
"type"
]
===
value
[
"type"
]
&&
item
[
"environment"
]
===
value
[
"environment"
])
initValue
[
"shopId"
]
=
shopInfo
[
0
][
"id"
]
// Edit使用
initValue
[
"memberUnitPriceList"
]
=
value
[
"memberUnitPriceList"
]
return
{
initValue
}
// const { tableUnitData, columsUnit } = constructTableData(value.memberUnitPriceList, ctx)
// initValue["memberUnitPriceList"] = constructTableData(value.memberUnitPriceList, ctx)["tableUnitData"]
// ctx.setFieldState("memberUnitPriceList", state => {
// columsUnit.push({
// dataIndex: 'ctl',
// title: '操作',
// align: 'center',
// render: (_i, _r) => <Button type='link' onClick={() => handleSetProductPrice(_r)}>设置价格</Button>
// })
// state.props["x-component-props"].columns = columsUnit
// })
}
}
src/pages/priceManage/priceStrategy/component/PriceModal.tsx
View file @
aa5fab19
...
...
@@ -78,6 +78,8 @@ const PriceModal:React.FC<PriceModalProps> = (props) => {
useEffect
(()
=>
{
if
(
isBatchSetting
)
{
setPriceForm
.
resetFields
()
setPriceForm
.
setFields
([{
name
:
'ladderPrice'
,
value
:
false
}])
currentRef
.
current
.
setLadderPrice
(
false
)
}
},
[
isBatchSetting
])
...
...
@@ -137,7 +139,7 @@ const PriceModal:React.FC<PriceModalProps> = (props) => {
return
(
<
Modal
title=
"设置价格"
title=
{
currentRef
.
current
.
isBatchSetting
?
"批量设置价格"
:
"设置价格"
}
visible=
{
visible
}
onOk=
{
handlePriceOk
}
onCancel=
{
()
=>
setVisible
(
false
)
}
...
...
src/pages/priceManage/priceStrategy/component/PriceSetting.tsx
View file @
aa5fab19
...
...
@@ -36,6 +36,8 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
const
[
visibleMember
,
setVisibleMember
]
=
useState
(
false
)
const
[
memberRowSelection
,
memberRowCtl
]
=
useRowSelectionTable
({
customKey
:
'memberId'
})
const
[
initFormValue
,
setInitialFormValue
]
=
useState
({});
const
dataRef
=
useRef
({})
const
[
priceType
,
setPriceType
]
=
useState
(
1
)
const
[
membersLength
,
setMembersLength
]
=
useState
(
0
);
const
{
...
...
@@ -49,6 +51,7 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
PublicApi
.
getProductCommodityGetUnitPriceStrategy
({
id
}).
then
(
res
=>
{
const
{
initValue
}
=
transformDataForNiceForm
(
res
.
data
,
addSchemaAction
)
setInitialFormValue
(
initValue
)
dataRef
.
current
=
initValue
addSchemaAction
.
setFieldState
(
'commodityMemberList'
,
state
=>
{
state
.
dataSource
=
initValue
.
commodityMemberList
})
...
...
@@ -115,36 +118,57 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
if
(
addSchemaAction
.
getFieldValue
(
"productId"
))
{
priceRef
.
current
.
setIsBatchSetting
(
true
)
priceRef
.
current
.
setVisible
(
true
)
priceRef
.
current
.
setLadderPrice
(
false
)
}
else
{
message
.
error
(
'请先选择适用商城或商品'
)
}
}
const
searchMember
=
(
value
)
=>
{
let
commodityMemberList
=
addSchemaAction
.
getFieldValue
(
"commodityMemberList"
).
filter
(
item
=>
item
.
name
===
value
)
addSchemaAction
.
setFieldValue
(
"commodityMemberList"
,
commodityMemberList
)
if
(
!
value
)
{
addSchemaAction
.
setFieldValue
(
"commodityMemberList"
,
addSchemaAction
.
getFieldState
(
"commodityMemberList"
)[
"dataSource"
])
return
;
}
}
let
commodityMemberList
=
addSchemaAction
.
getFieldValue
(
"commodityMemberList"
).
filter
(
item
=>
item
.
name
.
indexOf
(
value
)
!==
-
1
)
addSchemaAction
.
setFieldValue
(
"commodityMemberList"
,
commodityMemberList
)
}
// const paginationChange = async (page: number, size: number) => {
// if(id !== '') {
// const result = await getBindingMember({id, current: page.toString(), pageSize: size.toString()});
// addSchemaAction.setFieldValue('commodityMemberList', result.data);
// }
// }
/**
* 生成价格设置 table 和会员 column
* @param pId 商品id
* @param ctx action
* @param priceType 价格类型(可选)1现货2询价
*/
const
producePriceTableMemerColumn
=
async
(
pId
,
ctx
,
priceType
?)
=>
{
const
res
=
await
PublicApi
.
getProductCommodityGetCommodityUnitPrice
({
id
:
pId
,})
// 填充价格设置table(编辑采用initValue数据)
let
source
=
pageStatus
===
PageStatus
.
ADD
?
res
.
data
:
dataRef
.
current
[
"memberUnitPriceList"
]
const
{
columsUnit
,
tableUnitData
}
=
constructTableData
(
source
,
ctx
,
pageStatus
)
ctx
.
setFieldState
(
"memberUnitPriceList"
,
state
=>
{
state
.
dataSource
=
source
// 存源数据
priceType
!==
2
?
columsUnit
.
push
({
dataIndex
:
'ctl'
,
title
:
'操作'
,
align
:
'center'
,
render
:
(
_i
,
_r
)
=>
<
Button
disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
type=
'link'
onClick=
{
()
=>
handleSetProductPrice
(
_r
)
}
>
设置价格
</
Button
>
})
:
columsUnit
.
pop
()
state
.
props
[
"x-component-props"
].
columns
=
columsUnit
})
ctx
.
setFieldValue
(
"memberUnitPriceList"
,
priceType
===
2
?
tableUnitData
.
map
(
item
=>
{
delete
item
[
"单价"
];
return
item
})
:
tableUnitData
)
// // 拿到绑定会员
// const getBindingMember = async ({id = '1', current = '1', pageSize = '10'}) => {
// const res = await PublicApi.getWarehouseFreightSpaceMamberList({id, current, pageSize});
// return res.data
// }
console
.
log
(
columsUnit
,
tableUnitData
,
source
)
// 填充适用会员table
ctx
.
setFieldState
(
"commodityMemberList"
,
state
=>
{
memberColumns
[
memberColumns
.
length
-
1
].
render
=
(
text
,
record
)
=>
{
return
<
Button
disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
type=
'link'
onClick=
{
()
=>
handleDeleteMemberTable
(
record
)
}
>
删除
</
Button
>
}
state
.
props
[
"x-component-props"
].
columns
=
memberColumns
})
}
// 新增会员
const
tableAddMemberButton
=
pageStatus
!==
PageStatus
.
PREVIEW
&&
<>
...
...
@@ -159,10 +183,10 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
</>
// 批量设置价格按钮
const
batchPriceButton
=
pageStatus
!==
PageStatus
.
PREVIEW
&&
<
Button
type=
"text"
onClick=
{
clickBatchSetPrice
}
style=
{
{
marginBottom
:
12
,
float
:
"right"
}
}
><
SettingOutlined
/>
批量设置价格
</
Button
>
const
batchPriceButton
=
pageStatus
!==
PageStatus
.
PREVIEW
&&
priceType
!==
2
&&
<
Button
type=
"text"
onClick=
{
clickBatchSetPrice
}
style=
{
{
marginBottom
:
12
,
float
:
"right"
}
}
><
SettingOutlined
/>
批量设置价格
</
Button
>
// 选择商品
const
connectProduct
=
pageStatus
!==
PageStatus
.
PREVIEW
&&
<
div
className=
'connectBtn'
onClick=
{
handleAddProductBtn
}
><
LinkOutlined
style=
{
{
marginRight
:
4
}
}
/>
选择
</
div
>
const
connectProduct
=
pageStatus
===
PageStatus
.
ADD
&&
<
div
className=
'connectBtn'
onClick=
{
handleAddProductBtn
}
><
LinkOutlined
style=
{
{
marginRight
:
4
}
}
/>
选择
</
div
>
return
(
<>
...
...
@@ -196,40 +220,56 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
if
(
pageStatus
===
PageStatus
.
EDIT
)
{
state
.
props
[
'x-component-props'
].
disabled
=
true
;
}
})
ctx
.
setFieldState
(
'priceType'
,
state
=>
{
if
(
pageStatus
===
PageStatus
.
EDIT
)
{
state
.
props
[
'x-component-props'
].
disabled
=
true
;
}
});
}
})
$
(
'onFieldValueChange'
,
'productId'
).
subscribe
(
async
parentState
=>
{
if
(
parentState
.
value
)
{
const
res
=
await
PublicApi
.
getProductCommodityGetCommodityUnitPrice
({
id
:
parentState
.
value
,
})
if
(
res
.
code
===
1000
)
{
// 填充价格设置table
const
{
columsUnit
,
tableUnitData
}
=
constructTableData
(
res
.
data
,
ctx
)
ctx
.
setFieldState
(
"memberUnitPriceList"
,
state
=>
{
state
.
dataSource
=
res
.
data
// 存源数据
columsUnit
.
push
({
dataIndex
:
'ctl'
,
title
:
'操作'
,
align
:
'center'
,
render
:
(
_i
,
_r
)
=>
<
Button
disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
type=
'link'
onClick=
{
()
=>
handleSetProductPrice
(
_r
)
}
>
设置价格
</
Button
>
})
state
.
props
[
"x-component-props"
].
columns
=
columsUnit
})
ctx
.
setFieldValue
(
"memberUnitPriceList"
,
tableUnitData
)
console
.
log
(
columsUnit
,
tableUnitData
,
res
.
data
)
// 填充适用会员table
ctx
.
setFieldState
(
"commodityMemberList"
,
state
=>
{
memberColumns
[
memberColumns
.
length
-
1
].
render
=
(
text
,
record
)
=>
{
return
<
Button
disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
type=
'link'
onClick=
{
()
=>
handleDeleteMemberTable
(
record
)
}
>
删除
</
Button
>
}
state
.
props
[
"x-component-props"
].
columns
=
memberColumns
})
}
// const res = await PublicApi.getProductCommodityGetCommodityUnitPrice(
{
// id: parentState.value,
//
})
// if(res.code === 1000)
{
// // 填充价格设置table
// const
{
columsUnit
,
tableUnitData
}
=
constructTableData
(
res
.
data
,
ctx
)
// ctx.setFieldState("memberUnitPriceList", state =>
{
// state.dataSource = res.data // 存源数据
// columsUnit.push(
{
// dataIndex: 'ctl',
// title: '操作',
// align: 'center',
// render: (_i, _r) => <Button disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
type
=
'link'
onClick
=
{()
=>
handleSetProductPrice
(
_r
)}
>
设置价格
<
/Button
>
//
})
// state.props["x-component-props"].columns = columsUnit
//
})
// ctx.setFieldValue("memberUnitPriceList", tableUnitData)
// console.log(columsUnit, tableUnitData, res.data)
// // 填充适用会员table
// ctx.setFieldState("commodityMemberList", state =>
{
// memberColumns[memberColumns.length -1].render = (text, record) =>
{
// return <Button disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
type
=
'link'
onClick
=
{()
=>
handleDeleteMemberTable
(
record
)}
>
删除
<
/Button
>
//
}
// state.props["x-component-props"].columns = memberColumns
//
})
//
}
producePriceTableMemerColumn
(
parentState
.
value
,
ctx
)
}
})
$
(
"onFieldValueChange"
,
"priceType"
).
subscribe
(
parentState
=>
{
let
pId
=
ctx
.
getFieldValue
(
"productId"
)
if
(
pId
)
{
producePriceTableMemerColumn
(
pId
,
ctx
,
parentState
.
value
)
}
setPriceType
(
parentState
.
value
)
})
}
}
...
...
src/pages/priceManage/priceStrategy/index.tsx
View file @
aa5fab19
...
...
@@ -152,7 +152,13 @@ const PriceManage: React.FC<{}> = () => {
}
const
handleUpdateState
=
(
record
:
any
)
=>
{
PublicApi
.
postProductCommodityUpdateUnitPriceStrategyStatus
({
id
:
record
.
id
,
isEnable
:
!
record
.
isEnable
})
PublicApi
.
postProductCommodityUpdateUnitPriceStrategyStatus
({
id
:
record
.
id
,
isEnable
:
!
record
.
isEnable
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
setTimeout
(()
=>
{
ref
.
current
.
reload
()
},
1000
)
}
})
}
const
handleModify
=
(
record
:
any
)
=>
{
...
...
src/pages/priceManage/schema/index.tsx
View file @
aa5fab19
...
...
@@ -248,7 +248,10 @@ export const setPriceSchema: ISchema = {
value
:
2
}
],
default
:
1
default
:
1
,
"x-component-props"
:
{
disabled
:
false
,
},
},
}
}
...
...
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