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
a137fa4d
Commit
a137fa4d
authored
Oct 20, 2021
by
前端-李俊鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: 移除异常文件
parent
ff487e85
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
592 deletions
+0
-592
PriceSetting.tsx
...ages/priceManage/priceStrategy/component/PriceSetting.tsx
+0
-293
priceSetting.tsx
...ages/priceManage/priceStrategy/component/priceSetting.tsx
+0
-299
No files found.
src/pages/priceManage/priceStrategy/component/PriceSetting.tsx
deleted
100644 → 0
View file @
ff487e85
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
import
{
usePageStatus
,
PageStatus
}
from
'@/hooks/usePageStatus'
import
{
ISchemaFormActions
,
ISchema
,
FormEffectHooks
}
from
'@formily/antd'
import
{
useRowSelectionTable
}
from
'@/hooks/useRowSelectionTable'
import
{
PublicApi
}
from
'@/services/api'
import
{
PlusOutlined
,
LinkOutlined
,
SettingOutlined
,
QuestionCircleOutlined
,
}
from
'@ant-design/icons'
import
{
Button
,
message
,
Tooltip
,
Input
}
from
'antd'
import
NiceForm
from
'@/components/NiceForm'
import
{
GlobalConfig
}
from
'@/global/config'
import
{
columnsUnitProduct
,
memberColumns
}
from
'../../constant'
import
{
constructTableData
,
transformDataForNiceForm
}
from
'../../effect'
import
PriceModal
from
'./priceModal'
import
ProductModal
from
'./productModal'
import
MemberModal
from
'./memberModal'
const
{
Search
}
=
Input
export
interface
PriceSettingProps
{
addSchemaAction
:
ISchemaFormActions
,
schema
:
ISchema
,
onFieldChange
?(),
formSubmit
?(
values
),
}
const
PriceSetting
:
React
.
FC
<
PriceSettingProps
>
=
(
props
)
=>
{
const
{
addSchemaAction
,
schema
,
formSubmit
,
onFieldChange
=
()
=>
{
}
}
=
props
const
priceRef
=
useRef
<
any
>
({})
const
productRef
=
useRef
<
any
>
({})
const
memberRef
=
useRef
<
any
>
({})
const
[
formLoading
,
setFormLoading
]
=
useState
(
false
)
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
{
id
,
preview
,
pageStatus
}
=
usePageStatus
()
useEffect
(()
=>
{
if
(
id
)
{
PublicApi
.
getProductCommodityGetUnitPriceStrategy
({
id
}).
then
(
res
=>
{
const
{
initValue
}
=
transformDataForNiceForm
(
res
.
data
,
addSchemaAction
)
setInitialFormValue
(
initValue
)
dataRef
.
current
=
initValue
addSchemaAction
.
setFieldState
(
'commodityMemberList'
,
state
=>
{
state
.
dataSource
=
initValue
.
commodityMemberList
})
})
}
},
[])
// 删除会员
const
handleDeleteMemberTable
=
(
reocrd
)
=>
{
const
value
=
addSchemaAction
.
getFieldValue
(
'commodityMemberList'
)
const
res
=
value
.
filter
(
item
=>
item
.
memberId
!=
reocrd
.
memberId
);
addSchemaAction
.
setFieldValue
(
'commodityMemberList'
,
res
)
addSchemaAction
.
setFieldState
(
'commodityMemberList'
,
state
=>
{
state
.
isDelete
=
true
})
if
(
pageStatus
===
PageStatus
.
EDIT
)
{
let
hasMember
=
memberRef
.
current
.
rowSelectionCtl
.
selectRow
memberRef
.
current
.
rowSelectionCtl
.
setSelectRow
(
hasMember
.
filter
(
item
=>
item
.
memberId
!=
reocrd
.
memberId
))
}
}
const
handleAddMemberBtn
=
()
=>
{
const
shopId
=
addSchemaAction
.
getFieldValue
(
'shopId'
);
const
productId
=
addSchemaAction
.
getFieldValue
(
'productId'
);
if
(
!
shopId
||
!
productId
)
{
message
.
error
(
'请先选择适用商城或商品'
);
return
;
}
// const checkBoxs = addSchemaAction.getFieldValue('commodityMemberList')
// if(checkBoxs?.length) {
// memberRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.memberId))
// memberRowCtl.setSelectRow(checkBoxs)
// }
memberRef
.
current
.
setVisible
(
true
)
}
const
handleSetProductPrice
=
(
record
:
any
)
=>
{
console
.
log
(
record
,
'record'
)
if
(
record
?.
id
)
{
priceRef
.
current
.
setVisible
(
true
)
priceRef
.
current
.
setCurrentSetPriceRow
(
record
)
}
}
// 弹出商品选择
const
handleAddProductBtn
=
()
=>
{
const
shopId
=
addSchemaAction
.
getFieldValue
(
'shopId'
)
if
(
!
shopId
)
{
message
.
error
(
'请先选择适用商城'
)
return
false
}
productRef
.
current
.
setVisible
(
true
)
productRef
.
current
.
rowSelectionCtl
.
setSelectedRowKeys
([
addSchemaAction
.
getFieldValue
(
'productId'
)])
}
// 价格策略设置表单提交
const
handleSubmit
=
async
(
values
)
=>
{
formSubmit
&&
formSubmit
(
values
)
}
const
clickBatchSetPrice
=
()
=>
{
if
(
addSchemaAction
.
getFieldValue
(
"productId"
))
{
priceRef
.
current
.
setIsBatchSetting
(
true
)
priceRef
.
current
.
setVisible
(
true
)
}
else
{
message
.
error
(
'请先选择适用商城或商品'
)
}
}
const
searchMember
=
(
value
)
=>
{
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
)
}
/**
* 生成价格设置 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
)
// 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
&&
<>
<
p
style=
{
{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
flexWrap
:
'wrap'
}
}
>
<
Search
placeholder=
"会员名称"
onSearch=
{
value
=>
searchMember
(
value
)
}
style=
{
{
width
:
256
}
}
/>
</
p
>
<
Button
style=
{
{
marginBottom
:
16
}
}
block
icon=
{
<
PlusOutlined
/>
}
onClick=
{
handleAddMemberBtn
}
type=
'dashed'
>
选择指定会员
</
Button
>
</>
// 批量设置价格按钮
const
batchPriceButton
=
pageStatus
!==
PageStatus
.
PREVIEW
&&
priceType
!==
2
&&
<
Button
type=
"text"
onClick=
{
clickBatchSetPrice
}
style=
{
{
marginBottom
:
12
,
float
:
"right"
}
}
><
SettingOutlined
/>
批量设置价格
</
Button
>
// 选择商品
const
connectProduct
=
pageStatus
===
PageStatus
.
ADD
&&
<
div
className=
'connectBtn'
onClick=
{
handleAddProductBtn
}
><
LinkOutlined
style=
{
{
marginRight
:
4
}
}
/>
选择
</
div
>
const
questionNameLabel
=
<>
价格策略名称
<
Tooltip
title=
"建议名称 :商品名称+会员名称"
>
<
QuestionCircleOutlined
/>
</
Tooltip
>
</>
const
questionPriceTypeLabel
=
<>
商品定价
<
Tooltip
title=
"现货价格:表示是现货销售的价格,价格明码标价,采购时按照标价下单,价格需要询价:表示价格未设定,需要询价报价后再下单采购"
>
<
QuestionCircleOutlined
/>
</
Tooltip
>
</>
return
(
<>
<
NiceForm
loading=
{
formLoading
}
previewPlaceholder=
' '
editable=
{
pageStatus
!==
PageStatus
.
PREVIEW
}
value=
{
initFormValue
}
expressionScope=
{
{
questionNameLabel
,
questionPriceTypeLabel
,
connectProduct
,
batchPriceButton
,
columnsUnitProduct
,
memberColumns
,
tableAddMemberButton
,
// paginationChange,
// membersLength
}
}
effects=
{
(
$
,
ctx
)
=>
{
FormEffectHooks
.
onFormInputChange$
().
subscribe
(()
=>
{
onFieldChange
()
})
$
(
'onFieldValueChange'
,
'shopId'
).
subscribe
(
parentState
=>
{
if
(
parentState
.
value
)
{
ctx
.
setFieldState
(
'shopId'
,
state
=>
{
// state.dataSource = pageStatus === PageStatus.PREVIEW ?
// GlobalConfig.web.shopInfo.filter(v => v.id === parentState.value && state.value.includes(v.id))
// :
state
.
dataSource
=
GlobalConfig
.
web
.
shopInfo
.
filter
(
v
=>
v
.
id
===
parentState
.
value
)
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
)
{
producePriceTableMemerColumn
(
parentState
.
value
,
ctx
)
}
})
$
(
"onFieldValueChange"
,
"priceType"
).
subscribe
(
parentState
=>
{
let
pId
=
ctx
.
getFieldValue
(
"productId"
)
if
(
pId
)
{
producePriceTableMemerColumn
(
pId
,
ctx
,
parentState
.
value
)
}
setPriceType
(
parentState
.
value
)
})
}
}
onSubmit=
{
handleSubmit
}
actions=
{
addSchemaAction
}
schema=
{
schema
}
/>
{
/* 选择商品 Modal */
}
<
ProductModal
currentRef=
{
productRef
}
schemaAction=
{
addSchemaAction
}
/>
{
/* 选择会员 */
}
<
MemberModal
currentRef=
{
memberRef
}
schemaAction=
{
addSchemaAction
}
/>
{
/* 价格设置 Modal */
}
<
PriceModal
currentRef=
{
priceRef
}
schemaAction=
{
addSchemaAction
}
/>
</>
)
}
PriceSetting
.
defaultProps
=
{}
export
default
React
.
memo
(
PriceSetting
)
src/pages/priceManage/priceStrategy/component/priceSetting.tsx
deleted
100644 → 0
View file @
ff487e85
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
import
{
usePageStatus
,
PageStatus
}
from
'@/hooks/usePageStatus'
import
{
ISchemaFormActions
,
ISchema
,
FormEffectHooks
}
from
'@formily/antd'
import
{
useRowSelectionTable
}
from
'@/hooks/useRowSelectionTable'
import
{
PublicApi
}
from
'@/services/api'
import
{
PlusOutlined
,
LinkOutlined
,
SettingOutlined
,
QuestionCircleOutlined
,
}
from
'@ant-design/icons'
import
{
Button
,
message
,
Tooltip
,
Input
}
from
'antd'
import
NiceForm
from
'@/components/NiceForm'
import
{
GlobalConfig
}
from
'@/global/config'
import
{
columnsUnitProduct
,
memberColumns
}
from
'../../constant'
import
{
constructTableData
,
transformDataForNiceForm
}
from
'../../effect'
import
PriceModal
from
'./priceModal'
import
ProductModal
from
'./productModal'
import
MemberModal
from
'./memberModal'
import
{
useAsyncSelect
}
from
'@/formSchema/effects/useAsyncSelect'
import
{
fectchShopListsSource
}
from
'@/utils/type'
const
{
Search
}
=
Input
export
interface
PriceSettingProps
{
addSchemaAction
:
ISchemaFormActions
,
schema
:
ISchema
,
onFieldChange
?(),
formSubmit
?(
values
),
}
const
fetchShopLists
=
async
()
=>
{
return
await
fectchShopListsSource
({
type
:
1
})
}
const
PriceSetting
:
React
.
FC
<
PriceSettingProps
>
=
(
props
)
=>
{
const
{
addSchemaAction
,
schema
,
formSubmit
,
onFieldChange
=
()
=>
{}
}
=
props
const
priceRef
=
useRef
<
any
>
({})
const
productRef
=
useRef
<
any
>
({})
const
memberRef
=
useRef
<
any
>
({})
const
[
formLoading
,
setFormLoading
]
=
useState
(
false
)
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
{
id
,
preview
,
pageStatus
}
=
usePageStatus
()
useEffect
(()
=>
{
if
(
id
)
{
PublicApi
.
getProductCommodityGetUnitPriceStrategy
({
id
}).
then
(
res
=>
{
const
{
initValue
}
=
transformDataForNiceForm
(
res
.
data
,
addSchemaAction
)
setInitialFormValue
(
initValue
)
dataRef
.
current
=
initValue
addSchemaAction
.
setFieldState
(
'commodityMemberList'
,
state
=>
{
state
.
dataSource
=
initValue
.
commodityMemberList
})
})
}
},
[])
// 删除会员
const
handleDeleteMemberTable
=
(
reocrd
)
=>
{
const
value
=
addSchemaAction
.
getFieldValue
(
'commodityMemberList'
)
const
res
=
value
.
filter
(
item
=>
item
.
memberId
!=
reocrd
.
memberId
);
addSchemaAction
.
setFieldValue
(
'commodityMemberList'
,
res
)
addSchemaAction
.
setFieldState
(
'commodityMemberList'
,
state
=>
{
state
.
isDelete
=
true
})
if
(
pageStatus
===
PageStatus
.
EDIT
)
{
let
hasMember
=
memberRef
.
current
.
rowSelectionCtl
.
selectRow
memberRef
.
current
.
rowSelectionCtl
.
setSelectRow
(
hasMember
.
filter
(
item
=>
item
.
memberId
!=
reocrd
.
memberId
))
}
}
const
handleAddMemberBtn
=
()
=>
{
const
shopId
=
addSchemaAction
.
getFieldValue
(
'shopId'
);
const
productId
=
addSchemaAction
.
getFieldValue
(
'productId'
);
if
(
!
shopId
||
!
productId
)
{
message
.
error
(
'请先选择适用商城或商品'
);
return
;
}
// const checkBoxs = addSchemaAction.getFieldValue('commodityMemberList')
// if(checkBoxs?.length) {
// memberRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.memberId))
// memberRowCtl.setSelectRow(checkBoxs)
// }
memberRef
.
current
.
setVisible
(
true
)
}
const
handleSetProductPrice
=
(
record
:
any
)
=>
{
console
.
log
(
record
,
'record'
)
if
(
record
?.
id
)
{
priceRef
.
current
.
setVisible
(
true
)
priceRef
.
current
.
setCurrentSetPriceRow
(
record
)
}
}
// 弹出商品选择
const
handleAddProductBtn
=
()
=>
{
const
shopId
=
addSchemaAction
.
getFieldValue
(
'shopId'
)
if
(
!
shopId
)
{
message
.
error
(
'请先选择适用商城'
)
return
false
}
productRef
.
current
.
setVisible
(
true
)
productRef
.
current
.
rowSelectionCtl
.
setSelectedRowKeys
([
addSchemaAction
.
getFieldValue
(
'productId'
)])
}
// 价格策略设置表单提交
const
handleSubmit
=
async
(
values
)
=>
{
formSubmit
&&
formSubmit
(
values
)
}
const
clickBatchSetPrice
=
()
=>
{
if
(
addSchemaAction
.
getFieldValue
(
"productId"
))
{
priceRef
.
current
.
setIsBatchSetting
(
true
)
priceRef
.
current
.
setVisible
(
true
)
}
else
{
message
.
error
(
'请先选择适用商城或商品'
)
}
}
const
searchMember
=
(
value
)
=>
{
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
)
}
/**
* 生成价格设置 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
)
// 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
&&
<>
<
p
style=
{
{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
flexWrap
:
'wrap'
}
}
>
<
Search
placeholder=
"会员名称"
onSearch=
{
value
=>
searchMember
(
value
)
}
style=
{
{
width
:
256
}
}
/>
</
p
>
<
Button
style=
{
{
marginBottom
:
16
}
}
block
icon=
{
<
PlusOutlined
/>
}
onClick=
{
handleAddMemberBtn
}
type=
'dashed'
>
选择指定会员
</
Button
>
</>
// 批量设置价格按钮
const
batchPriceButton
=
pageStatus
!==
PageStatus
.
PREVIEW
&&
priceType
!==
2
&&
<
Button
type=
"text"
onClick=
{
clickBatchSetPrice
}
style=
{
{
marginBottom
:
12
,
float
:
"right"
}
}
><
SettingOutlined
/>
批量设置价格
</
Button
>
// 选择商品
const
connectProduct
=
pageStatus
===
PageStatus
.
ADD
&&
<
div
className=
'connectBtn'
onClick=
{
handleAddProductBtn
}
><
LinkOutlined
style=
{
{
marginRight
:
4
}
}
/>
选择
</
div
>
const
questionNameLabel
=
<>
价格策略名称
<
Tooltip
title=
"建议名称 :商品名称+会员名称"
>
<
QuestionCircleOutlined
/>
</
Tooltip
>
</>
const
questionPriceTypeLabel
=
<>
商品定价
<
Tooltip
title=
"现货价格:表示是现货销售的价格,价格明码标价,采购时按照标价下单,价格需要询价:表示价格未设定,需要询价报价后再下单采购"
>
<
QuestionCircleOutlined
/>
</
Tooltip
>
</>
return
(
<>
<
NiceForm
loading=
{
formLoading
}
previewPlaceholder=
' '
editable=
{
pageStatus
!==
PageStatus
.
PREVIEW
}
value=
{
initFormValue
}
expressionScope=
{
{
questionNameLabel
,
questionPriceTypeLabel
,
connectProduct
,
batchPriceButton
,
columnsUnitProduct
,
memberColumns
,
tableAddMemberButton
,
// paginationChange,
// membersLength
}
}
effects=
{
(
$
,
ctx
)
=>
{
FormEffectHooks
.
onFormInputChange$
().
subscribe
(()
=>
{
onFieldChange
()
})
useAsyncSelect
(
'shopId'
,
fetchShopLists
,
[
'name'
,
'id'
])
$
(
'onFieldValueChange'
,
'shopId'
).
subscribe
(
parentState
=>
{
if
(
parentState
.
value
)
{
ctx
.
setFieldState
(
'shopId'
,
state
=>
{
// state.dataSource = pageStatus === PageStatus.PREVIEW ?
// GlobalConfig.web.shopInfo.filter(v => v.id === parentState.value && state.value.includes(v.id))
// :
// state.dataSource = GlobalConfig.web.shopInfo.filter(v => v.id === parentState.value)
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
)
{
producePriceTableMemerColumn
(
parentState
.
value
,
ctx
)
}
})
$
(
"onFieldValueChange"
,
"priceType"
).
subscribe
(
parentState
=>
{
let
pId
=
ctx
.
getFieldValue
(
"productId"
)
if
(
pId
)
{
producePriceTableMemerColumn
(
pId
,
ctx
,
parentState
.
value
)
}
setPriceType
(
parentState
.
value
)
})
}
}
onSubmit=
{
handleSubmit
}
actions=
{
addSchemaAction
}
schema=
{
schema
}
/>
{
/* 选择商品 Modal */
}
<
ProductModal
currentRef=
{
productRef
}
schemaAction=
{
addSchemaAction
}
/>
{
/* 选择会员 */
}
<
MemberModal
currentRef=
{
memberRef
}
schemaAction=
{
addSchemaAction
}
/>
{
/* 价格设置 Modal */
}
<
PriceModal
currentRef=
{
priceRef
}
schemaAction=
{
addSchemaAction
}
/>
</>
)
}
PriceSetting
.
defaultProps
=
{}
export
default
React
.
memo
(
PriceSetting
)
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