| | |
| | | export function fieldRules(required, max) { |
| | | export function fieldRules(required,isSelect = false, max = 50, ) { |
| | | const trigger = ['blur', 'change'] |
| | | return [ |
| | | required ? { required: true, message: max ? '请输入' : '请选择', trigger } : {}, |
| | | max ? { max, message: `长度不超过${max}`, trigger } : {}, |
| | | ] |
| | | const rules = [] |
| | | if (required) { |
| | | rules.push({ required: true, message: isSelect ? '请选择' : '请输入', trigger, }) |
| | | } |
| | | if (!isSelect) { |
| | | rules.push({ max, message: `长度不超过${max}`, trigger }) |
| | | } |
| | | return rules |
| | | } |
| | | |
| | | |
| | | export function getDictLabel(value, dictList) { |
| | | return dictList.find(item => item.dictKey === value)?.dictValue || value || '-' |
| | | } |