UNPKG

@innoways/utils

Version:

drip-form通用方法

1,159 lines (1,157 loc) 34.6 kB
/* eslint-disable quotes */ export const unitedSchema = { validateTime: 'change', theme: 'antd', type: 'object', ui: { containerStyle: { padding: '0 16px', }, }, schema: [ { type: 'string', title: 'Display mode', fieldKey: 'viewMode', default: 'all', ui: { type: 'select', style: { width: '100%', }, options: [ { value: 'configured', label: 'Display only configured verification rules', }, { value: 'all', label: 'Display all', }, ], }, }, { type: 'object', title: 'General verification', fieldKey: 'common', ui: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { marginBottom: 5, padding: 0, }, }, schema: [ { type: 'boolean', title: 'Required?', fieldKey: 'required', ui: { type: 'switch', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, }, { type: 'number', fieldKey: 'minLength', title: 'Minimum Length', ui: { type: 'number', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, }, { type: 'number', fieldKey: 'maxLength', title: 'Maximum Length', ui: { type: 'number', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, }, { type: 'string', title: 'Regular expression without flags', fieldKey: 'pattern', ui: { type: 'text', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, }, { type: 'string', fieldKey: 'format', title: 'Common regular expressions', ui: { type: 'select', style: { width: '100%', }, allowClear: true, options: [ { value: 'color', label: 'color', }, { value: 'https', label: 'https', }, { value: 'jsonObject', label: 'jsonObject', }, { value: 'date', label: 'date', }, { value: 'time', label: 'time', }, { value: 'date-tiem', label: 'date-time', }, { value: 'duration', label: 'duration', }, { value: 'uri', label: 'uri', }, { value: 'uri-reference', label: 'uri-reference', }, { value: 'uri-template', label: 'uri-template', }, { value: 'url', label: 'url', }, { value: 'email', label: 'email', }, { value: 'hostname', label: 'hostname', }, { value: 'ipv4', label: 'ipv4', }, { value: 'ipv6', label: 'ipv6', }, { value: 'regex', label: 'regex', }, { value: 'uuid', label: 'uuid', }, { value: 'json-pointer', label: 'json-pointer', }, { value: 'relative-json-pointer', label: 'relative-json-pointer', }, { value: 'byte', label: 'byte', }, { value: 'int32', label: 'int32', }, { value: 'int64', label: 'int64', }, { value: 'float', label: 'float', }, { value: 'double', label: 'double', }, { value: 'password', label: 'password', }, { value: 'binary', label: 'binary', }, ], vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, }, { type: 'string', fieldKey: 'regexp', title: 'Regular expression with flags', ui: { description: { type: 'icon', trigger: 'hover', title: 'You can use regular symbols such as g, i, and u', }, type: 'text', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, }, { type: 'array', fieldKey: 'transform', title: 'Format', ui: { type: 'select', style: { width: '100%', }, mode: 'multiple', options: [ { value: 'trim', label: 'Remove leading and trailing spaces', }, { value: 'trimStart', label: 'Remove leading spaces', }, { value: 'trimEnd', label: 'Remove trailing spaces', }, { value: 'toLowerCase', label: 'Convert to lowercase', }, { value: 'trimUpperCase', label: 'Convert to uppercase', }, ], vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, }, ], }, { type: 'object', title: 'Business verification', fieldKey: 'business', ui: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { padding: 0, marginBottom: 5, }, }, schema: [ { type: 'object', fieldKey: 'rangeDelimiter', title: 'Delimiter Range', ui: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { padding: 0, marginBottom: 5, }, description: { type: 'icon', title: 'Use the character specified by delimiter to separate, minimum and maximum', }, vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, schema: [ { type: 'string', fieldKey: 'delimiter', title: 'Custom separator', ui: { type: 'text', }, }, { type: 'number', fieldKey: 'max', title: 'Maximum', ui: { type: 'number', }, }, { type: 'number', fieldKey: 'min', title: 'Minimum', ui: { type: 'number', }, }, ], }, { type: 'object', fieldKey: 'gbkLength', title: 'Length in Chinese and English', ui: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { padding: 0, marginBottom: 5, }, description: { type: 'icon', title: '2 characters for Chinese and 1 character for English', }, vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, schema: [ { type: 'number', fieldKey: 'max', title: 'Maximum', ui: { type: 'number', }, }, { type: 'number', fieldKey: 'min', title: 'Minimum', ui: { type: 'number', }, }, ], }, ], }, { type: 'object', title: 'Verification error copy configuration', fieldKey: 'errorMessage', ui: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { padding: 0, marginBottom: 5, }, }, schema: [ { type: 'string', title: 'Error backup copy', fieldKey: '_', ui: { type: 'text', description: { type: 'icon', trigger: 'hover', title: 'When the keyword is not configured with error copy, the copy will be displayed when an error occurs', }, }, }, { type: 'string', title: 'Required?', fieldKey: 'required', ui: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.required').data!=='number'){\n return !!props.get('common.required').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, { type: 'string', title: 'Minimum Length', fieldKey: 'minLength', ui: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.minLength').data!=='number'){\n return !!props.get('common.minLength').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, { type: 'string', title: 'Maximum Length', fieldKey: 'maxLength', ui: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.maxLength').data!=='number'){\n return !!props.get('common.maxLength').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, { type: 'string', title: 'Regular expression without flags', fieldKey: 'pattern', ui: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.pattern').data!=='number'){\n return !!props.get('common.pattern').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, { type: 'string', title: 'Common regular expressions', fieldKey: 'format', ui: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.format').data!=='number'){\n return !!props.get('common.format').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, { type: 'string', title: 'Regular expression with flags', fieldKey: 'regexp', ui: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.regexp').data!=='number'){\n return !!props.get('common.regexp').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, { type: 'string', title: 'Format', fieldKey: 'transform', ui: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.transform').data!=='number'){\n return !!props.get('common.transform').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, { type: 'string', title: 'Delimiter Range', fieldKey: 'rangeDelimiter', ui: { type: 'text', vcontrol: "try {\n if(typeof props.get('business.rangeDelimiter').data!=='number'){\n return !!props.get('business.rangeDelimiter').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, { type: 'string', title: 'Length in Chinese and English', fieldKey: 'gbkLength', ui: { type: 'text', vcontrol: "try {\n if(typeof props.get('business.gbkLength').data!=='number'){\n return !!props.get('business.gbkLength').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, ], }, ], } export const parsedSchema = { dataSchema: { validateTime: 'change', type: 'object', properties: { viewMode: { type: 'string', title: 'Display mode', default: 'all', }, common: { type: 'object', title: 'General verification', properties: { required: { type: 'boolean', title: 'Required?', }, minLength: { type: 'number', title: 'Minimum Length', }, maxLength: { type: 'number', title: 'Maximum Length', }, pattern: { type: 'string', title: 'Regular expression without flags', }, format: { type: 'string', title: 'Common regular expressions', }, regexp: { type: 'string', title: 'Regular expression with flags', }, transform: { type: 'array', title: 'Format', }, }, }, business: { type: 'object', title: 'Business verification', properties: { rangeDelimiter: { type: 'object', title: 'Delimiter Range', properties: { delimiter: { type: 'string', title: 'Custom separator', }, max: { type: 'number', title: 'Maximum', }, min: { type: 'number', title: 'Minimum', }, }, }, gbkLength: { type: 'object', title: 'Length in Chinese and English', properties: { max: { type: 'number', title: 'Maximum', }, min: { type: 'number', title: 'Minimum', }, }, }, }, }, errorMessage: { type: 'object', title: 'Verification error copy configuration', properties: { _: { type: 'string', title: 'Error backup copy', }, required: { type: 'string', title: 'Required?', }, minLength: { type: 'string', title: 'Minimum Length', }, maxLength: { type: 'string', title: 'Maximum Length', }, pattern: { type: 'string', title: 'Regular expression without flags', }, format: { type: 'string', title: 'Common regular expressions', }, regexp: { type: 'string', title: 'Regular expression with flags', }, transform: { type: 'string', title: 'Format', }, rangeDelimiter: { type: 'string', title: 'Delimiter Range', }, gbkLength: { type: 'string', title: 'Length in Chinese and English', }, }, }, }, }, uiSchema: { theme: 'antd', containerStyle: { padding: '0 16px', }, order: ['viewMode', 'common', 'business', 'errorMessage'], properties: { viewMode: { type: 'select', style: { width: '100%', }, options: [ { value: 'configured', label: 'Display only configured verification rules', }, { value: 'all', label: 'Display all', }, ], }, common: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { marginBottom: 5, padding: 0, }, order: [ 'required', 'minLength', 'maxLength', 'pattern', 'format', 'regexp', 'transform', ], properties: { required: { type: 'switch', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, minLength: { type: 'number', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, maxLength: { type: 'number', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, pattern: { type: 'text', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, format: { type: 'select', style: { width: '100%', }, allowClear: true, options: [ { value: 'color', label: 'color', }, { value: 'https', label: 'https', }, { value: 'jsonObject', label: 'jsonObject', }, { value: 'date', label: 'date', }, { value: 'time', label: 'time', }, { value: 'date-tiem', label: 'date-time', }, { value: 'duration', label: 'duration', }, { value: 'uri', label: 'uri', }, { value: 'uri-reference', label: 'uri-reference', }, { value: 'uri-template', label: 'uri-template', }, { value: 'url', label: 'url', }, { value: 'email', label: 'email', }, { value: 'hostname', label: 'hostname', }, { value: 'ipv4', label: 'ipv4', }, { value: 'ipv6', label: 'ipv6', }, { value: 'regex', label: 'regex', }, { value: 'uuid', label: 'uuid', }, { value: 'json-pointer', label: 'json-pointer', }, { value: 'relative-json-pointer', label: 'relative-json-pointer', }, { value: 'byte', label: 'byte', }, { value: 'int32', label: 'int32', }, { value: 'int64', label: 'int64', }, { value: 'float', label: 'float', }, { value: 'double', label: 'double', }, { value: 'password', label: 'password', }, { value: 'binary', label: 'binary', }, ], vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, regexp: { description: { type: 'icon', trigger: 'hover', title: 'You can use regular symbols such as g, i, and u', }, type: 'text', vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, transform: { type: 'select', style: { width: '100%', }, mode: 'multiple', options: [ { value: 'trim', label: 'Remove leading and trailing spaces', }, { value: 'trimStart', label: 'Remove leading spaces', }, { value: 'trimEnd', label: 'Remove trailing spaces', }, { value: 'toLowerCase', label: 'Convert to lowercase', }, { value: 'trimUpperCase', label: 'Convert to uppercase', }, ], vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', }, }, }, business: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { padding: 0, marginBottom: 5, }, order: ['rangeDelimiter', 'gbkLength'], properties: { rangeDelimiter: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { padding: 0, marginBottom: 5, }, description: { type: 'icon', title: 'Use the character specified by delimiter to separate, minimum and maximum', }, vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', order: ['delimiter', 'max', 'min'], properties: { delimiter: { type: 'text', }, max: { type: 'number', }, min: { type: 'number', }, }, }, gbkLength: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { padding: 0, marginBottom: 5, }, description: { type: 'icon', title: '2 characters for Chinese and 1 character for English', }, vcontrol: 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true', order: ['max', 'min'], properties: { max: { type: 'number', }, min: { type: 'number', }, }, }, }, }, errorMessage: { type: 'object', mode: 'collapse', '$:dripStyle': true, ghost: true, containerStyle: { padding: 0, marginBottom: 5, }, order: [ '_', 'required', 'minLength', 'maxLength', 'pattern', 'format', 'regexp', 'transform', 'rangeDelimiter', 'gbkLength', ], properties: { _: { type: 'text', description: { type: 'icon', trigger: 'hover', title: 'When the keyword is not configured with error copy, the copy will be displayed when an error occurs', }, }, required: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.required').data!=='number'){\n return !!props.get('common.required').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, minLength: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.minLength').data!=='number'){\n return !!props.get('common.minLength').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, maxLength: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.maxLength').data!=='number'){\n return !!props.get('common.maxLength').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, pattern: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.pattern').data!=='number'){\n return !!props.get('common.pattern').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, format: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.format').data!=='number'){\n return !!props.get('common.format').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, regexp: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.regexp').data!=='number'){\n return !!props.get('common.regexp').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, transform: { type: 'text', vcontrol: "try {\n if(typeof props.get('common.transform').data!=='number'){\n return !!props.get('common.transform').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, rangeDelimiter: { type: 'text', vcontrol: "try {\n if(typeof props.get('business.rangeDelimiter').data!=='number'){\n return !!props.get('business.rangeDelimiter').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, gbkLength: { type: 'text', vcontrol: "try {\n if(typeof props.get('business.gbkLength').data!=='number'){\n return !!props.get('business.gbkLength').data\n }else{\n return true\n }\n } catch (error) {\n return false\n }", }, }, }, }, }, typePath: { viewMode: { fatherKey: '', title: 'Display mode', unitedSchemaKey: 'schema.0', type: 'string', }, common: { fatherKey: '', title: 'General verification', unitedSchemaKey: 'schema.1', type: 'object', }, 'common.required': { fatherKey: 'common', title: 'Required?', unitedSchemaKey: 'schema.1.schema.0', type: 'boolean', }, 'common.minLength': { title: 'Minimum Length', fatherKey: 'common', unitedSchemaKey: 'schema.1.schema.1', type: 'number', }, 'common.maxLength': { fatherKey: 'common', title: 'Maximum Length', unitedSchemaKey: 'schema.1.schema.2', type: 'number', }, 'common.pattern': { fatherKey: 'common', unitedSchemaKey: 'schema.1.schema.3', title: 'Regular expression without flags', type: 'string', }, 'common.format': { fatherKey: 'common', title: 'Common regular expressions', unitedSchemaKey: 'schema.1.schema.4', type: 'string', }, 'common.regexp': { fatherKey: 'common', title: 'Regular expression with flags', unitedSchemaKey: 'schema.1.schema.5', type: 'string', }, 'common.transform': { title: 'Format', fatherKey: 'common', unitedSchemaKey: 'schema.1.schema.6', type: 'array', }, business: { fatherKey: '', title: 'Business verification', unitedSchemaKey: 'schema.2', type: 'object', }, 'business.rangeDelimiter': { title: 'Delimiter Range', fatherKey: 'business', unitedSchemaKey: 'schema.2.schema.0', type: 'object', }, 'business.rangeDelimiter.delimiter': { title: 'Custom separator', fatherKey: 'business.rangeDelimiter', unitedSchemaKey: 'schema.2.schema.0.schema.0', type: 'string', }, 'business.rangeDelimiter.max': { fatherKey: 'business.rangeDelimiter', title: 'Maximum', unitedSchemaKey: 'schema.2.schema.0.schema.1', type: 'number', }, 'business.rangeDelimiter.min': { fatherKey: 'business.rangeDelimiter', title: 'Minimum', unitedSchemaKey: 'schema.2.schema.0.schema.2', type: 'number', }, 'business.gbkLength': { title: 'Length in Chinese and English', fatherKey: 'business', unitedSchemaKey: 'schema.2.schema.1', type: 'object', }, 'business.gbkLength.max': { title: 'Maximum', fatherKey: 'business.gbkLength', unitedSchemaKey: 'schema.2.schema.1.schema.0', type: 'number', }, 'business.gbkLength.min': { title: 'Minimum', fatherKey: 'business.gbkLength', unitedSchemaKey: 'schema.2.schema.1.schema.1', type: 'number', }, errorMessage: { fatherKey: '', title: 'Verification error copy configuration', unitedSchemaKey: 'schema.3', type: 'object', }, 'errorMessage._': { fatherKey: 'errorMessage', title: 'Error backup copy', unitedSchemaKey: 'schema.3.schema.0', type: 'string', }, 'errorMessage.required': { fatherKey: 'errorMessage', title: 'Required?', unitedSchemaKey: 'schema.3.schema.1', type: 'string', }, 'errorMessage.minLength': { fatherKey: 'errorMessage', unitedSchemaKey: 'schema.3.schema.2', title: 'Minimum Length', type: 'string', }, 'errorMessage.maxLength': { title: 'Maximum Length', fatherKey: 'errorMessage', unitedSchemaKey: 'schema.3.schema.3', type: 'string', }, 'errorMessage.pattern': { fatherKey: 'errorMessage', title: 'Regular expression without flags', unitedSchemaKey: 'schema.3.schema.4', type: 'string', }, 'errorMessage.format': { fatherKey: 'errorMessage', unitedSchemaKey: 'schema.3.schema.5', title: 'Common regular expressions', type: 'string', }, 'errorMessage.regexp': { fatherKey: 'errorMessage', title: 'Regular expression with flags', unitedSchemaKey: 'schema.3.schema.6', type: 'string', }, 'errorMessage.transform': { fatherKey: 'errorMessage', title: 'Format', unitedSchemaKey: 'schema.3.schema.7', type: 'string', }, 'errorMessage.rangeDelimiter': { fatherKey: 'errorMessage', title: 'Delimiter Range', unitedSchemaKey: 'schema.3.schema.8', type: 'string', }, 'errorMessage.gbkLength': { fatherKey: 'errorMessage', unitedSchemaKey: 'schema.3.schema.9', title: 'Length in Chinese and English', type: 'string', }, }, customProps: [], }