You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

705 lines
18 KiB

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'
1 year ago
import * as ProductionlineApi from '@/api/wms/productionline'
import { Productionline } from '@/views/wms/basicDataManage/factoryModeling/productionline/productionline.data'
import * as UserApi from '@/api/system/user'
import { handleTreeToComponentOptions } from '@/utils/tree'
import * as DeptApi from '@/api/system/dept'
import * as BasicEamWorkshopApi from '@/api/eam/basicEamWorkshop'
import { BasicEamWorkshop } from '@/views/eam/basicEamWorkshop/basicEamWorkshop.data'
1 year ago
export interface User {
id: number,
nickname: string
}
const workshopNoPage = await BasicEamWorkshopApi.getBasicEamWorkshopNoPage({})
const equipmentManufacturerNoPage = await EquipmentManufacturerApi.getEquipmentManufacturerNoPage({})
const equipmentSupplierNoPage = await EquipmentSupplierApi.getEquipmentSupplierNoPage({})
1 year ago
const productionlineNoPage = await ProductionlineApi.getProductionlineNoPage({});
const autoCodeSwitch = await ConfigApi.getConfigKey('deviceCodeAutoSwitch')
1 year ago
// ProductionlineApi.getProductionlinePage
const autoSwitch = ref(false)
if (autoCodeSwitch == 'TRUE') {
autoSwitch.value = true
}
const allDeptList = await DeptApi.getSimpleDeptList();
const deptList = ref<Tree[]>([]) // 树形结构
// 加载部门树(默认格式)
deptList.value = handleTreeToComponentOptions(allDeptList)
const userList = ref<User[]>([])
userList.value = await UserApi.getSimpleUserList()
// 表单校验
export const EquipmentAccountsRules = reactive({
code: [required],
name: [required],
concurrencyStamp: [required],
principalTelephone: [
{ validator:validateHanset, message: '输入电话格式不正确', trigger: 'blur'}
],
power: [
{ validator:validateNum, message: '输入功率格式不正确', trigger: 'blur'}
],
1 year ago
workshopName: [required]
})
export const EquipmentAccounts = useCrudSchemas(reactive<CrudSchema[]>([
{
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: 'factoryCode',
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',
isTable: false,
isDetail: false,
isSearch: false,
isTableForm: false,
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
return allDeptList.find((item) => item.id == cellValue)?.name
},
form: {
component: 'TreeSelect',
componentProps: { // 假设deptList是部门数据列表
data: deptList,
placeholder: "请选择部门",
filterable: true,
}
}
},
{
label: '负责人',
field: 'principal',
sort: 'custom',
isSearch: false,
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
return userList.value.find((item) => item.id == cellValue)?.nickname
},
form: {
component: 'Select',
componentProps: {
options: userList.value,
optionsAlias: {
labelField: 'nickname',
valueField: 'id'
},
filterable: true,
}
}
},
{
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,
}
},
1 year ago
formatter: (_: Recordable, __: TableColumn, cellValue: string) => {
return equipmentSupplierNoPage.find((item) => item.number == cellValue)?.name
},
},
{
label: '供应商',
field: 'supplierName',
sort: 'custom',
isSearch: false,
1 year ago
isTable: 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,
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
return allDeptList.find((item) => item.id == cellValue)?.name
},
form: {
component: 'TreeSelect',
componentProps: { // 假设deptList是部门数据列表
data: deptList,
placeholder: "请选择部门",
filterable: true,
}
}
},
{
label: '采购人',
field: 'purchaser',
sort: 'custom',
isSearch: false,
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
return userList.value.find((item) => item.id == cellValue)?.nickname
},
form: {
component: 'Select',
componentProps: {
options: userList.value,
optionsAlias: {
labelField: 'nickname',
valueField: 'id'
},
filterable: true,
}
}
},
{
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'
}
}
},
1 year ago
formatter: (_: Recordable, __: TableColumn, cellValue: string) => {
return equipmentManufacturerNoPage.find((item) => item.number == cellValue)?.name
},
},
{
label: '生产厂商',
field: 'manufactureName',
sort: 'custom',
isSearch: false,
1 year ago
isTable: 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: BasicEamWorkshop.allSchemas, // 查询弹窗所需类
searchPage: BasicEamWorkshopApi.getBasicEamWorkshopPage, // 查询弹窗所需分页方法
searchCondition: [{
key: 'available',
value: 'TRUE',
isMainValue: false
}]
}
},
},
// {
// label: '产线编号',
// field: 'lineCode',
// sort: 'custom',
// isSearch: true,
// isDetail: false,
// isForm: false,
// isTable: true,
// isTableForm: false,
// search: {
// component: 'Select',
// componentProps: {
// options: productionlineNoPage,
// optionsAlias: {
// labelField: 'name',
// valueField: 'code'
// },
// filterable: true,
// }
// },
// formatter: (_: Recordable, __: TableColumn, cellValue: string) => {
// return productionlineNoPage.find((item) => item.code == cellValue)?.name
// },
// },
// {
// label: '产线编号',
// field: 'lineName',
// sort: 'custom',
// isSearch: false,
// 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
// }]
// }
// }
// },
1 year ago
// {
// 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: true
},
1 year ago
{
label: '平均故障间隔时间',
field: 'purchaseInterval',
sort: 'custom',
isSearch: false,
isDetail: false,
isTable: true,
isForm: false,
isTableForm: false,
},
{
label: '总运行时长',
field: 'totalRunningTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: false,
isDetail: false,
isTable: true,
isForm: false,
isTableForm: 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: 'maintenanceRunningTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: false,
isDetail: false,
isTable: true,
isForm: false,
isTableForm: 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: 'usageTimes',
sort: 'custom',
isSearch: false,
isDetail: false,
isTable: true,
isForm: false,
isTableForm: false,
},
{
label: '上一次检验日期',
field: 'lastInspectionDate',
sort: 'custom',
formatter: dateFormatter,
isSearch: false,
isDetail: false,
isTable: true,
isForm: false,
isTableForm: 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: 'outageRate',
sort: 'custom',
isSearch: false,
isDetail: false,
isTable: true,
isForm: false,
isTableForm: false,
},
{
label: '平均故障恢复时间',
field: 'breakdownRecover',
sort: 'custom',
isSearch: false,
isDetail: false,
isTable: true,
isForm: false,
isTableForm: false,
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 250,
fixed: 'right'
}
}
]))