Commit 5d35a57e authored by XieZhiXiong's avatar XieZhiXiong

chore: 添加校验是否元素真实有值

parent c3690119
......@@ -144,6 +144,24 @@ export type GroupItem = {
export type FieldType = 'string' | 'long' | 'upload' | 'radio' | 'select' | 'checkbox' | 'area' | string & {};
// 判断表单元素是否真的有值
const fieldHasValue = (fieldType: FieldType, value: any): boolean => {
switch (fieldType) {
case 'string':
case 'long':
case 'radio':
case 'select':
return !!value;
case 'upload':
case 'checkbox':
return value && value.length > 0;
case 'area':
return value && !!value.provinceCode;
default:
return true;
}
};
// 字段校验规则枚举:0-无校验规则,1-邮箱规则,2-手机号码规则,3-身份证规则,4-电话号码规则
const RULE_REG_MAP = {
1: PATTERN_MAPS.email,
......@@ -154,7 +172,7 @@ const RULE_REG_MAP = {
const getFieldType = (field: ElementType, editable: boolean = true) => {
const isDisabled = (!editable && field.fieldValue) || !!field.disabled;
const isDisabled = (!editable && fieldHasValue(field.fieldType as string, field.fieldValue)) || !!field.disabled;
// 默认是 输入框
let description: { [key: string]: any } = {
......
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