设备退运工作流完成

This commit is contained in:
2024-05-14 15:21:37 +08:00
parent 1075b33aa6
commit 174e50d784
7 changed files with 388 additions and 278 deletions

View File

@@ -1,35 +1,23 @@
<template>
<el-dialog draggable class='cn-operate-dialog' v-model='dialogVisible' :title='title'
style='max-width: 450px;height: 320px' top="30vh">
style='max-width: 450px;height: 320px' top='30vh'>
<el-scrollbar>
<el-form :inline='false' :model='formData' label-width='120px' :rules='rules' ref='formRef'>
<el-form-item label='设备类型' prop='deviceType'>
<el-radio-group v-model='formData.deviceType'>
<el-radio border label='1'>设备</el-radio>
<el-radio border label='2'>监测</el-radio>
<el-radio-group v-model='formData.deviceType' @change='changeType'>
<el-radio border label='1'>装置设备</el-radio>
<el-radio border label='2'>监测设备</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label='设备' prop='deviceId'>
<!-- <el-select-->
<!-- v-model='formData.deviceId'-->
<!-- clearable-->
<!-- placeholder='请选择设备'-->
<!-- style='width: 100%'-->
<!-- >-->
<!-- <el-option-->
<!-- v-for='category in categoryList'-->
<!-- :key='category.id'-->
<!-- :label='category.name'-->
<!-- :value='category.id'-->
<!-- />-->
<!-- </el-select>-->
<el-tree-select
v-model="value"
:data="data"
v-model='formData.deviceId'
:data='data'
filterable
style="width: 240px"
:default-expand-all='true'
style='width: 260px'
/>
</el-form-item>
@@ -57,90 +45,15 @@
import { ref, inject, reactive, nextTick } from 'vue'
import { ElMessage } from 'element-plus'
import TableStore from '@/utils/tableStore' // 若不是列表页面弹框可删除
import { getFormSimpleList } from '@/api/bpm-boot/form'
import { getCategorySimpleList } from '@/api/bpm-boot/category'
import { addModel, updateModel } from '@/api/bpm-boot/model'
import { getTerminalSelectTree } from '@/api/device-boot/Business'
import { addRunningDevice } from '@/api/supervision-boot/device/quitRunningDev'
const value = ref()
const sourceData = [
{
value: '1',
label: 'Level one 1',
children: [
{
value: '1-1',
label: 'Level two 1-1',
children: [
{
value: '1-1-1',
label: 'Level three 1-1-1',
},
],
},
],
},
{
value: '2',
label: 'Level one 2',
children: [
{
value: '2-1',
label: 'Level two 2-1',
children: [
{
value: '2-1-1',
label: 'Level three 2-1-1',
},
],
},
{
value: '2-2',
label: 'Level two 2-2',
children: [
{
value: '2-2-1',
label: 'Level three 2-2-1',
},
],
},
],
},
{
value: '3',
label: 'Level one 3',
children: [
{
value: '3-1',
label: 'Level two 3-1',
children: [
{
value: '3-1-1',
label: 'Level three 3-1-1',
},
],
},
{
value: '3-2',
label: 'Level two 3-2',
children: [
{
value: '3-2-1',
label: 'Level three 3-2-1',
},
],
},
],
},
]
const data = ref(sourceData)
const filterMethod = (value) => {
data.value = [...sourceData].filter((item) => item.label.includes(value))
}
const filterNodeMethod = (value, data) => data.label.includes(value)
//下拉数据源
const sourceData = ref()
const deviceList = ref()
const lineList = ref()
const data = ref()
const title = ref('')
const tableStore = inject('tableStore') as TableStore
const formRef = ref()
@@ -151,7 +64,7 @@ const formData = reactive({
id: '',
deviceId: '',
deviceType: '',
propertyNo: '',
propertyNo: ''
})
//form表单校验规则
@@ -165,17 +78,21 @@ const resetForm = () => {
}
}
const open = async (text: string, data?: any) => {
const open = async (text: string, tempData?: any) => {
title.value = text
//终端
await getTerminalSelectTree(4)
await getTerminalSelectTree(4).then(res => {
deviceList.value = res.data
})
//监测点
await getTerminalSelectTree(6)
getTerminalSelectTree(6).then(res => {
lineList.value = res.data
})
if (data) {
if (tempData) {
// 表单赋值
for (let key in formData) {
formData[key] = data[key]
formData[key] = tempData[key]
}
} else {
resetForm()
@@ -184,6 +101,8 @@ const open = async (text: string, data?: any) => {
formData[key] = ''
}
formData.deviceType = '1'
sourceData.value = deviceList.value
data.value = deviceList.value
}
dialogVisible.value = true
}
@@ -196,12 +115,12 @@ const submit = () => {
formRef.value.validate(async (valid: any) => {
if (valid) {
if (formData.id) {
await updateModel(formData)
// await updateModel(formData)
ElMessage.success('更新成功')
tableStore.index()
dialogVisible.value = false
} else {
await addModel(formData).then(res => {
await addRunningDevice(formData).then(res => {
formData.id = res.data
//查询进线数据避免一直处于loading状态
ElMessage.success('保存成功')
@@ -214,6 +133,20 @@ const submit = () => {
})
}
/**
* 设备类型切换
*/
const changeType = (event: any) => {
if (event == 1) {
sourceData.value = deviceList.value
} else {
sourceData.value = lineList.value
}
formData.deviceId = ''
data.value = sourceData.value
}
defineExpose({ open })
</script>