Commit eb6f99a4 authored by Bill's avatar Bill

Merge branch 'chore-v2' into 'v2'

chore: 合并会员分类抽屉组件 See merge request linkseeks-design/pro-platform!62
parents 6e6afb94 53cc8156
......@@ -13,17 +13,18 @@ import {
} from 'antd';
import NiceForm from '@/components/NiceForm';
import {
createFormActions,
createAsyncFormActions,
FormEffectHooks,
FormPath,
} from '@formily/antd';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { ArrayCards } from '@formily/antd-components';
import {
getMemberAbilityMaintenanceDetailRecordClassifyCategoryItems,
getMemberAbilityMaintenanceDetailRecordClassifyCity,
getMemberAbilityMaintenanceDetailRecordClassifyProvince,
getMemberDepositClassifyCategoryItems,
getMemberDepositClassifyCity,
getMemberDepositClassifyProvince,
} from '@/services/MemberV2Api';
import { getProductCustomerGetCustomerCategoryTree } from '@/services/ProductV2Api';
import {
......@@ -107,9 +108,17 @@ export type ValueType = {
* 主营品类列表
*/
categories: CategoriesType[],
/**
* 是否通过
*/
agree?: number,
/**
* 通过理由
*/
reason?: string,
}
export interface FormValueType extends Omit<ValueType, ('maxAmount' | 'categories')> {
export interface FormValueType extends Omit<ValueType, ('maxAmount' | 'categories' | 'agree' | 'reason')> {
/**
* 会员编码
*/
......@@ -184,11 +193,15 @@ interface IProps {
/**
* 值
*/
value: FormValueType,
value?: FormValueType,
/**
* 确认按钮 loading
*/
submitLoading: boolean,
/**
* 是否可审核的,默认 0
*/
isVerify?: 0 | 1,
}
const formActions = createAsyncFormActions();
......@@ -198,6 +211,27 @@ const {
onFieldInputChange$,
} = FormEffectHooks;
// 省级接口map
const PROVINCE_API_MAP = {
0: getMemberAbilityMaintenanceDetailRecordClassifyProvince,
1: getMemberDepositClassifyProvince,
};
// 会员品类接口map
const CATEGORY_TREE_API_MAP = {
0: getProductCustomerGetCustomerCategoryTree,
1: getProductCustomerGetCustomerCategoryTree,
};
// 结算类型、发票类型接口map
const ITEMS_API_MAP = {
0: getMemberAbilityMaintenanceDetailRecordClassifyCategoryItems,
1: getMemberDepositClassifyCategoryItems,
};
// 城市接口map
const CITY_API_MAP = {
0: getMemberAbilityMaintenanceDetailRecordClassifyCity,
1: getMemberDepositClassifyCity,
};
const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
const {
visible,
......@@ -206,6 +240,7 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
partnerTypes,
value,
submitLoading,
isVerify = 0,
} = props;
const categoryTreeRef = useRef<CategoryItemType[]>([]);
......@@ -291,7 +326,7 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
}
);
getMemberAbilityMaintenanceDetailRecordClassifyCity({
CITY_API_MAP[isVerify]({
provinceCode: fieldState.value,
}).then(res => {
if (res.code === 1000) {
......@@ -403,7 +438,7 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
onFormInit$().subscribe(() => {
// 请求省级数据
getMemberAbilityMaintenanceDetailRecordClassifyProvince().then(res => {
PROVINCE_API_MAP[isVerify]().then(res => {
if (res.code === 1000) {
const { data = [] } = res;
const options = data.map(item => ({ label: item.name, value: item.code }));
......@@ -416,10 +451,10 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
});
// 请求会员品类数据
getProductCustomerGetCustomerCategoryTree().then(res => {
CATEGORY_TREE_API_MAP[isVerify]().then(res => {
if (res.code === 1000) {
const { data = [] } = res;
categoryTreeRef.current = data as CategoryItemType[];
categoryTreeRef.current = data as unknown as CategoryItemType[];
formActions.setFieldState('categories.*.category', state => {
FormPath.setIn(state, 'props.x-component-props.options', data);
});
......@@ -429,7 +464,7 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
});
// 请求结算方式与发票类型数据
getMemberAbilityMaintenanceDetailRecordClassifyCategoryItems().then(res => {
ITEMS_API_MAP[isVerify]().then(res => {
if (res.code === 1000 && res.data) {
const { payTypes = [], invoiceTypes } = res.data;
formActions.setFieldState('categories.*.payType', state => {
......@@ -448,6 +483,22 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
}).catch((err) => {
console.warn(err);
});
if (isVerify === 0) {
setFieldState('VERIFY_APPLY', (state) => {
state.visible = false;
});
}
});
onFieldValueChange$('agree').subscribe(fieldState => {
setFieldState('reason', state => {
state.title = fieldState.value === 0 ? intl.formatMessage({ id: 'member.management.common.form.reason.noPass' }) : intl.formatMessage({ id: 'member.management.common.form.reason.pass' });
state.required = fieldState.value === 0;
setTimeout(() => {
formActions.validate('reason');
}, 0);
});
});
}}
actions={formActions}
......
......@@ -337,5 +337,55 @@ export const schema: ISchema = {
},
},
},
VERIFY_APPLY: {
type: 'object',
'x-component': 'FlagBox',
'x-component-props': {
title: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.verify' }),
},
properties: {
MEGA_LAYOUT: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
labelCol: 4,
wrapperCol: 18,
labelAlign: 'left',
},
properties: {
agree: {
type: 'string',
title: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.verify.agree' }),
default: 1,
'x-component': 'Radio',
required: true,
enum: [
{ label: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.verify.agree.pass' }), value: 1 },
{ label: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.verify.agree.noPass' }), value: 0 },
],
'x-component-props': {},
},
reason: {
type: 'string',
title: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.verify.reason' }),
'x-component': 'Textarea',
'x-component-props': {
placeholder: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.verify.placeholder' }),
rows: 5,
},
'x-rules': [
{
required: true,
},
{
limitByte: true, // 自定义校验规则
maxByte: 120,
}
],
},
},
},
},
},
},
};
\ No newline at end of file
@import '~antd/es/style/themes/default.less';
.description {
color: @text-color-secondary;
margin-bottom: @margin-md;
}
\ No newline at end of file
......@@ -13,9 +13,9 @@ import {
import { history, useIntl } from 'umi';
import { usePageStatus } from '@/hooks/usePageStatus';
import { postMemberDepositClassify, getMemberDepositClassifyDetail } from '@/services/MemberV2Api';
import ModifyClassifyDrawer, { ValueType } from '../components/ModifyClassifyDrawer';
import fetchDetailHoc from '../common/hoc/fetchDetailHoc';
import MemberProfile from '../components/MemberProfile';
import ComingClassifyDrawer, { ValueType } from './components/ComingClassifyDrawer';
const MemberPrComingClassifyVerify: React.FC<{}> = () => {
const { validateId } = usePageStatus();
......@@ -72,7 +72,7 @@ const MemberPrComingClassifyVerify: React.FC<{}> = () => {
{intl.formatMessage({ id: 'member.actions.apply.verify' })}
</Button>
<ComingClassifyDrawer
<ModifyClassifyDrawer
visible={visibleVerifyDrawer}
partnerTypes={(
info
......@@ -83,6 +83,7 @@ const MemberPrComingClassifyVerify: React.FC<{}> = () => {
onClose={() => handleVisibleVerifyDrawer(false)}
submitLoading={submitLoading}
onSubmit={handleSubmit}
isVerify={1}
/>
</>
)}
......
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