Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
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-admin
Commits
327f7c95
Commit
327f7c95
authored
Sep 23, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加适用会员类型
parent
6abb7e58
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
21 deletions
+103
-21
index.tsx
...CouponUnsubmitted/components/CouponForm/effects/index.tsx
+20
-2
useBusinessEffects.ts
...itted/components/CouponForm/effects/useBusinessEffects.ts
+28
-15
index.tsx
...platformCouponUnsubmitted/components/CouponForm/index.tsx
+7
-3
schema.tsx
...latformCouponUnsubmitted/components/CouponForm/schema.tsx
+48
-1
No files found.
src/pages/marketingManage/platformCoupon/platformCouponUnsubmitted/components/CouponForm/effects/index.tsx
View file @
327f7c95
...
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:03:34
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-0
8-03 15:52:33
* @LastEditTime: 2021-0
9-23 16:17:02
* @Description:
*/
import
{
FormPath
,
FormEffectHooks
}
from
'@formily/antd'
;
...
...
@@ -88,8 +88,24 @@ const fetchSuitableUser = async () => {
};
};
// 初始化 适用会员类型
const
fetchMemberTypes
=
async
()
=>
{
const
res
=
await
PublicApi
.
getMarketingCouponPlatformMemberTypeList
();
if
(
res
.
code
===
1000
)
{
const
{
data
=
[]
}
=
res
;
return
{
memberTypes
:
data
.
map
(
item
=>
({
label
:
item
.
name
,
value
:
item
.
value
})),
};
}
return
{
data
:
[],
totalCount
:
0
,
};
};
// 获取 实用会员选项
const
fetchMemberOptions
:
(
params
:
{
current
:
string
,
pageSize
:
string
,
levelConfigIds
:
string
,
roleIds
:
string
})
=>
Promise
<
ResponseType
>
=
async
(
params
)
=>
{
const
fetchMemberOptions
:
(
params
:
{
current
:
string
,
pageSize
:
string
,
levelConfigIds
:
string
,
roleIds
:
string
,
memberTypes
:
string
})
=>
Promise
<
ResponseType
>
=
async
(
params
)
=>
{
const
res
=
await
PublicApi
.
getMemberManageMarketingSuitableLevelConfigPage
(
params
);
if
(
res
.
code
===
1000
)
{
const
options
=
res
.
data
.
data
.
map
(
item
=>
({
...
...
@@ -124,6 +140,8 @@ export const createEffects = (context, actions) => {
useAsyncInitSelect
([
'suitableMemberTypes'
],
fetchSuitableUser
);
useAsyncInitSelect
([
'memberTypes'
],
fetchMemberTypes
);
// 初始化 适用商城数据
onFieldMount$
(
'suitableMallTypes'
).
subscribe
(()
=>
{
PublicApi
.
getManageShopAllByShopType
({
...
...
src/pages/marketingManage/platformCoupon/platformCouponUnsubmitted/components/CouponForm/effects/useBusinessEffects.ts
View file @
327f7c95
...
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:04:16
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-0
7-30 17:48:32
* @LastEditTime: 2021-0
9-23 16:14:31
* @Description:
*/
import
{
FormEffectHooks
,
FormPath
,
IFormActions
}
from
'@formily/antd'
;
...
...
@@ -19,8 +19,6 @@ import {
MERCHANT_COUPON_RECEIVE_OPERATE
,
SUITABLE_TYPE_NEW_USER
,
SUITABLE_TYPE_OLD_USER
,
SUITABLE_TYPE_NEW_MEMBER
,
SUITABLE_TYPE_OLD_MEMBER
,
}
from
'@/constants/const/marketing'
;
const
{
...
...
@@ -232,18 +230,6 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
});
});
// 适用用户
onFieldValueChange$
(
'suitableMemberTypes'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
// 包含新会员(仅会员用户) 或者 老会员(仅会员用户),展示 适用用户角色 与 会员等级列表
if
(
value
&&
(
value
.
includes
(
SUITABLE_TYPE_NEW_MEMBER
)
||
value
.
includes
(
SUITABLE_TYPE_OLD_MEMBER
)))
{
linkage
.
show
(
'*(applicationUserRole,applicationMemberLevel)'
);
}
else
{
linkage
.
hide
(
'*(applicationUserRole,applicationMemberLevel)'
);
}
});
// 券有效期类型,展示对应的 FieldItem
onFieldValueChange$
(
'effectiveType'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
...
...
@@ -255,4 +241,30 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
linkage
.
show
(
'invalidDay'
);
}
});
// 每日可领取量
onFieldInputChange$
(
'receiveCondition.conditionGetDay'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
const
conditionGetTotalValue
=
getFieldValue
(
'receiveCondition.conditionGetTotal'
);
// 每会员ID总共可领取;
if
(
+
value
>
+
conditionGetTotalValue
)
{
setFieldState
(
'receiveCondition.conditionGetDay'
,
fieldState
=>
{
FormPath
.
setIn
(
fieldState
,
'errors'
,
'每日可领取必须小于或等于总可领取量'
);
});
}
else
{
actions
.
clearErrors
(
'receiveCondition.conditionGetDay'
);
}
});
// 每会员ID总共可领取
onFieldInputChange$
(
'receiveCondition.conditionGetTotal'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
const
conditionGetDayValue
=
getFieldValue
(
'receiveCondition.conditionGetDay'
);
// 每会员ID总共可领取;
if
(
+
value
<
+
conditionGetDayValue
)
{
setFieldState
(
'receiveCondition.conditionGetTotal'
,
fieldState
=>
{
FormPath
.
setIn
(
fieldState
,
'errors'
,
'每会员ID总共可领取必须大于每日可领取'
);
});
}
else
{
actions
.
clearErrors
(
'receiveCondition.conditionGetTotal'
);
}
});
}
\ No newline at end of file
src/pages/marketingManage/platformCoupon/platformCouponUnsubmitted/components/CouponForm/index.tsx
View file @
327f7c95
...
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 13:47:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-0
8-13 15:14:24
* @LastEditTime: 2021-0
9-23 16:55:22
* @Description: 新增/修改 优惠券表单
*/
import
React
,
{
useState
,
useMemo
,
useEffect
}
from
'react'
;
...
...
@@ -122,6 +122,10 @@ export type SubmitValueType = {
* 适用商城
*/
suitableMallTypes
:
number
[],
/**
* 实用会员类型
*/
memberTypes
:
number
[],
}
export
type
CouponInfoType
=
SubmitValueType
&
{}
...
...
@@ -188,7 +192,7 @@ const CouponForm: React.FC<IProps> = (props) => {
goodsList
:
suitableCommoditySkuList
as
any
,
applicationUserRole
,
applicationMemberLevel
:
suitableMemberLevelTypes
?.
map
((
item
)
=>
item
.
id
),
suitableMemberTypes
:
suitableMemberTypes
?.
map
((
item
)
=>
item
.
value
)
,
suitableMemberTypes
:
suitableMemberTypes
,
suitableMallTypes
:
suitableMallTypes
?.
map
((
item
)
=>
item
.
id
),
denomination
:
`
${
denomination
}
`
,
quantity
:
`
${
quantity
}
`
,
...
...
@@ -355,7 +359,7 @@ const CouponForm: React.FC<IProps> = (props) => {
return
(
<
Spin
spinning=
{
infoLoading
}
>
<
AnchorPage
title=
"新增平台优惠券"
title=
{
`${!id ? '新增' : '编辑'}平台优惠券`
}
anchors=
{
anchorsArr
}
extra=
{
[
<
Button
...
...
src/pages/marketingManage/platformCoupon/platformCouponUnsubmitted/components/CouponForm/schema.tsx
View file @
327f7c95
...
...
@@ -2,13 +2,22 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:05:57
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-0
8-02 17:38:26
* @LastEditTime: 2021-0
9-22 14:02:44
* @Description:
*/
import
{
ISchema
}
from
'@formily/antd'
;
import
moment
from
'moment'
;
import
themeConfig
from
'@/../config/theme.config'
;
import
{
PATTERN_MAPS
}
from
'@/constants/regExp'
;
function
range
(
start
,
end
)
{
const
result
=
[];
for
(
let
i
=
start
;
i
<
end
;
i
++
)
{
result
.
push
(
i
);
}
return
result
;
}
const
schema
:
ISchema
=
{
type
:
'object'
,
properties
:
{
...
...
@@ -51,6 +60,12 @@ const schema: ISchema = {
'x-component-props'
:
{
allowClear
:
false
,
},
'x-rules'
:
[
{
limitByte
:
true
,
// 自定义校验规则
maxByte
:
60
,
}
],
},
denomination
:
{
title
:
'券面额'
,
...
...
@@ -89,6 +104,17 @@ const schema: ISchema = {
'x-component-props'
:
{
placeholder
:
[
'领(发)劵起始时间'
,
'领(发)劵截止时间'
],
showTime
:
true
,
disabledDate
:
(
current
)
=>
current
&&
current
<
moment
().
startOf
(
'day'
),
disabledTime
:
(
_
,
type
)
=>
{
if
(
type
===
'start'
)
{
return
{
disabledHours
:
()
=>
range
(
0
,
24
).
splice
(
0
,
moment
().
get
(
'hour'
)),
disabledMinutes
:
()
=>
range
(
0
,
60
).
splice
(
0
,
moment
().
get
(
'minute'
)),
disabledSeconds
:
()
=>
range
(
0
,
60
).
splice
(
0
,
moment
().
get
(
'second'
)),
};
}
return
{};
},
},
},
},
...
...
@@ -276,6 +302,17 @@ const schema: ISchema = {
'x-component-props'
:
{
placeholder
:
[
'劵有效期起始时间'
,
'劵有效期截止时间'
],
showTime
:
true
,
disabledDate
:
(
current
)
=>
current
&&
current
<
moment
().
startOf
(
'day'
),
disabledTime
:
(
_
,
type
)
=>
{
if
(
type
===
'start'
)
{
return
{
disabledHours
:
()
=>
range
(
0
,
24
).
splice
(
0
,
moment
().
get
(
'hour'
)),
disabledMinutes
:
()
=>
range
(
0
,
60
).
splice
(
0
,
moment
().
get
(
'minute'
)),
disabledSeconds
:
()
=>
range
(
0
,
60
).
splice
(
0
,
moment
().
get
(
'second'
)),
};
}
return
{};
},
},
},
invalidDay
:
{
...
...
@@ -388,6 +425,16 @@ const schema: ISchema = {
'x-component-props'
:
{
},
},
memberTypes
:
{
title
:
'适用会员类型'
,
type
:
'string'
,
enum
:
[],
default
:
[],
required
:
true
,
'x-component'
:
'TofuCheckGroup'
,
'x-component-props'
:
{
},
},
applicationUserRole
:
{
title
:
'适用用户角色'
,
type
:
'string'
,
...
...
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