From 2de83496f3ac13c63b45c5c93e37b4bb044522c3 Mon Sep 17 00:00:00 2001
From: dongyukun <1208714201@qq.com>
Date: 星期三, 06 十一月 2024 09:35:15 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/data/plan/item/ItemForm.vue |   34 ++++++++++++++++++++++------------
 1 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/src/views/data/plan/item/ItemForm.vue b/src/views/data/plan/item/ItemForm.vue
index 0fdf58b..97257c2 100644
--- a/src/views/data/plan/item/ItemForm.vue
+++ b/src/views/data/plan/item/ItemForm.vue
@@ -22,14 +22,14 @@
       <el-row>
         <el-col :span="12">
           <el-form-item label="计划分类" prop="itemCategory">
-            <el-select v-model="formData.itemCategory" clearable placeholder="请选择计划分类">
-              <el-option
-                v-for="item in dataCategoryList"
-                :key="item.id"
-                :label="item.label"
-                :value="item.id + ''"
-              />
-            </el-select>
+            <el-tree-select
+              v-model="formData.itemCategory"
+              :data="categoryTree"
+              :default-expanded-keys="[0]"
+              :props="defaultProps"
+              check-strictly
+              node-key="id"
+            />
           </el-form-item>
         </el-col>
         <el-col :span="12">
@@ -46,7 +46,7 @@
         </el-col>
       </el-row>
       <el-row>
-        <el-col :span="6">
+        <el-col :span="12">
           <el-form-item label="数据集" prop="dataSet">
             <el-select v-model="formData.dataSet" clearable placeholder="请选择数据集" @change="handleDataSetChange($event)">
               <el-option
@@ -76,6 +76,8 @@
 import { CommonStatusEnum } from '@/utils/constants'
 import * as DataSetApi from "@/api/data/plan/data";
 import * as CategoryApi from "@/api/data/plan/category";
+import {defaultProps} from "@/api/data/plan/category";
+import {handleTree} from "@/utils/tree";
 
 defineOptions({ name: 'PlanItemForm' })
 
@@ -103,7 +105,15 @@
 })
 const formRef = ref() // 表单 Ref
 const dataSetList = ref([] as DataSetApi.DataSetVO[])
-const dataCategoryList = ref([])
+
+const categoryTree = ref<Tree[]>([])
+const getCategoryTree = async () => {
+  categoryTree.value = []
+  const res = await CategoryApi.getCategoryListAllSimple()
+  let category: Tree = { id: 0, label: '主类目', children: [] }
+  category.children = handleTree(res, 'id', 'pid')
+  categoryTree.value.push(category)
+}
 
 /** 打开弹窗 */
 const open = async (type: string, id?: number) => {
@@ -113,8 +123,8 @@
   resetForm()
   // 加载数据源列表
   dataSetList.value = await DataSetApi.getDataSetList()
-  dataCategoryList.value = await CategoryApi.getCategoryListAllSimple()
-
+  // 加载类别
+  await getCategoryTree()
   // 修改时,设置数据
   if (id) {
     formLoading.value = true

--
Gitblit v1.9.3