import { ValidationSetter, RsFunButtonSetter } from '../_setters'; import { ValidationType, DEFAULT_EDITABLE_FUN } from '@/constants'; /** * 文本框校验属性 */ export default [ { name: 'editableExpression', title: { label: { type: 'i18n', zh_CN: '可编辑条件', en_US: 'Editable Expression', }, tip: { type: 'i18n', zh_CN: 'editableExpression: 可编辑条件函数 || 可编辑条件,支持函数表达式,返回值为 true 时可编辑', en_US: 'prop: editableExpression', }, }, setter: { componentName: RsFunButtonSetter, props: { defaultValue: DEFAULT_EDITABLE_FUN, header: '可编辑条件函数', }, }, }, { name: 'required', title: { label: { type: 'i18n', zh_CN: '必填', en_US: 'Required' }, }, setter: { componentName: ValidationSetter, }, extraProps: { getValue: (target: any, value: any) => { const columnProps = target.parent.parent; // 获取当前选中的字段 const currentField = (columnProps as any).extraProps?.defaultValue?.dataIndex || ''; target.extraProps.currentField = currentField; return value; }, }, }, { name: 'maxLength', title: { label: { type: 'i18n', zh_CN: '最大长度', en_US: 'Max Length' }, }, setter: { componentName: ValidationSetter, props: { type: ValidationType.MAX_LENGTH, }, }, }, { name: 'regex', title: { label: { type: 'i18n', zh_CN: '正则表达式', en_US: 'Regex' }, }, setter: { componentName: ValidationSetter, props: { type: ValidationType.REGEX, }, }, }, { name: 'customFunction', title: { label: { type: 'i18n', zh_CN: '自定义函数', en_US: 'Custom Function' }, tip: { type: 'i18n', zh_CN: 'customFunction | 自定义函数', en_US: 'customFunction | Custom Function', }, }, propType: 'func', setter: { componentName: ValidationSetter, props: { type: ValidationType.CUSTOM_FUNCTION, }, }, }, ];