From a35e1a8d806e7e9323665652c3ecc5ed22eddead Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Sat, 16 Aug 2025 10:34:56 +0800
Subject: [PATCH] Merge branch 'feature/v5.0/5.0.2' into feature/v5.0/5.0.3

---
 src/views/tickets/ticket.vue |  104 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 85 insertions(+), 19 deletions(-)

diff --git a/src/views/tickets/ticket.vue b/src/views/tickets/ticket.vue
index 72afd5c..db474cc 100644
--- a/src/views/tickets/ticket.vue
+++ b/src/views/tickets/ticket.vue
@@ -31,7 +31,7 @@
                 :value="item.value"
               />
             </el-select> -->
-            <el-select
+            <!-- <el-select
               v-model="filters.type"
               placeholder="请选择工单类型"
               class="filter-item"
@@ -44,7 +44,7 @@
                 :label="item.label"
                 :value="item.value"
               />
-            </el-select>
+            </el-select> -->
             <el-date-picker
               v-model="filters.dateRange"
               type="daterange"
@@ -69,7 +69,7 @@
                 :value="item.value"
               />
             </el-select>
-            <el-select
+            <!-- <el-select
               v-model="filters.algorithm"
               placeholder="请选择关联算法"
               class="filter-item"
@@ -82,7 +82,21 @@
                 :label="item.dict_value"
                 :value="item.dict_key"
               />
-            </el-select>
+            </el-select> -->
+            <el-tree-select
+              popper-class="custom-tree-select"
+              :style="{ width: pxToRem(186) }"
+              placeholder="请选择关联算法"
+              v-model="dictKey"
+              :data="dataList"
+              :default-expanded-keys="[dictKey]"
+              check-strictly
+              node-key="id"
+              :props="treePropsSF"
+              @node-click="handleSFNodeClick"
+              clearable
+              @clear="handleClear"
+          />
             <el-select
               v-model="filters.isReview"
               placeholder="请选择复核状态"
@@ -273,7 +287,7 @@
                   :disabled="!form.type"
                 >
                   <el-option
-                    v-for="item in algorithms"
+                    v-for="item in algorithms2"
                     :key="item.value"
                     :label="item.label"
                     :value="item.value"
@@ -464,7 +478,7 @@
                   class="required-input"
                 >
                   <el-option
-                    v-for="item in algorithms"
+                    v-for="item in algorithms2"
                     :key="item.value"
                     :label="item.label"
                     :value="item.value"
@@ -899,6 +913,7 @@
   getReviewById,
   getCreateEventJob,
 } from '@/api/tickets/ticket'
+import { getSFDictionaryTree  } from '@/api/job/task';
 import { export_json_to_excel } from '@/utils/exportExcel'
 import geoJson from '@/assets/geoJson.json'
 import { mapGetters } from 'vuex'
@@ -955,6 +970,7 @@
       ],
 
       algorithms: [],
+      algorithms2: [],
       statuses: [
         { label: '待审核', value: '2' },
         { label: '待处理', value: '0' },
@@ -1110,6 +1126,13 @@
 
       // 复核弹窗
       reCheckDialog: false,
+      treePropsSF: {
+        label: 'dictValue',
+        value: 'id',
+        children: 'children',
+      },
+      dictKey: '',
+      dataList: [],
     };
   },
   created() {
@@ -1122,6 +1145,8 @@
   },
 
   mounted() {
+
+    this.getAlgorithmList()
 
     const href = this.$route.href;
     if (this.$route?.query?.status !== undefined && this.$route?.query?.status !== null) {
@@ -1391,6 +1416,46 @@
   },
 
   methods: {
+    // 算法
+    getAlgorithmList() {
+      getSFDictionaryTree({code:'SF'}).then((res) => {
+          if (res.data.code === 200) {
+              const result = res.data.data[0].children
+              // 过滤第一层数据
+              const filteredData = result.map(item => {
+                  // 过滤第二层数据
+                  const children = item.children?.map(child => ({
+                      ...child,
+                      children: [] // 清空第三层数据
+                  }))
+                  return {
+                      ...item,
+                      children: children || []
+                  }
+              })
+              this.dataList = filteredData
+          }
+      })
+    },
+
+    handleSFNodeClick(data) {
+      this.filters.type = ''
+      this.filters.algorithm = ''
+        if (data.children && data.children.length) {
+            // 获取子节点dictKey
+            this.filters.type = data.dictKey
+        } else {
+            this.filters.algorithm = data.dictKey
+        }
+        // 更新列表请求
+        this.fetchTableData();
+    },
+    handleClear() {
+        this.dictKey = ''
+        this.filters.algorithm = ''
+         this.filters.type = ''
+        this.fetchTableData();
+    },
     handleCellClick(row, column) {
       console.log(row, column.no);
       if (column.no === 2) {
@@ -1555,14 +1620,16 @@
         console.log('工单类型',this.types);
         console.log('关联算法',this.allAlgorithms );
         // 确保算法数据的映射一致
-        // this.algorithms =
-        //   ai_type?.map(item => ({
-        //     dict_key: item.dict_key,
-        //     dict_value: item.dict_value,
-        //     // 同时添加 label 和 value 以兼容两处使用
-        //     label: item.dict_value,
-        //     value: item.dict_key,
-        //   })) || [];
+        this.algorithms =
+          ai_type?.map(item => ({
+            dict_key: item.dict_key,
+            dict_value: item.dict_value,
+            // 同时添加 label 和 value 以兼容两处使用
+            label: item.dict_value,
+            value: item.dict_key,
+          })) || [];
+
+        this.algorithms2 = _.cloneDeep(this.algorithms)
 
         // 构建用户ID和名称的映射关系
         this.userNameToIdMap = {};
@@ -1577,9 +1644,10 @@
     },
     // 工单类型变化时触发
     handleTypeChange(typeValue) {
+      this.form.algorithm = []
       if (!typeValue) {
         // 未选择类型时清空算法列表
-        this.algorithms = [];
+        this.algorithms2 = [];
         return;
       }
 
@@ -1589,13 +1657,11 @@
 
       if (!matchedCategory || !matchedCategory.algorithms || matchedCategory.algorithms.length === 0) {
         // 无匹配的算法时清空
-        this.algorithms = [];
+        this.algorithms2 = [];
         this.$message.info('该工单类型暂无关联算法');
         return;
       }
-// console.log('matchedCategory',matchedCategory);
-
-      this.algorithms = matchedCategory.algorithms.map(algo => ({
+      this.algorithms2 = matchedCategory.algorithms.map(algo => ({
         label: algo.dict_value,
         value: algo.dict_key,
         dict_key: algo.dict_key,

--
Gitblit v1.9.3