import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' const { t } = useI18n() // 国际化 import {validateYS} from '@/utils/validator' /** * @returns {Array} 基础物料信息 */ export const Itembasic = useCrudSchemas(reactive([ { label: '代码', field: 'code', sort: 'custom', isSearch: true, table: { width: 180, fixed: 'left' }, }, { label: '名称', field: 'name', sort: 'custom', isSearch: true, table: { width: 150 }, }, { label: '是否可用', field: 'available', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, isSearch: true, table: { width: 120 }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, }, { label: '描述1', field: 'desc1', sort: 'custom', table: { width: 150 } , // isTableForm:false }, { label: '描述2', field: 'desc2', sort: 'custom', table: { width: 150 } , }, // { // label: '状态', // field: 'status', // sort: 'custom', // dictType: DICT_TYPE.ITEM_STATUS, // dictClass: 'string', // isForm: false, // isSearch: false, // isTable: false, // table: { // width: 100 // } , // form: { // component: 'Switch', // value: 'ENABLE', // componentProps: { // inactiveValue: 'DISABLE', // activeValue: 'ENABLE' // } // }, // }, { label: '计量单位', field: 'uom', sort: 'custom', dictType: DICT_TYPE.UOM, dictClass: 'string', isSearch: true, isTable: true, table: { width: 120 } }, { label: '替代计量单位', field: 'altUom', sort: 'custom', dictType: DICT_TYPE.UOM, dictClass: 'string', isTable: true, table: { width: 150 } , }, { label: '是否标包', field: 'isStdPack', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', // colorType: 'danger', isTable: true, table: { width: 120 }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, // tableForm:{ // width: 180, // type:'Radio', // } }, { label: '可采购', field: 'enableBuy', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, table: { width: 100 }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, }, { label: '可制造', field: 'enableMake', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, table: { width: 100 } , form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, }, { label: '可委外加工', field: 'enableOutsourcing', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, table: { width: 120 } , form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, }, { label: '回收件', field: 'isRecycled', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, table: { width: 100 }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, }, { label: '虚零件', field: 'isPhantom', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, table: { width: 100 } , form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, }, { label: '是否脱离ERP管理', field: 'isOutErp', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, table: { width: 100 }, form: { component: 'Switch', value: 'FALSE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, }, { label: 'ABC类', field: 'abcClass', sort: 'custom', dictType: DICT_TYPE.ABC_CLASS, dictClass: 'string', isTable: true, table: { width: 100 } , }, { label: '类型', field: 'type', sort: 'custom', dictType: DICT_TYPE.ITEM_TYPE, dictClass: 'string', isTable: true, table: { width: 100 } , }, { label: '产品类', field: 'prodCla', sort: 'custom', isForm:false, table: { width: 100 } , }, { label: '种类', field: 'category', sort: 'custom', dictType: DICT_TYPE.ITEM_CATEGORY, dictClass: 'string', isTable: true, table: { width: 100 } , }, { label: '分组', field: 'itemGroup', sort: 'custom', dictType: DICT_TYPE.ITEM_GROUP, dictClass: 'string', isTable: true, table: { width: 100 } , }, { label: '颜色', field: 'color', sort: 'custom', dictType: DICT_TYPE.ITEM_COLOR, dictClass: 'string', isTable: true, table: { width: 100 } , }, { label: '配置', field: 'configuration', sort: 'custom', dictType: DICT_TYPE.ITEM_CONFIGURATION, dictClass: 'string', isTable: true, table: { width: 100 } , }, { label: '结算方式', field: 'settlementType', dictType: DICT_TYPE.SETTLEMENT_TYPE, dictClass: 'string', sort: 'custom', isTable: true, table: { width: 120 } , }, { label: '项目', field: 'project', sort: 'custom', table: { width: 100 } , }, { label: '质量等级', field: 'eqLevel', sort: 'custom', dictType: DICT_TYPE.EQ_LEVEL, dictClass: 'string', isTable: true, table: { width: 120 } , }, { label: '有效天数', field: 'validityDays', sort: 'custom', table: { width: 120 }, form: { component: 'InputNumber', componentProps: { min: 0, precision: 0 } }, }, { label: '生效时间', field: 'activeTime', sort: 'custom', isTable: true, 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', } }, // tableForm:{ // width: 200, // type:'FormDateTime', // } }, { label: '失效时间', field: 'expireTime', sort: 'custom', isTable: true, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, table: { width: 180 } , form: { component: 'DatePicker', value:'activeTime', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } }, }, { label: '创建时间', field: 'createTime', sort: 'custom', isTable: true, formatter: dateFormatter, isForm: false, 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: 'creator', isForm: false, isTable: true }, { label: '最后更新时间', field: 'updateTime', sort: 'custom', isTable: false, isDetail: true, formatter: dateFormatter, isForm: false, 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 }, { label: '备注', field: 'remark', sort: 'custom', isTable: false}, { label: '操作', field: 'action', isDetail: false, isForm: false , table: { width: 150, fixed: 'right' }, } ])) // 表单校验 export const rules = reactive({ code: [ { required: true, message: '请输入代码', trigger: 'blur' }, { max: 30, message: '不得超过30个字符', trigger: 'blur' }, { validator:validateYS, message: '请输入正确的代码', trigger: 'blur'} ], name: [ { required: true, message: '请输入名称', trigger: 'blur' }, { max: 50, message: '不得超过50个字符', trigger: 'blur' }, ], // status: [ // { required: true, message: '请选择状态', trigger: 'change' }, // ], uom: [ { required: true, message: '请选择计量单位', trigger: 'change' }, ], altUom: [ { required: false, message: '请选择替代计量单位', trigger: 'change' }, ], isStdPack: [ { required: true, message: '请选择是否标包', trigger: 'change' }, ], enableBuy: [ { required: true, message: '请选择是否可采购', trigger: 'change' }, ], enableMake: [ { required: true, message: '请选择是否可制造', trigger: 'change' }, ], enableOutsourcing: [ { required: true, message: '请选择是否可委外加工', trigger: 'change' }, ], isRecycled: [ { required: true, message: '请选择回收件', trigger: 'change' }, ], isPhantom: [ { required: true, message: '请选择虚零件', trigger: 'change' }, ], abcClass: [ { required: true, message: '请选择ABC类', trigger: 'change' }, ], type: [ { required: true, message: '请选择类型', trigger: 'change' }, ], validityDays: [ { required: true, message: '请输入有效天数', trigger: 'change' }, ], available: [ { required: true, message: '请选择是否可用', trigger: 'change' }, ], }) console.log(Itembasic)