From 1220f5ca98b10b735a47c37a81fbfc554b01e2fe Mon Sep 17 00:00:00 2001
From: liriming <1343021927@qq.com>
Date: 星期一, 20 一月 2025 14:41:35 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/data/ind/item/DerIndDefineForm.vue |   97 +++++++++++++++++++++++++++++-------------------
 1 files changed, 58 insertions(+), 39 deletions(-)

diff --git a/src/views/data/ind/item/DerIndDefineForm.vue b/src/views/data/ind/item/DerIndDefineForm.vue
index f16a4ea..dc35975 100644
--- a/src/views/data/ind/item/DerIndDefineForm.vue
+++ b/src/views/data/ind/item/DerIndDefineForm.vue
@@ -7,26 +7,6 @@
       :rules="formRules" label-width="100px">
       <el-row>
         <el-col :span="12">
-          <el-form-item label="原子指标" prop="atomItem.id">
-            <el-select v-model="selected" clearable placeholder="请选择原子指标"
-                       @change="handleChange($event)">
-              <el-option
-                v-for="item in atomItemList"
-                :key="item.id"
-                :label="item.itemNo"
-                :value="item.id"
-              />
-            </el-select>
-          </el-form-item>
-        </el-col>
-        <el-col :span="12">
-          <el-form-item label="原子指标名称" prop="atomItem.itemName">
-            <el-input v-model="formData.atomItem.itemName" disabled/>
-          </el-form-item>
-        </el-col>
-      </el-row>
-      <el-row>
-        <el-col :span="12">
           <el-form-item label="指标编码" prop="itemNo">
             <el-input v-model="formData.itemNo" disabled/>
           </el-form-item>
@@ -39,15 +19,36 @@
       </el-row>
       <el-row>
         <el-col :span="12">
-          <el-form-item label="指标分类" prop="itemCategory">
-            <el-select v-model="formData.itemCategory" clearable placeholder="请选择指标分类">
+          <el-form-item label="原子指标" prop="atomItem.itemId">
+            <el-select v-model="formData.atomItem.itemId" filterable
+                       allow-create clearable placeholder="请选择原子指标"
+                       @change="handleChange($event)">
               <el-option
-                v-for="item in dataCategoryList"
+                v-for="item in atomItemList"
                 :key="item.id"
-                :label="item.label"
+                :label="item.itemNo"
                 :value="item.id + ''"
               />
             </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="原子指标名称" prop="atomItem.itemName">
+            <el-input v-model="formData.atomItem.itemName" disabled/>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="12">
+          <el-form-item label="指标分类" prop="itemCategory">
+            <el-tree-select
+              v-model="formData.itemCategory"
+              :data="dataCategoryList"
+              :default-expanded-keys="[0]"
+              :props="defaultProps"
+              check-strictly
+              node-key="id"
+            />
           </el-form-item>
         </el-col>
         <el-col :span="12">
@@ -83,19 +84,19 @@
       <el-row>
         <el-col :span="6">
           <el-form-item label="时间标识" prop="timeLabel">
-            <el-select v-model="formData.derItem.timeLabel" clearable placeholder="请选择时间标识">
+            <el-select v-model="formData.derItem.timeLabel" allow-create filterable clearable placeholder="请选择时间标识">
               <el-option
                 v-for="item in dataSetFieldList"
                 :key="item.id"
                 :label="item.fieldCode"
-                :value="item.id + ''"
+                :value="item.fieldCode"
               />
             </el-select>
           </el-form-item>
         </el-col>
         <el-col :span="6">
           <el-form-item label="时间限定" prop="timeLimit">
-            <el-select v-model="formData.timeLimit" placeholder="请选择"
+            <el-select v-model="formData.derItem.timeLimit" placeholder="请选择"
                        @change="handleTimeLimitChange($event)">
               <el-option
                 v-for="dict in getStrDictOptions(DICT_TYPE.IND_TIME_LIMIT)"
@@ -130,12 +131,13 @@
       <el-row>
         <el-col :span="24">
           <el-form-item label="分析维度" prop="dimension">
-            <el-select v-model="formData.derItem.dimension" clearable placeholder="请选择分析维度" multiple>
+            <el-select v-model="formData.derItem.dimension" filterable
+                       allow-create clearable placeholder="请选择分析维度" multiple>
               <el-option
                 v-for="item in dataSetFieldList"
                 :key="item.id"
                 :label="item.fieldCode"
-                :value="item.id + ''"
+                :value="item.fieldCode"
               />
             </el-select>
           </el-form-item>
@@ -164,6 +166,7 @@
   import {PageParam} from "@/api/data/ind/item/item";
   import * as CategoryApi from "@/api/data/ind/category";
   import * as DataSetFieldApi from "@/api/data/ind/data/data.field";
+  import {handleTree} from "@/utils/tree";
 
   defineOptions({name: 'IndDataSetForm'})
 
@@ -187,6 +190,7 @@
     timeGranularity: '',
     atomItem: {
       id: '',
+      itemId: '',
       itemNo: '',
       itemName: '',
     },
@@ -198,9 +202,6 @@
       timeEnd: '',
       dimension: ''
     }
-  })
-  const queryParams = ref({
-    itemType: 'ATOM'
   })
 
   const validateAsNumber = (rule, value, callback) => {
@@ -218,13 +219,18 @@
     /*"atomItem.id": [{required: true, message: '原子指标不能为空', trigger: 'blur'}]*/
   })
   const formRef = ref() // 表单 Ref
-  const dataSourceList = ref([] as DataSourceConfigApi.DataSourceConfigVO[])
   const atomItemList = ref([] as ItemApi.ItemVO[])
-  const selected = ref(null)
   const showTimeChange = ref(false)
-  const dataCategoryList = ref([] as CategoryApi.IndItemCategoryVO[])
   const dataSetFieldList = ref([] as DataSetFieldApi.DataSetFieldVO[])
+  const dataCategoryList = ref<Tree[]>([])
 
+  const getCategoryTree = async () => {
+    dataCategoryList.value = []
+    const res = await CategoryApi.getCategoryListAllSimple()
+    let category: Tree = {id: 0, label: '主类目', children: []}
+    category.children = handleTree(res, 'id', 'pid')
+    dataCategoryList.value.push(category)
+  }
   /** 打开弹窗 */
   const open = async (type: string, id?: string) => {
     dialogVisible.value = true
@@ -232,14 +238,23 @@
     formType.value = type
     resetForm()
     // 加载数据源列表
-    dataCategoryList.value = await CategoryApi.getCategoryListAllSimple()
+    await getCategoryTree()
+    const queryParams = reactive({
+      itemType: 'ATOM'
+    })
     atomItemList.value = await ItemApi.getItemList(queryParams)
-    selected.value = null
     // 修改时,设置数据
     if (id) {
       formLoading.value = true
       try {
         formData.value = await ItemApi.getItem(id)
+        if(formData.value.derItem.dimension.length > 0){
+          formData.value.derItem.dimension = formData.value.derItem.dimension.split(',')
+        }else {
+          formData.value.derItem.dimension = ""
+        }
+        showTimeChange.value = formData.value.derItem.timeLimit === 'CUSTOM'
+        await handleChange(formData.value.derItem.atomItemId)
       } finally {
         formLoading.value = false
       }
@@ -258,13 +273,15 @@
     formLoading.value = true
     try {
       formData.value.itemType = 'DER'
-      formData.value.derItem.atomItemId = formData.value.atomItem.id
+      formData.value.derItem.atomItemId = formData.value.atomItem.itemId
       if(formData.value.derItem.dimension.length > 0){
         let dimension = ''
         for (let index in formData.value.derItem.dimension){
           dimension = dimension + formData.value.derItem.dimension[index] + ','
         }
         formData.value.derItem.dimension = dimension.substring(0, dimension.length - 1)
+      }else{
+        formData.value.derItem.dimension = ''
       }
       const data = formData.value as ItemApi.ItemVO
       if (formType.value === 'create') {
@@ -314,8 +331,10 @@
   async function handleChange(event) {
     if (event !== null && event !== undefined) {
       const itemData = await ItemApi.getItem(event)
+      let a = itemData.atomItem.id
+      formData.value.atomItem.id = a
       formData.value.atomItem.itemName = itemData.itemName
-      formData.value.atomItem.id = itemData.atomItem.id
+      formData.value.atomItem.itemId = itemData.atomItem.itemId
       const queryParams = reactive({
         dataSetId: itemData.atomItem.dataSet,
       })

--
Gitblit v1.9.3