import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import { handleTreeToComponentOptions } from '@/utils/tree' import * as DeptApi from '@/api/system/dept' import * as UserApi from '@/api/system/user' import { EquipmentAccounts,EquipmentAccountsRules } from '../equipmentAccounts/equipmentAccounts.data' import * as EquipmentAccountsApi from '@/api/eam/equipmentAccounts' import * as ProductionlineApi from '@/api/wms/productionline' import { Productionline } from '@/views/wms/basicDataManage/factoryModeling/productionline/productionline.data' import * as WorkshopApi from '@/api/wms/workshop' import { Workshop } from '@/views/wms/basicDataManage/factoryModeling/workshop/workshop.data' import * as ProcessApi from '@/api/wms/process' import { Process } from '@/views/wms/basicDataManage/factoryModeling/process/process.data' import * as WorkStationApi from '@/api/wms/workstation' import { Workstation } from '@/views/wms/basicDataManage/factoryModeling/workstation/workstation.data' export interface User { id: number, nickname: string } const allDeptList = await DeptApi.getSimpleDeptList() const deptList = ref([]) // 树形结构 const userList = ref([]) userList.value = await UserApi.getSimpleUserList() // 加载部门树(默认格式) deptList.value = handleTreeToComponentOptions(await DeptApi.getSimpleDeptList()) // 表单校验 export const EquipmentSigningRules = reactive({ equipmentCode: [required], operationDate: [required], operationer: [required], operationDept: [required], supplierCode: [required], status: [required], storageLocation: [required], concurrencyStamp: [required], workshopCode: [required] }) export const EquipmentSigning = useCrudSchemas(reactive([ { label: '设备编码', field: 'equipmentCode', sort: 'custom', isSearch: true, form: { // labelMessage: '信息提示说明!!!', componentProps: { isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择设备', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '设备信息', // 查询弹窗标题 searchAllSchemas: EquipmentAccounts.allSchemas, // 查询弹窗所需类 searchPage: EquipmentAccountsApi.getEquipmentAccountsPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] } }, }, { label: '验收日期', field: 'operationDate', 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: 'operationDept', sort: 'custom', isSearch: true, formatter: (_: Recordable, __: TableColumn, cellValue: number) => { return allDeptList.find((item) => item.id == cellValue)?.name }, form: { component: 'TreeSelect', componentProps: { // 假设deptList是部门数据列表 data: deptList.value, disabled: false, placeholder: "请选择部门", filterable: true, multiple: false, } } }, { label: '验收人', field: 'operationer', sort: 'custom', isSearch: true, formatter: (_: Recordable, __: TableColumn, cellValue: number) => { return userList.value.find((item) => item.id == cellValue)?.nickname }, form: { component: 'Select', componentProps: { // 假设deptList是部门数据列表 options: userList.value, optionsAlias: { valueField: 'id', labelField: 'nickname' }, disabled: false, placeholder: "请先选择部门", filterable: true, multiple: false, } } }, { label: '验收人联系方式', field: 'telephone', sort: 'custom', isSearch: false }, { label: '供应商编号', field: 'supplierCode', sort: 'custom', isSearch: true, isForm: false }, { label: '供应商联系人', field: 'supplierPeople', sort: 'custom', isSearch: true, isForm: false }, { label: '供应商联系方式', field: 'supplierTelephone', sort: 'custom', isSearch: false, isForm: false, }, // { // label: '流程状态', // field: 'status', // sort: 'custom', // isSearch: true, // dictType: DICT_TYPE.JOB_STATUS, // dictClass: 'string', // 默认都是字符串类型其他暂不考虑 // form: { // component: 'Select' // } // }, // { // label: '审核人', // field: 'approver', // sort: 'custom', // isSearch: true, // form: { // component: 'InputNumber', // value: 0 // } // }, // { // label: '审核内容', // field: 'approveContent', // sort: 'custom', // isSearch: false, // form: { // component: 'Input', // componentProps: { // type: 'textarea', // valueHtml: '', // height: 200 // } // } // }, // { // label: '审核时间', // field: 'approveTime', // 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: 'autoExamine', // sort: 'custom', // dictType: DICT_TYPE.TRUE_FALSE, // dictClass: 'string', // 默认都是字符串类型其他暂不考虑 // isSearch: false, // form: { // component: 'Switch', // value: 'TRUE', // componentProps: { // inactiveValue: 'FALSE', // activeValue: 'TRUE' // } // } // }, // { // label: '自动通过', // field: 'autoAgree', // sort: 'custom', // dictType: DICT_TYPE.TRUE_FALSE, // dictClass: 'string', // 默认都是字符串类型其他暂不考虑 // isSearch: false, // form: { // component: 'Switch', // value: 'TRUE', // componentProps: { // inactiveValue: 'FALSE', // activeValue: 'TRUE' // } // } // }, // { // label: '直接生成记录', // field: 'directCreateRecord', // sort: 'custom', // dictType: DICT_TYPE.TRUE_FALSE, // dictClass: 'string', // 默认都是字符串类型其他暂不考虑 // isSearch: false, // form: { // component: 'Switch', // value: 'TRUE', // componentProps: { // inactiveValue: 'FALSE', // activeValue: 'TRUE' // } // } // }, { label: '存放位置描述', field: 'storageLocation', sort: 'custom', isSearch: false, form: { component: 'Input', componentProps: { type: 'textarea', placeholder: '请输入存放位置描述' } } }, // { // label: '所属厂区编号', // field: 'factoryAreaCode', // sort: 'custom', // isSearch: false // }, { label: '车间编号', field: 'workshopCode', sort: 'custom', isSearch: true, form: { // labelMessage: '信息提示说明!!!', componentProps: { isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择车间代码', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '车间信息', // 查询弹窗标题 searchAllSchemas: Workshop.allSchemas, // 查询弹窗所需类 searchPage: WorkshopApi.getWorkshopPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] } }, }, { label: '产线编号', field: 'lineCode', sort: 'custom', isSearch: true, form: { // labelMessage: '信息提示说明!!!', componentProps: { isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择生产线代码', // 输入框占位文本 multiple:true, searchField: 'code', // 查询弹窗赋值字段 searchTitle: '生产线信息', // 查询弹窗标题 searchAllSchemas: Productionline.allSchemas, // 查询弹窗所需类 searchPage: ProductionlineApi.getProductionlinePage, // 查询弹窗所需分页方法 searchCondition: [{ key:'workshopCode', value:'workshopCode', message: '请填写车间代码!', isMainValue: true },{ key: 'available', value: 'TRUE', isMainValue: false }] } } }, // { // label: '工序编号', // field: 'processCode', // sort: 'custom', // isSearch: true, // form:{ // componentProps: { // isSearchList: true, // searchListPlaceholder: '请选择工序代码', // searchField: 'code', // searchTitle: '工序信息', // searchAllSchemas: Process.allSchemas, // searchPage: ProcessApi.getProcessPage, // searchCondition: [{ // key:'productionLineCode', // value:'lineCode', // message: '请填写生产线代码!', // isMainValue: true // },{ // key:'workshopCode', // value:'workshopCode', // message: '请填写车间代码!', // isMainValue: true // },{ // key: 'available', // value: 'TRUE', // isMainValue: false // }] // } // }, // }, // { // label: '工位编号', // field: 'workstationCode', // sort: 'custom', // isSearch: true, // form:{ // componentProps: { // isSearchList: true, // 开启查询弹窗 // searchListPlaceholder: '请选择工位', // 输入框占位文本 // searchField: 'code', // 查询弹窗赋值字段 // searchTitle: '工位信息', // 查询弹窗标题 // searchAllSchemas: Workstation.allSchemas, // 查询弹窗所需类 // searchPage: WorkStationApi.getWorkstationPage, // 查询弹窗所需分页方法 // searchCondition: [{ // key:'productionLineCode', // value:'lineCode', // message: '请填写生产线代码!', // isMainValue: true // },{ // key:'workshopCode', // value:'workshopCode', // message: '请填写车间代码!', // isMainValue: true // },{ // key:'available', // value:'TRUE', // isMainValue: false // }] // } // }, // }, { label: '备注', field: 'remark', sort: 'custom', isSearch: false }, // { // label: '是否可用', // field: 'available', // sort: 'custom', // dictType: DICT_TYPE.TRUE_FALSE, // dictClass: 'string', // 默认都是字符串类型其他暂不考虑 // isSearch: true, // form: { // component: 'Switch', // value: 'TRUE', // componentProps: { // inactiveValue: 'FALSE', // activeValue: 'TRUE' // } // } // }, { label: '操作', field: 'action', isForm: false, table: { width: 150, fixed: 'right' } } ]))