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
eb046247
Commit
eb046247
authored
Jul 02, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: 完善联动逻辑
parent
0c3df8f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
10 deletions
+83
-10
index.tsx
...CouponUnsubmitted/components/CouponForm/effects/index.tsx
+40
-3
useBusinessEffects.ts
...itted/components/CouponForm/effects/useBusinessEffects.ts
+43
-7
No files found.
src/pages/transaction/marketingAbility/merchantCoupon/merchantCouponUnsubmitted/components/CouponForm/effects/index.tsx
View file @
eb046247
...
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:03:34
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-0
6-30 17:57:05
* @LastEditTime: 2021-0
7-02 10:32:13
* @Description:
*/
import
{
FormPath
,
FormEffectHooks
}
from
'@formily/antd'
;
...
...
@@ -40,6 +40,28 @@ const fetchCouponGetWay = async () => {
return
{};
};
// 初始化 适用用户角色
const
fetchApplicationUserRole
=
async
()
=>
{
const
res
=
await
PublicApi
.
getMemberAbilityLevelRoleList
();
const
allItem
=
{
label
:
'全部'
,
value
:
0
,
};
if
(
res
.
code
===
1000
)
{
const
{
data
=
[]
}
=
res
;
const
options
=
[
allItem
,
...(
data
.
map
(
item
=>
({
label
:
item
.
roleName
,
value
:
item
.
roleId
})))
];
return
{
applicationUserRole
:
options
,
};
}
return
{};
};
export
const
createEffects
=
(
context
,
actions
)
=>
{
const
{
setFieldState
}
=
actions
;
...
...
@@ -49,19 +71,22 @@ export const createEffects = (context, actions) => {
useAsyncInitSelect
([
'getWay'
],
fetchCouponGetWay
);
useAsyncInitSelect
([
'applicationUserRole'
],
fetchApplicationUserRole
);
// 初始化 品牌数据
onFieldMount$
(
'applicableBrands'
).
subscribe
(()
=>
{
PublicApi
.
getProductSelectGetSelectBrand
().
then
((
res
)
=>
{
if
(
res
.
code
===
1000
)
{
const
{
data
=
[]
}
=
res
;
setFieldState
(
'applicableBrands.*.brand'
,
state
=>
{
FormPath
.
setIn
(
state
,
'props.enum'
,
data
.
map
(
item
=>
({
label
:
item
.
name
,
value
:
item
.
id
})));
FormPath
.
setIn
(
state
,
'props.enum'
,
data
.
map
(
item
=>
({
label
:
item
.
name
,
value
:
`
${
item
.
id
}
`
})));
});
}
});
});
// 初始化 品类数据
onFieldMount$
(
'applicableCategories'
).
subscribe
(()
=>
{
// 初始化 品类数据
PublicApi
.
getProductCustomerGetCustomerCategoryTree
().
then
((
res
)
=>
{
if
(
res
.
code
===
1000
)
{
const
{
data
=
[]
}
=
res
;
...
...
@@ -71,4 +96,15 @@ export const createEffects = (context, actions) => {
}
});
});
onFieldMount$
(
'suitableMallTypes'
).
subscribe
(()
=>
{
PublicApi
.
getManageShopFindByMemberType
().
then
((
res
)
=>
{
if
(
res
.
code
===
1000
)
{
const
{
data
=
[]
}
=
res
;
setFieldState
(
'suitableMallTypes'
,
state
=>
{
FormPath
.
setIn
(
state
,
'props.enum'
,
data
.
map
(
item
=>
({
label
:
item
.
name
,
value
:
item
.
id
,
logo
:
item
.
logoUrl
})));
});
}
});
});
};
\ No newline at end of file
src/pages/transaction/marketingAbility/merchantCoupon/merchantCouponUnsubmitted/components/CouponForm/effects/useBusinessEffects.ts
View file @
eb046247
...
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:04:16
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-0
1 14:21:31
* @LastEditTime: 2021-07-0
2 14:14:20
* @Description:
*/
import
{
FormEffectHooks
,
FormPath
,
IFormActions
}
from
'@formily/antd'
;
...
...
@@ -17,6 +17,7 @@ import {
MERCHANT_COUPON_RECEIVE_ACTIVITY
,
MERCHANT_COUPON_RECEIVE_OPERATE
,
}
from
'@/constants/marketing'
;
import
{
PublicApi
}
from
'@/services/api'
;
const
{
onFieldInputChange$
,
...
...
@@ -121,6 +122,7 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
});
}
else
{
actions
.
clearErrors
(
'denomination'
);
actions
.
clearErrors
(
'useConditionMoney'
);
}
});
...
...
@@ -153,6 +155,7 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
});
}
else
{
actions
.
clearErrors
(
'useConditionMoney'
);
actions
.
clearErrors
(
'denomination'
);
}
});
...
...
@@ -160,8 +163,8 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
onFieldValueChange$
(
'getWay'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
const
applicationUserEnum
=
[...
getFieldState
(
'applicationUser
'
,
state
=>
state
.
props
.
enum
)];
const
newData
=
applicationUser
Enum
.
map
((
item
)
=>
{
const
suitableMemberTypesEnum
=
[...
getFieldState
(
'suitableMemberTypes
'
,
state
=>
state
.
props
.
enum
)];
const
newData
=
suitableMemberTypes
Enum
.
map
((
item
)
=>
{
const
newItem
=
{...
item
};
newItem
.
disabled
=
false
;
if
(
...
...
@@ -178,17 +181,50 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
return
newItem
;
});
setFieldState
(
'applicationUser'
,
state
=>
{
FormPath
.
setIn
(
state
,
'value'
,
[]);
setFieldState
(
'suitableMemberTypes'
,
state
=>
{
if
(
state
.
value
&&
state
.
value
.
length
)
{
FormPath
.
setIn
(
state
,
'value'
,
[]);
}
FormPath
.
setIn
(
state
,
'props.enum'
,
newData
);
});
});
// 适用用户角色
onFieldValueChange$
(
'applicationUserRole'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
const
filtered
=
(
value
||
[]).
filter
((
item
)
=>
item
!==
0
);
// 过滤掉 0全选元素
// 查询会员列表,0 表示全部
PublicApi
.
getMemberAbilityLevelTagPage
({
roleIds
:
filtered
.
join
(
','
),
current
:
`
${
1
}
`
,
pageSize
:
`
${
9999
}
`
,
levelConfigIds
:
''
,
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
const
options
=
res
.
data
.
data
.
map
(
item
=>
({
label
:
item
.
roleName
,
value
:
item
.
id
,
level
:
item
.
level
,
roleName
:
item
.
roleName
,
levelTypeName
:
item
.
levelTypeName
,
memberTypeName
:
item
.
memberTypeName
,
}));
linkage
.
enum
(
'applicationMemberLevel'
,
options
);
}
});
});
// 适用用户
onFieldValueChange$
(
'
applicationUser
'
).
subscribe
(
state
=>
{
onFieldValueChange$
(
'
suitableMemberTypes
'
).
subscribe
(
state
=>
{
const
{
value
}
=
state
;
console
.
log
(
'value'
,
value
)
// 包含新会员(仅会员用户) 或者 老会员(仅会员用户),展示 适用用户角色 与 会员等级列表
if
(
value
&&
(
value
.
includes
(
3
)
||
value
.
includes
(
4
)))
{
linkage
.
show
(
'*(applicationUserRole,applicationMemberLevel)'
);
}
else
{
linkage
.
hide
(
'*(applicationUserRole,applicationMemberLevel)'
);
}
});
// 券有效期类型,展示对应的 FieldItem
...
...
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