Эх сурвалжийг харах

清表模板、私有WBSbug修改

admin 3 жил өмнө
parent
commit
96155a1b19

+ 8 - 9
src/views/exctab/excelmodel/excelmodel.vue

@@ -283,8 +283,9 @@ export default {
         lazy: true,
         treeLoad: (async (node, resolve) => {
           console.log(node);
+          console.log(resolve);
           if (node.data.hasChildren) {
-            const { data: res } = await tabLazytree({ modeId: node.data.id })
+            const { data: res } = await tabLazytree({ parentId: node.data.id, modeId: this.$route.params.id })
             console.log(res);
             if (res.code === 200) {
               if (Array.isArray(res.data)) {
@@ -369,8 +370,8 @@ export default {
   },
   methods: {
     //#region 接口
-    async tabLazytree (modeId) {//清表树
-      const { data: res } = await tabLazytree({ modeId })
+    async tabLazytree (parentId, modeId) {//清表树
+      const { data: res } = await tabLazytree({ parentId, modeId })
       console.log(res);
       if (res.code === 200) {
         if (Array.isArray(res.data)) {
@@ -437,6 +438,7 @@ export default {
       }
     },
     async deleteExcelshu (ids) {//删除清表
+      // console.log(ids);
       const { data: res } = await deleteExcelshu(ids)
       console.log(res);
       if (res.code === 200) {
@@ -444,8 +446,7 @@ export default {
           message: '删除清表树成功',
           type: 'success'
         });
-        // this.tabLazytree(0)
-        this.tabLazytree(this.$route.params.id)//获取清表树
+        this.tabLazytree(0, this.$route.params.id)//获取清表树
         this.from = {
           checkd: false,//判断是否可以进行上传、重新上传excel
           id: '',//清表树ID
@@ -459,8 +460,7 @@ export default {
       const { data: res } = await Excelmodify(wbsExclTabParmVO)
       console.log(res);
       if (res.code === 200) {
-        // await this.tabLazytree(0)
-        await this.tabLazytree(this.$route.params.id)//获取清表树
+        await this.tabLazytree(0, this.$route.params.id)//获取清表树
         this.dialogTap = false
       }
     },
@@ -697,8 +697,7 @@ export default {
   },
   created () {
     this.excelType()//清表类型
-    // this.tabLazytree(0)
-    this.tabLazytree(this.$route.params.id)//获取清表树
+    this.tabLazytree(0, this.$route.params.id)//获取清表树
   }
 }
 </script>

+ 32 - 53
src/views/manager/projectinfo/tree.vue

@@ -280,6 +280,7 @@
                 <el-link
                   class="mg-l-10"
                   type="primary"
+                  @click="adjustExcel"
                 >调整表单</el-link>
                 <el-link
                   class="mg-l-10"
@@ -324,20 +325,19 @@
           <el-input
             style="width:400px;"
             v-model.trim="GLExcelFrom.search"
-            @input="searchInput"
             placeholder="请输入需要选择的内容"
           ></el-input>
           <el-tree
+            :filter-node-method="filterNode"
+            ref="tree"
+            class="filter-tree"
             style="margin-top:10px;"
             :props="GLExcelProps"
-            :load="loadNodess"
-            lazy
             :data="exceldata"
             node-key="id"
-            :default-checked-keys="xuanzhong"
             accordion
             show-checkbox
-            @check-change="checkchange"
+            @check="checkchange"
           >
           </el-tree>
         </el-scrollbar>
@@ -1240,7 +1240,6 @@
 </template>
 
 <script>
-let setTimeout22
 import {
   saveFormAndElement, selectFormElements,
   importWbsTree
@@ -1270,9 +1269,9 @@ export default {
       GLExcelProps: {
         label: 'name',
         children: 'children',
-        isLeaf: 'hasChildren',
+        disabled: 'hasChildren',
+        // isLeaf: !'hasChildren',
       },
-      xuanzhong: [],//选中值得ID
       exceldata: [],//清表模板
       //#endregion
 
@@ -1541,7 +1540,7 @@ export default {
     },
 
     updateTreeNewNode () {
-      getLazytree(this.id, this.nodeDetail.parentId,this.userInfo.tenant_id, this.projectid).then((res) => {
+      getLazytree(this.id, this.nodeDetail.parentId, this.userInfo.tenant_id, this.projectid).then((res) => {
         this.$refs.tree.updateKeyChildren(this.nodeDetail.parentId, res.data.data)
       })
     },
@@ -1956,13 +1955,6 @@ export default {
       })
       console.log(res);
       if (res.code === 200 && res.msg === '操作成功') {
-        res.data.forEach(val => {
-          if (val.hasChildren) {
-            val.disabled = false
-          } else {
-            val.disabled = true
-          }
-        })
         this.exceldata = res.data
       }
     },
@@ -1974,7 +1966,7 @@ export default {
         size: 100000,
         parentId: 0
       })
-      this.GLExcelFrom.id = scope.row.id
+      this.GLExcelFrom.id = scope.row.pkeyId
     },
     changetherr () {//清表类型选择框change事件
       if (this.GLExcelFrom.name != "") {
@@ -1986,47 +1978,20 @@ export default {
       this.GLExcelFrom.name = ""
       this.GLExcelFrom.search = ''
       this.GLExcelFrom.id
-      this.xuanzhong = []
+      this.$refs.tree.setCheckedKeys([])
       this.GLExcel = false
     },
-    async loadNodess (node, resolve) {//check事件
-      console.log(node);
-      if (this.GLExcelFrom.name) {
-        console.log(node.data.id);
-        console.log(resolve);
-        const { data: res } = await tabLazytreeAll({
-          modeId: node.data.id,
-          name: '',
-        })
-        if (res.code === 200 && res.msg === '操作成功') {
-          res.data.forEach(val => {
-            if (val.hasChildren) {
-              val.disabled = false
-            } else {
-              val.disabled = true
-            }
-          })
-          resolve(res.data)
-        }
-      }
-    },
-    checkchange (data, checked,) {//节点选中回调
-      if (checked) {
-        this.xuanzhong = [data.id]
+    checkchange (data) {//节点选中回调
+      if (this.$refs.tree.getCheckedNodes().length == 0) {
+        this.$refs.tree.setCheckedKeys([])
       } else {
-        this.xuanzhong = []
+        this.$refs.tree.setCheckedKeys([data.id])
       }
     },
-    searchInput () {//输入回调
-      window.clearTimeout(setTimeout22)
-      setTimeout22 = window.setTimeout(() => {
-        this.tabLazytreeAll()
-      }, 500)
-    },
-    async saveLinkTab () {
+    async saveLinkTab () {//保存按钮
       const { data: res } = await saveLinkTab({
-        exceTabId: this.GLExcelFrom.id,
-        tabId: this.xuanzhong[0]
+        exceTabId: this.$refs.tree.getCheckedNodes()[0].id,
+        tabId: this.GLExcelFrom.id,
       })
       console.log(res);
       if (res.code === 200) {
@@ -2035,11 +2000,25 @@ export default {
           message: '关联清表成功',
         })
         this.GLExcel = false
+        this.GLExcelMD()
       }
     },
+    filterNode (value, data) {
+      console.log(value, data);
+      if (!value) return true;
+      return data.name.indexOf(value) !== -1;
+    },
     //#endregion
+    adjustExcel () {//调整表单
+      this.$router.push('/ceshi/trees')
+    },
+  },
+  watch: {
+    'GLExcelFrom.search' (val) {
+      this.$refs.tree.filter(val);
+    }
+  },
 
-  }
 };
 </script>