Browse Source

Merge branch 'apiupdate' of git.sagacloud.cn:web/ibms into apiupdate-zy

zhangyu 5 years ago
parent
commit
e943d80bac

+ 19 - 1
src/api/scan/request.js

@@ -908,12 +908,18 @@ export function queryLinkSys(param, success) {
     http.postJson(url, param, success)
 }
 
-//设备清单 - 设备关联系统
+//设备清单 - 设备关联系统 设备1-n
 export function equipLinkSys(param, success) {
     let url = `${baseUrl}/datacenter/sy-in-eq/link-sy`;
     http.postJson(url, param, success)
 }
 
+//设备清单 - 设备关联系统 系统1-n   
+export function sysLinkEquip(param, success) {
+    let url = `${baseUrl}/datacenter/sy-in-eq/link-eq`;
+    http.postJson(url, param, success)
+} 
+
 //设备清单 - 统计项目下所有设备数量
 export function countEquip(param, success) {
     let url = `${baseUrl}/datacenter/equip/count`;
@@ -1005,6 +1011,18 @@ export function createGeneralSys(param, success) {
     http.postJson(url, param, success)
 }
 
+//查询不在当前系统下的设备
+export function getEquipNotInSys(param, success) {
+    let url = `${baseUrl}/equip-component/equip-query/equip-sys?sysId=${param.sysId}`;
+    http.postJson(url, param.data, success)
+}
+
+//查询当前系统下的设备
+export function getEquipInSys(param, success) {
+    let url = `${baseUrl}/equip-component/equip-query/sys-equip`;
+    http.postJson(url, param, success)
+}
+
 //根据条件查询统计数量
 export function countGeneralSys(param, success) {
     let url = `${baseUrl}/datacenter/general—system/count`;

+ 2 - 2
src/components/ledger/handsontables/system.vue

@@ -475,7 +475,7 @@ export default {
     getInfors(infos, row) {
       //其他的开始判断
       let val = this.hot.colToProp(row.col);
-      this.systemId = infos.EquipID
+      this.systemId = infos.SysID
       this.row = row.row
       this.messKey = val
       switch (val) {
@@ -493,7 +493,7 @@ export default {
             this.$message("此设备没有设备二维码");
           }
           break;
-        //包含的部件字段
+        //关联设备数量
         case 'Count':
           if (!this.onlyRead) {
             this.myDialog.relevance = true

+ 1 - 1
src/components/ledger/lib/cascader.vue

@@ -7,7 +7,7 @@
 </template>
 <script>
 import { mapGetters } from 'vuex';
-import { getEqCode, getEquipBelongs, queryEquip } from "@/api/scan/request";
+import { getEquipBelongs, queryEquip } from "@/api/scan/request";
 export default {
   name: "getCode",
   props: {

+ 155 - 253
src/components/ledger/tableTransfers.vue

@@ -6,106 +6,61 @@
         <div class="border-view">
           <div class="search">
             <div class="search-small" style="padding: 10px 10px 0 10px">
-              <el-input
-                placeholder="输入设备名称进行查询"
-                v-model="search.filter"
-                style="width:300px;margin-right: 10px;"
-                size="small"
-                clearable
-              ></el-input>
+              <el-input placeholder="输入设备名称进行查询" v-model="search1" style="width:300px;margin-right: 10px;" size="small" clearable></el-input>
               <el-button @click="getLeftData" size="small">查找</el-button>
             </div>
             <div class="search-small" style="padding: 10px">
-              <floor-cascader :isWidth="false"></floor-cascader>
-              <cascader :isWidth="false" @change="changeCascader" :isAll="true"></cascader>
+              <floor-cascader :isWidth="false" @change="changeBuild"></floor-cascader>
+              <cascader :isWidth="false" @change="changeCascader" :all="true"></cascader>
             </div>
           </div>
-          <el-table
-            ref="multipleTable"
-            :data="tableData"
-            height="300px"
-            tooltip-effect="dark"
-            style="width: 100%"
-            class="data-table"
-            @selection-change="handleSelectionChange"
-            v-loading="isLoading1"
-            border
-          >
+          <el-table ref="multipleTable" :data="tableData" height="300px" tooltip-effect="dark" style="width: 100%" class="data-table"
+            @selection-change="handleSelectionChange" v-loading="isLoading1" border>
             <el-table-column type="selection" width="55"></el-table-column>
             <el-table-column label="设备名称" width="120">
-              <template
-                slot-scope="scope"
-              >{{ scope.row.infos.EquipLocalName || scope.row.infos.EquipName }}</template>
+              <template slot-scope="scope">{{ scope.row.EquipLocalName || scope.row.EquipName }}</template>
             </el-table-column>
             <el-table-column label="设备编号" width="120">
-              <template slot-scope="scope">{{ scope.row.infos.EquipLocalID || "--" }}</template>
+              <template slot-scope="scope">{{ scope.row.EquipLocalID || "--" }}</template>
             </el-table-column>
             <el-table-column label="设备类" show-overflow-tooltip>
-              <template slot-scope="scope">{{ getName(scope.row.category) }}</template>
+              <template slot-scope="scope">{{ getName(scope.row.Category) }}</template>
             </el-table-column>
             <el-table-column prop="address" label="安装位置" show-overflow-tooltip>
-              <template slot-scope="scope">{{ scope.row.infos.InstallLocation || "--" }}</template>
+              <template slot-scope="scope">{{ scope.row.InstallLocation || "--" }}</template>
             </el-table-column>
           </el-table>
           <div class="right">
-              <my-pagination @change="changePages1" :page="pages1"></my-pagination>
+            <my-pagination @change="changePages1" :page="pages1"></my-pagination>
           </div>
         </div>
       </div>
       <div class="main-button">
-        <el-button
-          class="top"
-          @click="rightToLeft"
-          :disabled="SelectionList && SelectionList.length ? false : true"
-          :type="SelectionList && SelectionList.length ? 'primary' : ''"
-          icon="el-icon-arrow-left"
-          circle
-        ></el-button>
-        <el-button
-          class="bottom"
-          @click="leftToRight"
-          :disabled="multipleSelection && multipleSelection.length ? false : true"
-          :type="multipleSelection && multipleSelection.length ? 'primary' : ''"
-          icon="el-icon-arrow-right"
-          circle
-        ></el-button>
+        <el-button class="top" @click="rightToLeft" :disabled="SelectionList && SelectionList.length ? false : true"
+          :type="SelectionList && SelectionList.length ? 'primary' : ''" icon="el-icon-arrow-left" circle></el-button>
+        <el-button class="bottom" @click="leftToRight" :disabled="multipleSelection && multipleSelection.length ? false : true"
+          :type="multipleSelection && multipleSelection.length ? 'primary' : ''" icon="el-icon-arrow-right" circle></el-button>
       </div>
       <div class="main-right">
         <h4>已关联该系统的设备</h4>
         <div class="border-view">
           <div class="search">
             <div class="search-big">
-              <el-input
-                placeholder="输入设备名称、设备类名称进行查询"
-                v-model="search2.filter"
-                style="width:200px; margin-bottom: 10px;"
-                size="small"
-                clearable
-              ></el-input>
+              <el-input placeholder="输入设备名称进行查询" v-model="search2" style="width:200px; margin-bottom: 10px;" size="small" clearable>
+              </el-input>
               <el-button @click="getRightData" size="small">查找</el-button>
             </div>
           </div>
-          <el-table
-            ref="multipleTable"
-            :data="table2Data"
-            height="300px"
-            tooltip-effect="dark"
-            style="width: 100%"
-            class="data-table"
-            @selection-change="tableChange"
-            v-loading="isLoading2"
-            border
-          >
+          <el-table ref="multipleTable" :data="table2Data" height="300px" tooltip-effect="dark" style="width: 100%" class="data-table"
+            @selection-change="tableChange" v-loading="isLoading2" border>
             <el-table-column type="selection" width="55"></el-table-column>
             <el-table-column label="设备名称">
-              <template
-                slot-scope="scope"
-              >{{ scope.row.infos.EquipLocalName || scope.row.infos.EquipName }}</template>
+              <template slot-scope="scope">{{ scope.row.EquipLocalName || scope.row.EquipName }}</template>
             </el-table-column>
           </el-table>
-            <div class="right">
-                <my-pagination :page="pages2" @change="changePages2" :isSmall="false"></my-pagination>
-            </div>
+          <div class="right">
+            <my-pagination :page="pages2" @change="changePages2" :isSmall="false"></my-pagination>
+          </div>
         </div>
       </div>
     </div>
@@ -116,11 +71,16 @@ import myPagination from "@/components/common/myPagination";
 import floorCascader from "@/components/ledger/lib/floorCascader";
 import cascader from "@/components/ledger/lib/cascader";
 
-import { getBillEquipList, getEqCode, getBussines, deleteRelation, getGraphyId, getSysToEq, createRelation } from "@/api/scan/request"
 import {
-        mapGetters,
-        mapActions
-    } from "vuex";
+  getEquipNotInSys,
+  getEquipInSys,
+  getEquipBelongs,
+  sysLinkEquip
+} from "@/api/scan/request"
+import {
+  mapGetters,
+  mapActions
+} from "vuex";
 export default {
   props: {
     dialog: {
@@ -141,12 +101,8 @@ export default {
     cascader
   },
   computed: {
-            ...mapGetters("layout", [
-                "projectId",
-                "secret",
-                "userId"
-            ])
-        },
+    ...mapGetters("layout", ["projectId", "secret", "userId"])
+  },
   data() {
     return {
       dialogVisible: true,
@@ -162,30 +118,22 @@ export default {
         total: 0,
         currentPage: 1
       },
-      search: {//第一个table的搜索条件
-        filter: "",//文本框条件
-        build: "all",//建筑
-        floor: "",//楼层
-        category: "all"//设备类别
-      },
-      search2: {//第二个搜索条件
-        filter: "",//搜索文案
-      },
-      tableData: [
-      ], //第一个表格的数据
-      table2Data: [
-      ], //第二个表格的数据
+      search1: '', //左侧输条件
+      search2: '',//右侧输入条件
+      buildingId: '',//建筑id
+      floorId: '',//楼层id
+      category: '',//设备类型 
+      tableData: [], //第一个表格的数据
+      table2Data: [], //第二个表格的数据
       multipleSelection: [], //第一个表格的被选择数组
       SelectionList: [], //第二个表格的被选择数组
-      list: [],
-      graphyId: "",
+      List: [],
       isLoading1: false,
       isLoading2: false,
     };
   },
   created() {
-    this.getData();
-    this.getgraphyId();
+    this.getAllData();
   },
   methods: {
     //关闭
@@ -193,52 +141,51 @@ export default {
       this.$emit("close")
       done()
     },
-    getgraphyId() {
-      getGraphyId({
-        type: "SystemEquip",
-        secret: this.secret,
-        ProjId: this.projectId
-      }).then(res => {
-        if (res.data.Result == "success") {
-          this.graphyId = res.data.graph_id
-        } else {
-          this.$message.error("请求失败:" + res.data.ResultMsg)
-        }
-      }).catch(_ => [
-        this.$message.error("请求失败")
-      ])
-    },
+    //根据设备类型编码获取名称
     getName(code) {
-      code = code.substring(2, 6)
       let str = ""
-      this.list.map(item => {
+      this.List.map(item => {
         if (item.code == code) {
           str = item.facility
         }
       })
       return str
     },
-    getData() {
-      getEqCode().then(res => {
-        this.list = this.changeArr(res.data.Content)
-      });
+    //获取物理世界所有设备类型
+    getAllData() {
+      let param = {
+        data: {
+          Distinct: true,
+          Orders: "EquipName asc",
+          PageNumber: 1,
+          PageSize: 500,
+          Projection: [
+            "EquipCode", "EquipName"
+          ]
+        }
+      }
+      getEquipBelongs(param, res => {
+        this.List = this.formatOptions(res.Content)
+      })
     },
-    //修改
-    changeArr(arr) {
+    //格式化List数据
+    formatOptions(arr) {
       let data = [];
-      arr.map(item => {
-        if (item.content && item.content.length) {
-          return item.content.map(children => {
-            if (children.content && children.content.length) {
-              return children.content.map(i => {
-                data.push(i);
-              });
-            }
-          });
-        }
-      });
+      arr.map(t => {
+        let temp = {};
+        temp.code = t.EquipCode;
+        temp.facility = t.EquipName;
+        data.push(temp)
+      })
       return data;
     },
+    //获取两侧数据
+    getAllTable() {
+      this.pages1.currentPage = 1
+      this.pages2.currentPage = 1
+      this.getLeftData()
+      this.getRightData()
+    },
     //pages1改变
     changePages1() {
       this.getLeftData()
@@ -246,173 +193,128 @@ export default {
     changePages2() {
       this.getRightData()
     },
+    //修改设备类型
     changeCascader(val) {
-      this.search.category = val.code
+      this.category = val.code
       this.getLeftData()
     },
-    getAllData() {
-      console.log(this.id)
-      this.getLeftData()
-      this.getRightData()
-    },
-
+    //获取未关联该系统的设备
     getLeftData() {
       this.isLoading1 = true
       let param = {
         data: {
-          "limit": {        // 分页查询, 选填.
-            "skip": this.pages1.size * (this.pages1.currentPage - 1),  // 跳过多少数据
-            "count": this.pages1.size   // 查询跳过300条数据之后的50条 (默认按照创建时间从大-->小排序)
-          },
-          id: "",
-          excludeSystemId: this.id,
-          type: [this.search.category == "all" ? "Eq" : this.search.category]
+          Filters: '',
+          Orders: "EquipID desc",
+          PageNumber: this.pages1.currentPage,
+          PageSize: this.pages1.size
         },
-        secret: this.secret,
-        ProjId: this.projectId
+        sysId: this.id
+      }
+      if (this.search1 != '') {
+        param.data.Filters = `EquipLocalName contain "${this.search1}";`
       }
-      if (this.search.filter) {
-        param.data.filter = {}
-        param.data.filter.EquipLocalName = this.search.filter == ""
+      //建筑id
+      if (this.buildingId == "noKnow") {
+        param.data.Filters += `buildingId isNull;`
+      } else if (this.buildingId && this.buildingId != "all") {
+        param.data.Filters += `buildingId='${this.buildingId}';`
       }
-      if (this.search.build == "all") {
-        param.data.id = this.projectId
-      } else if (this.search.floor && this.search.floor != "all") {
-        param.data.id = this.search.floor
-      } else if (this.search.floor == 'all') {
-        param.data.id = this.search.build
+      //楼层id
+      if (this.floorId == "noKnow") {
+        param.data.Filters += `floorId isNull;`
+      } else if (this.floorId && this.floorId != "all") {
+        param.data.Filters += `floorId='${this.floorId}';`
+      }
+      //设备类型
+      if (this.category) {
+        param.data.Filters += `category='${this.category}';`
+      }
+      if (param.data.Filters) {
+        param.data.Filters = param.data.Filters.substring(0, param.data.Filters.length - 1)
       } else {
-        param.data.id = this.search.ProjId
+        delete param.data.Filters;
       }
-      getBillEquipList(param, res => {
+      getEquipNotInSys(param, res => {
         this.tableData = res.Content
-        this.pages1.total = res.TotalCount
+        this.pages1.total = res.Total
         this.isLoading1 = false
       })
     },
-
+    //获取已关联该系统的设备
     getRightData() {
       this.isLoading2 = true
       let param = {
-        data: {
-          "limit": {        // 分页查询, 选填.
-            "skip": this.pages2.size * (this.pages2.currentPage - 1),  // 跳过多少数据
-            "count": this.pages2.size   // 查询跳过300条数据之后的50条 (默认按照创建时间从大-->小排序)
-          },
-          filter: {
-            EquipLocalName: this.search2.filter
-          },
-          criteria: {
-            fromId: this.id,
-            graphType: "SystemEquip",
-            relType: "1",
-            side: "toId",
-            type: ["Eq"]
-          }
-        },
-        secret: this.secret,
-        ProjId: this.projectId
+        Filters: `sysId='${this.id}'`,
+        Orders: "EquipID desc",
+        PageNumber: this.pages1.currentPage,
+        PageSize: this.pages1.size
       }
-      getSysToEq(param, res => {
+      if (this.search2 != '') {
+        param.Filters += `;EquipLocalName contain "${this.search2}"`
+      }
+      getEquipInSys(param, res => {
         this.table2Data = res.Content
-        this.pages2.total = res.TotalCount
+        this.pages2.total = res.Total
         this.isLoading2 = false
       })
     },
-
-    getList() {
-
-    },
-
     //左侧多选框改变
     handleSelectionChange(val) {
-      this.multipleSelection = val;
+      this.multipleSelection = val
     },
-
-    //多选框发生改变
+    //右侧多选框发生改变
     tableChange(val) {
       this.SelectionList = val;
     },
-
     //关联
     leftToRight() {
-      let param = {
-        data: {
-          criterias: []
-        },
-        secret: this.secret,
-        ProjId: this.projectId
-      }
-      this.multipleSelection.map(item => {
-        param.data.criterias.push({
-          from_id: this.id,
-          to_id: item.id,
-          graph_id: this.graphyId,
-          rel_type: "1",
-          infos: null
-        })
-      })
-      createRelation(param).then(res => {
-        if (res.data.Result == "success") {
-          this.$message.success("关联成功")
-          this.getAllData()
-        } else {
-          this.$message.error("请求失败:" + res.data.ResultMsg)
-        }
-      }).catch(_ => {
-        this.$message.error("请求失败")
+      let relationList = this.multipleSelection.concat(this.table2Data)
+      relationList = relationList.map(t => {
+        return t.EquipID || t.EquipId
       })
+      this.relationChange(relationList)
     },
-
     //取消关联
     rightToLeft() {
+      let relationList = [];
+      let tempIDs = this.SelectionList.map(t => {
+        return t.EquipId
+      })
+      this.table2Data.map(t => {
+        if (tempIDs.indexOf(t.EquipId) < 0) {
+          relationList.push(t.EquipId)
+        }
+      })
+      this.relationChange(relationList)
+    },
+    //更新设备 系统关系
+    relationChange(arr) {
       let param = {
-        data: {
-          criterias: []
-        },
-        secret: this.secret,
-        ProjId: this.projectId
+        SysID: this.id,
+        EquipIdList: arr
       }
-      this.SelectionList.map(item => {
-        param.data.criterias.push({
-          from_id: this.id,
-          to_id: item.id,
-          graph_id: this.graphyId,
-          rel_type: "1"
-        })
+      sysLinkEquip(param, res => {
+        this.$message.success('修改关联关系成功')
+        this.getAllTable()
       })
-
-      if (!!this.id) {
-        deleteRelation(param).then(res => {
-          if (res.data.Result == "success") {
-            this.$message.success("取消关联成功")
-            this.getAllData()
-          } else {
-            this.$message.error("请求失败:" + res.data.ResultMsg)
-          }
-        }).catch(_ => {
-          this.$message.error("请求失败")
-        })
-      } else {
-        this.$message.error("id为空")
+    },
+    //修改楼层
+    changeBuild(val) {
+      this.buildingId = val[0]
+      if (val[1]) {
+        this.floorId = val[1]
       }
-    }
+      this.getLeftData()
+    },
   },
   watch: {
     dialog: {
       deep: true,
       handler: function () {
         if (this.dialog.relevance) {
-          this.search = {//第一个table的搜索条件
-            filter: "",//文本框条件
-            build: "all",//建筑
-            floor: "",//楼层
-            category: "all"//设备类别
-          }
-          this.search2 = {//第二个搜索条件
-            filter: "",//搜索文案
-          }
-          this.getAllData()
+          this.search1 = ''
+          this.search2 = ''
+          this.getAllTable()
         }
       }
     }
@@ -421,21 +323,21 @@ export default {
 </script>
 <style lang="less">
 #tableTransfers {
-    height: 500px;
+  height: 500px;
   width: 100%;
   overflow-x: hidden;
-  overflow-y: auto; 
+  overflow-y: auto;
   h4 {
     font-size: 20px;
     font-weight: 500;
   }
   .search {
     .search-small {
-        overflow: hidden;
+      overflow: hidden;
     }
     border-bottom: #dcdfe6 1px solid;
     .search-big {
-        padding: 10px;
+      padding: 10px;
     }
   }
   .main-left {