Browse Source

EAM ——> 保养方案与保养选择集与保养项关联 新增

master_hella_20240701
gaojs 6 months ago
parent
commit
55fdf36201
  1. 27
      src/views/eam/basicMaintenanceOption/index.vue
  2. 369
      src/views/eam/basicMaintenanceOption/itemSelectSetForm.vue
  3. 1
      src/views/eam/equipmentMaintenanceMain/DetailEam.vue
  4. 13
      src/views/eam/equipmentMaintenanceMain/equipmentMaintenanceMain.data.ts
  5. 2
      src/views/eam/equipmentMaintenanceMain/index.vue

27
src/views/eam/basicMaintenanceOption/index.vue

@ -39,16 +39,17 @@
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="basicFormRef"
@success="formsSuccess"
:rules="BasicMaintenanceOptionRules"
:formAllSchemas="BasicMaintenanceOption.allSchemas"
:apiUpdate="BasicMaintenanceOptionApi.updateBasicMaintenanceOption"
:apiCreate="BasicMaintenanceOptionApi.createBasicMaintenanceOption"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- <BasicForm-->
<!-- ref="basicFormRef"-->
<!-- @success="formsSuccess"-->
<!-- :rules="BasicMaintenanceOptionRules"-->
<!-- :formAllSchemas="BasicMaintenanceOption.allSchemas"-->
<!-- :apiUpdate="BasicMaintenanceOptionApi.updateBasicMaintenanceOption"-->
<!-- :apiCreate="BasicMaintenanceOptionApi.createBasicMaintenanceOption"-->
<!-- @searchTableSuccess="searchTableSuccess"-->
<!-- :isBusiness="false"-->
<!-- />-->
<ItemForm ref="basicFormRef" @success="getData"/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="BasicMaintenanceOption.allSchemas" />
@ -65,6 +66,7 @@ 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 ItemForm from "@/views/eam/basicMaintenanceOption/itemSelectSetForm.vue";
defineOptions({ name: 'BasicMaintenanceOption' })
@ -205,6 +207,11 @@ const formsSuccess = async (formType,data) => {
getList()
}
//
const getData = async() => {
getList();
}
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {

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

@ -0,0 +1,369 @@
<template>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<el-form
ref="basicFormRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="100px"
>
<el-row>
<el-col :span="12">
<el-form-item label="方案编号" prop="code">
<el-input v-model="formData.code" placeholder="方案编号" :disabled="isDisabled"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="方案名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入方案名称" />
</el-form-item>
</el-col>
</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-option label="是" value="TRUE"></el-option>
<el-option label="否" value="FALSE"></el-option>
</el-select>
</el-form-item>
</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-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)">
{{ ent.selectId}}
</el-tag>
<el-input v-if="inputVisible" ref="InputRef" v-model="inputValue" class="w-20" size="small"/>
<el-button v-else class="button-new-tag" size="small" @click="addItem">
添加保养选择集
</el-button>
</div>
</el-form-item>
</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" >
<template #header>
<span>是否必选默认是</span>
</template>
<template #default="scope">
<el-switch
v-model="scope.row.replaceFlag"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="是"
inactive-text="否"
/>
</template>
</el-table-column>
</el-table>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
<!--添加巡检项弹窗-->
<SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" />
</template>
<script lang="ts" setup>
import * as SelectSetApi from '@/api/eam/inspectionItemSelectSet'
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";
defineOptions({ name: 'TeamForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const tags=ref([])
const inputValue = ref('')
const inputVisible = ref(false)
const isDisabled = ref(false)
const InputRef = ref<InstanceType<typeof ElInput>>()
//
const maintenanceItemData = ref([])
const itemData = ref({
id: '',
content: '',
selectId:''
})
const formData = ref({
code: '',
name: '',
describing: '',
isUpdated: '',
remark: '',
available: '',
selectId: ''
})
const formRules = reactive({
name: [
{ required: true, message: '选择集名称不能为空', trigger: 'blur' },
{ max: 50, message: '不得超过50个字符', trigger: 'blur' }
],
remark: [
{ max: 50, message: '不得超过50个字符', trigger: 'blur' }
],
})
const basicFormRef = ref() // Ref
/** 删除巡检项 */
const handleClose = (id: string) => {
const index = tags.value.findIndex(tag => tag.id === id);
if (index !== -1) {
tags.value.splice(index, 1);
}
}
/** 弹窗相关参数 */
const searchTableRef = ref();
const _searchTableTitle = ref();
const _searchTableAllSchemas = ref();
const _searchTablePage = ref();
const _formField = ref();
const _searchField = ref();
const _multiple = ref();
const _type = ref();
const _row = ref();
const _searchCondition = ref({})
const addItem = () =>{
addItemCommon(true,'baoYangItem')
}
/** 选择巡检项弹窗 */
const addItemCommon = (multiple,field) => {
_searchCondition.value = {}
const filters: any[] = []
filters.push({
action: "==",
column: 'available',
value: 'TRUE'
})
//
_searchCondition.value.isSearch = true
_searchCondition.value.filters = filters
_searchTableTitle.value = '选择保养项'
//_multiple.value = multiple
_formField.value = field
_searchField.value = field
_searchTablePage.value = maintenanceItemSelectSetApi.getBasicMaintenanceItemSelectSetPage
_searchTableAllSchemas.value = BasicMaintenanceItemSelectSet.allSchemas
openCommon()
}
/** 弹窗选择之后 回调函数 添加选择集 */
const searchTableSuccess = (formField, searchField, val, formRef, type, row ) => {
nextTick?.(async () => {
if (formField === 'baoYangItem') {
let itemsId = '';
//ID
val.forEach(item => {
const isExist = tags.value.some(tag => tag.id === item.id);
if (!isExist) {
const newItem = {};
newItem['itemCode'] = item.itemCode;
newItem['selectId'] = item.id;
tags.value = [];
tags.value.push(newItem);
}
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);
}
} finally {
formLoading.value = false;
}
}
})
}
/*打开弹窗*/
const openCommon = () => {
searchTableRef.value.open(
_searchTableTitle.value,
_searchTableAllSchemas.value,
_searchTablePage.value,
_formField.value,
_searchField.value,
_multiple.value,
_type.value,
_row.value,
_searchCondition.value
)
}
/** 初始化弹窗 */
const open = async (type: string, row?: object) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
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);
}
} finally {
formLoading.value = false
}
let res = await request.get({url: `/eam/relation-maintenance-item-select-set/getList?selectId=` + row.selectId})
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);
}
} finally {
formLoading.value = false;
}
}
//
else {
resetForm()
isDisabled.value = false;
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!basicFormRef) return
const valid = await basicFormRef.value.validate()
if (!valid) return
if (maintenanceItemData.value.length > 10 ){
message.warning('保养项最多10个');
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
//
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'))
} else {
await SelectSetApi.updateInspectionItemSelectSet(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
code: '',
name: '',
describing: '',
isUpdated: '',
remark: '',
available: '',
selectId: ''
}
tags.value=[];
maintenanceItemData.value = [];
basicFormRef.value?.resetFields()
}
</script>
<style scoped>
.tag-container {
margin-top: 10px; /* 可根据需要调整标签容器与表单项之间的间距 */
border: 1px solid #ccc; /* 添加边框样式 */
padding: 10px; /* 可根据需要调整容器内边距 */
width: 950px; /* 设置固定宽度为 950px */
overflow-y: auto; /* 当内容溢出容器高度时显示滚动条 */
word-wrap: break-word; /* 使用 word-wrap 属性实现超出范围换行 */
overflow-wrap: break-word; /* 兼容性更好的写法 */
flex-wrap: wrap;
}
.input-with-button {
display: flex;
align-items: center;
width: 100%;
}
.input-with-button > .el-input {
flex: 1;
/*margin-right: 10px;*/
}
</style>

1
src/views/eam/equipmentMaintenanceMain/DetailEam.vue

@ -862,7 +862,6 @@ const openForm = async (type: string, row?: number) => {
row.actualMinutes = row.actualMinutes.toString()
EquipmentMaintenanceDetail.allSchemas.formSchema.forEach((item) => {
if(item.field == 'peoples'){
console.log(item);
item.componentProps.disabled = false
EquipmentMaintenanceDetailRules.peoples[0].required = true
}

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

@ -383,13 +383,12 @@ export const EquipmentMaintenanceDetailRules = reactive({
validator:validateroundNumber,
message: '请输入正确的正整数',
trigger: 'blur'}],
completionTime: [required],
// [
// {
// required:false ,
// message:'该项为必填项',
// tagger:['blur']
// }],
// completionTime: [
// {
// required:false ,
// message:'该项为必填项',
// tagger:['blur']
// }],
result: [
{
required:false ,

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

@ -195,7 +195,7 @@ const buttonTableClick = async (val, row) => {
handleExecute(row.id)
} else if (val == 'finish') { //
handleFinish(row.id)
} else if (val == 'validate') { //
} else if (val == 'validate') { //
handleValidate(row.id)
}
}

Loading…
Cancel
Save