Commit 8562b489 authored by XieZhiXiong's avatar XieZhiXiong

chore: 修改 修改会员信息 相关

parent 61ba864a
import { ISchema } from '@formily/antd';
import { PATTERN_MAPS } from '@/constants/regExp';
import { createMemberSchema, GroupItem } from '../../../../utils';
type FieldType = 'string' | 'long' | 'upload' | 'radio' | 'select' | 'checkbox';
// 字段校验规则枚举:0-无校验规则,1-邮箱规则,2-手机号码规则,3-身份证规则,4-电话号码规则
const RULE_REG_MAP = {
1: PATTERN_MAPS.email,
2: PATTERN_MAPS.phone,
3: PATTERN_MAPS.identity,
4: PATTERN_MAPS.tel,
};
const getFieldType = (field) => {
// 默认是 输入框
let description: { [key: string]: any } = {
type: 'string',
required: field.fieldEmpty === 0,
title: field.fieldLocalName,
default: field.fieldValue,
'x-component-props': {
placeholder: field.fieldRemark,
disabled: field.disabled,
},
};
// 公共的属性
const common = {
type: 'string',
required: field.fieldEmpty === 0,
title: field.fieldLocalName,
default: field.fieldValue,
'x-rules': [
(
field.ruleEnum
? {
pattern: RULE_REG_MAP[field.ruleEnum],
message: field.msg,
}
: null
),
(
field.pattern
? {
pattern: field.pattern,
message: field.msg,
}
: null
),
].filter(Boolean),
};
switch (field.fieldType as FieldType) {
case 'upload': {
description = {
'x-component': 'CustomUpload',
'x-component-props': {
showDesc: false,
disabled: field.disabled,
},
};
break;
}
case 'radio': {
description = {
'x-component': 'RadioGroup',
enum: field.fieldEnum,
'x-component-props': {
showDesc: false,
disabled: field.disabled,
},
};
break;
}
case 'select': {
description = {
enum: field.fieldEnum,
};
break;
}
case 'checkbox': {
description = {
'x-component': 'CheckboxGroup',
enum: field.fieldEnum,
};
break;
}
default:
break;
}
return Object.assign({}, description, common);
};
const getComponentValue = (elements: any) => {
const components = {};
for (let item of elements) {
components[item.fieldName] = getFieldType(item);
}
return components;
};
export const initDetailSchema = (props: any) => {
export const initDetailSchema = (props: GroupItem[]) => {
let tabSchema: ISchema = {
properties: {
'tab-1': {
......@@ -316,7 +219,7 @@ export const initDetailSchema = (props: any) => {
wrapperCol: 8,
labelAlign: 'left',
},
properties: getComponentValue(item.elements),
properties: createMemberSchema(item.elements),
},
},
};
......
......@@ -6,7 +6,7 @@ const EditMySelf: React.FC = () => {
const { id, validateId } = usePageStatus();
return (
<MemberForm id={+id} validateId={+validateId} isEdit={true} mode={"myself"} />
<MemberForm id={+id} validateId={+validateId} isEdit={true} mode="myself" />
);
};
......
......@@ -70,6 +70,17 @@ export type ElementType = {
editable?: boolean,
}
export type GroupItem = {
/**
* 组名
*/
groupName: string,
/**
* 元素
*/
elements: ElementType[],
}
export function coverColFiltersItem(
data: Array<{[key: string]: any}>,
dataIndex: string,
......@@ -100,7 +111,7 @@ const getFieldType = (field: ElementType) => {
let description: { [key: string]: any } = {
'x-component-props': {
placeholder: field.fieldRemark,
disabled: field.disabled || !field.editable || false,
disabled: field.disabled || !field.editable,
},
};
// 公共的属性
......@@ -135,7 +146,7 @@ const getFieldType = (field: ElementType) => {
'x-component': 'CustomUpload',
'x-component-props': {
showDesc: false,
disabled: field.disabled || !field.editable || false,
disabled: field.disabled || !!field.editable,
},
};
break;
......@@ -146,7 +157,7 @@ const getFieldType = (field: ElementType) => {
enum: field.fieldEnum,
'x-component-props': {
showDesc: false,
disabled: field.disabled || !field.editable || false,
disabled: field.disabled || !!field.editable,
},
};
break;
......
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