Browse Source

Merge remote-tracking branch 'origin/master'

onlyh 3 years ago
parent
commit
a1b51bcd48

+ 4 - 4
src/views/maintain/relationship/relation/components/table.vue

@@ -63,12 +63,12 @@ export default class extends Vue {
       relType: this.$route.query.relationType,
       graphicType: this.$route.query.graphicType,
       fromId: val.id, //主对象id
-      toId: val.objectInfo.id, //从对象id
+      toId: val.objectInfo[0].id, //从对象id
     };
     relDel(data).then((res) => {
       if (res.result == "success") {
         this.$message.success("删除成功!");
-        this.$emit("updata");
+        this.$emit("updata"); //删除
       } else {
         this.$message.error("删除失败!");
       }
@@ -84,8 +84,8 @@ export default class extends Vue {
         };
       } else {
         return {
-          rowspan: 0,
-          colspan: 0,
+          rowspan: row.firstSpan ? 0 : 1,
+          colspan: row.firstSpan ? 0 : 1,
         };
       }
     }

+ 26 - 8
src/views/maintain/relationship/relation/index.vue

@@ -50,7 +50,7 @@
     </el-row>
     <relationTable
       v-if="tableHeight"
-      @updata="relManualQuery"
+      @updata="addRelationSucess(0)"
       @openMoreRelation="openMoreRelation"
       :tableHeader="tableHeader"
       :tableData="tableData"
@@ -72,7 +72,7 @@
     </div>
     <addRelationDialog
       @closeAddRelation="addRelationValue = false"
-      @update="relManualQuery"
+      @update="addRelationSucess(1)"
       :addRelationValue="addRelationValue"
       :values="values"
     />
@@ -209,8 +209,8 @@ export default class extends Vue {
    */
   mainSelect(val: any) {
     this.categoryFrom = val;
+    this.page.currentPage = 1; //初始化页面
     this.relManualQuery();
-    console.log("mainSelect", val);
   }
 
   /**
@@ -218,18 +218,21 @@ export default class extends Vue {
    */
   minorSelect(val: any) {
     this.categoryTo = val;
+    this.page.currentPage = 1; //初始化页面
     this.relManualQuery();
   }
 
   // 主关系模糊搜索
   mainSerch(val: string) {
     this.vagueFrom = val;
+    this.page.currentPage = 1; //初始化页面
     this.relManualQuery();
   }
 
   // 从关系模糊搜索
   minorSearch(val: string) {
     this.vagueTo = val;
+    this.page.currentPage = 1; //初始化页面
     this.relManualQuery();
   }
 
@@ -241,6 +244,17 @@ export default class extends Vue {
   }
 
   /**
+   * 添加关系成功后
+   */
+  addRelationSucess(initPage) {
+    if (initPage) {
+      this.page.currentPage = 1; //初始化页面
+    }
+    this.relManualQuery();
+    this.relToTfype(); //重新f获取关系对象
+  }
+
+  /**
    * 获取主对象从对象关系
    */
   relToType() {
@@ -302,13 +316,14 @@ export default class extends Vue {
   relManualQuery() {
     this.loading = true;
     // 获取table数据
+    const objectType = this.vagueTo.length && this.vagueFrom.length ? 3 : this.vagueTo.length ? 2 :1;
     const data = {
       projectId: this.$route.query.projectId,
       categoryFrom: this.categoryFrom,
       categoryTo: this.categoryTo,
-      vagueTo: this.vagueTo, //关系
-      vagueFrom: this.vagueFrom, //关系
-      objectType: 1,
+      vagueTo: this.vagueTo, //关系
+      vagueFrom: this.vagueFrom, //关系
+      objectType: objectType,
       relType: this.$route.query.relationType,
       pageSize: this.page.pageSize,
       pageNumber: this.page.currentPage,
@@ -341,8 +356,8 @@ export default class extends Vue {
           // 取9个
           if (item.objectInfo.length >= 9) {
             objList = [...item.objectInfo.slice(0, 9)];
-          }else{
-            objList = item.objectInfo.slice(0, 9)
+          } else {
+            objList = item.objectInfo.slice(0, 9);
           }
           const objInfo = JSON.parse(JSON.stringify(objList));
           objInfo.forEach((objItem: any, index: number) => {
@@ -350,6 +365,7 @@ export default class extends Vue {
             Object.assign(newItem, {
               objectInfo: [objItem],
               rowspan: index == 0 ? objInfo.length : 0,
+              firstSpan: true, //首行是否合并
             });
             newList.push(newItem);
           });
@@ -358,12 +374,14 @@ export default class extends Vue {
             newList.push(
               Object.assign(item, {
                 moreMsg: true,
+                firstSpan: true, //首行是否合并
               })
             );
           }
         } else {
           Object.assign(item, {
             rowspan: 1,
+            firstSpan: false,
           });
           newList.push(item);
         }