Ver Fonte

元素识别多节点新增关联

gangyj há 3 anos atrás
pai
commit
9b64d31eaa
2 ficheiros alterados com 101 adições e 31 exclusões
  1. 26 1
      src/api/exctab/excelmodel.js
  2. 75 30
      src/views/exctab/ElementIdentification/index.vue

+ 26 - 1
src/api/exctab/excelmodel.js

@@ -156,10 +156,35 @@ export const cancelRelation = (params) => {
     })
 }
 
+//保存关联
+export const saveRelation = (id,excelTabId,elementList) => {
+    return request({
+      url: '/api/blade-manager/wbsFormElement/saveRelation',
+      method: 'post',
+      data: {
+        id,
+        excelTabId,
+        elementList
+      }
+    })
+}
+
 export const getLazytree = (params) => {
     return request({
         url: '/api/blade-manager/wbsTree/lazy-tree',
         method: 'get',
         params
     })
-}
+}
+
+//查看节点下已关联的元素表信息
+export const searchNodeTables = (nodeId,excelTabId) => {
+    return request({
+        url: ' /api/blade-manager/wbsFormElement/searchNodeTables',
+        method: 'get',
+        params:{
+            nodeId,
+            excelTabId
+        }
+    })
+}

+ 75 - 30
src/views/exctab/ElementIdentification/index.vue

@@ -172,6 +172,8 @@
                 lazy
                 node-key="id"
                 accordion
+                :show-checkbox="activeName == 'add'"
+                :check-strictly="true"
               >
               </el-tree>
             </el-scrollbar>
@@ -206,6 +208,7 @@
                         style="margin:0px;"
                         @click="relationMD(scope.row,'关联')"
                         v-show="!scope.row.checknd"
+                        :loading="scope.row.loading"
                       >选择关联</el-button>
                       <el-button
                         type="danger"
@@ -213,6 +216,7 @@
                         style="margin:0px;"
                         @click="relationMD(scope.row,'取消关联')"
                         v-show="scope.row.checknd"
+                        :loading="scope.row.loading"
                       >取消关联</el-button>
                     </template>
                   </el-table-column>
@@ -273,7 +277,7 @@
   </div>
 </template>
 <script>
-import { tabLazytree, getExcelHtmlCol, excelType, submitExcelRelationWbsTreeAndElement, getWbsTypeList, getLazytree,cancelRelation } from "@/api/exctab/excelmodel";
+import { tabLazytree, getExcelHtmlCol, excelType, submitExcelRelationWbsTreeAndElement, getWbsTypeList, getLazytree,cancelRelation,saveRelation,searchNodeTables } from "@/api/exctab/excelmodel";
 import { dictionarydataType } from "@/api/exctab/editelement";
 import { getColByTabId } from "@/api/manager/AdjustForm";
 import { selectByNodeTable } from "@/api/manager/wbstree";
@@ -431,21 +435,22 @@ export default {
       this.AssociatedPublicTap = true
     },
     AssociatedPublicClose () {//关联公共WBS模板关闭事件
-      this.addElementForm = {
-        id: "",
-        initTableName: "",
-        deptName: this.addElementForm.deptName,
-        tableType: '',
-        tableOwner: '',
-        wbsId: '',
-        parentId: '',
-      }
-      this.GLExcelFrom = {
-        name: '',
-        search: ''
-      }
-      this.exceldata = []
-      this.addElement = false
+      // this.addElementForm = {
+      //   id: "",
+      //   initTableName: "",
+      //   deptName: this.addElementForm.deptName,
+      //   tableType: '',
+      //   tableOwner: '',
+      //   wbsId: '',
+      //   parentId: '',
+      // }
+      // this.GLExcelFrom = {
+      //   name: '',
+      //   search: ''
+      // }
+      // this.exceldata = []
+      // this.addElement = false
+      this.addTableData = []
       this.AssociatedPublicTap = false
     },
     async loadNodeTan (node, resolve) {//懒加载
@@ -498,7 +503,8 @@ export default {
     handleNodeClickExcel (data) {//点击节点事件
       this.addElementForm.wbsId = this.GLExcelFrom.name
       this.addElementForm.parentId = data.id
-      this.selectByNodeTable(data.id)
+      //this.selectByNodeTable(data.id)
+      this.searchNodeTables(data.id)
     },
     async selectByNodeTable (id) {//获取清表信息
       const { data: res } = await selectByNodeTable(id)
@@ -511,6 +517,7 @@ export default {
             } else {
               val.checknd = false
             }
+            val.loading = false;
           })
           this.addTableData = res.data
         }else{
@@ -519,6 +526,26 @@ export default {
 
       }
     },
+
+    //查看节点下已关联的元素表信息
+    searchNodeTables(id){
+      searchNodeTables(id,this.from.id).then((res)=>{
+        if (res.data.data.length > 0) {
+          res.data.data.forEach(val => {
+            if (val.isLinkTable == 2) {
+              val.checknd = true
+            } else {
+              val.checknd = false
+            }
+            val.loading = false;
+          })
+          this.addTableData = res.data.data
+        }else{
+          this.addTableData = []
+        }
+      })
+    },
+
     async excelType () {//清表类型
       const { data: res } = await excelType({ code: 'sys_excltab_type' })
       console.log(res);
@@ -527,38 +554,56 @@ export default {
       }
     },
     relationMD (row, type) {//关联取消关联
+      row.loading = true;
       if (type == '关联') {
-        row.checknd = true;
+        saveRelation(row.id,this.from.id,this.tableData).then(()=>{
+          row.checknd = true;
+          row.isLinkTable = 2;
+        }).finally(()=>{
+          row.loading = false;
+        })
+        
       } else {
-        cancelRelation({id:row.id}).then(()=>{
+        cancelRelation({
+          id:row.id,
+          excelTabId:this.from.id,
+        }).then(()=>{
           row.checknd = false;
           row.isLinkTable = 1;
+        }).finally(()=>{
+          row.loading = false;
         })
       }
     },
     saveElementMD () {//保存按钮
       if (this.addElementForm.wbsId) {
         if (this.activeName == 'link') {
-          let tableIds = [];
-          this.addTableData.forEach((table)=>{
-            if(table.checknd){
-              tableIds.push(table.id);
-            }
-          })
-
+          
           this.submitExcelRelationWbsTreeAndElement({
-            tableIds:tableIds,
-            elementList: this.tableData
+            excelTabId:this.from.id,
+            elementList: this.tableData,
+            submitStatus:1
           })
         } else {
           if (this.addElementForm.deptName && this.addElementForm.tableType && this.addElementForm.tableOwner) {
+            let nodeIds = this.$refs.tree.getCheckedKeys();
+            if(nodeIds.length < 1){
+              this.$message({
+                type: 'warning',
+                message: '至少勾选一个节点'
+              })
+              return;
+            }
+
             this.submitExcelRelationWbsTreeAndElement({
               deptName: this.addElementForm.deptName,
               tableType: this.addElementForm.tableType,
               tableOwner: this.addElementForm.tableOwner,
               wbsId: this.addElementForm.wbsId,
-              parentId: this.addElementForm.parentId,
-              elementList: this.tableData
+              elementList: this.tableData,
+              nodeIds:nodeIds,
+              excelTabId:this.from.id,
+              submitStatus:2
             })
           }else{
             this.$message({