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
976fab19
Commit
976fab19
authored
Jul 23, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 对接优惠券修改相关
parent
c1c49121
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
137 additions
and
30 deletions
+137
-30
useBusinessEffects.ts
...itted/components/CouponForm/effects/useBusinessEffects.ts
+27
-9
index.tsx
...merchantCouponUnsubmitted/components/CouponForm/index.tsx
+106
-19
edit.tsx
...Ability/merchantCoupon/merchantCouponUnsubmitted/edit.tsx
+4
-2
No files found.
src/pages/transaction/marketingAbility/merchantCoupon/merchantCouponUnsubmitted/components/CouponForm/effects/useBusinessEffects.ts
View file @
976fab19
...
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:04:16
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-
19 17:26:55
* @LastEditTime: 2021-07-
23 17:36:48
* @Description:
*/
import
{
FormEffectHooks
,
FormPath
,
IFormActions
}
from
'@formily/antd'
;
...
...
@@ -29,6 +29,23 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
const
linkage
=
useLinkageUtils
();
// 优惠券类型
onFieldInputChange$
(
'type'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
const
denominationValue
=
getFieldValue
(
'denomination'
);
// 券面额
const
useConditionMoneyValue
=
getFieldValue
(
'useConditionMoney'
);
// 使用条件
// 0元抵扣券
if
(
value
===
MERCHANT_COUPON_TYPE_VOUCHER
)
{
}
else
{
setFieldState
(
'getWay'
,
fieldState
=>
{
FormPath
.
setIn
(
fieldState
,
'value'
,
undefined
);
FormPath
.
setIn
(
fieldState
,
'props.x-component-props.disabled'
,
false
);
});
}
});
// 优惠券类型
onFieldValueChange$
(
'type'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
const
denominationValue
=
getFieldValue
(
'denomination'
);
// 券面额
...
...
@@ -55,11 +72,6 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
});
}
setFieldState
(
'getWay'
,
fieldState
=>
{
FormPath
.
setIn
(
fieldState
,
'value'
,
undefined
);
FormPath
.
setIn
(
fieldState
,
'props.x-component-props.disabled'
,
false
);
});
// 非0元抵扣券,使用条件 必须大于 0
if
(
useConditionMoneyValue
&&
+
useConditionMoneyValue
===
0
)
{
setFieldState
(
'useConditionMoney'
,
fieldState
=>
{
...
...
@@ -159,6 +171,15 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
});
// 领券方式
onFieldInputChange$
(
'getWay'
).
subscribe
(()
=>
{
setFieldState
(
'suitableMemberTypes'
,
state
=>
{
if
(
state
.
value
&&
state
.
value
.
length
)
{
FormPath
.
setIn
(
state
,
'value'
,
[]);
}
});
});
// 领券方式
onFieldValueChange$
(
'getWay'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
...
...
@@ -181,9 +202,6 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
});
setFieldState
(
'suitableMemberTypes'
,
state
=>
{
if
(
state
.
value
&&
state
.
value
.
length
)
{
FormPath
.
setIn
(
state
,
'value'
,
[]);
}
FormPath
.
setIn
(
state
,
'props.enum'
,
newData
);
});
});
...
...
src/pages/transaction/marketingAbility/merchantCoupon/merchantCouponUnsubmitted/components/CouponForm/index.tsx
View file @
976fab19
...
...
@@ -2,12 +2,12 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 13:47:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-23 1
4:42:48
* @LastEditTime: 2021-07-23 1
8:03:47
* @Description: 新增/修改 优惠券表单
*/
import
React
,
{
useState
,
useMemo
}
from
'react'
;
import
React
,
{
useState
,
useMemo
,
useEffect
}
from
'react'
;
import
{
Spin
,
Button
,
message
}
from
'antd'
;
import
{
PlusOutlined
,
DeleteOutlined
,
SaveOutlined
}
from
'@ant-design/icons'
;
import
{
DeleteOutlined
,
SaveOutlined
}
from
'@ant-design/icons'
;
import
{
createFormActions
,
FormEffectHooks
}
from
'@formily/antd'
;
import
{
Radio
,
DatePicker
,
ArrayTable
}
from
'@formily/antd-components'
;
import
{
history
,
Prompt
}
from
'umi'
;
...
...
@@ -50,7 +50,7 @@ export type SubmitValueType = {
*/
name
:
string
,
/**
*
优惠券名称
*
券面额
*/
denomination
:
string
,
/**
...
...
@@ -105,28 +105,24 @@ export type SubmitValueType = {
/**
* 使用说明
*/
use
r
ConditionDesc
:
string
,
useConditionDesc
:
string
,
/**
* 适用商品
*/
goodsList
:
ProductItemType
[],
goodsList
?
:
ProductItemType
[],
/**
* 适用品类
*/
applicableCategories
?:
{
category
:
string
[][],
category
:
number
[][],
}[],
/**
* 适用品牌
*/
applicableBrands
:
{
brand
:
string
[]
,
applicableBrands
?
:
{
brand
:
number
,
}[],
/**
* 适用用户
*/
applicationUser
:
any
[],
/**
* 适用用户角色
*/
applicationUserRole
:
any
[],
...
...
@@ -140,6 +136,8 @@ export type SubmitValueType = {
suitableMallTypes
:
number
[],
}
export
type
CouponInfoType
=
SubmitValueType
&
{}
interface
IProps
{
/**
* 数据id
...
...
@@ -156,10 +154,76 @@ const CouponForm: React.FC<IProps> = (props) => {
id
,
editable
=
true
,
}
=
props
;
const
[
couponInfo
,
setCouponInfo
]
=
useState
<
CouponInfoType
>
();
const
[
infoLoading
,
setInfoLoading
]
=
useState
(
false
);
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
const
[
typeValue
,
setTypeValue
]
=
useState
<
undefined
|
number
>
(
undefined
);
const
[
unsaved
,
setUnsaved
]
=
useState
(
false
);
const
getCouponDetail
=
()
=>
{
if
(
!
id
)
{
return
;
}
setInfoLoading
(
true
);
PublicApi
.
getMarketingCouponWaitAuditGet
({
id
:
`
${
id
}
`
,
}).
then
((
res
)
=>
{
if
(
res
.
code
===
1000
)
{
const
{
id
,
status
,
statusName
,
suitableCommoditySkuList
,
suitableCategoryList
,
suitableBrandList
,
suitableMallTypes
,
suitableMemberLevelTypes
,
denomination
,
quantity
,
releaseTimeStart
,
releaseTimeEnd
,
effectiveTimeStart
,
effectiveTimeEnd
,
invalidDay
,
useConditionMoney
,
conditionGetTotal
,
conditionGetDay
,
createTime
,
taskSteps
,
history
,
...
rest
}
=
res
.
data
;
setCouponInfo
({
goodsList
:
suitableCommoditySkuList
as
any
,
applicableCategories
:
(
suitableCategoryList
as
any
)?.
map
((
item
)
=>
({
category
:
item
.
map
((
category
)
=>
`
${
category
.
id
}
`
)})),
applicableBrands
:
suitableBrandList
?.
map
((
item
)
=>
({
brand
:
item
.
id
})),
applicationUserRole
:
[],
applicationMemberLevel
:
suitableMemberLevelTypes
,
suitableMallTypes
:
suitableMallTypes
?.
map
((
item
)
=>
item
.
id
),
denomination
:
`
${
denomination
}
`
,
quantity
:
`
${
quantity
}
`
,
releaseTimeStart
:
releaseTimeStart
?
moment
(
releaseTimeStart
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
''
,
releaseTimeEnd
:
releaseTimeEnd
?
moment
(
releaseTimeEnd
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
''
,
effectiveTimeStart
:
effectiveTimeStart
?
moment
(
effectiveTimeStart
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
''
,
effectiveTimeEnd
:
effectiveTimeEnd
?
moment
(
effectiveTimeEnd
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
''
,
invalidDay
:
invalidDay
!==
null
?
`
${
invalidDay
}
`
:
undefined
,
useConditionMoney
:
`
${
useConditionMoney
}
`
,
receiveCondition
:
{
conditionGetTotal
:
`
${
conditionGetTotal
}
`
,
conditionGetDay
:
`
${
conditionGetDay
}
`
,
},
...
rest
,
});
}
}).
finally
(()
=>
{
setInfoLoading
(
false
);
});
};
useEffect
(()
=>
{
getCouponDetail
();
},
[]);
const
anchorsArr
=
[
{
key
:
'basicInfo'
,
...
...
@@ -169,6 +233,10 @@ const CouponForm: React.FC<IProps> = (props) => {
key
:
'couponRules'
,
name
:
'优惠券规则'
,
},
{
key
:
'applicableShopList'
,
name
:
'适用商城'
,
},
(
typeValue
===
MERCHANT_COUPON_TYPE_PRODUCT
||
typeValue
===
MERCHANT_COUPON_TYPE_VOUCHER
...
...
@@ -198,10 +266,6 @@ const CouponForm: React.FC<IProps> = (props) => {
key
:
'applicableMember'
,
name
:
'适用用户'
,
},
{
key
:
'applicableShopList'
,
name
:
'适用商城'
,
},
].
filter
(
Boolean
);
// 删除商品项
...
...
@@ -293,6 +357,29 @@ const CouponForm: React.FC<IProps> = (props) => {
msg
();
setSubmitLoading
(
false
);
});
}
else
{
setSubmitLoading
(
true
);
const
msg
=
message
.
loading
({
content
:
'正在修改,请稍候...'
,
duration
:
0
,
});
PublicApi
.
postMarketingCouponWaitAuditUpdate
({
id
,
...
payload
,
},
{
timeout
:
0
,
}).
then
((
res
)
=>
{
if
(
res
.
code
!==
1000
)
{
return
;
}
setUnsaved
(
false
);
setTimeout
(()
=>
{
history
.
goBack
();
},
800
);
}).
finally
(()
=>
{
msg
();
setSubmitLoading
(
false
);
});
}
};
...
...
@@ -305,7 +392,7 @@ const CouponForm: React.FC<IProps> = (props) => {
);
return
(
<
Spin
spinning=
{
false
}
>
<
Spin
spinning=
{
infoLoading
}
>
<
AnchorPage
title=
"新增商家优惠券"
anchors=
{
anchorsArr
}
...
...
@@ -325,7 +412,7 @@ const CouponForm: React.FC<IProps> = (props) => {
previewPlaceholder=
" "
onSubmit=
{
handleSubmit
}
actions=
{
formActions
}
initialValues=
{
{}
}
initialValues=
{
couponInfo
}
components=
{
{
RadioGroup
:
Radio
.
Group
,
RangePicker
:
DatePicker
.
RangePicker
,
...
...
src/pages/transaction/marketingAbility/merchantCoupon/merchantCouponUnsubmitted/edit.tsx
View file @
976fab19
...
...
@@ -2,15 +2,17 @@
* @Author: XieZhiXiong
* @Date: 2021-06-25 17:00:46
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-0
6-25 17:00:47
* @LastEditTime: 2021-0
7-23 17:09:45
* @Description: 编辑商家优惠券
*/
import
React
from
'react'
;
import
{
usePageStatus
}
from
'@/hooks/usePageStatus'
;
import
CouponForm
from
'./components/CouponForm'
;
const
MerchantCouponEdit
:
React
.
FC
=
()
=>
{
const
{
id
}
=
usePageStatus
();
return
(
<
CouponForm
/>
<
CouponForm
id=
{
+
id
}
/>
);
};
...
...
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