2024-05-13 18:36:19 +08:00
|
|
|
|
<template>
|
2024-06-18 16:38:33 +08:00
|
|
|
|
<el-dialog draggable class="cn-operate-dialog" v-model="dialogVisible" :title="title" width="450px" top="20vh">
|
|
|
|
|
|
<el-scrollbar>
|
|
|
|
|
|
<el-form :inline="false" :model="form" label-width="120px" :rules="rules" ref="formRef">
|
|
|
|
|
|
<el-form-item label="终端" prop="deviceId">
|
|
|
|
|
|
<el-tree-select
|
|
|
|
|
|
v-model="form.deviceId"
|
|
|
|
|
|
:data="data"
|
|
|
|
|
|
filterable
|
2024-08-21 16:05:06 +08:00
|
|
|
|
:filter-node-method="filterNode"
|
2024-06-18 16:38:33 +08:00
|
|
|
|
style="width: 100%"
|
|
|
|
|
|
@change="changeDevStatus"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="终端当前状态:">
|
|
|
|
|
|
<el-select v-model="runFlag" disabled placeholder="请选择终端" clearable class="select">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in devStatusList"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="变更状态:" prop="devStatus">
|
|
|
|
|
|
<el-select v-model="form.devStatus" placeholder="请选择终端状态" clearable class="select">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in devStatuData"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2024-06-04 18:36:17 +08:00
|
|
|
|
|
2024-06-18 16:38:33 +08:00
|
|
|
|
<el-form-item label="变更原因" prop="propertyNo">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
type="textarea"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
:autosize="{ minRows: 2, maxRows: 4 }"
|
|
|
|
|
|
placeholder="请输入变更原因"
|
|
|
|
|
|
v-model="form.propertyNo"
|
|
|
|
|
|
></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-scrollbar>
|
2024-06-04 18:36:17 +08:00
|
|
|
|
|
2024-06-18 16:38:33 +08:00
|
|
|
|
<template #footer>
|
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
|
<el-button @click="dialogVisible = false">取消</el-button>
|
2024-06-19 19:37:39 +08:00
|
|
|
|
<!-- <el-button type="primary" @click="submit">确认</el-button> -->
|
|
|
|
|
|
<el-button type="primary" @click="submit(true)">保存</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="submit(false)">提交审批</el-button>
|
2024-05-13 18:36:19 +08:00
|
|
|
|
</span>
|
2024-06-18 16:38:33 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2024-05-13 18:36:19 +08:00
|
|
|
|
</template>
|
2024-06-18 16:38:33 +08:00
|
|
|
|
<script lang="ts" setup>
|
2024-06-04 18:36:17 +08:00
|
|
|
|
import { ref, inject } from 'vue'
|
2024-05-13 18:36:19 +08:00
|
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
|
|
import TableStore from '@/utils/tableStore' // 若不是列表页面弹框可删除
|
|
|
|
|
|
import { getTerminalSelectTree } from '@/api/device-boot/Business'
|
2024-05-14 20:03:20 +08:00
|
|
|
|
import { addRunningDevice, quitRunningDeviceUpdate } from '@/api/supervision-boot/device/quitRunningDev'
|
2024-06-04 18:36:17 +08:00
|
|
|
|
import { getDeviceDetailData } from '@/api/device-boot/line'
|
2024-06-06 22:14:20 +08:00
|
|
|
|
import { defaultProps } from '@/utils/tree'
|
2024-06-04 18:36:17 +08:00
|
|
|
|
const devStatusList = ref([
|
2024-06-18 16:38:33 +08:00
|
|
|
|
{ name: '运行', value: '0' },
|
|
|
|
|
|
{ name: '检修', value: '1' },
|
|
|
|
|
|
{ name: '退运', value: '4' }
|
2024-06-04 18:36:17 +08:00
|
|
|
|
])
|
2024-05-14 15:21:37 +08:00
|
|
|
|
//下拉数据源
|
|
|
|
|
|
const sourceData = ref()
|
|
|
|
|
|
const deviceList = ref()
|
|
|
|
|
|
const data = ref()
|
2024-05-13 18:36:19 +08:00
|
|
|
|
const title = ref('')
|
|
|
|
|
|
const tableStore = inject('tableStore') as TableStore
|
|
|
|
|
|
const formRef = ref()
|
2024-06-18 16:38:33 +08:00
|
|
|
|
const devStatuData: any = ref([])
|
2024-05-13 18:36:19 +08:00
|
|
|
|
|
|
|
|
|
|
const dialogVisible = ref(false)
|
2024-06-18 16:38:33 +08:00
|
|
|
|
const runFlag = ref('')
|
2024-05-13 18:36:19 +08:00
|
|
|
|
// 注意不要和表单ref的命名冲突
|
2024-06-03 09:17:00 +08:00
|
|
|
|
const form = ref({
|
2024-06-18 16:38:33 +08:00
|
|
|
|
id: '',
|
|
|
|
|
|
deviceId: '',
|
|
|
|
|
|
deviceType: '1',
|
|
|
|
|
|
devOriginalStatus: '0',
|
|
|
|
|
|
devStatus: '',
|
2024-06-19 19:37:39 +08:00
|
|
|
|
propertyNo: '',
|
|
|
|
|
|
saveOrCheckflag: ''
|
2024-05-13 18:36:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
//form表单校验规则
|
|
|
|
|
|
const rules = {
|
2024-06-18 16:38:33 +08:00
|
|
|
|
deviceId: [{ required: true, message: '终端不能为空', trigger: 'change' }],
|
|
|
|
|
|
devStatus: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
|
|
|
|
|
propertyNo: [{ required: true, message: '请输入退役原因', trigger: 'blur' }]
|
2024-05-13 18:36:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
const resetForm = () => {
|
2024-06-18 16:38:33 +08:00
|
|
|
|
if (formRef.value) {
|
|
|
|
|
|
formRef.value.resetFields()
|
|
|
|
|
|
}
|
2024-05-13 18:36:19 +08:00
|
|
|
|
}
|
2024-08-21 16:05:06 +08:00
|
|
|
|
const filterNode = (value: string, data: any, node: any) => {
|
|
|
|
|
|
if (!value) return true
|
|
|
|
|
|
|
|
|
|
|
|
if (data.label) {
|
|
|
|
|
|
return chooseNode(value, data, node)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配,则返回该节点以及其下的所有子节点;如果参数是子节点,则返回该节点的父节点。label是中文字符,enlabel是英文字符.
|
|
|
|
|
|
const chooseNode = (value: string, data: any, node: any) => {
|
|
|
|
|
|
if (data.label.indexOf(value) !== -1) {
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
const level = node.level
|
|
|
|
|
|
// 如果传入的节点本身就是一级节点就不用校验了
|
|
|
|
|
|
if (level === 1) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
// 先取当前节点的父节点
|
|
|
|
|
|
let parentData = node.parent
|
|
|
|
|
|
// 遍历当前节点的父节点
|
|
|
|
|
|
let index = 0
|
|
|
|
|
|
while (index < level - 1) {
|
|
|
|
|
|
// 如果匹配到直接返回,此处label值是中文字符,enlabel是英文字符。判断匹配中英文过滤
|
|
|
|
|
|
if (parentData.data.label.indexOf(value) !== -1) {
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
// 否则的话再往上一层做匹配
|
|
|
|
|
|
parentData = parentData.parent
|
|
|
|
|
|
index++
|
|
|
|
|
|
}
|
|
|
|
|
|
// 没匹配到返回false
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
2024-05-13 18:36:19 +08:00
|
|
|
|
|
2024-05-14 15:21:37 +08:00
|
|
|
|
const open = async (text: string, tempData?: any) => {
|
2024-06-18 16:38:33 +08:00
|
|
|
|
title.value = text
|
|
|
|
|
|
//终端
|
|
|
|
|
|
await getTerminalSelectTree(4).then(res => {
|
|
|
|
|
|
deviceList.value = res.data
|
|
|
|
|
|
})
|
|
|
|
|
|
sourceData.value = deviceList.value
|
|
|
|
|
|
data.value = deviceList.value
|
|
|
|
|
|
if (tempData) {
|
|
|
|
|
|
// 表单赋值
|
|
|
|
|
|
for (let key in form.value) {
|
|
|
|
|
|
form.value[key] = tempData[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
form.value.deviceType = form.value.deviceType + ''
|
|
|
|
|
|
changeDevStatus(form.value.deviceId, true)
|
2024-06-20 16:54:19 +08:00
|
|
|
|
form.value.devStatus = tempData.devStatus != null ? tempData.devStatus + '' : ''
|
2024-06-18 16:38:33 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
resetForm()
|
|
|
|
|
|
// 在此处恢复默认表单
|
|
|
|
|
|
for (let key in form.value) {
|
|
|
|
|
|
form.value[key] = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
runFlag.value = ''
|
|
|
|
|
|
form.value.deviceType = '1'
|
2024-05-13 18:36:19 +08:00
|
|
|
|
}
|
2024-06-04 18:36:17 +08:00
|
|
|
|
form.value.deviceType = '1'
|
2024-06-18 16:38:33 +08:00
|
|
|
|
|
|
|
|
|
|
// changeType(form.value.deviceType)
|
|
|
|
|
|
dialogVisible.value = true
|
2024-05-13 18:36:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 提交用户表单数据
|
|
|
|
|
|
*/
|
2024-06-19 19:37:39 +08:00
|
|
|
|
const submit = (flag: boolean) => {
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
|
form.value.saveOrCheckflag = '1'
|
|
|
|
|
|
|
|
|
|
|
|
addRunningDevice(form.value).then(res => {
|
|
|
|
|
|
ElMessage.success('保存成功!')
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
formRef.value.validate(async (valid: any) => {
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
form.value.saveOrCheckflag = '2'
|
|
|
|
|
|
if (form.value.devOriginalStatus == form.value.devStatus) {
|
|
|
|
|
|
if (form.value.devOriginalStatus == '0') {
|
|
|
|
|
|
ElMessage.warning('终端当前状态就是运行,无需变更!')
|
|
|
|
|
|
} else if (form.value.devOriginalStatus == '1') {
|
|
|
|
|
|
ElMessage.warning('终端当前状态就是检修,无需变更!')
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ElMessage.warning('终端当前状态就是退运,无需变更!')
|
|
|
|
|
|
}
|
2024-06-18 16:38:33 +08:00
|
|
|
|
} else {
|
2024-06-19 19:37:39 +08:00
|
|
|
|
if (form.value.id) {
|
|
|
|
|
|
await quitRunningDeviceUpdate(form.value).then(res => {
|
|
|
|
|
|
ElMessage.success('重新发起成功')
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
await addRunningDevice(form.value).then(res => {
|
|
|
|
|
|
//查询进线数据,避免一直处于loading状态
|
|
|
|
|
|
ElMessage.success('申请成功')
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2024-06-18 16:38:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-19 19:37:39 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
2024-05-13 18:36:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-14 15:21:37 +08:00
|
|
|
|
/**
|
2024-06-13 13:32:50 +08:00
|
|
|
|
* 终端类型切换
|
2024-05-14 15:21:37 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
const changeType = (event: any) => {
|
2024-06-18 16:38:33 +08:00
|
|
|
|
sourceData.value = deviceList.value
|
|
|
|
|
|
form.value.deviceId = ''
|
|
|
|
|
|
data.value = sourceData.value
|
2024-06-04 18:36:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-18 16:38:33 +08:00
|
|
|
|
const changeDevStatus = async (event: any, flag?: boolean) => {
|
|
|
|
|
|
await getDeviceDetailData(event).then(res => {
|
|
|
|
|
|
//给当前终端赋值初始运行状态
|
|
|
|
|
|
runFlag.value = res.data.runFlag + ''
|
2024-06-19 19:37:39 +08:00
|
|
|
|
form.value.devOriginalStatus = runFlag.value
|
2024-06-18 16:38:33 +08:00
|
|
|
|
if (!flag) form.value.devStatus = ''
|
|
|
|
|
|
devStatuData.value = devStatusList.value.filter(item => item.value != res.data.runFlag)
|
|
|
|
|
|
})
|
2024-05-14 15:21:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-13 18:36:19 +08:00
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2024-06-06 22:14:20 +08:00
|
|
|
|
<style scoped lang="scss">
|
2024-05-13 18:36:19 +08:00
|
|
|
|
.el-upload-list__item {
|
2024-06-18 16:38:33 +08:00
|
|
|
|
transition: none !important;
|
2024-05-13 18:36:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-select {
|
2024-06-18 16:38:33 +08:00
|
|
|
|
min-width: 180px;
|
2024-05-13 18:36:19 +08:00
|
|
|
|
}
|
2024-06-18 16:38:33 +08:00
|
|
|
|
::v-deep .el-tree-node__children > div {
|
2024-06-06 22:14:20 +08:00
|
|
|
|
display: block !important;
|
|
|
|
|
|
}
|
2024-08-21 16:05:06 +08:00
|
|
|
|
:deep(.el-select__input) {
|
|
|
|
|
|
width: 100% !important;
|
|
|
|
|
|
}
|
2024-05-13 18:36:19 +08:00
|
|
|
|
</style>
|