import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import * as CustomerApi from '@/api/wms/customer' import { Customer } from '../customer/customer.data' const { t } = useI18n() // 国际化 import {validateYS} from '@/utils/validator' /** * @returns {Array} 项目 */ export const Project = useCrudSchemas(reactive([ { label: '代码', field: 'code', sort: 'custom', table: { fixed: 'left' }, isSearch: true, }, { label: '名称', field: 'name', sort: 'custom', isSearch: true, }, { label: '客户代码', field: 'customerCode', sort: 'custom', isSearch: true, form: { // labelMessage: '信息提示说明!!!', componentProps: { enterSearch:true, isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择客户代码', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '客户信息', // 查询弹窗标题 searchAllSchemas: Customer.allSchemas, // 查询弹窗所需类 searchPage: CustomerApi.getCustomerPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] } }, }, { label: '是否可用', field: 'available', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, isSearch: true, sort: 'custom', 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', 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: 'remark', sort: 'custom', table: { width: 150 }, }, { label: '创建时间', field: 'createTime', isForm: false, table: { width: 180 }, formatter: dateFormatter, detail: { dateFormat : 'YYYY-MM-DD HH:mm:ss' }, form: { component: 'DatePicker', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '创建者', field: 'creator', table: { width: 130 }, isForm: false, isTable: true }, { label: '最后更新时间', field: 'updateTime', sort: 'custom', isDetail: true, isForm: false, isTable: false, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '最后更新者', field: 'updater', isDetail: true, isForm: false, isTable: false, table: { width: 150 } }, { label: '操作', field: 'action', isDetail: false, isForm: false , table: { width: 150, fixed: 'right' } } ])) //表单校验 export const ProjectRules = reactive({ code: [ { required: true, message: '请输入代码', trigger: 'blur' }, { max: 50, message: '不得超过50个字符', trigger: 'blur' }, { validate: validateYS, message: '请输入正确的代码', trigger: 'blur' } ], name: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], customerCode: [ { required: true,message: '请输入客户代码', trigger: 'blur' } ], remark: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], available: [ { required: true, message: '请选择是否可用', trigger: 'change' } ], })