Commit 35a468f3 authored by XieZhiXiong's avatar XieZhiXiong

对接会员信息查询新增业务

parent 6d1b13e3
...@@ -186,6 +186,12 @@ const MemberRoute = { ...@@ -186,6 +186,12 @@ const MemberRoute = {
hideInMenu: true, hideInMenu: true,
component: '@/pages/member/memberQuery/update', component: '@/pages/member/memberQuery/update',
}, },
{
path: '/memberCenter/memberAbility/addSubRole',
name: 'addSubRole',
hideInMenu: true,
component: '@/pages/member/memberQuery/addSubRole',
},
] ]
} }
......
...@@ -49,6 +49,7 @@ const Search = props => { ...@@ -49,6 +49,7 @@ const Search = props => {
<Button <Button
onClick={() => { onClick={() => {
props.form.reset(); props.form.reset();
props.form.submit();
}} }}
> >
重置 重置
......
...@@ -236,6 +236,16 @@ export const MEMBER_OUTER_STATUS = { ...@@ -236,6 +236,16 @@ export const MEMBER_OUTER_STATUS = {
[MEMBER_OUTER_STATUS_SUCCESS]: '审核通过', [MEMBER_OUTER_STATUS_SUCCESS]: '审核通过',
}; };
// 会员等级类型枚举
export const MEMBER_LEVEL_TYPE_PLATFORM = 1; // 平台会员
export const MEMBER_LEVEL_TYPE_MERCHANT = 2; // 商户会员
export const MEMBER_LEVEL_TYPE_CHANNEL = 3; // 渠道会员
export const MEMBER_LEVEL_TYPE = {
[MEMBER_LEVEL_TYPE_PLATFORM]: '平台会员',
[MEMBER_LEVEL_TYPE_MERCHANT]: '商户会员',
[MEMBER_LEVEL_TYPE_CHANNEL]: '渠道会员',
};
export const ORDER_TYPE = ['', export const ORDER_TYPE = ['',
'询价采购', '询价采购',
'需求采购', '需求采购',
......
/* /*
* @Author: LeeJiancong * @Author: LeeJiancong
* @Date: 2020-07-13 14:08:50 * @Date: 2020-07-13 14:08:50
* @LastEditors: LeeJiancong * @LastEditors: XieZhiXiong
* @LastEditTime: 2020-09-12 18:01:48 * @LastEditTime: 2020-09-15 11:48:29
*/ */
export default { export default {
...@@ -97,6 +97,7 @@ export default { ...@@ -97,6 +97,7 @@ export default {
'menu.memberAbility.memberQueryDetailed.equityInfo': '权益信息', 'menu.memberAbility.memberQueryDetailed.equityInfo': '权益信息',
'menu.memberAbility.memberQueryDetailed.sincerityInfo': '诚信信息', 'menu.memberAbility.memberQueryDetailed.sincerityInfo': '诚信信息',
'menu.memberAbility.memberUpdate': '变更会员信息', 'menu.memberAbility.memberUpdate': '变更会员信息',
'menu.memberAbility.addSubRole': '新增会员角色',
// 店铺能力 // 店铺能力
'menu.shopAbility': '店铺', 'menu.shopAbility': '店铺',
......
import React, { useState, useEffect, useRef, ReactNode } from 'react';
import { history, Prompt } from 'umi';
import { Badge, Button, Card, Spin, message } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd';
import { usePageStatus } from '@/hooks/usePageStatus';
import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { PublicApi } from '@/services/api';
import { GetMemberAbilitySubGetResponse } from '@/services/MemberApi';
import { initDetailSchema } from './schema';
const formActions = createFormActions();
const {
onFieldValueChange$,
onFieldInputChange$,
onFormInputChange$,
} = FormEffectHooks;
const AddSubRole: React.FC<any> = props => {
const areaRef = useRef<any[]>([])
const { memberTypeId, roleId } = usePageStatus();
const [memberItems, setMemberItems] = useState<any>({});
const [memberInfo, setMemberInfo] = useState<GetMemberAbilitySubGetResponse>(null);
const [submitLoading, setSubmitLoading] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [unsaved, setUnsaved] = useState(false);
const getDetailedInfo = async () => {
if (memberTypeId && roleId) {
setInfoLoading(true);
const infoRes = await PublicApi.getMemberAbilityInfoDetailByrole({
roleId,
});
setInfoLoading(false);
if (infoRes.code !== 1000) {
return;
}
const { groups = [] } = infoRes.data;
setMemberItems(groups);
}
};
useEffect(() => {
getDetailedInfo();
}, []);
const handleSubmit = (values: any) => {
if (!memberTypeId || !roleId) {
return;
}
setSubmitLoading(true);
const msg = message.loading({
content: '正在保存,请稍候...',
duration: 0,
});
PublicApi.postMemberAbilityInfoAddrole({
memberTypeId,
roleId,
detail: values,
}).then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
msg();
setSubmitLoading(false);
});
};
return (
<Spin spinning={infoLoading}>
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title="填写会员资料"
extra={[
<Button
key="1"
type="primary"
icon={<SaveOutlined />}
loading={submitLoading}
onClick={() => formActions.submit()}
>
保存
</Button>,
]}
>
<Card>
<NiceForm
onSubmit={handleSubmit}
actions={formActions}
initialValues={memberInfo || {}}
effects={($, actions) => {
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
schema={initDetailSchema(memberItems)}
/>
</Card>
</PageHeaderWrapper>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</Spin>
);
};
export default AddSubRole;
\ No newline at end of file
...@@ -4,9 +4,6 @@ import { ...@@ -4,9 +4,6 @@ import {
Card, Card,
Space, Space,
Button, Button,
Menu,
Popconfirm,
Dropdown,
Badge, Badge,
Modal, Modal,
} from 'antd'; } from 'antd';
...@@ -18,16 +15,22 @@ import { ...@@ -18,16 +15,22 @@ import {
} from '@ant-design/icons'; } from '@ant-design/icons';
import { StandardTable } from 'god'; import { StandardTable } from 'god';
import { ColumnType } from 'antd/lib/table/interface'; import { ColumnType } from 'antd/lib/table/interface';
import { createFormActions, FormEffectHooks } from '@formily/antd'; import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'; import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect'; import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import EyePreview from '@/components/EyePreview'; import EyePreview from '@/components/EyePreview';
import StatusSwitch from '@/components/StatusSwitch';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import {
MEMBER_LEVEL_TYPE_PLATFORM,
MEMBER_LEVEL_TYPE_MERCHANT,
MEMBER_LEVEL_TYPE_CHANNEL,
MEMBER_OUTER_STATUS_FAILED,
} from '@/constants';
import LevelBrand from '../components/LevelBrand'; import LevelBrand from '../components/LevelBrand';
import { maintianSchema } from './schema'; import { maintianSchema, addRoleSchema } from './schema';
import { coverColFiltersItem } from '../utils'; import { coverColFiltersItem } from '../utils';
import { import {
MEMBER_STATUS_TAG_MAP, MEMBER_STATUS_TAG_MAP,
...@@ -37,20 +40,40 @@ import { ...@@ -37,20 +40,40 @@ import {
} from '../constant'; } from '../constant';
const formActions = createFormActions(); const formActions = createFormActions();
const modalFormActions = createFormActions();
const {
onFieldValueChange$,
onFieldInputChange$,
onFormInputChange$,
onFormInit$,
} = FormEffectHooks;
const MemberQuery: React.FC<{}> = () => {
const ref = useRef<any>({});
const [modalVisible, setModalVisible] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false);
const fetchData = async (params: any) => { const fetchData = async (params: any) => {
let res = await PublicApi.getMemberAbilityInfoPage(params); let res = await PublicApi.getMemberAbilityInfoPage(params);
return res.data; return res.data;
}; };
const MemberQuery: React.FC<[]> = () => {
const ref = useRef<any>({});
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<string>>([]);
const handleJumpUpdate = record => { const handleJumpUpdate = record => {
history.push(`/memberCenter/memberAbility/update?id=${record.memberId}&validateId=${record.validateId}`); history.push(`/memberCenter/memberAbility/update?id=${record.memberId}&validateId=${record.validateId}`);
}; };
// 再次申请
const handleReapply = record => {
PublicApi.postMemberAbilityInfoValidateRecommit({
memberId: record.memberId,
validateId: record.validateId,
}).then(res => {
if (res.code === 1000) {
ref.current.reload();
}
});
};
const defaultColumns: ColumnType<any>[] = [ const defaultColumns: ColumnType<any>[] = [
{ {
title: 'ID', title: 'ID',
...@@ -120,36 +143,45 @@ const MemberQuery: React.FC<[]> = () => { ...@@ -120,36 +143,45 @@ const MemberQuery: React.FC<[]> = () => {
dataIndex: 'option', dataIndex: 'option',
align: 'center', align: 'center',
render: (text, record) => ( render: (text, record) => (
<>
{/* 渠道会员, 且外部审核状态为不通过才可以 变更信息 */}
{
(
record.levelTypeEnum === MEMBER_LEVEL_TYPE_PLATFORM &&
record.outerStatus === MEMBER_OUTER_STATUS_FAILED
) && (
<Button <Button
type="link" type="link"
onClick={() => handleJumpUpdate(record)} onClick={() => handleJumpUpdate(record)}
> >
变更信息 变更信息
</Button> </Button>
)
}
{/* 商户会员、渠道会员 且外部审核状态为不通过才可以 再次申请 */}
{
(
(
record.levelTypeEnum === MEMBER_LEVEL_TYPE_MERCHANT ||
record.levelTypeEnum === MEMBER_LEVEL_TYPE_CHANNEL
) &&
record.outerStatus === MEMBER_OUTER_STATUS_FAILED
) && (
<Button
type="link"
onClick={() => handleReapply(record)}
>
再次申请
</Button>
)
}
</>
), ),
}, },
]; ];
const rowSelection = {
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectedRowKeys(selectedRowKeys);
},
selectedRowKeys: selectedRowKeys,
};
const [columns, setColumns] = useState<any[]>(defaultColumns); const [columns, setColumns] = useState<any[]>(defaultColumns);
// 更改会员状态
const handleModify = record => {
PublicApi.postMemberMaintenanceStatus({
memberId: record.memberId,
validateId: record.validateId,
status: record.status === 1 ? 0 : 1,
}).then(res => {
if (res.code === 1000) return ref.current.reload();
});
};
// 初始化高级筛选选项 // 初始化高级筛选选项
const fetchSelectOptions = async () => { const fetchSelectOptions = async () => {
const res = await PublicApi.getMemberAbilityInfoPageitems(); const res = await PublicApi.getMemberAbilityInfoPageitems();
...@@ -178,6 +210,84 @@ const MemberQuery: React.FC<[]> = () => { ...@@ -178,6 +210,84 @@ const MemberQuery: React.FC<[]> = () => {
return {}; return {};
}; };
const handleSubmit = values => {
history.push({
pathname: `/memberCenter/memberAbility/addSubRole`,
query: {
...values,
},
});
};
const getMembertype = () => {
return new Promise((resolve, reject) => {
PublicApi.getMemberAbilityInfoMembertypeList().then(res => {
if (res.code === 1000) {
const options = res.data.map(item => ({ label: item.memberTypeName, value: item.memberTypeId }))
resolve(options);
}
reject();
}).catch(() => {
reject();
});
});
};
const getRoleByMemberType = memberTypeId => {
return new Promise((resolve, reject) => {
PublicApi.getMemberAbilityInfoRoleList({
memberTypeId,
}).then(res => {
if (res.code === 1000) {
const { roles = [], checkIds = [] } = res.data;
const options = roles.map(item => (
{
label: item.roleName,
value: item.roleId,
disabled: checkIds.find(id => id === item.roleId),
}
));
resolve(options);
}
reject();
}).catch(() => {
reject();
});
});
};
const useAsyncDataSource = (name, service) => {
const { dispatch, setFieldState } = createFormActions();
const linkage = useLinkageUtils();
onFormInit$().subscribe(() => {
setFieldState(name, state => {
FormPath.setIn(state, 'props.x-props.hasFeedback', true)
})
linkage.loading(name)
service().then(res => {
linkage.loaded(name)
linkage.enum(name, res)
// 请求结束可以dispatch一个自定义事件收尾,方便后续针对该事件做联动
dispatch('requestAsyncDataSource', {
name,
payload: res
})
})
})
}
const controllerBtns = (
<Space>
<Button
type="primary"
onClick={() => setModalVisible(true)}
>
<PlusOutlined />
增加会员角色
</Button>
</Space>
);
return ( return (
<Card> <Card>
<StandardTable <StandardTable
...@@ -187,10 +297,12 @@ const MemberQuery: React.FC<[]> = () => { ...@@ -187,10 +297,12 @@ const MemberQuery: React.FC<[]> = () => {
columns={columns} columns={columns}
currentRef={ref} currentRef={ref}
fetchTableData={(params: any) => fetchData(params)} fetchTableData={(params: any) => fetchData(params)}
rowSelection={rowSelection}
controlRender={ controlRender={
<NiceForm <NiceForm
actions={formActions} actions={formActions}
expressionScope={{
controllerBtns,
}}
onSubmit={values => ref.current.reload(values)} onSubmit={values => ref.current.reload(values)}
effects={($, actions) => { effects={($, actions) => {
useStateFilterSearchLinkageEffect( useStateFilterSearchLinkageEffect(
...@@ -208,6 +320,41 @@ const MemberQuery: React.FC<[]> = () => { ...@@ -208,6 +320,41 @@ const MemberQuery: React.FC<[]> = () => {
/> />
} }
/> />
<Modal
title="新增会员角色"
visible={modalVisible}
confirmLoading={confirmLoading}
onOk={() => modalFormActions.submit()}
onCancel={() => setModalVisible(false)}
destroyOnClose
>
<NiceForm
effects={($, { setFieldState }) => {
const linkage = useLinkageUtils();
onFieldValueChange$('agree').subscribe(fieldState => {
setFieldState('reason', state => {
state.visible = !fieldState.value;
});
});
useAsyncDataSource('memberTypeId', getMembertype);
onFieldInputChange$('memberTypeId').subscribe(fieldState => {
linkage.loading('roleId');
getRoleByMemberType(fieldState.value)
.then(res => {
linkage.enum('roleId', res);
})
.finally(() => {
linkage.loaded('roleId');
});
});
}}
actions={modalFormActions}
schema={addRoleSchema}
onSubmit={handleSubmit}
/>
</Modal>
</Card> </Card>
); );
}; };
......
...@@ -9,12 +9,27 @@ export const maintianSchema: ISchema = { ...@@ -9,12 +9,27 @@ export const maintianSchema: ISchema = {
type: 'object', type: 'object',
'x-component': 'mega-layout', 'x-component': 'mega-layout',
properties: { properties: {
topLayout: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
},
properties: {
ctl: {
type: 'object',
'x-component': 'Children',
'x-component-props': {
children: '{{controllerBtns}}',
},
},
name: { name: {
type: 'string', type: 'string',
'x-component': 'Search', 'x-component': 'Search',
'x-component-props': { 'x-component-props': {
placeholder: '搜索', placeholder: '搜索',
align: 'flex-left', },
},
}, },
}, },
[FORM_FILTER_PATH]: { [FORM_FILTER_PATH]: {
...@@ -70,6 +85,7 @@ const getXComponentProps = (type, item) => { ...@@ -70,6 +85,7 @@ const getXComponentProps = (type, item) => {
const MAP = { const MAP = {
'string': { 'string': {
placeholder: item.fieldRemark, placeholder: item.fieldRemark,
disabled: item.disabled,
}, },
'upload': { 'upload': {
listType: 'card', listType: 'card',
...@@ -77,6 +93,7 @@ const getXComponentProps = (type, item) => { ...@@ -77,6 +93,7 @@ const getXComponentProps = (type, item) => {
data: { fileType: UPLOAD_TYPE }, data: { fileType: UPLOAD_TYPE },
fileList: [], fileList: [],
onChange: file => console.log(file), onChange: file => console.log(file),
disabled: item.disabled,
}, },
}; };
return MAP[type]; return MAP[type];
...@@ -147,3 +164,49 @@ export const initDetailSchema = (props: any) => { ...@@ -147,3 +164,49 @@ export const initDetailSchema = (props: any) => {
const maintianDetailSchema: ISchema = detailSchema; const maintianDetailSchema: ISchema = detailSchema;
return maintianDetailSchema; return maintianDetailSchema;
}; };
export const addRoleSchema: ISchema = {
type: 'object',
properties: {
tip: {
type: 'object',
'x-component': 'Children',
'x-component-props': {
children: '您需要增加的会员角色是:',
},
},
MEGA_LAYOUT: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
},
properties: {
memberTypeId: {
type: 'string',
title: '会员类型',
'x-component': "Radio",
'x-rules': [
{
required: true,
message: '请选择会员类型',
},
],
enum: [],
},
roleId: {
type: 'string',
title: '会员角色',
'x-component': "Radio",
'x-rules': [
{
required: true,
message: '请选择会员角色',
},
],
enum: [],
},
},
},
},
};
...@@ -36,14 +36,13 @@ const MemberUpdate: React.FC<any> = props => { ...@@ -36,14 +36,13 @@ const MemberUpdate: React.FC<any> = props => {
validateId, validateId,
}); });
setInfoLoading(false);
if (infoRes.code !== 1000) { if (infoRes.code !== 1000) {
return; return;
} }
const { groups = [] } = infoRes.data; const { groups = [] } = infoRes.data;
setMemberItems(groups); setMemberItems(groups);
setInfoLoading(false);
} }
}; };
...@@ -52,24 +51,9 @@ const MemberUpdate: React.FC<any> = props => { ...@@ -52,24 +51,9 @@ const MemberUpdate: React.FC<any> = props => {
}, []); }, []);
const handleSubmit = (values: any) => { const handleSubmit = (values: any) => {
const { if (!id || !validateId) {
memberTypeId, return;
roleId, }
levelId,
countryCodeId,
phone,
email,
channelLevel,
channelTypeId,
areas,
remark,
outerStatus,
status,
statusName,
...rest
} = values;
setSubmitLoading(true); setSubmitLoading(true);
const msg = message.loading({ const msg = message.loading({
content: '正在保存,请稍候...', content: '正在保存,请稍候...',
...@@ -93,25 +77,6 @@ const MemberUpdate: React.FC<any> = props => { ...@@ -93,25 +77,6 @@ const MemberUpdate: React.FC<any> = props => {
}); });
}; };
const useAsyncLinkageEffect = () => {
const linkage = useLinkageUtils();
// 根据会员角色,查询其他注册资料
onFieldValueChange$('roleId').subscribe(fieldState => {
if (!fieldState.value) {
return;
}
PublicApi.getMemberAbilitySubPageitemsDetail({
roleId: fieldState.value,
}).then(res => {
if (res.code === 1000) {
const { data = [] } = res;
setMemberItems(data);
}
});
});
}
return ( return (
<Spin spinning={infoLoading}> <Spin spinning={infoLoading}>
<PageHeaderWrapper <PageHeaderWrapper
......
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