Commit e86a725b authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加 分页展示相关

parent ee716a42
......@@ -2,13 +2,14 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:03:34
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-02 10:32:13
* @LastEditTime: 2021-07-08 16:35:58
* @Description:
*/
import { FormPath, FormEffectHooks } from '@formily/antd';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { PublicApi } from '@/services/api';
import { useBusinessEffects } from './useBusinessEffects';
import { ResponseType } from '../../../../../components/MemberCheckboxGroup';
const {
onFieldMount$,
......@@ -62,6 +63,25 @@ const fetchApplicationUserRole = async () => {
return {};
};
// 获取 实用会员选项
const fetchMemberOtions: (params: { current: string, pageSize: string, levelConfigIds: string, roleIds: string }) => Promise<ResponseType> = async (params) => {
const res = await PublicApi.getMemberAbilityLevelTagPage(params);
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,
}));
return {
data: options,
totalCount: res.data.totalCount,
};
}
};
export const createEffects = (context, actions) => {
const { setFieldState } = actions;
......@@ -97,6 +117,7 @@ export const createEffects = (context, actions) => {
});
});
// 初始化 适用商城数据
onFieldMount$('suitableMallTypes').subscribe(() => {
PublicApi.getManageShopFindByMemberType().then((res) => {
if (res.code === 1000) {
......@@ -107,4 +128,14 @@ export const createEffects = (context, actions) => {
}
});
});
// 初始化 适用会员列表
onFieldMount$('applicationMemberLevel').subscribe(() => {
setFieldState('applicationMemberLevel', state => {
FormPath.setIn(state, 'props.x-component-props', {
showMoreAction: true,
fetchOptions: fetchMemberOtions,
});
});
});
};
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:04:16
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-02 14:14:20
* @LastEditTime: 2021-07-08 17:08:56
* @Description:
*/
import { FormEffectHooks, FormPath, IFormActions } from '@formily/antd';
......@@ -17,7 +17,6 @@ import {
MERCHANT_COUPON_RECEIVE_ACTIVITY,
MERCHANT_COUPON_RECEIVE_OPERATE,
} from '@/constants/marketing';
import { PublicApi } from '@/services/api';
const {
onFieldInputChange$,
......@@ -190,28 +189,24 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
});
// 适用用户角色
onFieldValueChange$('applicationUserRole').subscribe(state => {
onFieldInputChange$('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);
}
let filtered = [...value];
// 这里处理一下全部,当点击了 全部 把 0 去掉,否则插入一个 0
if (value.includes(0)) {
filtered = (value || []).filter((item) => item !== 0); // 过滤掉 0全选元素
} else {
filtered.unshift(0);
}
setFieldState('applicationMemberLevel', fieldState => {
FormPath.setIn(fieldState, 'props.x-component-props', Object.assign({}, fieldState.props['x-component-props'], {
extraParams: {
roleIds: filtered.join(','),
levelConfigIds: '',
},
}));
});
});
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:05:57
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-02 13:54:30
* @LastEditTime: 2021-07-08 16:43:22
* @Description:
*/
import { ISchema } from '@formily/antd';
......@@ -527,11 +527,9 @@ const schema: ISchema = {
},
applicationMemberLevel: {
type: 'string',
enum: [],
required: true,
'x-component': 'MemberCheckboxGroup',
'x-component-props': {
},
'x-component-props': {},
},
},
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment