import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import { TableColumn } from '@/types/table' import * as WorkshopApi from '@/api/wms/workshop' import { Workshop } from '@/views/wms/basicDataManage/factoryModeling/workshop/workshop.data' import { validateHanset, validateNum } from '@/utils/validator' import { EquipmentSupplier } from '@/views/eam/equipmentSupplier/equipmentSupplier.data' import * as EquipmentSupplierApi from '@/api/eam/equipmentSupplier' import { EquipmentManufacturer } from '@/views/eam/equipmentManufacturer/equipmentManufacturer.data' import * as EquipmentManufacturerApi from '@/api/eam/equipmentManufacturer' import * as ConfigApi from '@/api/infra/config' const workshopNoPage = await WorkshopApi.getWorkshopNoPage({}) const equipmentManufacturerNoPage = await EquipmentManufacturerApi.getEquipmentManufacturerNoPage({}) const equipmentSupplierNoPage = await EquipmentSupplierApi.getEquipmentSupplierNoPage({}) const autoCodeSwitch = await ConfigApi.getConfigKey('deviceCodeAutoSwitch') const autoSwitch = ref(false) if (autoCodeSwitch == 'TRUE') { autoSwitch.value = true } // 表单校验 export const EquipmentAccountsRules = reactive({ code: [required], name: [required], concurrencyStamp: [required], principalTelephone: [ { validator:validateHanset, message: '输入电话格式不正确', trigger: 'blur'} ], power: [ { validator:validateNum, message: '输入功率格式不正确', trigger: 'blur'} ], }) export const EquipmentAccounts = useCrudSchemas(reactive([ { label: '设备编号', field: 'code', sort: 'custom', isForm: !autoSwitch.value, isSearch: true, fixed: 'left' }, { label: '名称', field: 'name', sort: 'custom', isSearch: true }, { label: '设备型号', field: 'specification', sort: 'custom', isSearch: false }, { label: '设备类型', field: 'type', sort: 'custom', dictType: DICT_TYPE.DEVICE_CLASS, dictClass: 'string', // 默认都是字符串类型其他暂不考虑 isSearch: true, form: { component: 'Select' } }, { label: '功率(kw)', field: 'power', sort: 'custom', isSearch: false }, { label: '产权', field: 'equity', sort: 'custom', isSearch: false }, { label: '电机', field: 'electricMachine', sort: 'custom', isSearch: false }, { label: '节拍', field: 'beat', sort: 'custom', isSearch: false }, { label: '存放位置', field: 'storageLocation', sort: 'custom', isSearch: false }, { label: '使用部门', field: 'useDept', sort: 'custom', isSearch: false }, { label: '负责人', field: 'principal', sort: 'custom', isSearch: false }, { label: '负责人联系方式', field: 'principalTelephone', sort: 'custom', isSearch: false, }, { label: '设备状态', field: 'status', sort: 'custom', isSearch: true, dictType: DICT_TYPE.DEVICE_STATUS, dictClass: 'string', // 默认都是字符串类型其他暂不考虑 form: { component: 'Select' } }, { label: '启用日期', field: 'startDate', sort: 'custom', formatter: dateFormatter, isSearch: false, search: { component: 'DatePicker', componentProps: { valueFormat: 'YYYY-MM-DD HH:mm:ss', type: 'daterange', defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] } }, form: { component: 'DatePicker', componentProps: { type: 'datetime', valueFormat: 'x' } } }, { label: '供应商', field: 'supplierCode', sort: 'custom', isSearch: true, isDetail: false, isForm: false, isTable: true, isTableForm: false, search: { component: 'Select', componentProps: { options: equipmentSupplierNoPage, optionsAlias: { labelField: 'name', valueField: 'number' }, filterable: true, } }, formatter: (_: Recordable, __: TableColumn, cellValue: number) => { return equipmentSupplierNoPage.find((item) => item.number == cellValue)?.name }, }, { label: '供应商', field: 'supplierName', sort: 'custom', isSearch: false, form: { // labelMessage: '信息提示说明!!!', componentProps: { isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择供应商', // 输入框占位文本 searchField: 'number', // 查询弹窗赋值字段 searchTitle: '供应商信息', // 查询弹窗标题 searchAllSchemas: EquipmentSupplier.allSchemas, // 查询弹窗所需类 searchPage: EquipmentSupplierApi.getEquipmentSupplierPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] } }, }, { label: '采购时间', field: 'purchaseTime', sort: 'custom', formatter: dateFormatter, isSearch: false, search: { component: 'DatePicker', componentProps: { valueFormat: 'YYYY-MM-DD HH:mm:ss', type: 'daterange', defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] } }, form: { component: 'DatePicker', componentProps: { type: 'datetime', valueFormat: 'x' } } }, { label: '采购部门', field: 'purchaseDept', sort: 'custom', isSearch: false }, { label: '采购人', field: 'purchaser', sort: 'custom', isSearch: false }, { label: '出厂日期', field: 'productionDate', sort: 'custom', formatter: dateFormatter, isSearch: false, search: { component: 'DatePicker', componentProps: { valueFormat: 'YYYY-MM-DD HH:mm:ss', type: 'daterange', defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] } }, form: { component: 'DatePicker', componentProps: { type: 'datetime', valueFormat: 'x' } } }, { label: '生产厂商', field: 'manufactureCode', sort: 'custom', isSearch: true, isDetail: false, isForm: false, isTable: true, isTableForm: false, search: { component: 'Select', componentProps: { options: equipmentManufacturerNoPage, optionsAlias: { labelField: 'name', valueField: 'number' } } }, formatter: (_: Recordable, __: TableColumn, cellValue: number) => { return equipmentManufacturerNoPage.find((item) => item.number == cellValue)?.name }, }, { label: '生产厂商', field: 'manufactureName', sort: 'custom', isSearch: false, form: { componentProps: { isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择厂商', // 输入框占位文本 searchField: 'number', // 查询弹窗赋值字段 searchTitle: '生产厂商', // 查询弹窗标题 searchAllSchemas: EquipmentManufacturer.allSchemas, // 查询弹窗所需类 searchPage: EquipmentManufacturerApi.getEquipmentManufacturerPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] } }, }, { label: '设备使用寿命', field: 'equipmentLife', sort: 'custom', isSearch: false }, { label: '验收日期', field: 'acceptanceDate', sort: 'custom', formatter: dateFormatter, isSearch: false, search: { component: 'DatePicker', componentProps: { valueFormat: 'YYYY-MM-DD HH:mm:ss', type: 'daterange', defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] } }, form: { component: 'DatePicker', componentProps: { type: 'datetime', valueFormat: 'x' } } }, { label: '价格', field: 'purchasePrice', sort: 'custom', isSearch: false }, { label: '车间编号', field: 'workshopCode', sort: 'custom', isSearch: true, isDetail: false, isForm: false, isTable: true, isTableForm: false, search: { component: 'Select', componentProps: { options: workshopNoPage, optionsAlias: { labelField: 'name', valueField: 'code' }, filterable: true, } }, formatter: (_: Recordable, __: TableColumn, cellValue: string) => { return workshopNoPage.find((item) => item.code == cellValue)?.name }, }, { label: '车间编号', field: 'workshopName', sort: 'custom', isTable: false, form: { // labelMessage: '信息提示说明!!!', componentProps: { isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择车间代码', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '车间信息', // 查询弹窗标题 searchAllSchemas: Workshop.allSchemas, // 查询弹窗所需类 searchPage: WorkshopApi.getWorkshopPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] } }, }, { label: '工段编号', field: 'workshopSectionCode', sort: 'custom', isSearch: false }, { label: '备注', field: 'remark', sort: 'custom', isSearch: true }, { label: '操作', field: 'action', isForm: false, table: { width: 150, fixed: 'right' } } ]))