|
|
@@ -5,7 +5,12 @@
|
|
|
<h1 class="header-title">工况模拟监控</h1>
|
|
|
<div class="panel">
|
|
|
<template v-for="item in faultList" :key="item.value">
|
|
|
- <device-item :item="{ id: item.value, title: item.label, isRunning: deviceStatus[item.value] ?? true }" @update:start="handleStart" @update:stop="handleStop" />
|
|
|
+ <device-item
|
|
|
+ :showButton="isDevice(item.value)"
|
|
|
+ :item="{ id: item.value, title: item.label, isRunning: deviceStatus[item.value] ?? true }"
|
|
|
+ @update:start="handleStart"
|
|
|
+ @update:stop="handleStop"
|
|
|
+ />
|
|
|
</template>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -16,22 +21,30 @@
|
|
|
import DeviceItem from './device-item.vue'
|
|
|
import { useDictStore } from '@/store/modules/dict'
|
|
|
import { DictItem } from '@/api/dict.api'
|
|
|
+ import request from '@/api'
|
|
|
|
|
|
const dictStore = useDictStore()
|
|
|
-
|
|
|
+ // 设备控制
|
|
|
+ const deviceList = ref<DictItem[]>([])
|
|
|
+ // 故障列表
|
|
|
const faultList = ref<DictItem[]>([])
|
|
|
const listFaultList = async (line: string = '556') => {
|
|
|
- const list = await dictStore.getDictByType(`FaultSetStatus_${line}`)
|
|
|
- faultList.value = list
|
|
|
+ faultList.value = (await dictStore.getDictByType(`FaultSetStatus_${line}`)) ?? []
|
|
|
+ deviceList.value = (await dictStore.getDictByType(`FaultSetCtrl_${line}`)) ?? []
|
|
|
}
|
|
|
+ const isDevice = (id: string) => deviceList.value.some((item) => item.value === id)
|
|
|
|
|
|
// 设备状态
|
|
|
const deviceStatus = ref<Record<string, boolean>>({})
|
|
|
- const handleStart = (id: string) => {
|
|
|
+ const handleStart = async (id: string) => {
|
|
|
deviceStatus.value[id] = true
|
|
|
+ await request.post('/serverctrl/seteqpmtfault', { EqpmtStrID: id, EventType: 1, EventId: Number(id) })
|
|
|
+ ElMessage.success(`设置故障[${id}]成功`)
|
|
|
}
|
|
|
- const handleStop = (id: string) => {
|
|
|
+ const handleStop = async (id: string) => {
|
|
|
deviceStatus.value[id] = false
|
|
|
+ await request.post('/serverctrl/seteqpmtfault', { EqpmtStrID: id, EventType: 2, EventId: Number(id) })
|
|
|
+ ElMessage.success(`取消故障[${id}]成功`)
|
|
|
}
|
|
|
|
|
|
const [Dialog, dialogApi] = useDialog({
|
|
|
@@ -43,9 +56,6 @@
|
|
|
closeOnClickModal: true,
|
|
|
closeOnPressEscape: true
|
|
|
})
|
|
|
- onMounted(() => {
|
|
|
- listFaultList()
|
|
|
- })
|
|
|
defineExpose({
|
|
|
show(line: string) {
|
|
|
dialogApi.setState({ title: `工况设置 - ${line}` })
|