Browse Source

EAM ——> 保养计划/保养工单 增改查 停用启用更新

master_hella_20240701
gaojs 6 months ago
parent
commit
96c5a1acf6
  1. 74
      src/api/eam/equipmentMaintenanceMain/index.ts
  2. 3
      src/utils/dict.ts
  3. 318
      src/views/eam/equipmentMaintenanceMain/equipmentMaintenanceMain.data.ts
  4. 244
      src/views/eam/equipmentMaintenanceMain/index.vue
  5. 35
      src/views/eam/maintenance/index.vue
  6. 33
      src/views/eam/maintenance/maintenance.data.ts

74
src/api/eam/equipmentMaintenanceMain/index.ts

@ -0,0 +1,74 @@
import request from '@/config/axios'
export interface EquipmentMaintenanceMainVO {
id: number
number: string
describing: string
equipmentCode: string
type: string
classes: string
planNumber: string
faultType: string
cycle: string
times: string
verifyer: number
verifyContent: string
verifyTime: Date
maintenancer: number
maintenancePhone: string
completeResult: string
completionTime: Date
maintenanceTime: Date
status: string
factoryAreaCode: string
workshopCode: string
workshopSectionCode: string
departmentCode: string
remark: string
siteId: string
available: string
deletionTime: Date
deleterId: byte[]
concurrencyStamp: number
}
// 查询设备保养工单主列表
export const getEquipmentMaintenanceMainPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/eam/equipment-maintenance-main/senior', data })
} else {
return await request.get({ url: `/eam/equipment-maintenance-main/page`, params })
}
}
// 查询设备保养工单主详情
export const getEquipmentMaintenanceMain = async (id: number) => {
return await request.get({ url: `/eam/equipment-maintenance-main/get?id=` + id })
}
// 新增设备保养工单主
export const createEquipmentMaintenanceMain = async (data: EquipmentMaintenanceMainVO) => {
return await request.post({ url: `/eam/equipment-maintenance-main/create`, data })
}
// 修改设备保养工单主
export const updateEquipmentMaintenanceMain = async (data: EquipmentMaintenanceMainVO) => {
return await request.put({ url: `/eam/equipment-maintenance-main/update`, data })
}
// 删除设备保养工单主
export const deleteEquipmentMaintenanceMain = async (id: number) => {
return await request.delete({ url: `/eam/equipment-maintenance-main/delete?id=` + id })
}
// 导出设备保养工单主 Excel
export const exportEquipmentMaintenanceMain = async (params) => {
return await request.download({ url: `/eam/equipment-maintenance-main/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/eam/equipment-maintenance-main/get-import-template' })
}

3
src/utils/dict.ts

@ -348,4 +348,5 @@ export enum DICT_TYPE {
SUBJECT = 'subject', //科目
REGION = 'region', //区域
PART_CLASS = 'part_class', //备件分类
}
MAINTENANCE_CYCLE ='maintenance_cycle' // 保养周期
}

318
src/views/eam/equipmentMaintenanceMain/equipmentMaintenanceMain.data.ts

@ -0,0 +1,318 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const EquipmentMaintenanceMainRules = reactive({
number: [required],
equipmentCode: [required],
planNumber: [required],
status: [required],
factoryAreaCode: [required],
concurrencyStamp: [required],
})
export const EquipmentMaintenanceMain = useCrudSchemas(reactive<CrudSchema[]>([
{
label: 'id',
field: 'id',
sort: 'custom',
isSearch: false,
isTable: false,
isForm: false,
isDetail:false,
},
{
label: '保养工单编号',
field: 'number',
sort: 'custom',
isSearch: true,
},
{
label: '描述',
field: 'describing',
sort: 'custom',
isSearch: true,
},
{
label: '设备编号',
field: 'equipmentCode',
sort: 'custom',
isSearch: true,
},
{
label: '设备分类',
field: 'type',
sort: 'custom',
isSearch: true,
},
{
label: '班次枚举',
field: 'classes',
sort: 'custom',
isSearch: true,
},
{
label: '保养计划工单号',
field: 'planNumber',
sort: 'custom',
isSearch: true,
},
{
label: '故障类型枚举',
field: 'faultType',
sort: 'custom',
isSearch: true,
},
{
label: '保养周期',
field: 'cycle',
sort: 'custom',
isSearch: true,
},
{
label: '保养次数',
field: 'times',
sort: 'custom',
isSearch: true,
},
{
label: '验证人',
field: 'verifyer',
sort: 'custom',
isSearch: true,
form: {
component: 'InputNumber',
value: 0
},
},
{
label: '验证内容',
field: 'verifyContent',
sort: 'custom',
isSearch: true,
form: {
component: 'Editor',
componentProps: {
valueHtml: '',
height: 200
}
},
},
{
label: '验证时间',
field: 'verifyTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
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: '保养人id',
field: 'maintenancer',
sort: 'custom',
isSearch: true,
form: {
component: 'InputNumber',
value: 0
},
},
{
label: '保养人联系电话',
field: 'maintenancePhone',
sort: 'custom',
isSearch: true,
},
{
label: '结果枚举临时措施、完成',
field: 'completeResult',
sort: 'custom',
isSearch: true,
},
{
label: '完成时间',
field: 'completionTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
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: 'maintenanceTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
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: 'status',
sort: 'custom',
isSearch: true,
form: {
component: 'Radio'
},
},
{
label: '所属厂区编号',
field: 'factoryAreaCode',
sort: 'custom',
isSearch: true,
},
{
label: '车间编号',
field: 'workshopCode',
sort: 'custom',
isSearch: true,
},
{
label: '工段编号',
field: 'workshopSectionCode',
sort: 'custom',
isSearch: true,
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
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')]
}
},
isForm: false,
},
{
label: '部门id',
field: 'departmentCode',
sort: 'custom',
isSearch: false,
isTable: false,
isForm: false,
isDetail:false,
},
{
label: '备注',
field: 'remark',
sort: 'custom',
isSearch: true,
},
{
label: '地点ID',
field: 'siteId',
sort: 'custom',
isSearch: false,
isTable: false,
isForm: false,
isDetail:false,
},
{
label: '是否可用默认TRUE',
field: 'available',
sort: 'custom',
isSearch: true,
},
{
label: '删除时间',
field: 'deletionTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: false,
isTable: false,
isForm: false,
isDetail: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: '删除人id',
field: 'deleterId',
sort: 'custom',
isSearch: false,
isTable: false,
isForm: false,
isDetail:false,
},
{
label: '并发乐观锁',
field: 'concurrencyStamp',
sort: 'custom',
isSearch: false,
isTable: false,
isForm: false,
isDetail:false,
form: {
component: 'InputNumber',
value: 0
},
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))

244
src/views/eam/equipmentMaintenanceMain/index.vue

@ -0,0 +1,244 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="EquipmentMaintenanceMain.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="EquipmentMaintenanceMain.allSchemas"
/>
<!-- 列表 -->
<ContentWrap>
<Table
:columns="tableColumns"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort"
>
<template #code="{row}">
<el-button type="primary" link @click="openDetail(row, '代码', row.code)">
<span>{{ row.code }}</span>
</el-button>
</template>
<template #action="{ row }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" />
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="basicFormRef"
@success="formsSuccess"
:rules="EquipmentMaintenanceMainRules"
:formAllSchemas="EquipmentMaintenanceMain.allSchemas"
:apiUpdate="EquipmentMaintenanceMainApi.updateEquipmentMaintenanceMain"
:apiCreate="EquipmentMaintenanceMainApi.createEquipmentMaintenanceMain"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="EquipmentMaintenanceMain.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/equipment-maintenance-main/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { EquipmentMaintenanceMain,EquipmentMaintenanceMainRules } from './equipmentMaintenanceMain.data'
import * as EquipmentMaintenanceMainApi from '@/api/eam/equipmentMaintenanceMain'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue'
defineOptions({ name: 'EquipmentMaintenanceMain' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(EquipmentMaintenanceMain.allSchemas.tableColumns)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
const { tableObject, tableMethods } = useTable({
getListApi: EquipmentMaintenanceMainApi.getEquipmentMaintenanceMainPage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'eam:equipmentMaintenanceMain:create'}), //
//defaultButtons.defaultImportBtn({hasPermi:'eam:equipmentMaintenanceMain:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'eam:equipmentMaintenanceMain:export'}), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
// {
// label: '',
// name: 'zdy',
// hide: false,
// type: 'primary',
// icon: 'Select',
// color: ''
// },
]
//
const buttonBaseClick = (val, item) => {
if (val == 'add') { //
openForm('create')
} else if (val == 'import') { //
handleImport()
} else if (val == 'export') { //
handleExport()
} else if (val == 'refresh') { //
getList()
} else if (val == 'filtrate') { //
} else { //
console.log('其他按钮', item)
}
}
// -
const butttondata = [
defaultButtons.mainListEditBtn({hasPermi:'eam:equipmentMaintenanceMain:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'eam:equipmentMaintenanceMain:delete'}), //
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =EquipmentMaintenanceMain.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime';
});
if(isHave){
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){
message.error('失效时间要大于生效时间')
return;
}
}
if(data.activeTime==0)data.activeTime = null;
if(data.expireTime==0)data.expireTime = null;
if (formType === 'create') {
await EquipmentMaintenanceMainApi.createEquipmentMaintenanceMain(data)
message.success(t('common.createSuccess'))
} else {
await EquipmentMaintenanceMainApi.updateEquipmentMaintenanceMain(data)
message.success(t('common.updateSuccess'))
}
basicFormRef.value.dialogVisible = false
getList()
}
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicEquipmentMaintenanceMain')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await EquipmentMaintenanceMainApi.deleteEquipmentMaintenanceMain(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const exportLoading = ref(false) //
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await EquipmentMaintenanceMainApi.exportEquipmentMaintenanceMain(tableObject.params)
download.excel(data, '设备保养工单主.xlsx')
} catch {
} finally {
exportLoading.value = false
}
}
/** 导入 */
const importFormRef = ref()
const handleImport = () => {
importFormRef.value.open()
}
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: '设备保养工单主导入模版.xlsx'
})
//
const importSuccess = () => {
getList()
}
//
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() //
}
/** 初始化 **/
onMounted(async () => {
getList()
importTemplateData.templateUrl = await EquipmentMaintenanceMainApi.importTemplate()
})
</script>

35
src/views/eam/maintenance/index.vue

@ -48,6 +48,7 @@
:apiCreate="MaintenanceApi.createMaintenance"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
@onChange="onChange"
/>
<!-- 详情 -->
@ -65,7 +66,10 @@ import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue'
import * as BasicInspectionOptionApi from "@/api/eam/basicInspectionOption";
import {EquipmentAccounts} from "@/views/eam/equipmentAccounts/equipmentAccounts.data";
import * as EquipmentItemApi from "@/api/eam/equipmentAccounts";
import { ToolAccounts } from "@/views/eam/toolAccounts/ToolAccounts.data";
import * as ToolItemApi from "@/api/eam/toolAccounts";
defineOptions({ name: 'Maintenance' })
@ -243,6 +247,35 @@ const handleDisable = async (id: number) => {
} catch {}
}
const onChange = (field, item) => {
console.log(field)
console.log(item)
//
if(field == 'type' && item == 'DEVICE'){
Maintenance.allSchemas.formSchema.forEach((items) => {
if (items.field == 'equipmentCode') {
basicFormRef.value.formRef.setValues({
equipmentCode:''
})
items.componentProps.searchAllSchemas = EquipmentAccounts.allSchemas
items.componentProps.searchPage = EquipmentItemApi.getEquipmentAccountsPage
}
})
}
//
if(field == 'type' && item == 'EQUIPMENT'){
Maintenance.allSchemas.formSchema.forEach((items) => {
if (items.field == 'equipmentCode') {
basicFormRef.value.formRef.setValues({
equipmentCode:''
})
items.componentProps.searchAllSchemas = ToolAccounts.allSchemas
items.componentProps.searchPage = ToolItemApi.getToolAccountsPage
}
})
}
}
/** 导出按钮操作 */
const exportLoading = ref(false) //
const handleExport = async () => {

33
src/views/eam/maintenance/maintenance.data.ts

@ -1,5 +1,7 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import { EquipmentAccounts } from "@/views/eam/equipmentAccounts/equipmentAccounts.data";
import * as EquipmentItemApi from "@/api/eam/equipmentAccounts";
// 表单校验
export const MaintenanceRules = reactive({
@ -33,16 +35,37 @@ export const Maintenance = useCrudSchemas(reactive<CrudSchema[]>([
isSearch: true,
},
{
label: '设备编号',
field: 'equipmentCode',
label: '设备类别',
field: 'type',
dictType: DICT_TYPE.DEVICE_TYPE,
dictClass: 'string',
sort: 'custom',
isSearch: true,
},
{
label: '设备类别枚举',
field: 'type',
label: '设备编号',
field: 'equipmentCode',
sort: 'custom',
isSearch: true,
isForm: true,
form: {
componentProps: {
isSearchList: true, // 开启查询弹窗
searchTitle: '设备信息', // 查询弹窗标题
searchListPlaceholder: '请选择 设备编号', // 输入框占位文本
searchAllSchemas: EquipmentAccounts.allSchemas, // 查询弹窗所需类
searchField: 'code', // 查询弹窗赋值字段
searchPage: EquipmentItemApi.getEquipmentAccountsPage, // 查询弹窗所需分页方法
multiple:true,
searchCondition: [{
key: 'status',
value: 'NORMAL',
action: '==',
isSearch: true,
isMainValue: false
}]
}
}
},
{
label: '方案编号',
@ -53,6 +76,8 @@ export const Maintenance = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '周期',
field: 'cycle',
dictType: DICT_TYPE.MAINTENANCE_CYCLE,
dictClass: 'string',
sort: 'custom',
isSearch: true,
},

Loading…
Cancel
Save