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
5e8725eb
Commit
5e8725eb
authored
Jul 02, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 对接部分类型新增逻辑
parent
eb046247
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
220 additions
and
53 deletions
+220
-53
index.tsx
...merchantCouponUnsubmitted/components/CouponForm/index.tsx
+207
-10
schema.tsx
...erchantCouponUnsubmitted/components/CouponForm/schema.tsx
+13
-43
No files found.
src/pages/transaction/marketingAbility/merchantCoupon/merchantCouponUnsubmitted/components/CouponForm/index.tsx
View file @
5e8725eb
...
...
@@ -2,14 +2,24 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 13:47:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-0
6-28 17:12:06
* @LastEditTime: 2021-0
7-02 14:58:21
* @Description: 新增/修改 优惠券表单
*/
import
React
,
{
useState
,
useMemo
}
from
'react'
;
import
{
Spin
,
Button
}
from
'antd'
;
import
{
Spin
,
Button
,
message
}
from
'antd'
;
import
{
PlusOutlined
,
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'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
moment
from
'moment'
;
import
{
MERCHANT_COUPON_TYPE_UNIVERSAL
,
MERCHANT_COUPON_TYPE_CATEGORY
,
MERCHANT_COUPON_TYPE_BRAND
,
MERCHANT_COUPON_TYPE_PRODUCT
,
MERCHANT_COUPON_TYPE_VOUCHER
,
}
from
'@/constants/marketing'
;
import
AnchorPage
from
'@/layouts/AnchorPage'
;
import
NiceForm
from
'@/components/NiceForm'
;
import
schema
from
'./schema'
;
...
...
@@ -29,6 +39,106 @@ const {
onFormInputChange$
,
}
=
FormEffectHooks
;
export
type
SubmitValueType
=
{
/**
* 优惠券类型
*/
type
:
number
,
/**
* 优惠券名称
*/
name
:
string
,
/**
* 优惠券名称
*/
denomination
:
string
,
/**
* 发券数量
*/
quantity
:
string
,
/**
* 领(发)劵起始时间
*/
releaseTimeStart
:
string
,
/**
* 领(发)劵结束时间
*/
releaseTimeEnd
:
string
,
/**
* 领券方式
*/
getWay
:
number
,
/**
* 券有效期
*/
effectiveType
:
number
,
/**
* 领券条件
*/
receiveCondition
:
{
/**
* 每会员ID总共可领取
*/
conditionGetTotal
:
string
,
/**
* 每日可领取
*/
conditionGetDay
:
string
,
},
/**
* 劵有效期起始时间
*/
effectiveTimeStart
:
string
,
/**
* 劵有效期结束时间
*/
effectiveTimeEnd
:
string
,
/**
* 自领取后多少天内失效
*/
invalidDay
:
string
,
/**
* 使用条件
*/
useConditionMoney
:
string
,
/**
* 使用说明
*/
userConditionDesc
:
string
,
/**
* 适用商品
*/
goodsList
:
any
[],
/**
* 适用品类
*/
applicableCategories
:
{
category
:
string
[],
}[],
/**
* 适用品牌
*/
applicableBrands
:
{
brand
:
string
,
}[],
/**
* 适用用户
*/
applicationUser
:
any
[],
/**
* 适用用户角色
*/
applicationUserRole
:
any
[],
/**
* 适用会员
*/
applicationMemberLevel
:
number
[],
/**
* 适用商城
*/
suitableMallTypes
:
number
[],
}
interface
IProps
{
/**
* 数据id
...
...
@@ -47,6 +157,7 @@ const CouponForm: React.FC<IProps> = (props) => {
}
=
props
;
const
[
visibleGoodsDrawer
,
setVisibleGoodsDrawer
]
=
useState
(
false
);
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
const
[
typeValue
,
setTypeValue
]
=
useState
<
undefined
|
number
>
(
undefined
);
const
[
unsaved
,
setUnsaved
]
=
useState
(
false
);
const
anchorsArr
=
[
...
...
@@ -58,18 +169,31 @@ const CouponForm: React.FC<IProps> = (props) => {
key
:
'couponRules'
,
name
:
'优惠券规则'
,
},
{
(
typeValue
===
MERCHANT_COUPON_TYPE_PRODUCT
||
typeValue
===
MERCHANT_COUPON_TYPE_VOUCHER
?
{
key
:
'applicableGoods'
,
name
:
'适用商品'
,
},
{
}
:
null
),
(
typeValue
===
MERCHANT_COUPON_TYPE_CATEGORY
?
{
key
:
'applicableCategories'
,
name
:
'适用品类'
,
},
{
}
:
null
),
(
typeValue
===
MERCHANT_COUPON_TYPE_BRAND
?
{
key
:
'applicableBrands'
,
name
:
'适用品牌'
,
},
}
:
null
),
{
key
:
'applicableMember'
,
name
:
'适用用户'
,
...
...
@@ -78,7 +202,7 @@ const CouponForm: React.FC<IProps> = (props) => {
key
:
'applicableShopList'
,
name
:
'适用商城'
,
},
];
]
.
filter
(
Boolean
)
;
const
handleVisibleGoodsDrawer
=
(
flag
?:
boolean
)
=>
{
setVisibleGoodsDrawer
(
!!
flag
);
...
...
@@ -108,8 +232,75 @@ const CouponForm: React.FC<IProps> = (props) => {
/>
);
const
handleSubmit
=
(
values
:
any
)
=>
{
const
handleSubmit
=
(
values
:
SubmitValueType
)
=>
{
console
.
log
(
'values'
,
values
)
const
{
receiveCondition
:
{
conditionGetDay
,
conditionGetTotal
,
},
useConditionMoney
,
quantity
,
invalidDay
,
denomination
,
applicableBrands
,
applicableCategories
,
applicationMemberLevel
,
applicationUserRole
,
releaseTimeStart
,
releaseTimeEnd
,
effectiveTimeStart
,
effectiveTimeEnd
,
...
restValue
}
=
values
;
let
applicationRelated
:
string
[]
=
[];
if
(
applicableBrands
&&
applicableBrands
.
length
)
{
applicationRelated
=
applicableBrands
.
map
((
item
)
=>
item
.
brand
);
}
if
(
applicableCategories
&&
applicableCategories
.
length
)
{
applicationRelated
=
applicableCategories
.
map
((
item
)
=>
item
.
category
.
join
(
'.'
));
}
const
payload
=
{
conditionGetDay
:
+
conditionGetDay
,
conditionGetTotal
:
+
conditionGetTotal
,
useConditionMoney
:
+
useConditionMoney
,
quantity
:
+
quantity
,
invalidDay
:
+
invalidDay
,
denomination
:
+
denomination
,
releaseTimeStart
:
moment
(
releaseTimeStart
).
valueOf
(),
releaseTimeEnd
:
moment
(
releaseTimeEnd
).
valueOf
(),
effectiveTimeStart
:
effectiveTimeStart
?
moment
(
effectiveTimeStart
).
valueOf
()
:
undefined
,
effectiveTimeEnd
:
effectiveTimeEnd
?
moment
(
effectiveTimeEnd
).
valueOf
()
:
undefined
,
suitableMemberLevelTypes
:
applicationMemberLevel
,
relevanceProductData
:
applicationRelated
as
any
,
...
restValue
,
};
if
(
!
id
)
{
setSubmitLoading
(
true
);
const
msg
=
message
.
loading
({
content
:
'正在添加,请稍候...'
,
duration
:
0
,
});
PublicApi
.
postMarketingCouponWaitAuditAdd
(
payload
,
{
timeout
:
0
,
}).
then
((
res
)
=>
{
if
(
res
.
code
!==
1000
)
{
return
;
}
setUnsaved
(
false
);
setTimeout
(()
=>
{
history
.
goBack
();
},
800
);
}).
finally
(()
=>
{
msg
();
setSubmitLoading
(
false
);
});
}
};
const
useFields
=
():
any
=>
(
...
...
@@ -163,6 +354,10 @@ const CouponForm: React.FC<IProps> = (props) => {
setUnsaved
(
true
);
}
});
onFieldValueChange$
(
'type'
).
subscribe
((
state
)
=>
{
setTypeValue
(
state
.
value
);
});
}
}
schema=
{
schema
}
editable=
{
!!
editable
}
...
...
@@ -174,6 +369,8 @@ const CouponForm: React.FC<IProps> = (props) => {
onSubmit=
{
()
=>
{}
}
/>
</
AnchorPage
>
<
Prompt
when=
{
unsaved
}
message=
"您还有未保存的内容,是否确定要离开?"
/>
</
Spin
>
);
};
...
...
src/pages/transaction/marketingAbility/merchantCoupon/merchantCouponUnsubmitted/components/CouponForm/schema.tsx
View file @
5e8725eb
...
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:05:57
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-0
6-30 18:12:17
* @LastEditTime: 2021-0
7-02 13:54:30
* @Description:
*/
import
{
ISchema
}
from
'@formily/antd'
;
...
...
@@ -256,7 +256,7 @@ const schema: ISchema = {
},
],
},
use
r
ConditionDesc
:
{
useConditionDesc
:
{
title
:
'使用说明'
,
type
:
'string'
,
'x-mega-props'
:
{
...
...
@@ -411,9 +411,10 @@ const schema: ISchema = {
category
:
{
type
:
'string'
,
enum
:
[],
required
:
true
,
'x-component'
:
'CascaderFormItem'
,
'x-component-props'
:
{
fieldNames
:
{
label
:
'title'
,
value
:
'
title
'
,
children
:
'children'
},
fieldNames
:
{
label
:
'title'
,
value
:
'
id
'
,
children
:
'children'
},
},
},
},
...
...
@@ -453,6 +454,7 @@ const schema: ISchema = {
brand
:
{
type
:
'string'
,
enum
:
[],
required
:
true
,
'x-component-props'
:
{
allowClear
:
true
,
},
...
...
@@ -483,7 +485,7 @@ const schema: ISchema = {
labelAlign
:
'left'
,
},
properties
:
{
applicationUser
:
{
suitableMemberTypes
:
{
title
:
'适用用户'
,
type
:
'string'
,
enum
:
[
...
...
@@ -508,6 +510,7 @@ const schema: ISchema = {
disabled
:
false
,
},
],
default
:
[],
required
:
true
,
'x-component'
:
'TofuCheckGroup'
,
'x-component-props'
:
{
...
...
@@ -516,37 +519,15 @@ const schema: ISchema = {
applicationUserRole
:
{
title
:
'适用用户角色'
,
type
:
'string'
,
enum
:
[
{
label
:
'哈哈'
,
value
:
1
,
disabled
:
false
,
},
{
label
:
'嘻嘻'
,
value
:
2
,
disabled
:
true
,
},
],
required
:
true
,
enum
:
[],
default
:
[
0
],
'x-component'
:
'TofuCheckGroup'
,
'x-component-props'
:
{
},
},
applicationMember
:
{
applicationMember
Level
:
{
type
:
'string'
,
enum
:
[
{
label
:
'哈哈'
,
value
:
1
,
disabled
:
false
,
},
{
label
:
'嘻嘻'
,
value
:
2
,
disabled
:
true
,
},
],
enum
:
[],
required
:
true
,
'x-component'
:
'MemberCheckboxGroup'
,
'x-component-props'
:
{
...
...
@@ -575,20 +556,9 @@ const schema: ISchema = {
labelAlign
:
'left'
,
},
properties
:
{
applicableShopList
:
{
suitableMallTypes
:
{
type
:
'string'
,
enum
:
[
{
label
:
'WEB-渠道商城'
,
value
:
1
,
logo
:
'http://www.yyfun001.com/res/htmlLX/gunbo3.jpg'
,
},
{
label
:
'H5-渠道商城'
,
value
:
2
,
logo
:
'http://www.yyfun001.com/res/htmlLX/gunbo3.jpg'
,
},
],
enum
:
[],
required
:
true
,
'x-component'
:
'ApplicableList'
,
'x-component-props'
:
{
...
...
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