Commit 86aaebbd authored by XieZhiXiong's avatar XieZhiXiong

feat: 调整 会员信息查询 相关

parent e4ca589c
......@@ -444,72 +444,87 @@ const MemberRoute: RouterChild = {
},
// 会员信息查询
{
path: '/memberCenter/memberAbility/query',
name: 'memberQuery',
component: '@/pages/member/memberQuery/index',
},
// 会员信息查询-详情
{
path: '/memberCenter/memberAbility/query/detail',
name: 'memberQueryDetail',
component: '@/pages/member/memberQuery/detailed',
hideInMenu: true,
noMargin: true,
path: '/memberCenter/memberAbility/profile',
name: 'memberProfile',
routes: [
// 会员信息查询-详情-基本信息
// 会员信息查询
{
path: '/memberCenter/memberAbility/profile/query',
name: 'memberQuery',
component: '@/pages/member/memberQuery/index',
},
// 会员信息查询-详情
{
path: '/memberCenter/memberAbility/profile/query/detail',
name: 'memberQueryDetail',
component: '@/pages/member/memberQuery/detailed',
hideInMenu: true,
noMargin: true,
routes: [
// 会员信息查询-详情-基本信息
{
path: '/memberCenter/memberAbility/profile/query/detail/basicInfo',
name: 'basicInfo',
component: '@/pages/member/memberQuery/detailed/basicInfo',
hideInMenu: true,
},
// 会员信息查询-详情-等级信息
{
path: '/memberCenter/memberAbility/profile/query/detail/levelInfo',
name: 'levelInfo',
component: '@/pages/member/memberQuery/detailed/levelInfo',
hideInMenu: true,
},
// 会员信息查询-详情-权益信息
{
path: '/memberCenter/memberAbility/profile/query/detail/equityInfo',
name: 'equityInfo',
component: '@/pages/member/memberQuery/detailed/equityInfo',
hideInMenu: true,
},
// 会员信息查询-详情-诚信信息
{
path: '/memberCenter/memberAbility/profile/query/detail/sincerityInfo',
name: 'sincerityInfo',
component: '@/pages/member/memberQuery/detailed/sincerityInfo',
hideInMenu: true,
},
],
},
// 新增会员角色
{
path: '/memberCenter/memberAbility/query/detail/basicInfo',
name: 'basicInfo',
component: '@/pages/member/memberQuery/detailed/basicInfo',
path: '/memberCenter/memberAbility/profile/query/addSubRole',
name: 'addSubRole',
hideInMenu: true,
noMargin: true,
component: '@/pages/member/memberQuery/addSubRole',
},
// 会员信息查询-详情-等级信息
// 申请会员
{
path: '/memberCenter/memberAbility/query/detail/levelInfo',
name: 'levelInfo',
component: '@/pages/member/memberQuery/detailed/levelInfo',
path: '/memberCenter/memberAbility/profile/query/apply',
name: 'applyMember',
hideInMenu: true,
noMargin: true,
component: '@/pages/member/memberQuery/applyMember',
},
// 会员信息查询-详情-权益信息
// 会员信息变更
{
path: '/memberCenter/memberAbility/query/detail/equityInfo',
name: 'equityInfo',
component: '@/pages/member/memberQuery/detailed/equityInfo',
path: '/memberCenter/memberAbility/profile/query/modify',
name: 'modifyMember',
hideInMenu: true,
noMargin: true,
component: '@/pages/member/memberQuery/applyMember',
},
// 会员信息查询-详情-诚信信息
// 修改注册信息
{
path: '/memberCenter/memberAbility/query/detail/sincerityInfo',
name: 'sincerityInfo',
component: '@/pages/member/memberQuery/detailed/sincerityInfo',
path: '/memberCenter/memberAbility/profile/query/update',
name: 'memberUpdate',
hideInMenu: true,
noMargin: true,
component: '@/pages/member/memberQuery/updateMember',
},
],
},
// 会员信息变更
{
path: '/memberCenter/memberAbility/query/update',
name: 'memberUpdate',
hideInMenu: true,
noMargin: true,
component: '@/pages/member/memberQuery/update',
},
// 新增会员角色
{
path: '/memberCenter/memberAbility/query/addSubRole',
name: 'addSubRole',
hideInMenu: true,
noMargin: true,
component: '@/pages/member/memberQuery/addSubRole',
},
// 申请会员
{
path: '/memberCenter/memberAbility/query/apply',
name: 'applyMember',
hideInMenu: true,
noMargin: true,
component: '@/pages/member/memberQuery/applyMember',
},
// 会员考察
{
path: '/memberCenter/memberAbility/memberInspection',
......
......@@ -134,15 +134,16 @@ export default {
'menu.memberAbility.memberManage.maintainUnfreeze': '会员解除',
'menu.memberAbility.memberManage.maintainEliminate': '解除关系',
'menu.memberAbility.memberManage.maintainBlack': '加入黑名单',
'menu.memberAbility.memberQuery': '会员信息查询',
'menu.memberAbility.memberQueryDetail': '会员信息详情',
'menu.memberAbility.memberQueryDetail.basicInfo': '会员基本信息',
'menu.memberAbility.memberQueryDetail.levelInfo': '会员等级信息',
'menu.memberAbility.memberQueryDetail.equityInfo': '权益信息',
'menu.memberAbility.memberQueryDetail.sincerityInfo': '诚信信息',
'menu.memberAbility.memberUpdate': '变更会员信息',
'menu.memberAbility.addSubRole': '新建会员角色',
'menu.memberAbility.applyMember': '申请会员',
'menu.memberAbility.memberProfile.memberQuery': '会员信息查询',
'menu.memberAbility.memberProfile.memberQueryDetail': '会员信息详情',
'menu.memberAbility.memberProfile.memberQueryDetail.basicInfo': '会员基本信息',
'menu.memberAbility.memberProfile.memberQueryDetail.levelInfo': '会员等级信息',
'menu.memberAbility.memberProfile.memberQueryDetail.equityInfo': '权益信息',
'menu.memberAbility.memberProfile.memberQueryDetail.sincerityInfo': '诚信信息',
'menu.memberAbility.memberProfile.memberUpdate': '修改注册信息',
'menu.memberAbility.memberProfile.addSubRole': '新建会员角色',
'menu.memberAbility.memberProfile.modifyMember': '变更会员信息',
'menu.memberAbility.memberProfile.applyMember': '申请会员',
'menu.memberAbility.memberRuleConfiguration': '会员规则配置',
'menu.memberAbility.memberRuleConfiguration.memberLevel': '会员等级',
'menu.memberAbility.memberRuleConfiguration.memberLevelEdit': '会员权益设置',
......
......@@ -87,7 +87,7 @@ const TopBar: React.FC<TopBarPropsType> = (props) => {
</Link>
</div>
<div className={styles.nav_list_item}>
<Link to="/memberCenter/memberAbility/query">
<Link to="/memberCenter/memberAbility/profile/query">
<img src={memberInfoIcon} />
<span>会员信息</span>
</Link>
......@@ -99,7 +99,7 @@ const TopBar: React.FC<TopBarPropsType> = (props) => {
</Link>
</div>
<div className={styles.nav_list_item}>
<Link to="/memberCenter/memberAbility/query">
<Link to="/memberCenter/memberAbility/profile/query">
<img src={memberBenefitsIcon} />
<span>会员权益</span>
</Link>
......
/*
* @Author: XieZhiXiong
* @Date: 2021-01-06 11:36:35
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-04 15:53:07
* @Description: 新增会员角色
*/
import React, { useState, useEffect } from 'react';
import { history, Prompt } from 'umi';
import { Button, Card, Spin, message } from 'antd';
......@@ -8,8 +15,7 @@ import { usePageStatus } from '@/hooks/usePageStatus';
import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm';
import { PublicApi } from '@/services/api';
import { GetMemberAbilitySubGetResponse } from '@/services/MemberApi';
import { initDetailSchema } from './schema';
import { schema, GroupItem } from './schema/createRole';
const formActions = createFormActions();
const {
......@@ -18,8 +24,7 @@ const {
const AddSubRole: React.FC<any> = props => {
const { memberTypeId, roleId } = usePageStatus();
const [memberItems, setMemberItems] = useState<any>({});
const [memberInfo, setMemberInfo] = useState<GetMemberAbilitySubGetResponse>(null);
const [memberItems, setMemberItems] = useState<GroupItem[]>([]);
const [submitLoading, setSubmitLoading] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [unsaved, setUnsaved] = useState(false);
......@@ -97,15 +102,14 @@ const AddSubRole: React.FC<any> = props => {
<NiceForm
onSubmit={handleSubmit}
actions={formActions}
initialValues={memberInfo || {}}
effects={($, actions) => {
effects={() => {
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
schema={initDetailSchema(memberItems)}
schema={schema(memberItems)}
/>
</Card>
</PageHeaderWrapper>
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-01-06 11:36:35
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-05-26 16:07:15
* @LastEditTime: 2021-06-04 16:00:10
* @Description: 会员权益信息详情
*/
import React, { useEffect, useState } from 'react';
......@@ -15,14 +15,13 @@ import MemberRights from '../../components/MemberRights';
import MemberRightsRecords, { ReceivedData, UsageData } from '../../components/MemberRightsRecords';
const MemberRightsInfo: React.FC<{}> = () => {
const { id, validateId } = usePageStatus();
const { validateId } = usePageStatus();
const [equityInfo, setEquityInfo] = useState<GetMemberAbilityMaintenanceDetailRightBasicResponse>(null);
const [infoLoading, setInfoLoading] = useState(false);
const getEquityInfo = () => {
setInfoLoading(true);
PublicApi.getMemberAbilityInfoDetailRightBasic({
memberId: id,
validateId,
}).then(res => {
if (res.code !== 1000) {
......@@ -41,7 +40,6 @@ const MemberRightsInfo: React.FC<{}> = () => {
const getReceivedList = params => {
return new Promise<{ data: ReceivedData[] , totalCount: number }>((resolve, reject) => {
PublicApi.getMemberAbilityInfoDetailRightHistoryPage({
memberId: id,
validateId,
...params,
}).then(res => {
......@@ -56,7 +54,6 @@ const MemberRightsInfo: React.FC<{}> = () => {
const getUsageList = params => {
return new Promise<{ data: UsageData[] , totalCount: number }>((resolve, reject) => {
PublicApi.getMemberAbilityInfoDetailRightSpendHistoryPage({
memberId: id,
validateId,
...params,
}).then(res => {
......
......@@ -36,17 +36,16 @@ interface QueryProps {
const MemberQueryDetailed: React.FC<QueryProps> = props => {
const { MemberStore, children } = props;
const { id, validateId } = usePageStatus();
const { validateId } = usePageStatus();
const [memberInfo, setMemberInfo] = useState<GetMemberAbilityInfoDetailBasicResponse>(null);
const [infoLoading, setInfoLoading] = useState(false);
const getBasicInfo = () => {
if (!id || !validateId) {
if (!validateId) {
return;
}
setInfoLoading(true);
PublicApi.getMemberAbilityInfoDetailBasic({
memberId: id,
validateId,
}).then(res => {
if (res.code !== 1000) {
......@@ -61,7 +60,7 @@ const MemberQueryDetailed: React.FC<QueryProps> = props => {
useEffect(() => {
// 手动重定向到基础信息页,防止查询字符串被弄掉
history.replace(`/memberCenter/memberAbility/query/detail/basicInfo?id=${id}&validateId=${validateId}`);
history.replace(`/memberCenter/memberAbility/profile/query/detail/basicInfo?&validateId=${validateId}`);
getBasicInfo();
}, []);
......@@ -70,16 +69,16 @@ const MemberQueryDetailed: React.FC<QueryProps> = props => {
const url = match.url === '/' ? '' : match.url;
switch (val) {
case 'basicInfo':
history.push(`${url}/basicInfo?id=${id}&validateId=${validateId}`);
history.push(`${url}/basicInfo?&validateId=${validateId}`);
break;
case 'levelInfo':
history.push(`${url}/levelInfo?id=${id}&validateId=${validateId}`);
history.push(`${url}/levelInfo?&validateId=${validateId}`);
break;
case 'equityInfo':
history.push(`${url}/equityInfo?id=${id}&validateId=${validateId}`);
history.push(`${url}/equityInfo?&validateId=${validateId}`);
break;
case 'sincerityInfo':
history.push(`${url}/sincerityInfo?id=${id}&validateId=${validateId}`);
history.push(`${url}/sincerityInfo?&validateId=${validateId}`);
break;
default:
break;
......@@ -200,7 +199,7 @@ const MemberQueryDetailed: React.FC<QueryProps> = props => {
)}
/>
)}
onBack={() => history.push(`/memberCenter/memberAbility/manage/maintain`)}
onBack={() => history.push(`/memberCenter/memberAbility/profile/query`)}
anchors={getAnchorsArr()}
extra={(
<Bookmark value={getBookmarkKey()} onChange={handleBookmarkChange}>
......
......@@ -21,17 +21,16 @@ import MemberDocRectificationInfo from '../../components/MemberDocRectificationI
import MemberChangedInfo from '../../components/MemberChangedInfo';
const MemberLevelInfo: React.FC<{}> = () => {
const { id, validateId } = usePageStatus();
const { validateId } = usePageStatus();
const [levelInfo, setLevelInfo] = useState<GetMemberAbilityMaintenanceDetailLevelBasicResponse>(null);
const [infoLoading, setInfoLoading] = useState(false);
const getMemberLevelInfo = () => {
if (!id && !validateId) {
if (!validateId) {
return;
}
setInfoLoading(true);
PublicApi.getMemberAbilityInfoDetailLevelBasic({
memberId: id,
validateId,
}).then(res => {
if (res.code !== 1000) {
......@@ -51,7 +50,6 @@ const MemberLevelInfo: React.FC<{}> = () => {
const getActivePointRecords = params => {
return new Promise<{ data: ListItem[] , totalCount: number }>((resolve, reject) => {
PublicApi.getMemberAbilityInfoDetailLevelHistoryPage({
memberId: id,
validateId,
...params,
}).then(res => {
......
......@@ -29,7 +29,7 @@ export interface BasicInfo {
};
const MemberSincerityInfo: React.FC<{}> = () => {
const { id, validateId } = usePageStatus();
const { validateId } = usePageStatus();
const [basicInfo, setBasicInfo] = useState<BasicInfo>(null);
const [basicInfoLoading, setBasicInfoLoading] = useState(false);
const [orderEstimateSum, setOrderEstimateSum] = useState<EstimateSumItems[]>([]);
......@@ -47,7 +47,6 @@ const MemberSincerityInfo: React.FC<{}> = () => {
const getBasicInfo = () => {
setBasicInfoLoading(true);
PublicApi.getMemberAbilityInfoDetailCreditBasic({
memberId: id,
validateId,
}).then(res => {
if (res.code !== 1000) {
......@@ -91,7 +90,6 @@ const MemberSincerityInfo: React.FC<{}> = () => {
const getOrderEstimateSum = () => {
setOrderEstimateSumLoading(true);
PublicApi.getMemberAbilityInfoDetailCreditTradeSummary({
memberId: id,
validateId,
}).then(res => {
if (res.code !== 1000) {
......@@ -108,7 +106,6 @@ const MemberSincerityInfo: React.FC<{}> = () => {
const getAfterEstimateSum = () => {
setAfterServiceEstimateSumLoading(true);
PublicApi.getMemberAbilityInfoDetailCreditAftersaleSummary({
memberId: id,
validateId,
}).then(res => {
if (res.code !== 1000) {
......@@ -124,7 +121,6 @@ const MemberSincerityInfo: React.FC<{}> = () => {
// 反馈汇总
const getFeedbackSum = () => {
PublicApi.getMemberAbilityInfoDetailCreditComplainSummary({
memberId: id,
validateId,
}).then(res => {
if (res.code !== 1000) {
......@@ -145,7 +141,6 @@ const MemberSincerityInfo: React.FC<{}> = () => {
const getOrderEvaluationList = (params) => {
return new Promise<{ data: ListItem[] , totalCount: number }>((resolve, reject) => {
PublicApi.getMemberAbilityInfoDetailCreditTradeHistoryPage({
memberId: id,
validateId,
...params,
}).then(res => {
......@@ -161,7 +156,6 @@ const MemberSincerityInfo: React.FC<{}> = () => {
const getAfterServiceEvaluationList = (params) => {
return new Promise<{ data: ListItem[] , totalCount: number }>((resolve, reject) => {
PublicApi.getMemberAbilityInfoDetailCreditAftersaleHistoryPage({
memberId: id,
validateId,
...params,
}).then(res => {
......@@ -177,7 +171,6 @@ const MemberSincerityInfo: React.FC<{}> = () => {
const getFeedbackList = (params) => {
return new Promise<{ data: FeedbackItem[] , totalCount: number }>((resolve, reject) => {
PublicApi.getMemberAbilityInfoDetailCreditComplainHistoryPage({
memberId: id,
validateId,
...params,
}).then(res => {
......
......@@ -24,7 +24,8 @@ import {
MEMBER_LEVEL_TYPE_CHANNEL,
MEMBER_OUTER_STATUS_FAILED,
} from '@/constants/member';
import { maintianSchema } from './schema';
import useSpliceArray from '@/hooks/useSpliceArray';
import { querySchema } from './schema';
import { coverColFiltersItem } from '../utils';
import {
MEMBER_OUTER_STATUS_BADGE_COLOR,
......@@ -43,20 +44,14 @@ const MemberQuery: React.FC<{}> = () => {
return res.data;
};
const handleJumpUpdate = record => {
history.push(`/memberCenter/memberAbility/query/update?id=${record.memberId}&validateId=${record.validateId}`);
// 跳转修改会员信息页面
const handleJumpModify = record => {
history.push(`/memberCenter/memberAbility/profile/query/modify?&validateId=${record.validateId}`);
};
// 再次申请
const handleReapply = record => {
PublicApi.postMemberAbilityInfoValidateRecommit({
memberId: record.memberId,
validateId: record.validateId,
}).then(res => {
if (res.code === 1000) {
ref.current.reload();
}
});
// 跳转修改注册信息页面
const handleJumpUpdate = record => {
history.push(`/memberCenter/memberAbility/profile/query/update?&validateId=${record.validateId}`);
};
const defaultColumns: ColumnType<any>[] = [
......@@ -66,7 +61,7 @@ const MemberQuery: React.FC<{}> = () => {
align: 'center',
render: (text, record) => (
<EyePreview
url={`/memberCenter/memberAbility/query/detail?id=${record.memberId}&validateId=${record.validateId}`}
url={`/memberCenter/memberAbility/profile/query/detail?validateId=${record.validateId}`}
>
{text}
</EyePreview>
......@@ -100,7 +95,7 @@ const MemberQuery: React.FC<{}> = () => {
},
{
title: '入库时间',
dataIndex: 'comingTime',
dataIndex: 'depositTime',
align: 'center',
},
{
......@@ -120,45 +115,42 @@ const MemberQuery: React.FC<{}> = () => {
title: '操作',
dataIndex: 'option',
align: 'center',
render: (text, record) => (
render: (_, record) => (
<>
{/* 渠道会员, 且外部审核状态为不通过才可以 变更信息 */}
{
(
record.levelTypeEnum === MEMBER_LEVEL_TYPE_PLATFORM &&
record.outerStatus === MEMBER_OUTER_STATUS_FAILED
) && (
record.showModify && (
<Button
type="link"
onClick={() => handleJumpUpdate(record)}
onClick={() => handleJumpModify(record)}
>
变更信息
变更
</Button>
)
}
{/* 商户会员、渠道会员 且外部审核状态为不通过才可以 再次申请 */}
{
(
(
record.levelTypeEnum === MEMBER_LEVEL_TYPE_MERCHANT ||
record.levelTypeEnum === MEMBER_LEVEL_TYPE_CHANNEL
) &&
record.outerStatus === MEMBER_OUTER_STATUS_FAILED
) && (
record.showUpdate && (
<Button
type="link"
onClick={() => handleReapply(record)}
onClick={() => handleJumpUpdate(record)}
>
再次申请
修改
</Button>
)
}
<Button
type="link"
onClick={() => handleJumpUpdate(record)}
>
修改
</Button>
</>
),
},
];
const [columns, setColumns] = useState<any[]>(defaultColumns);
const [columns, columnsHandle] = useSpliceArray<ColumnType<any>>(defaultColumns);
// 初始化高级筛选选项
const fetchSelectOptions = async () => {
......@@ -170,16 +162,14 @@ const MemberQuery: React.FC<{}> = () => {
outerStatus = [],
} = data;
const newColumns = columns.slice();
// filter 0 过滤掉全部选项
coverColFiltersItem(
newColumns,
'outerStatusName',
outerStatus.map(item => ({ text: item.text, value: item.id })).filter(item => item.value !== 0),
);
setColumns(newColumns);
const outerIndex = columns.findIndex((item) => item.dataIndex === 'memberTypeName');
if (outerIndex) {
columnsHandle.replace(outerIndex, {
...columns[outerIndex],
filters: outerStatus.map(item => ({ text: item.text, value: item.id })).filter(item => item.value !== 0),
});
}
return {
outerStatus: outerStatus.map(item => ({ label: item.text, value: item.id })),
......@@ -190,14 +180,14 @@ const MemberQuery: React.FC<{}> = () => {
const handleSubmit = values => {
history.push({
pathname: `/memberCenter/memberAbility/query/addSubRole`,
pathname: `/memberCenter/memberAbility/profile/query/addSubRole`,
query: {
...values,
},
});
};
const controllerBtns = (
const ControllerBtns = () => (
<Space>
<Button
type="primary"
......@@ -221,8 +211,8 @@ const MemberQuery: React.FC<{}> = () => {
controlRender={
<NiceForm
actions={formActions}
expressionScope={{
controllerBtns,
components={{
ControllerBtns,
}}
onSubmit={values => ref.current.reload(values)}
effects={($, actions) => {
......@@ -237,7 +227,7 @@ const MemberQuery: React.FC<{}> = () => {
fetchSelectOptions,
);
}}
schema={maintianSchema}
schema={querySchema}
/>
}
/>
......
/*
* @Author: XieZhiXiong
* @Date: 2021-06-04 15:51:19
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-04 15:51:20
* @Description:
*/
import { ISchema } from '@formily/antd';
import { createMemberSchema, ElementType } from '../../utils';
export type GroupItem = {
/**
* 组名
*/
groupName: string,
/**
* 元素
*/
elements: ElementType[],
};
export const schema = (groups: GroupItem[]): ISchema => {
const tabSchema: ISchema = {
properties: {},
};
if (Array.isArray(groups)) {
for (let [index, item] of groups.entries()) {
tabSchema.properties[`tab-${index}`] = {
type: 'object',
'x-component': 'TabPane',
'x-component-props': {
tab: item.groupName,
},
properties: {
[`MEGA_LAYOUT${index}`]: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
labelCol: 4,
wrapperCol: 8,
labelAlign: 'left',
},
properties: createMemberSchema(item.elements),
},
},
};
}
}
return {
type: 'object',
properties: {
tabs: {
type: 'object',
'x-component': 'Tab',
'x-component-props': {
type: 'card',
},
...tabSchema,
},
},
};
};
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { UPLOAD_TYPE } from '@/constants'
export const maintianSchema: ISchema = {
export const querySchema: ISchema = {
type: 'object',
properties: {
megaLayout: {
......@@ -18,10 +17,7 @@ export const maintianSchema: ISchema = {
properties: {
ctl: {
type: 'object',
'x-component': 'Children',
'x-component-props': {
children: '{{controllerBtns}}',
},
'x-component': 'ControllerBtns',
},
name: {
type: 'string',
......
import React, { useState, useEffect, useRef } from 'react';
import { history, Prompt } from 'umi';
import { 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 { PublicApi } from '@/services/api';
import { GetMemberAbilitySubGetResponse } from '@/services/MemberApi';
import { initDetailSchema } from './schema';
const formActions = createFormActions();
const {
onFormInputChange$,
} = FormEffectHooks;
const MemberUpdate: React.FC<any> = props => {
const areaRef = useRef<any[]>([])
const { id, validateId } = 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 (id && validateId) {
setInfoLoading(true);
const infoRes = await PublicApi.getMemberAbilityInfoDetailUpdateGet({
memberId: id,
validateId,
});
setInfoLoading(false);
if (infoRes.code !== 1000) {
return;
}
const { groups = [] } = infoRes.data;
setMemberItems(groups);
}
};
useEffect(() => {
getDetailedInfo();
}, []);
const handleSubmit = (values: any) => {
if (!id || !validateId) {
return;
}
setSubmitLoading(true);
const msg = message.loading({
content: '正在保存,请稍候...',
duration: 0,
});
PublicApi.postMemberAbilityInfoDetailUpdate({
memberId: id,
validateId,
detail: values,
}).then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
msg();
setSubmitLoading(false);
});
};
return (
<Spin spinning={infoLoading}>
<PageHeaderWrapper
style={{
padding: 24,
}}
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>
);
};
/*
* @Author: XieZhiXiong
* @Date: 2021-06-04 15:37:19
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-04 15:54:38
* @Description: 修改会员注册信息
*/
import React, { useState, useEffect } from 'react';
import { history, Prompt } from 'umi';
import { 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 { PublicApi } from '@/services/api';
import { schema, GroupItem } from '../schema/createRole';
const formActions = createFormActions();
const {
onFormInputChange$,
} = FormEffectHooks;
const MemberUpdate: React.FC<any> = props => {
const { validateId } = usePageStatus();
const [memberItems, setMemberItems] = useState<GroupItem[]>([]);
const [submitLoading, setSubmitLoading] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [unsaved, setUnsaved] = useState(false);
const getDetailedInfo = async () => {
if (validateId) {
setInfoLoading(true);
const infoRes = await PublicApi.getMemberAbilityInfoDetail({
validateId,
});
setInfoLoading(false);
if (infoRes.code !== 1000) {
return;
}
const { groups = [] } = infoRes.data;
setMemberItems(groups);
}
};
useEffect(() => {
getDetailedInfo();
}, []);
const handleSubmit = (values: any) => {
if (!validateId) {
return;
}
setSubmitLoading(true);
const msg = message.loading({
content: '正在保存,请稍候...',
duration: 0,
});
PublicApi.postMemberAbilityInfoDetailUpdate({
validateId,
detail: values,
}).then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
msg();
setSubmitLoading(false);
});
};
return (
<Spin spinning={infoLoading}>
<PageHeaderWrapper
style={{
padding: 24,
}}
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}
effects={() => {
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
schema={schema(memberItems)}
/>
</Card>
</PageHeaderWrapper>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</Spin>
);
};
export default MemberUpdate;
\ No newline at end of file
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