Просмотр исходного кода

fix(useTimer): 修复计时器结束时未重置秒数的问题

fix(list-referee): 仅在已操作时显示操作得分滑块
feat(device-item): 添加showButton属性控制按钮显示
refactor(device-list): 重构设备控制逻辑,添加API调用和状态提示

重构设备列表页面,分离可控制设备与故障设备,添加API调用和操作反馈。
zhanghaijun месяцев назад: 9
Родитель
Сommit
8e0644e6d8

+ 1 - 0
src/composables/useTimer.ts

@@ -37,6 +37,7 @@ export const useTimer = () => {
   const end = () => {
     if (timerStatus.value === 'noStart') return
     clearTimer()
+    secondsNumber.value = 0
     timerStatus.value = 'noStart'
   }
 

+ 2 - 1
src/views/train/evaluation/list-referee.vue

@@ -2,7 +2,7 @@
   <ArtTable ref="refereeTableRef" :loading="refereeLoading" :data="refereeData" :columns="refereeColumns" empty-height="360px">
     <!-- 操作得分 -->
     <template #operScore="{ row }">
-      <div class="my-slider">
+      <div v-if="row.isOperated == '1'" class="my-slider">
         <div class="my-slider__tooltip" :style="style(row.operScore, Math.max(0, row.evaDeduction), row.evaScore)">
           <el-button class="my-slider__tooltip-wrapper" size="small">
             {{ row.operScore }}
@@ -17,6 +17,7 @@
           @change="saveRefereeRow(row, 'operScore', '操作得分已修改')"
         ></el-slider>
       </div>
+      <div v-else>{{ row.operScore }}</div>
     </template>
     <!-- 是否失格项 -->
     <template #disqualificationItem="{ row }">

+ 4 - 3
src/views/train/fault/device-item.vue

@@ -4,8 +4,8 @@
     <div class="panel-content">
       <div class="status-indicator" :class="{ 'status-normal': deviceStatus === '正常', 'status-abnormal': deviceStatus === '异常' }" :aria-label="`状态:${deviceStatus}`"></div>
       <div class="control-buttons">
-        <button class="btn btn-start cursor-pointer" :class="{ active: item.isRunning }" :aria-pressed="item.isRunning" @click="emits('update:start', item.id)"> 启 </button>
-        <button class="btn btn-stop cursor-pointer" :class="{ active: !item.isRunning }" :aria-pressed="!item.isRunning" @click="emits('update:stop', item.id)"> 停 </button>
+        <button v-if="showButton" class="btn btn-start cursor-pointer" :class="{ active: item.isRunning }" :aria-pressed="item.isRunning" @click="emits('update:start', item.id)"> 启 </button>
+        <button v-if="showButton" class="btn btn-stop cursor-pointer" :class="{ active: !item.isRunning }" :aria-pressed="!item.isRunning" @click="emits('update:stop', item.id)"> 停 </button>
       </div>
     </div>
   </div>
@@ -13,6 +13,7 @@
 
 <script setup lang="ts">
   interface ItemProps {
+    showButton: boolean
     item: {
       id: string
       title: string
@@ -21,7 +22,7 @@
     }
   }
 
-  const props = withDefaults(defineProps<ItemProps>(), {})
+  const props = withDefaults(defineProps<ItemProps>(), { showButton: true })
   const emits = defineEmits<{
     (e: 'update:start', id: string): void
     (e: 'update:stop', id: string): void

+ 19 - 9
src/views/train/fault/device-list.vue

@@ -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}` })