Explorar el Código

feat: 优化课程运行相关功能及界面

- 在operation_drawer.vue中添加nextTick处理模板变更
- 修改dict.api.ts中字典项查询不显示错误消息
- 在device-list.vue中增加线路参数支持
- 更新course.schema.ts中运行图选项的动态过滤
- 调整trainer_run界面按钮颜色和状态显示
- 重构fault/index.vue中的线路图加载逻辑,支持动态切换
zhanghaijun hace 9 meses
padre
commit
ae48b2b732

+ 1 - 1
src/api/dict.api.ts

@@ -33,7 +33,7 @@ export class DictService {
 /** 字典项查询 */
 export class DictItemService {
   // 获取字典项列表
-  static dictItemList = async (dictCode: string) => request.get<DictItem[]>('/system/dict/item/list', { dictCode })
+  static dictItemList = async (dictCode: string) => request.get<DictItem[]>('/system/dict/item/list', { dictCode }, { showErrorMessage: false })
   // 分页查询
   static page = (params: any) => request.postPage<DictItem[]>('/system/dict/item/list', params)
   // 详情

+ 3 - 0
src/components/business/EasyProcess/node/operation_drawer.vue

@@ -211,6 +211,9 @@
         deduction: Number(operationNode?.deduction || 0),
         subjectiveEvaluation: String(operationNode?.subjectiveEvaluation || '0')
       })
+      nextTick(() => {
+        handleTemplateChange(String(operationNode?.templateID || ''))
+      })
     })
   })
 

+ 19 - 1
src/views/train/course/detail/course.schema.ts

@@ -39,7 +39,25 @@ export const courseSchema: FormItemSchema[] = [
   { prop: 'typeID', label: '课程分类', component: 'ApiDict', componentProps: { code: 'course_category' }, colSpan: 6 },
   { prop: 'externalTypeID', label: '外部分类ID', component: 'Input', colSpan: 6 },
   { prop: 'lineNo', label: '线路号', component: 'ApiDict', componentProps: { code: 'course_line' }, colSpan: 6 },
-  { prop: 'runningMap', label: '运行图', component: 'ApiDict', componentProps: { code: 'course_run_map' }, colSpan: 6 },
+  {
+    prop: 'runningMap',
+    label: '运行图',
+    component: 'ApiDict',
+    componentProps: (values) => {
+      // return { code: 'course_run_map' }
+      const items = [
+        { label: '金州-扶余运行图', value: '555001', lineNo: '555' },
+        { label: '小城子-乌兰浩特运行图', value: '556001', lineNo: '556' },
+        { label: '四平东-实训基地运行图', value: '557001', lineNo: '557' }
+      ]
+      let l = items.filter((item) => item.lineNo == values.lineNo)
+      if (l.length == 0) l = items
+      return {
+        options: l.map((item) => ({ label: item.label, value: item.value }))
+      }
+    },
+    colSpan: 6
+  },
   { prop: 'guideDesc', label: '指导描述', component: 'Input', colSpan: 12 },
   { prop: 'guideFilePath', label: '指导文件地址', component: 'Upload', colSpan: 12 },
   { prop: 'creator', label: '创建人', component: 'Span', colSpan: 6 },

+ 9 - 5
src/views/train/course/trainer_run/index.vue

@@ -30,15 +30,19 @@
       <div class="flex w-[320px] flex-col gap-4">
         <div class="run-action relative">
           <div class="status-header mt-8 ml-6">
-            <div class="status-indicator" :style="timerStatus === 'noStart' ? 'background-color: #FF4D4F' : timerStatus === 'running' ? 'background-color: #409EFF' : 'background-color: #E6A23C'">
+            <div class="status-indicator" :style="timerStatus === 'noStart' ? 'background-color: #f5222d' : timerStatus === 'running' ? 'background-color: #389e0d' : 'background-color: #d2d23c'">
             </div>
             <h3 class="status-title">{{ timerStatus === 'noStart' ? '课程未开始' : timerStatus === 'running' ? '课程运行中' : '课程已暂停' }}</h3>
           </div>
           <div v-if="!runStatus || runStatus?.runCourseID === Number(courseId)" class="absolute right-[10px] bottom-[20px] left-[10px] flex items-center justify-center">
-            <el-button v-if="timerStatus === 'noStart'" type="primary" @click="courseStart">开始课程</el-button>
-            <el-button v-else-if="timerStatus === 'running'" type="primary" @click="coursePause">暂停课程</el-button>
-            <el-button v-else-if="timerStatus === 'paused'" type="primary" @click="courseResume">恢复课程</el-button>
-            <el-button type="primary" :disabled="timerStatus === 'noStart'" @click="courseReset">结束课程</el-button>
+            <!-- 深绿 -->
+            <el-button v-if="timerStatus === 'noStart'" type="primary" style="background-color: #389e0d !important; color: #fff" @click="courseStart">开始课程</el-button>
+            <!-- 深蓝 -->
+            <el-button v-else-if="timerStatus === 'running'" type="primary" style="background-color: #d2d23c !important; color: #fff" @click="coursePause">暂停课程</el-button>
+            <!-- 深蓝 -->
+            <el-button v-else-if="timerStatus === 'paused'" type="primary" style="background-color: #d2d23c !important; color: #fff" @click="courseResume">恢复课程</el-button>
+            <!-- 红色 -->
+            <el-button type="primary" :disabled="timerStatus === 'noStart'" style="background-color: #f5222d !important; color: #fff" @click="courseReset">结束课程</el-button>
           </div>
           <div v-else class="course-running-status">
             <div class="status-content">

+ 8 - 4
src/views/train/fault/device-list.vue

@@ -20,8 +20,8 @@
   const dictStore = useDictStore()
 
   const faultList = ref<DictItem[]>([])
-  const listFaultList = async () => {
-    const list = await dictStore.getDictByType('FaultSetStatus_556')
+  const listFaultList = async (line: string = '556') => {
+    const list = await dictStore.getDictByType(`FaultSetStatus_${line}`)
     faultList.value = list
   }
 
@@ -47,8 +47,12 @@
     listFaultList()
   })
   defineExpose({
-    show() {
-      dialogApi.open()
+    show(line: string) {
+      dialogApi.setState({ title: `工况设置 - ${line}` })
+      listFaultList(line)
+      nextTick(() => {
+        dialogApi.open()
+      })
     }
   })
 </script>

+ 36 - 39
src/views/train/fault/index.vue

@@ -20,56 +20,53 @@
   defineOptions({ name: 'Device' })
   import Meta2dView from '@/components/business/meta2d/Meta2dView.vue'
   import { useCourseRun } from '@/views/train/course/course.helper'
-  // import dataJson from './device.json'
   import FaultList from './fault-list.vue'
   import DeviceList from './device-list.vue'
-  const { runConrseLine, runConrseStation } = useCourseRun()
+  const { runConrseLine } = useCourseRun()
 
-  watch(runConrseLine, loadJson)
-  watch(runConrseStation, loadJson)
-
-  // ---------- 下拉选择主线路图
-  const isManual = ref<boolean>(false)
-  const deviceActive = ref<string>('0')
-  const deviceOptions = [
-    { value: '0', label: '小合隆' },
-    { value: '1', label: '长春西' },
-    { value: '2', label: '实训基地' }
-  ]
-  watch(deviceActive, () => {
-    isManual.value = true
-    loadJson()
-  })
-
-  // -------- 主线路图的数据配置
+  // ---------- 线路图 ----------
+  const dataJson = ref<any>(null)
   const deviceList = [
-    { index: '0', value: 'device.json', line: '555', station: '1' },
-    { index: '1', value: 'device.001.json', line: '556', station: '35' },
-    { index: '2', value: 'device.002.json', line: '557', station: '36' }
+    { value: '0', label: '小合隆', draw: 'device.json', line: '555', station: '555001' },
+    { value: '1', label: '长春西', draw: 'device.001.json', line: '556', station: '556001' },
+    { value: '2', label: '实训基地', draw: 'device.002.json', line: '556', station: '556001' }
   ]
-  const getCurrentDevice = () => {
-    if (isManual.value) {
-      return deviceList.find((item) => item.index == deviceActive.value) || deviceList[0]
-    }
-    const device = deviceList.find((item) => item.station == runConrseStation.value && item.line == runConrseLine.value) || deviceList[0]
-    deviceActive.value = device.index
-    return device
-  }
+  // ---------- 线路图:下拉 ----------
+  const deviceActive = ref<string>('0')
+  const deviceOptions = ref<{ value: string; label: string }[]>(deviceList.map((item) => ({ value: item.value, label: item.label })))
 
+  // ---------- 线路图:设备监控 ----------
   const faultListRef = ref()
-  const dataJson = ref<any>(null)
-  async function loadJson() {
-    const device = getCurrentDevice()
-    const url = `${import.meta.env.BASE_URL}${device.value}`
+  // ---------- 线路图:工况监控 ----------
+  const deviceListRef = ref()
+  const showDeviceList = () => {
+    deviceListRef.value?.show(runConrseLine.value)
+  }
+  // -------- ----------
+  const updateDraw = async (val: string = runConrseLine.value) => {
+    // 线路下拉
+    let l = deviceList.filter((item) => item.line == val)
+    if (l.length == 0) l = deviceList
+    deviceOptions.value = l.map((item) => ({ value: item.value, label: item.label }))
+    // 线路下拉选中
+    const device = l.find((item) => item.line == val) || l[0]
+    deviceActive.value = device.value
+    // 线路绘制
+    const url = `${import.meta.env.BASE_URL}${device.draw}`
     const res = await fetch(url)
     dataJson.value = await res.json()
   }
 
-  const deviceListRef = ref()
-  const showDeviceList = () => {
-    deviceListRef.value?.show()
-  }
-  onMounted(loadJson)
+  // 开课线路
+  watch(runConrseLine, async (val) => updateDraw(val))
+  // 下拉选中
+  watch(deviceActive, async (val) => {
+    const device = deviceList.find((item) => item.value == val) || deviceList[0]
+    const url = `${import.meta.env.BASE_URL}${device.draw}`
+    const res = await fetch(url)
+    dataJson.value = await res.json()
+  })
+  onMounted(() => updateDraw())
 </script>
 
 <style lang="scss" scoped></style>