From e06c9706ca3735b7abb26e2f70b7dda23d791494 Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Fri, 15 Aug 2025 14:38:19 +0800
Subject: [PATCH] feat:更新树状算法
---
src/views/job/components/SearchBox.vue | 66 +++++++++++++++++++++-
src/views/tickets/ticket.vue | 72 ++++++++++++++++++++++-
src/api/job/task.js | 10 +++
3 files changed, 141 insertions(+), 7 deletions(-)
diff --git a/src/api/job/task.js b/src/api/job/task.js
index fda4ed7..a0cb20a 100644
--- a/src/api/job/task.js
+++ b/src/api/job/task.js
@@ -225,6 +225,16 @@
})
}
+export const getSFDictionaryTree = (params) => {
+ return request({
+ url: '/blade-system/dict-biz/dictionary-tree',
+ method: 'get',
+ params: {
+ ...params,
+ },
+ });
+ };
+
// 生成固定uuid
const uuid = uuidv4()
// 轮询刷新
diff --git a/src/views/job/components/SearchBox.vue b/src/views/job/components/SearchBox.vue
index 89ac36e..f374b37 100644
--- a/src/views/job/components/SearchBox.vue
+++ b/src/views/job/components/SearchBox.vue
@@ -70,11 +70,24 @@
<!-- <div class="btn add" @click="addTask"><img src="@/assets/images/task/add.png"/>新增</div> -->
</div>
<el-form-item label="任务算法:" v-if="isExpand" class="taskAlgorithm">
- <TaskAlgorithmBusiness
+ <!-- <TaskAlgorithmBusiness
ref="algorithmRef"
:setWidth="160"
:showAlgorithm="true"
@algorithmChange="algorithmChange"
+ /> -->
+ <el-tree-select
+ popper-class="custom-tree-select"
+ :style="{ width: pxToRem(186) }"
+ v-model="dictKey"
+ :data="dataList"
+ :default-expanded-keys="[dictKey]"
+ check-strictly
+ node-key="id"
+ :props="treePropsSF"
+ @node-click="handleSFNodeClick"
+ clearable
+ @clear="handleClear"
/>
</el-form-item>
<!-- <el-form-item label="所属部门:" v-if="isExpand">
@@ -130,8 +143,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';
@@ -215,6 +228,52 @@
handleNodeClick({ id: userAreaCode.value });
});
};
+
+// 算法
+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 => {
// 处理机巢数据
@@ -340,6 +399,7 @@
onMounted(() => {
requestDockInfo();
+ getAlgorithmList();
// 日历传值
const calendarday = ref(route.query.day);
diff --git a/src/views/tickets/ticket.vue b/src/views/tickets/ticket.vue
index 87c2bf8..86165c6 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="请选择复核状态"
@@ -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'
@@ -1111,6 +1126,13 @@
// 复核弹窗
reCheckDialog: false,
+ treePropsSF: {
+ label: 'dictValue',
+ value: 'id',
+ children: 'children',
+ },
+ dictKey: '',
+ dataList: [],
};
},
created() {
@@ -1123,6 +1145,8 @@
},
mounted() {
+
+ this.getAlgorithmList()
const href = this.$route.href;
if (this.$route?.query?.status !== undefined && this.$route?.query?.status !== null) {
@@ -1392,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) {
--
Gitblit v1.9.3