ソースを参照

修改汾渭数据搜索框选择完之后定位不到选中的指标

chenlei 7 ヶ月 前
コミット
f9a94a072b

+ 21 - 5
src/views/dataEntry_manage/thirdBase/FwmtData.vue

@@ -55,10 +55,11 @@
           ref="treeRef"
           class="target_tree word-wrap"
           :data="classifyList"
-          node-key="ClassifyId"
+          node-key="key"
           :props="{
             label: 'ClassifyName',
             children: 'Child',
+            isLeaf: 'leaf'
           }"
           :default-checked-keys = "defaultCheckedKeys"
           :default-expanded-keys="defaultShowNodes"
@@ -180,6 +181,8 @@ export default {
       indexFrequency: 0, // 当前选中的指标code
       select_frequency: '', // 当前选中的频度
       classId: '', // 当前选中的指标的分类id
+      selectedEdb: false, // 是否选中指标
+      FenweiIndexId: '', // 当前选中的指标的key
     };
   },
   methods: {
@@ -187,7 +190,13 @@ export default {
     getClassify() {
       fwmtInterface.classifyList().then((res) => {
         if (res.Ret !== 200) return;
-        this.classifyList = res.Data || [];
+        const addKey = arr => arr.map(item => ({
+          ...item,
+          key: item.ClassifyId, // key值为当前项ClassifyId
+          Child: item.Child ? addKey(item.Child) : null // 这里要判断原数据有没有子级如果没有判断会报错
+        }))
+        this.classifyList = addKey(res.Data || []);
+        // this.classifyList = res.Data || [];
         this.select_classify = this.classifyList.length ? (this.classifyList[0].Child && this.classifyList[0].Child.length ? this.classifyList[0].Child[0].ClassifyId : this.classifyList[0].ClassifyId) : 0; // 获取classifyList中第一个元素的ClassifyId,如果该元素有子元素,则取第一个子元素的ClassifyId
         // this.defaultShowNodes = [this.classifyList[0].ClassifyId]
         this.$nextTick(() => { // 获取到节点后设置选中
@@ -358,7 +367,8 @@ export default {
               return {
                 ...item,
                 classId,
-                isLeaf: true
+                key: item.FenweiIndexId,
+                leaf: true
               }
             })
           } else {
@@ -369,6 +379,9 @@ export default {
         arr=node.data.Child||[]
       }
       resolve(arr)
+      this.$nextTick(() => { // 获取到节点后设置选中
+        this.$refs.treeRef.setCurrentKey(this.FenweiIndexId)
+      })
     },
     // 树节点展开
     handleNodeExpand(data) {
@@ -400,8 +413,9 @@ export default {
     //添加指标到库
     intoBaseBack() {
       this.isAddIndicsDiaShow = false
-      if(this.selectedEdb){
-        this.$refs.edbDetailRef.getEdbDetail()
+      if(this.isShowSingleData){
+        // this.$refs.edbDetailRef.getEdbDetail()
+        this.getTargetDataList(this.leftSearchTradeCode)
       }else {
         this.getDataList()
       }
@@ -491,11 +505,13 @@ export default {
     },
     // 选中左侧搜索值
     handleSelectLeftSearchval(e) {
+      console.log(e);
       if (!e.IndexCode) return;
       this.leftSearchTradeCode = e.IndexCode;
       this.leftSearchVal = e.IndexName;
       const ParentClassifyId = this.classifyList[this.findIndex(this.classifyList, (item) => item.ClassifyId === e.ClassifyId)[0]].ClassifyId
       this.defaultShowNodes = [ParentClassifyId, e.ClassifyId];
+      this.FenweiIndexId = e.FenweiIndexId;
       // this.defaultShowNodes = [ParentClassifyId, e.ClassifyId];
       // 获取单独指标数据
       this.getTargetDataList(e.IndexCode);

+ 20 - 9
src/views/dataEntry_manage/thirdBase/components/batchFwAddIndicsDia.vue

@@ -192,15 +192,7 @@ export default {
             btnloading:false,
 
             frequency: '',
-            frequencyOptions: [
-                { label:'日度',val: '日度' },
-                { label:'周度',val: '周度' },
-                { label:'旬度',val: '旬度' },
-                { label:'月度',val: '月度' },
-                { label:'季度',val: '季度' },
-                { label:'半年度',val: '半年度' },
-                { label:'年度',val: '年度' },
-            ]
+            frequencyOptions: []
         };
     },
     methods: {
@@ -210,6 +202,7 @@ export default {
         initDia(){
             this.getClassifyList()
             this.getClassifyOpt()
+            this.getFrequency()
             this.searchClassify = ''
             this.searchName = ''
             this.edbList = []
@@ -217,6 +210,19 @@ export default {
             this.selectClassify=''
             this.btnloading=false
         },
+        // 获取频度
+        getFrequency() {
+            fwmtInterface.getFrequency().then((res) => {
+                if (res.Ret !== 200) return;
+                const frequencyList = res.Data || [];
+                this.frequencyOptions = frequencyList.map((item) => {
+                    return {
+                        label: item,
+                        val: item
+                    };
+                })
+            });
+        },
         //获取钢联化工数据库目录
         getClassifyList(){
             fwmtInterface.classifyList().then((res) => {
@@ -242,6 +248,11 @@ export default {
         },
         //获取对应目录下的钢联化工指标
         getEdbList(){
+            console.log(this.searchClassify);
+            console.log(this.searchName);
+            console.log(this.frequency);
+            
+            if (!this.searchClassify.length && !this.searchName && !this.frequency) return this.edbList = []
             //每一次筛选项改变清空选择框
             this.selectEdbList = []
             this.classifyType = 1