Browse Source

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

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

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

@ -1,10 +1,10 @@
import request from '@/config/axios'
import {EquipmentMainPartVO} from "@/api/eam/equipmentMainPart";
export interface BasicMaintenanceOptionVO {
id: number
code: string
name: string
selectId: string
describing: string
isUpdated: boolean
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 })
}

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

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

Loading…
Cancel
Save