From 02409bfbe15f22fc3b5dccadabfd860a660a49d9 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Sat, 11 Oct 2025 10:37:14 +0800
Subject: [PATCH] feat: 名称修改

---
 src/views/job/components/SearchBox.vue |  175 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 130 insertions(+), 45 deletions(-)

diff --git a/src/views/job/components/SearchBox.vue b/src/views/job/components/SearchBox.vue
index 89ccc3c..2752438 100644
--- a/src/views/job/components/SearchBox.vue
+++ b/src/views/job/components/SearchBox.vue
@@ -23,6 +23,7 @@
             v-model="searchForm.device_sn"
             placeholder="请选择"
             clearable
+            @change="handleSearch"
           >
             <el-option
               v-for="item in machineData"
@@ -57,14 +58,43 @@
             </div>
           </div>
         </el-form-item>
+        <div class="more" v-if="isExpand" @click="toggleExpand">收起</div>
+        <div class="more" v-else @click="toggleExpand">更多</div>
+        <div class="search-btn" :style="{ bottom: isExpand ? '5px' : '-3px' }">
+          
+          <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
+          <el-button icon="el-icon-refresh" @click="handleReset">清空</el-button>
+        </div>
         <el-form-item label="任务算法:" v-if="isExpand" class="taskAlgorithm">
-          <TaskAlgorithmBusiness
-            :setWidth="222"
+          <!-- <TaskAlgorithmBusiness
+          ref="algorithmRef"
+            :setWidth="160"
             :showAlgorithm="true"
             @algorithmChange="algorithmChange"
+          /> -->
+          <el-tree-select
+          style="z-index: 1000"
+            :teleported="false"
+            class="custom-tree-select"
+            :style="{ width: pxToRem(186) }"
+            v-model="dictKey"
+            :data="dataList"
+            :default-expanded-keys="[dictKey]"
+            :props="treePropsSF"
+            :render-after-expand="false"
+            :default-checked-keys="checkedKeys"
+            node-key="id"
+            multiple
+            show-checkbox
+            collapse-tags
+            collapse-tags-tooltip
+            clearable
+            @node-click="handleNodeClick"
+            @check="handleCheck"
+            @clear="handleClear"
           />
         </el-form-item>
-        <el-form-item label="所属部门:" v-if="isExpand">
+        <!-- <el-form-item label="所属部门:" v-if="isExpand">
           <el-select
             :teleported="false"
             v-model="searchForm.create_dept"
@@ -78,9 +108,10 @@
               :value="item.id"
             />
           </el-select>
-        </el-form-item>
+        </el-form-item> -->
         <el-form-item label="任务状态:" v-if="isExpand">
           <el-select
+          style="z-index: 1000"
             :teleported="false"
             v-model="searchForm.status"
             placeholder="请选择"
@@ -88,6 +119,7 @@
             multiple
             collapse-tags
             collapse-tags-tooltip
+              @change="handleSearch"
           >
             <el-option
               v-for="item in statusOptions"
@@ -103,22 +135,12 @@
             v-model="searchForm.is_circle_job"
             placeholder="请选择"
             clearable
+            @change="handleSearch"
           >
             <el-option label="周期任务" :value="1" />
             <el-option label="临时任务" :value="0" />
           </el-select>
         </el-form-item>
-        <div class="more" v-if="isExpand" @click="toggleExpand">收起</div>
-        <div class="more" v-else @click="toggleExpand">更多</div>
-        <div class="search-btn" :style="{ bottom: isExpand ? '5px' : '-3px' }">
-          <div class="btn search" @click="handleSearch">
-            <img src="@/assets/images/task/search.png" />搜索
-          </div>
-          <div class="btn clear" @click="handleReset">
-            <img src="@/assets/images/task/clear.png" />清空
-          </div>
-          <!-- <div class="btn add" @click="addTask"><img src="@/assets/images/task/add.png"/>新增</div> -->
-        </div>
       </div>
     </el-form>
   </div>
@@ -126,8 +148,8 @@
 <script setup>
 import { pxToRem } from '@/utils/rem';
 import { ElMessage } from 'element-plus';
-import { deptsByAreaCode } from '@/api/job/task';
-import TaskAlgorithmBusiness from './TaskAlgorithmBusiness.vue';
+import { deptsByAreaCode, getSFDictionaryTree  } from '@/api/job/task';
+// import TaskAlgorithmBusiness from './TaskAlgorithmBusiness.vue';
 import dayjs from 'dayjs';
 import { useStore } from 'vuex';
 import { getRegionTreeAll } from '@/api/job/task';
@@ -136,6 +158,8 @@
 const store = useStore();
 const userAreaCode = computed(() => store.getters.userInfo.detail.areaCode);
 const selectedAreaCode = computed(() => store.state.user.selectedAreaCode);
+
+const algorithmRef = ref(null)
 const isExpand = ref(false);
 const toggleExpand = () => {
   isExpand.value = !isExpand.value;
@@ -153,7 +177,7 @@
   ai_types: [], // 算法类型
   area_code: userAreaCode.value, // 区域code
   create_dept: '', // 创建部门
-  date_enum: 'TODAY', // 日期枚举,可用值:TODAY,CURRENT_WEEK,CURRENT_MONTH,CURRENT_YEAR
+  date_enum: 'CURRENT_MONTH', // 日期枚举,可用值:TODAY,CURRENT_WEEK,CURRENT_MONTH,CURRENT_YEAR
   device_sn: '', // 设备编号
   end_date: null, // 结束时间
   industry_type: '', // 行业key
@@ -179,6 +203,7 @@
 
 const algorithmChange = val => {
   searchForm.ai_types = val;
+  handleSearch()
 };
 
 const businessChange = val => {
@@ -209,6 +234,52 @@
   });
 };
 
+// 算法
+const treePropsSF = {
+    label: 'dictValue',
+    value: 'id',
+    children: 'children',
+}
+const dictKey = ref('')
+const dataList = ref([])
+function 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 || []
+              }
+          })
+          dataList.value = filteredData
+      }
+  })
+}
+
+function handleSFNodeClick(data) {
+    if (data.children && data.children.length) {
+        // 获取子节点dictKey
+        const childDictKeys = data.children.map(child => child.dictKey)
+        searchForm.ai_types = childDictKeys
+    } else {
+        searchForm.ai_types = [data.dictKey]
+    }
+    // 更新列表
+    handleSearch()
+}
+function handleClear() {
+    dictKey.value = ''
+    searchForm.ai_types = []
+    handleSearch()
+}
+
 const handleNodeClick = async data => {
   // 处理机巢数据
   searchForm.device_sn = '';
@@ -225,21 +296,25 @@
   searchForm.create_dept = '';
   deptData.value = [];
   getDeptsByAreaCode();
+  handleSearch();
 };
 
 // 日期 和周期
 let timeList = ['today', 'week', 'month', 'year'];
 let timeListStr = ['今日', '本周', '本月', '本年'];
 let timeListEnum = ['TODAY', 'CURRENT_WEEK', 'CURRENT_MONTH', 'CURRENT_YEAR'];
-let checked = ref('today');
+let checked = ref('month');
 
 let timeClick = (item, index) => {
-  checked.value = item;
-  // dateRange.value = dateRanges[item];
-  dateRange.value = [];
-  // emit('change', dateRanges[item],timeListEnum[index]);
-  searchForm.date_enum = timeListEnum[index];
-  handleSearch();
+  if (checked.value === item){
+    checked.value = null
+    searchForm.date_enum = undefined
+  }else{
+    checked.value = item
+    searchForm.date_enum = timeListEnum[index]
+  }
+  dateRange.value = []
+  handleSearch()
 };
 // 搜索
 const handleSearch = () => {
@@ -265,18 +340,9 @@
   emit('search', params);
 };
 const handleDateChange = val => {
-  if (val && val.length === 2) {
-    const start = dayjs(val[0]);
-    const end = dayjs(val[1]);
-    const diff = end.diff(start, 'day');
-
-    if (diff > 31) {
-      ElMessage.warning('日期范围不能超过31天');
-      dateRange.value = [];
-      return;
-    }
-  }
-  handleSearch();
+  checked.value = null
+  searchForm.date_enum = undefined
+  handleSearch()
 };
 
 // 重置
@@ -286,9 +352,13 @@
     searchForm[key] = '';
   });
   searchForm.ai_types = [];
-  searchForm.date_enum = 'TODAY';
+  searchForm.date_enum = 'CURRENT_MONTH';
   searchForm.area_code = userAreaCode.value;
-  checked.value = 'today';
+  checked.value = 'month';
+  signDevice_sn.value = ''
+  // 清除算法
+  dictKey.value = '';
+	// algorithmRef.value?.clear()
   handleNodeClick({ id: userAreaCode.value });
   handleSearch();
 };
@@ -302,7 +372,7 @@
 // watch(
 //   () => store.state.task.jumpTask,
 //   newVal => {
- 
+
 //     if (newVal && Object.keys(newVal).length) {
 //       // 兼容当日任务 计划任务 历史任务传参
 //       if (newVal.clickValue) {
@@ -329,6 +399,16 @@
 //   { immediate: true, deep: true }
 // );
 
+const checkedKeys = ref([])
+
+const handleCheck = (data, { checkedKeys, checkedNodes }) => {
+	dictKey.value = checkedKeys
+	// 获取所有选中节点的 dictKey
+	const selectedDictKeys = checkedNodes.map(node => node.dictKey).filter(Boolean)
+  searchForm.ai_types = selectedDictKeys
+  handleSearch()
+}
+
 onBeforeUnmount(() => {
   checked.value = 'today';
   searchForm.date_enum = 'TODAY';
@@ -336,6 +416,7 @@
 
 onMounted(() => {
   requestDockInfo();
+  getAlgorithmList();
   // 日历传值
   const calendarday = ref(route.query.day);
 
@@ -343,10 +424,12 @@
     const date = dayjs(calendarday.value).format(timeFormat);
 
     const dateArray = [date, date];
-  
+
     dateRange.value = dateArray;
+    const find = store.state.tags.bsTagList.find(i => i.path === '/job/jobstatistics')
+          find && (find.query = {})
   }
-    // 查询一次
+      // 查询一次
     handleSearch()
 });
 </script>
@@ -367,7 +450,7 @@
     display: flex;
     flex-wrap: wrap;
     align-items: center;
-    gap: 20px 12px; // 设置行间距和列间距
+    gap: 20px 15px; // 设置行间距和列间距
 
     .more {
       cursor: pointer;
@@ -376,11 +459,12 @@
       color: #1c5cff;
       line-height: 32px;
       font-size: 16px;
+      margin: 0 28px;
     }
 
     .search-btn {
-      position: absolute;
-      right: 0;
+      // position: absolute;
+      // right: 0;
       display: flex;
       justify-content: space-between;
       cursor: pointer;
@@ -394,6 +478,7 @@
         display: flex;
         justify-content: center;
         align-items: center;
+        // margin-left: px;
         img {
           width: 14px;
           height: 14px;

--
Gitblit v1.9.3