Просмотр исходного кода

Merge branch 'master' of http://39.106.8.246:3003/web/wanda-adm

haojianlong 3 лет назад
Родитель
Сommit
449188859b

+ 9 - 9
src/views/maintain/relationship/components/tableHeader.ts

@@ -1,12 +1,12 @@
 const tableHeader = {
-    '设备所在建筑': [['建筑', 'objectInfo'], ['BIM构件名称', ''], '系统分类', '设备类型名称', ['设备本地编码', "localId"]],
-    '设备所在楼层': [['建筑', 'objectInfo'], '楼层', ['BIM构件名称', ''], '系统分类', '设备类型名称', ['设备本地编码', "localId"]],
-    '设备所在功能空间': [['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], '楼层', ['BIM构件名称', ''], '系统分类', '设备类型名称', ['设备本地编码', "localId"]],
-    '设备服务功能空间': [['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], '楼层', ['BIM构件名称', ''], '系统分类', '设备类型名称', ['设备本地编码', "localId"]],
-    '设备所在供电空间': [['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], '楼层', ['BIM构件名称', ''], '系统分类', '设备类型名称', ['设备本地编码', "localId"]],
-    '空间所在建筑': [['建筑', 'objectInfo'], ['空间本地名称', "localName"], ['空间本地编码', "localId"], '楼层'],
-    '空间所在楼层': [['建筑', 'objectInfo'], '楼层', ['空间本地名称', "localName"], ['空间本地编码', "localId"]],
-    '空间服务空间': [['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], '楼层', ['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], '楼层'],
-    '系统下的设备': ['系统分类', '分类名称', '系统编码', ['BIM构件名称', ''], '系统分类', '设备类型名称', ['设备本地编码', "localId"]],
+    '设备所在建筑': [['建筑', 'objectInfo'], ['BIM构件名称', 'localName'], ['系统分类','systemCategory'], ['设备类型名称','codeName'], ['设备本地编码', "localId"]],
+    '设备所在楼层': [['建筑', 'objectInfo'], ['楼层','floorName'], ['BIM构件名称', 'localName'], ['系统分类','systemCategory'], ['设备类型名称','codeName'], ['设备本地编码', "localId"]],
+    '设备所在功能空间': [['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], ['楼层','floorName'], ['BIM构件名称', 'localName'], ['系统分类','systemCategory'], ['设备类型名称','codeName'], ['设备本地编码', "localId"]],
+    '设备服务功能空间': [['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], ['楼层','floorName'], ['BIM构件名称', 'localName'], ['系统分类','systemCategory'], ['设备类型名称','codeName'], ['设备本地编码', "localId"]],
+    '设备所在供电空间': [['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], ['楼层','floorName'], ['BIM构件名称', 'localName'], ['系统分类','systemCategory'], ['设备类型名称','codeName'], ['设备本地编码', "localId"]],
+    '空间所在建筑': [['建筑', 'objectInfo'], ['空间本地名称', "localName"], ['空间本地编码', "localId"], ['楼层','floorName']],
+    '空间所在楼层': [['建筑', 'objectInfo'], ['楼层','floorName'], ['空间本地名称', "localName"], ['空间本地编码', "localId"]],
+    '空间服务空间': [['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], ['楼层','floorName'], ['空间本地名称', "localName"], ['空间本地编码', "localId"], ['建筑', 'objectInfo'], ['楼层','floorName']],
+    '系统下的设备': [['系统分类','systemCategory'], ['分类名称',''], ['系统编码',''], ['BIM构件名称', 'localName'], ['系统分类','systemCategory'], ['设备类型名称','codeName'], ['设备本地编码', "localId"]],
 }
 export default tableHeader

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

@@ -1,53 +1,73 @@
 <template>
-    <el-table
-        :data="tableData"
-        :span-method="objectSpanMethod"
-        :header-cell-style="{ background: '#e1e4e5',color: '#2b2b2b', lineHeight: '30px' }"
-        class="table"
-        style="width: 100%;"
-        height="100%"
+  <el-table
+    :data="tableData"
+    :span-method="objectSpanMethod"
+    :header-cell-style="{
+      background: '#e1e4e5',
+      color: '#2b2b2b',
+      lineHeight: '30px',
+    }"
+    v-loading="loading"
+    class="table"
+    style="width: 100%"
+    :height="height ? height : '100%'"
+  >
+    <el-table-column
+      v-for="(item, index) in tableHeader"
+      :key="index"
+      :prop="item[1]"
+      :label="item[0]"
+      align="left"
     >
-        <el-table-column
-            v-for="(item,index) in tableHeader"
-            :key="index"
-            prop="cCADID"
-            :label="item"
-            align="left"
-        >
-        </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>
+      <template slot-scope="scope">
+        {{ item[1] == 'objectInfo' ? scope.row.objectInfo[0].name :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>
 </template>
 
 <script lang="ts">
+import { relDel } from "@/api/datacenter";
 import { Component, Prop, Vue } from "vue-property-decorator";
-
 @Component({
-    name: 'relation-table'
+  name: "relation-table",
 })
 export default class extends Vue {
+  @Prop({ default: Array }) tableHeader?: [];
+  @Prop({ default: Array }) tableData?: [];
+  @Prop({ default: String || Number }) height?: "";
+  @Prop({ default: Boolean }) loading?: false;
 
-    @Prop({default:Array}) tableHeader?:[]
-    @Prop({default:Array}) tableData?:[]
-
-    objectSpanMethod() {
-
-    }
-
-    deleteObject() {
-
-    }
+  objectSpanMethod() {}
+  //  删除
+  deleteObject(index: number, val: any) {
+    const data = {
+      relType: this.$route.query.relationType,
+      graphicType: this.$route.query.graphicType,
+      fromId: val.id, //主对象id
+      toId: val.objectInfo.id, //主对象id
+    };
+    relDel(data).then((res) => {
+      if (res.result == "success") {
+        this.$message.success("删除成功!");
+        this.$emit("updata");
+      } else {
+        this.$message.error("删除失败!");
+      }
+    });
+  }
 }
 </script>
 
-<style scoped>
-
+<style  scoped>
 </style>

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

@@ -48,9 +48,30 @@
         <AdmSearch @SearchValue="minorSearch" />
       </el-col>
     </el-row>
-    <relationTable :tableHeader="tableHeader" :tableData="tableData" />
+    <relationTable
+      v-if="tableHeight"
+      @updata="relManualQuery"
+      :tableHeader="tableHeader"
+      :tableData="tableData"
+      :height="tableHeight"
+      :loading="loading"
+    />
+    <!-- 分页 -->
+    <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>
     <addRelationDialog
       @closeAddRelation="addRelationValue = false"
+      @update="relManualQuery"
       :addRelationValue="addRelationValue"
       :values="values"
     />
@@ -67,7 +88,7 @@ import tableHeader from "@/views/maintain/relationship/components/tableHeader";
 import addRelationDialog from "./components/addRelationDialog.vue";
 import editRelationDialog from "./components/editRelationDialog.vue";
 import excelDialog from "./components/excelDialog.vue";
-import { relToType, relManualQuery } from "@/api/datacenter";
+import { relToType, relManualQuery, relDel } from "@/api/datacenter";
 
 @Component({
   name: "relation",
@@ -119,6 +140,13 @@ export default class extends Vue {
   };
   relTypeStatus: any = 0; //关系相关类型主从 0 None 1主 2从 3主从
 
+  page: object = {
+    total: 0, //总数
+    currentPage: 1, //当前页
+    pageSize: 15, //当前页数量
+  };
+  tableHeight: number = 0; //table高
+  loading: Boolean = false; //是否显示loadding
   /////////////////////////////////////////
   // 方法
 
@@ -136,6 +164,26 @@ export default class extends Vue {
   }
 
   /**
+   * 分页数量切换
+   */
+
+  handleSizeChange(val: any) {
+    Object.assign(this.page, {
+      pageSize: val,
+    });
+    this.relManualQuery();
+  }
+  /**
+   * 分页切换
+   */
+  handleCurrentChange(val: any) {
+    Object.assign(this.page, {
+      currentPage: val,
+    });
+    this.relManualQuery();
+  }
+
+  /**
    * 主关系下拉框选择
    */
   mainSelect(val: any) {
@@ -214,22 +262,30 @@ export default class extends Vue {
    * 获取table列表
    */
   relManualQuery() {
+    this.loading = true;
     // 获取table数据
     const data = {
       projectId: this.$route.query.projectId,
+      categoryFrom: this.categoryFrom,
+      categoryTo: this.categoryTo,
       vagueTo: this.vagueTo, //主关系
       vagueFrom: this.vagueFrom, //从关系
       objectType: 1,
       relType: this.$route.query.relationType,
-      pageSize: 50,
-      pageNumber: 1,
+      pageSize: this.page.pageSize,
+      pageNumber: this.page.currentPage,
       graphicType: this.$route.query.graphicType,
       zoneType: this.$route.query.zoneType ? this.$route.query.zoneType : "",
     };
-    relManualQuery(data).then((res) => {
-      console.log("this.tableHeader", this.tableHeader);
-      this.tableData = res.content;
-    });
+    relManualQuery(data)
+      .then((res) => {
+        this.tableData = res.content;
+        this.page.total = res.total;
+        this.loading = false;
+      })
+      .catch((error) => {
+        this.loading = false;
+      });
   }
 
   created() {
@@ -241,6 +297,14 @@ export default class extends Vue {
     // 获取table列表
     this.relManualQuery();
   }
+  mounted() {
+    //计算table的高度
+    let allHeight =
+      document.getElementsByClassName("relation")[0].offsetHeight - 57; //57是Head的高
+    let contentHeight = document.getElementsByClassName("content")[0]
+      .offsetHeight;
+    this.tableHeight = allHeight - contentHeight - 47;
+  }
 }
 </script>
 
@@ -266,5 +330,10 @@ export default class extends Vue {
       }
     }
   }
+  .pagination {
+    margin-top: 12px;
+    margin-right: 24px;
+    float: right;
+  }
 }
 </style>