YaolongHan 3 years ago
parent
commit
790edbf679

+ 46 - 31
src/api/datacenter.ts

@@ -6,32 +6,32 @@ const baseApi = "/datacenter";
 
 // 创建项目
 export function projectCreate(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/project/create`, postParams);
+    return httputils.postJson(`${baseApi}/object/project/create`, postParams);
 }
 
 // 查询项目信息
 export function projectQuery(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/project/query`, postParams);
+    return httputils.postJson(`${baseApi}/object/project/query`, postParams);
 }
 
 // 更新项目信息
 export function projectUpdate(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/project/update`, postParams);
+    return httputils.postJson(`${baseApi}/object/project/update`, postParams);
 }
 
 // 查询建筑信息
 export function buildingQuery(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/building/query`, postParams);
+    return httputils.postJson(`${baseApi}/object/building/query`, postParams);
 }
 
 // 查询建筑信息
 export function floorQuery(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/floor/query`, postParams);
+    return httputils.postJson(`${baseApi}/object/floor/query`, postParams);
 }
 
 // 字典查询
 export function dictCategoryQuery(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/dict/category`, postParams);
+    return httputils.postJson(`${baseApi}/dict/category`, postParams);
 }
 
 // 查询项目下类型的信息点-->编辑器 空间功能类型 列表-->自己转成树
@@ -40,7 +40,7 @@ export function dictQuery(postParams: any): any {
     // "filters": "code='roomFuncType'",
     // "type": "FunctionZone"
     // }
-    return httputils.postJson(`${ baseApi }/dict/query`, postParams);
+    return httputils.postJson(`${baseApi}/dict/query`, postParams);
 }
 
 // 查询空间实例
@@ -49,122 +49,137 @@ export function PartiInstancQuery(postParams: any): any {
     // "filters": "code='roomFuncType'",
     // "type": "FunctionZone"
     // }
-    return httputils.postJson(`${ baseApi }/object/zone/query`, postParams);
+    return httputils.postJson(`${baseApi}/object/zone/query`, postParams);
 }
 
 // 查询设备信息
 export function queryEquip(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/equip/query`, postParams)
+    return httputils.postJson(`${baseApi}/object/equip/query`, postParams)
 }
 
 // 根据id删除设备信息
 export function deleteEquip(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/equip/delete`, postParams)
+    return httputils.postJson(`${baseApi}/object/equip/delete`, postParams)
 }
 
 // 创建设备信息
 export function createEquip(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/equip/create`, postParams)
+    return httputils.postJson(`${baseApi}/object/equip/create`, postParams)
 }
 
 // 更新设备信息
 export function updateEquip(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/equip/update`, postParams)
+    return httputils.postJson(`${baseApi}/object/equip/update`, postParams)
 }
 
 // 查询系统信息
 export function querySystem(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/system/query`, postParams)
+    return httputils.postJson(`${baseApi}/object/system/query`, postParams)
 }
 
 // 查询空间信息
 export function queryZone(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/zone/query`, postParams)
+    return httputils.postJson(`${baseApi}/object/zone/query`, postParams)
 }
 
 // 查询元空间信息
 export function queryIspace(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/ispace/query`, postParams)
+    return httputils.postJson(`${baseApi}/object/ispace/query`, postParams)
 }
 
 // 创建空间
 export function createZone(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/zone/create`, postParams)
+    return httputils.postJson(`${baseApi}/object/zone/create`, postParams)
 }
 
 // 更新空间
 export function updateZone(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/zone/update`, postParams)
+    return httputils.postJson(`${baseApi}/object/zone/update`, postParams)
 }
 
 // 更新空间
 export function deleteZone(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/zone/delete`, postParams)
+    return httputils.postJson(`${baseApi}/object/zone/delete`, postParams)
 }
 
 // 查询设备统计
 export function queryCount(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/equip/count`, postParams)
+    return httputils.postJson(`${baseApi}/object/equip/count`, postParams)
 }
 
 // 查询系统统计
 export function queryCountSystem(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/system/count`, postParams)
+    return httputils.postJson(`${baseApi}/object/system/count`, postParams)
 }
 
 // 创建系统信息
 export function createSystem(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/system/create`, postParams)
+    return httputils.postJson(`${baseApi}/object/system/create`, postParams)
 }
 
 // 更新系统信息
 export function updateSystem(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/system/update`, postParams)
+    return httputils.postJson(`${baseApi}/object/system/update`, postParams)
+}
+
+// 查询空间信息
+export function zoneQuery(postParams: any): any {
+    return httputils.postJson(`${baseApi}/object/zone/query`, postParams)
 }
 
 // 查询空间统计
 export function queryCountSpace(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/object/zone/count`, postParams)
+    return httputils.postJson(`${baseApi}/object/zone/count`, postParams)
 }
 
 // 查询关系总览
 export function relationshipOverview(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/rel/graphic/overview`, postParams)
+    return httputils.postJson(`${baseApi}/rel/graphic/overview`, postParams)
 }
 
 // 查询关系数量
 export function relationshipCount(postParams: any): any {
-    return httputils.postJson(`${ baseApi }/rel/graphic/query/count`, postParams)
+    return httputils.postJson(`${baseApi}/rel/graphic/query/count`, postParams)
 }
 
 // 查看关系相关的数据类型
 export function relToType(getParams: any) {
-    return httputils.getJson(`${ baseApi }/rel/graphic/relToType`, getParams)
+    return httputils.getJson(`${baseApi}/rel/graphic/relToType`, getParams)
 }
 
 // 查询关系数据
 export function relManualQuery(postParams: any) {
-    return httputils.postJson(`${ baseApi }/rel/manual/query`, postParams)
+    return httputils.postJson(`${baseApi}/rel/manual/query`, postParams)
 }
 
 // 添加关系数据
 export function relAdd(postParams: any) {
-    return httputils.postJson(`${ baseApi }/rel/manual/add`, postParams)
+    return httputils.postJson(`${baseApi}/rel/manual/add`, postParams)
 }
 
 // 删除关系数据
 export function relDel(postParams: any) {
-    return httputils.postJson(`${ baseApi }/rel/manual/del`, postParams)
+    return httputils.postJson(`${baseApi}/rel/manual/del`, postParams)
 }
 
 // 关系计算
 export function relationCalc(postParams: any) {
-    const url = `${ baseApi }/relation-calc${ postParams.requestUrl }?objectTypes=${ postParams.objectTypes }&graphCode=${ postParams.graphCode }&relType=${ postParams.relType }`
+    const url = `${baseApi}/relation-calc${postParams.requestUrl}?objectTypes=${postParams.objectTypes}&graphCode=${postParams.graphCode}&relType=${postParams.relType}`
     return httputils.postJson(url, {})
 }
 
 // 更新计算时间
 export function updateCalcTime(getParams: any) {
-    const url = `${ baseApi }/rel/graphic/updateCalcTime?graphCode=${ getParams.graphCode }&relType=${ getParams.relType }&computingTime=${ getParams.computingTime }`
+    const url = `${baseApi}/rel/graphic/updateCalcTime?graphCode=${getParams.graphCode}&relType=${getParams.relType}&computingTime=${getParams.computingTime}`
     return httputils.getJson(url, {})
 }
+// execl上传
+export function importGrahpic(postParams: any) {
+    return httputils.postJson(`${baseApi}/rel/graphic/import`, postParams)
+}
+
+// 导出Execl
+export function exportGraphic(getParams: any) {
+    const url = `${baseApi}/rel/graphic/export`
+    return httputils.getJson(url, getParams)
+}

+ 126 - 0
src/views/maintain/relationship/relation/components/moreRelationDialog.vue

@@ -0,0 +1,126 @@
+<template>
+  <el-dialog
+    @open="openEvent"
+    title="更多关系"
+    :visible.sync="dialogTableVisible"
+  >
+    <el-table :data="gridData">
+      <el-table-column
+        v-for="(item, index) in tableHeader"
+        :key="index"
+        :prop="item[1]"
+        :label="item[0]"
+        align="left"
+      >
+        <template slot-scope="scope">
+          {{
+            (item[1].includes("objectInfo") && scope.row.objectInfo
+              ? scope.row.objectInfo[0][item[1].split("-")[1]]
+              : scope.row[item[1]]) || "--"
+          }}
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="left">
+        <template slot-scope="scope">
+          <el-button
+            slot="reference"
+            size="mini"
+            icon="el-icon-delete"
+            @click="deleteObject(scope.$index, scope.row)"
+          />
+        </template>
+      </el-table-column>
+    </el-table>
+    <div class="pagination">
+      <el-pagination
+        @size-change="handleSizeChange"
+        @current-change="handleCurrentChange"
+        :current-page="page.currentPage"
+        :page-sizes="[10, 15, 20, 30]"
+        :page-size="page.pageSize"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="page.total"
+      >
+      </el-pagination>
+    </div>
+  </el-dialog>
+</template>
+<script lang="ts">
+import { Component, Prop, Vue } from "vue-property-decorator";
+import { zoneQuery, relDel } from "@/api/datacenter";
+@Component({
+  name: "moreRelationDialog",
+})
+export default class extends Vue {
+  @Prop({ default: Array }) tableHeader?: [];
+  @Prop({ default: String }) mainId?: ""; //主对象id
+  //    分页
+  page: object = {
+    total: 0, //总数
+    currentPage: 1, //当前页
+    pageSize: 10, //当前页数量
+  };
+
+  gridData: any[] = [];
+
+  //   是否显示弹窗
+  dialogTableVisible: boolean = false;
+
+  /**
+   * 分页数量切换
+   */
+
+  handleSizeChange(val: any) {}
+
+  /**
+   * 分页切换
+   */
+  handleCurrentChange(val: any) {}
+
+  getTable() {
+    const data = {
+      pageSize: this.page.pageSize,
+      pageNumber: this.page.currentPage,
+      orders: "name asc, createTime desc",
+      filters: `buildingId='${this.mainId}'`,
+    };
+    zoneQuery(data).then((res: any) => {
+      if (res.content && res.content.length) {
+        this.gridData = res.content;
+      }
+      this.page.total = res.total;
+    });
+  }
+
+  /**
+   * 打开前的回调
+   *
+   */
+  openEvent() {
+    // 请求从关系接口
+    this.getTable();
+  }
+  /**
+   * 删除关系
+   */
+  //  删除
+  deleteObject(index: number, val: any) {
+    const data = {
+      relType: this.$route.query.relationType,
+      graphicType: this.$route.query.graphicType,
+      fromId: this.mainId, //主对象id
+      toId: val.id, //从对象id
+    };
+    relDel(data).then((res) => {
+      if (res.result == "success") {
+        this.$message.success("删除成功!");
+        this.getTable();
+      } else {
+        this.$message.error("删除失败!");
+      }
+    });
+  }
+}
+</script>
+<style lang="">
+</style>

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

@@ -29,8 +29,13 @@
     </el-table-column>
     <el-table-column label="操作" align="left">
       <template slot-scope="scope">
-        <!-- <span v-if="">更多</span> -->
+        <div v-if="scope.row.moreMsg" class="scope-better">
+          <el-button type="text" @click="openMoreRelation(scope.row)"
+            >...更多主从关系</el-button
+          >
+        </div>
         <el-button
+          v-else
           slot="reference"
           size="mini"
           icon="el-icon-delete"
@@ -79,13 +84,13 @@ export default class extends Vue {
         };
       } else {
         return {
-          rowspan: 1,
+          rowspan: 0,
           colspan: 0,
         };
       }
     }
-
-    if (rowIndex === 9) {
+    if (row.moreMsg) {
+      // 如果为打开更多按钮则合并
       if (columnIndex === 4) {
         return [1, 4];
       } else if (columnIndex < 4 && columnIndex > 0) {
@@ -93,8 +98,24 @@ export default class extends Vue {
       }
     }
   }
+  /**
+   * 获取更多主从关系
+   *
+   * @param obj 中从相关数据
+   */
+  openMoreRelation(obj: any): void {
+    this.$emit("openMoreRelation", obj);
+  }
 }
 </script>
 
 <style  scoped>
+.scope-better {
+  /* width: 100%;
+  height: 100%;
+  display: flex;
+  justify-content: center;
+  align-items: left */
+  margin: 0 auto;
+}
 </style>

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

@@ -51,6 +51,7 @@
     <relationTable
       v-if="tableHeight"
       @updata="relManualQuery"
+      @openMoreRelation="openMoreRelation"
       :tableHeader="tableHeader"
       :tableData="tableData"
       :height="tableHeight"
@@ -77,6 +78,11 @@
     />
     <excelDialog :values="values" ref="excelDialog"></excelDialog>
     <editRelationDialog :values="values"></editRelationDialog>
+    <moreRelationDialog
+      :mainId="mainId"
+      :tableHeader="tableHeader"
+      ref="moreRelation"
+    ></moreRelationDialog>
   </div>
 </template>
 
@@ -90,6 +96,7 @@ import editRelationDialog from "./components/editRelationDialog.vue";
 import excelDialog from "./components/excelDialog.vue";
 import { relToType, relManualQuery, relDel } from "@/api/datacenter";
 import { ElSelect } from "element-ui/types/select";
+import moreRelationDialog from "./components/moreRelationDialog.vue";
 
 @Component({
   name: "relation",
@@ -99,6 +106,7 @@ import { ElSelect } from "element-ui/types/select";
     addRelationDialog,
     excelDialog,
     editRelationDialog,
+    moreRelationDialog,
   },
 })
 export default class extends Vue {
@@ -108,6 +116,7 @@ export default class extends Vue {
   minorOptions = []; //次关系选项
   vagueFrom = ""; //主关系模糊收索
   vagueTo = ""; //次关系模糊收索
+  mainId: string = ""; //主关系id
   //表头数据
   tableHeader = [];
   //表格数据
@@ -159,6 +168,15 @@ export default class extends Vue {
   }
 
   /**
+   * 更多关系
+   *
+   */
+  openMoreRelation(obj: any) {
+    this.mainId = obj.id;
+    this.$refs.moreRelation.dialogTableVisible = true;
+  }
+
+  /**
    * 上传 execl
    */
   updataExecl() {
@@ -313,32 +331,36 @@ export default class extends Vue {
    * 重新拼装数组
    */
   eachResData(list: []) {
-
     if (list.length) {
       let newList: any[] = [];
       list.forEach((item: any) => {
         //  从对象为多个则新曾对象
         if (item.objectInfo && item.objectInfo.length >= 2) {
           // 只展示最多展示9个合并
-          let objList:any = [];
+          let objList: any = [];
           // 取9个
-          if(item.objectInfo.length>=9){
-             objList = [...item.objectInfo.slice(0,10)]
+          if (item.objectInfo.length >= 9) {
+            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) => {
             const newItem = JSON.parse(JSON.stringify(item));
             Object.assign(newItem, {
               objectInfo: [objItem],
-              rowspan: index == 0 ? item.objectInfo.length : 1,
+              rowspan: index == 0 ? objInfo.length : 0,
             });
             newList.push(newItem);
           });
           // 如果从关系大于10个则需要添加打开弹窗按钮
-          if(item.objectInfo.length>9){
-               newList.push()
+          if (item.objectInfo.length > 9) {
+            newList.push(
+              Object.assign(item, {
+                moreMsg: true,
+              })
+            );
           }
-
         } else {
           Object.assign(item, {
             rowspan: 1,