import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' const { t } = useI18n() // 国际化 import {validateHanset,validateFax,validatePostCode} from '@/utils/validator' /** * @returns {Array} 货主 */ export const Owner = useCrudSchemas(reactive([ { label: '代码', field: 'code', sort: 'custom', table: { width: 150, fixed: 'left' }, isSearch: true }, { label: '名称', field: 'name', sort: 'custom', isSearch: true, table: { width: 150 }, }, { label: '简称', field: 'shortName', sort: 'custom', table: { width: 150 }, }, { label: '地址', field: 'address', sort: 'custom', table: { width: 150 }, }, { label: '国家', field: 'country', sort: 'custom', table: { width: 150 }, }, { label: '城市', field: 'city', sort: 'custom', table: { width: 150 }, }, { label: '电话', field: 'phone', sort: 'custom', table: { width: 150 }, }, { label: '传真', field: 'fax', sort: 'custom', table: { width: 150 }, }, { label: '邮编', field: 'postId', sort: 'custom', table: { width: 150 }, }, { label: '联系人', field: 'contacts', sort: 'custom', table: { width: 150 }, }, { label: '银行', field: 'bank', sort: 'custom', table: { width: 150 }, }, { label: '币种', field: 'currency', dictType: DICT_TYPE.CURRENCY, dictClass: 'string', isTable: true, sort: 'custom', table: { width: 150 }, }, { label: '税率', field: 'taxRate', form: { component: 'InputNumber', componentProps: { min: 0 } }, sort: 'custom', table: { width: 150 }, }, { label: '类型', field: 'type', dictType: DICT_TYPE.OWNER_TYPE, dictClass: 'string', isTable: true, sort: 'custom', table: { width: 150 }, }, { label: '是否可用', field: 'available', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, isSearch: true, sort: 'custom', table: { width: 150 }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, }, { label: '生效时间', field: 'activeTime', isTable: true, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, sort: 'custom', table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } }, }, { label: '失效时间', field: 'expireTime', formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, sort: 'custom', table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } }, }, { label: '备注', field: 'remark', sort: 'custom', table: { width: 150 }, }, { label: '创建时间', field: 'createTime', formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, sort: 'custom', table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } }, isForm: false, isTable: false, }, { label: '创建者', field: 'creator', sort: 'custom', table: { width: 150 }, isForm: false, isTable: false, }, { label: '操作', field: 'action', isDetail: false, isForm: false , table: { width: 150, fixed: 'right' } } ])) //表单校验 export const OwnerRules = reactive({ code: [ { required: true, message: '请输入代码', trigger: 'blur' }, { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], name: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], shortName: [ { required: true, message: '请输入简称', trigger: 'blur' }, { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], address: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], country: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], city: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], phone: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' }, { validator:validateHanset, message: '请输入正确的手机号', trigger: 'blur'} ], fax: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' }, { validator:validateFax, message: '请输入正确的传真', trigger: 'blur'} ], postId: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' }, { validator:validatePostCode, message: '请输入正确的邮编', trigger: 'blur'} ], contacts: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], bank: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], remark: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], available: [ { required: true, message: '请选择是否可用', trigger: 'change' } ], })