Browse Source

EAM ——> 保养方案 及 保养方案与保养项关联 更新

master_hella_20240701
gaojs 6 months ago
parent
commit
d81f21832b
  1. 4
      src/api/eam/basicMaintenanceOption/index.ts
  2. 118
      src/views/eam/basicMaintenanceOption/itemSelectSetForm.vue

4
src/api/eam/basicMaintenanceOption/index.ts

@ -1,10 +1,10 @@
import request from '@/config/axios' import request from '@/config/axios'
import {EquipmentMainPartVO} from "@/api/eam/equipmentMainPart";
export interface BasicMaintenanceOptionVO { export interface BasicMaintenanceOptionVO {
id: number id: number
code: string code: string
name: string name: string
selectId: string
describing: string describing: string
isUpdated: boolean isUpdated: boolean
type: string type: string
@ -34,7 +34,7 @@ export const getBasicMaintenanceOption = async (id: number) => {
} }
// 新增保养方案 // 新增保养方案
export const createBasicMaintenanceOption = async (data: BasicMaintenanceOptionVO) => { export const createBasicMaintenanceOption = async (data) => {
return await request.post({ url: `/eam/basic-maintenance-option/create`, data }) return await request.post({ url: `/eam/basic-maintenance-option/create`, data })
} }

118
src/views/eam/basicMaintenanceOption/itemSelectSetForm.vue

@ -20,36 +20,40 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12">
<el-form-item label="是否可修改" prop="isUpdated">
<el-select v-model="formData.isUpdated" style="width: 200px">
<el-option label="是" value="TRUE"></el-option>
<el-option label="否" value="FALSE"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="描述" prop="describing"> <el-form-item label="描述" prop="describing">
<el-input v-model="formData.describing" placeholder="请输入描述" /> <el-input v-model="formData.describing" placeholder="请输入描述" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-form-item label="项是否可修改" prop="isUpdated"> </el-row>
<el-select v-model="formData.isUpdated" style="width: 150px"> <el-row>
<el-col :span="12">
<el-form-item label="是否可用" prop="available">
<el-select v-model="formData.available" style="width: 200px">
<el-option label="是" value="TRUE"></el-option> <el-option label="是" value="TRUE"></el-option>
<el-option label="否" value="FALSE"></el-option> <el-option label="否" value="FALSE"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-row> </el-col>
<el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入备注" /> <el-input v-model="formData.remark" placeholder="请输入备注" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-form-item label="是否可用" prop="available">
<el-select v-model="formData.available" style="width: 150px">
<el-option label="是" value="TRUE"></el-option>
<el-option label="否" value="FALSE"></el-option>
</el-select>
</el-form-item>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="11"> <el-col :span="11">
<el-form-item label="选择集ID" prop="selectId"> <el-form-item label="选择集ID" prop="selectId">
<div class="tag-container flex gap-2"> <div class="tag-container flex gap-2">
<el-tag v-for="ent in tags" :key="ent.content" closable :disable-transitions="false" @close="handleClose(ent.selectId)"> <el-tag v-for="ent in tags" :key="ent.selectId" closable :disable-transitions="false" @close="handleClose(ent.selectId)">
{{ ent.selectId}} {{ ent.selectId}}
</el-tag> </el-tag>
<el-input v-if="inputVisible" ref="InputRef" v-model="inputValue" class="w-20" size="small"/> <el-input v-if="inputVisible" ref="InputRef" v-model="inputValue" class="w-20" size="small"/>
@ -61,17 +65,17 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<el-table :data="maintenanceItemData" ref="tableEquipment" style="width: 100%; height: 80%"> <el-table :data="maintenanceItemData" style="width: 100%; height: 80%">
<el-table-column prop="name" label="保养名称" /> <el-table-column prop="itemCode" label="保养项ID" />
<el-table-column prop="content" label="保养要求" /> <el-table-column prop="itemName" label="保养名称" />
<el-table-column prop="equipmentParts" label="保养部位" /> <!-- <el-table-column prop="equipmentParts" label="保养部位" />-->
<el-table-column prop="opera" label="" width="130" > <el-table-column prop="isSelectd" label="" width="150" >
<template #header> <template #header>
<span>是否必选默认是</span> <span>是否必选默认是</span>
</template> </template>
<template #default="scope"> <template #default="scope">
<el-switch <el-switch
v-model="scope.row.replaceFlag" v-model="scope.row.isSelectd"
active-color="#13ce66" active-color="#13ce66"
inactive-color="#ff4949" inactive-color="#ff4949"
active-text="是" active-text="是"
@ -91,12 +95,16 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import * as SelectSetApi from '@/api/eam/inspectionItemSelectSet' import * as BasicMaintenanceOptionApi from '@/api/eam/basicMaintenanceOption'
import request from "@/config/axios"; import request from "@/config/axios";
import { SearchTable } from '@/components/SearchTable' import { SearchTable } from '@/components/SearchTable'
import { BasicMaintenanceItemSelectSet} from "@/views/eam/maintenanceItemSelectSet/maintenanceItemSelectSet.data"; import { BasicMaintenanceItemSelectSet} from "@/views/eam/maintenanceItemSelectSet/maintenanceItemSelectSet.data";
import * as maintenanceItemSelectSetApi from "@/api/eam/maintenanceItemSelectSet"; import * as maintenanceItemSelectSetApi from "@/api/eam/maintenanceItemSelectSet";
import {ElInput} from "element-plus"; import {ElInput} from "element-plus";
import {
BasicMaintenanceOptionVO,
createBasicMaintenanceOption, updateBasicMaintenanceOption
} from "@/api/eam/basicMaintenanceOption";
defineOptions({ name: 'TeamForm' }) defineOptions({ name: 'TeamForm' })
@ -129,13 +137,24 @@ const formData = ref({
isUpdated: '', isUpdated: '',
remark: '', remark: '',
available: '', available: '',
selectId: '' selectId: '',
optionItem:[]
}) })
const formRules = reactive({ const formRules = reactive({
code: [
{ required: true, message: '方案编号不能为空', trigger: 'blur' },
{ max: 50, message: '不得超过50个字符', trigger: 'blur' }
],
name: [ name: [
{ required: true, message: '选择集名称不能为空', trigger: 'blur' }, { required: true, message: '方案名称不能为空', trigger: 'blur' },
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } { max: 50, message: '不得超过50个字符', trigger: 'blur' }
], ],
isUpdated: [
{ required: true, message: '不能为空', trigger: 'blur' },
],
available: [
{ required: true, message: '不能为空', trigger: 'blur' },
],
remark: [ remark: [
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } { max: 50, message: '不得超过50个字符', trigger: 'blur' }
], ],
@ -144,7 +163,9 @@ const basicFormRef = ref() // 表单 Ref
/** 删除巡检项 */ /** 删除巡检项 */
const handleClose = (id: string) => { const handleClose = (id: string) => {
const index = tags.value.findIndex(tag => tag.id === id); console.log(id)
console.log(tags)
const index = tags.value.findIndex(tag => tag.selectId === id);
if (index !== -1) { if (index !== -1) {
tags.value.splice(index, 1); tags.value.splice(index, 1);
} }
@ -203,7 +224,7 @@ const searchTableSuccess = (formField, searchField, val, formRef, type, row ) =>
tags.value = []; tags.value = [];
tags.value.push(newItem); tags.value.push(newItem);
} }
itemsId = item.itemCode itemsId = item.itemCode;
}); });
// //
try { try {
@ -212,9 +233,10 @@ const searchTableSuccess = (formField, searchField, val, formRef, type, row ) =>
for (const item of itemsId.split(",")) { for (const item of itemsId.split(",")) {
let res = await request.get({url: `/eam/basic/maintenance-item/get?id=` + item}) let res = await request.get({url: `/eam/basic/maintenance-item/get?id=` + item})
const newItem = {}; const newItem = {};
newItem['name'] = res.name; newItem['itemCode'] = res.id;
newItem['content'] = res.content; newItem['itemName'] = res.name;
newItem['equipmentParts'] = res.equipmentParts; newItem['equipmentParts'] = res.equipmentParts;
newItem['isSelectd'] = true;
maintenanceItemData.value.push(newItem); maintenanceItemData.value.push(newItem);
} }
} finally { } finally {
@ -244,13 +266,13 @@ const open = async (type: string, row?: object) => {
formType.value = type formType.value = type
// //
if (row) { if (row) {
tags.value=[];
maintenanceItemData.value = [];
isDisabled.value = true; isDisabled.value = true;
formLoading.value = true formLoading.value = true
formData.value = row; formData.value = row;
//
let item = (row.id.toString()).split(",") let item = (row.id.toString()).split(",")
try { try {
tags.value=[];
for (var i = 0; i < item.length; i++) { for (var i = 0; i < item.length; i++) {
itemData.value = await request.get({ url: `/eam/basic-maintenance-option/get?id=` + item[i] }); itemData.value = await request.get({ url: `/eam/basic-maintenance-option/get?id=` + item[i] });
tags.value.push(itemData.value); tags.value.push(itemData.value);
@ -258,25 +280,22 @@ const open = async (type: string, row?: object) => {
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
//
let res = await request.get({url: `/eam/relation-maintenance-item-select-set/getList?selectId=` + row.selectId}) let res = await request.get({url: `/eam/relation-maintenance-option-item/getList?optionCode=` + row.code})
try { try {
maintenanceItemData.value = [];
formLoading.value = true; formLoading.value = true;
for (const item of res) { for (const item of res) {
console.log(item)
let res = await request.get({url: `/eam/basic/maintenance-item/get?id=` + item.itemCode})
const newItem = {}; const newItem = {};
newItem['name'] = res.name; newItem['id'] = item.id;
newItem['content'] = res.content; newItem['itemCode'] = item.itemCode;
newItem['equipmentParts'] = res.equipmentParts; newItem['itemName'] = item.itemName;
newItem['isSelectd'] = item.isSelectd;
maintenanceItemData.value.push(newItem); maintenanceItemData.value.push(newItem);
} }
} finally { } finally {
formLoading.value = false; formLoading.value = false;
} }
} }
// //
else { else {
@ -298,24 +317,27 @@ const submitForm = async () => {
return return
} }
let result = ''; // ID
for (var i = 0; i < tags.value.length; i++) { formData.value.selectId = tags.value[0].selectId
result += tags.value[i].id + ',';
}
if(result.endsWith(',')){
result = result.substring(0,result.length -1)
}
formData.value.itemCode = result
// //
formLoading.value = true formLoading.value = true
//formData.value.members = JSON.stringify(tags.value) //formData.value.members = JSON.stringify(tags.value)
try { try {
const data = formData.value as unknown as SelectSetApi.InspectionItemSelectSetVO
if (formType.value === 'create') { if (formType.value === 'create') {
await SelectSetApi.createInspectionItemSelectSet(data) for (var i = 0; i < maintenanceItemData.value.length; i++) {
maintenanceItemData.value[i].optionCode = formData.value.code
}
formData.value.optionItem = maintenanceItemData.value
//
await BasicMaintenanceOptionApi.createBasicMaintenanceOption(formData.value)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
await SelectSetApi.updateInspectionItemSelectSet(data) for (var i = 0; i < maintenanceItemData.value.length; i++) {
maintenanceItemData.value[i].optionCode = formData.value.code
}
formData.value.optionItem = maintenanceItemData.value
console.log(formData.value)
await BasicMaintenanceOptionApi.updateBasicMaintenanceOption(formData.value)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }
dialogVisible.value = false dialogVisible.value = false

Loading…
Cancel
Save