Browse Source

modify equip and system

haojianlong 5 years ago
parent
commit
82f247bd47

+ 12 - 0
src/api/scan/request.js

@@ -908,6 +908,18 @@ export function equipLinkSys(param, success) {
     http.postJson(url, param, success)
 }
 
+//设备清单 - 统计项目下所有设备数量
+export function countEquip(param, success) {
+    let url = `${baseUrl}/datacenter/equip/count`;
+    http.postJson(url, param, success)
+}
+
+//设备清单 - 查询设备信息
+export function queryEquip(param, success) {
+    let url = `${baseUrl}/datacenter/equip/query`;
+    http.postJson(url, param, success)
+}
+
 //创建资产所需(Family族id3位编码)-根据设备类型(4位编码)或部件类型(6位编码)查询
 export function getEquipBelongs(param, success) {
     let url = `${baseUrl}/datacenter/data-dictionary/family-query`;

+ 3 - 2
src/components/ledger/handsontables/device.vue

@@ -61,7 +61,7 @@
     <!-- 新增设备 -->
     <el-dialog title="确定新增设备的类型" :visible.sync="myDialog.addDevice" width="30%">
       <el-row>
-        <my-cascader ref="cascader" @change="changeAddType"></my-cascader>
+        <my-cascader ref="cascader" @change="changeAddType" :all="true"></my-cascader>
       </el-row>
       <span slot="footer" class="dialog-footer">
         <el-button type="primary" @click="toAddDevice">下 一 步</el-button>
@@ -519,6 +519,7 @@ export default {
       }
       let param = []
       params.map(item => {
+        this.deleteCode = item.Category
         param.push({ EquipID: item.EquipID })
       })
       this.$confirm("此操作将删除设备,是否继续?", "提示", {
@@ -536,7 +537,7 @@ export default {
     async removeDevice(param) {
       await deleteEquip(param, res => {
         this.$message.success("删除成功")
-        this.$emit('close','')
+        this.$emit('close', { code: this.deleteCode })
         this.getTableData()
       })
     },

+ 61 - 72
src/components/ledger/lib/cascader.vue

@@ -1,22 +1,13 @@
 <template>
   <div id="cascaderMap">
     <span class="buildFloor" style="margin-right: 12px;">设备类别</span>
-    <el-cascader
-      placeholder="请选择"
-      :options="options"
-      v-model="value"
-      :props="props"
-      filterable
-      :style="isWidth ? '' : 'width:160px;'"
-      size="small"
-      @change="changeVal"
-      change-on-select
-    ></el-cascader>
+    <el-cascader placeholder="请选择" :options="options" v-model="value" :props="props" filterable :style="isWidth ? '' : 'width:160px;'" size="small"
+      @change="changeVal" change-on-select></el-cascader>
   </div>
 </template>
 <script>
-import {mapGetters} from 'vuex';
-import { getEqCode } from "@/api/scan/request";
+import { mapGetters } from 'vuex';
+import { getEqCode, getEquipBelongs, queryEquip } from "@/api/scan/request";
 export default {
   name: "getCode",
   props: {
@@ -24,15 +15,13 @@ export default {
       type: Boolean,
       default: true
     },
-    isAll: {
+    all: {
       type: Boolean,
       default: false,
     }
   },
-    computed: {
-        ...mapGetters("layout", [
-            "projectId",
-        ])
+  computed: {
+    ...mapGetters("layout", ["projectId"])
   },
   data() {
     return {
@@ -47,13 +36,16 @@ export default {
     };
   },
   created() {
-    this.getData();
+    this.getAllData();
+    if (!this.all) {
+      this.getData();
+    }
   },
   watch: {
-      projectId() {
-          this.value = [''];
-          this.getData();
-      }
+    projectId() {
+      this.value = [''];
+      this.getAllData();
+    }
   },
   methods: {
     setValue(val) {
@@ -70,66 +62,63 @@ export default {
       this.value = val
       this.$emit("change", value)
     },
-    async getData() {
-      await getEqCode().then(res => {
-        if (this.isAll) {
-          let data = this.changeArr(res.data.Content)
-          data.unshift({
-            code: "all",
-            facility: "全部"
-          });
-          this.options = data
-          this.value = ["all"]
-        } else {
-          this.options = this.changeArr(res.data.Content);
+    //获取当前项目下的设备类型(只拿到编码-需要过滤)
+    getData() {
+      let param = {
+        Distinct: true,
+        PageNumber: 1,
+        PageSize: 500,
+        Projection: [
+          "Category"
+        ]
+      }
+      queryEquip(param, res => {
+        this.content = res.Content.map(t => {
+          return t.Category
+        });
+        this.filterForOptions();
+        if (this.value) {
+          this.changeVal(this.value)
         }
-        if (!!this.value && this.value.length) {
-          let value = {}
-          this.options.map(item => {
-            if (item.code == this.value[0]) {
-              value = item
-            }
-          })
-          this.$emit("change", value)
+      })
+    },
+    //获取物理世界所有设备类型
+    getAllData() {
+      let param = {
+        data: {
+          Distinct: true,
+          Orders: "EquipName asc",
+          PageNumber: 1,
+          PageSize: 500,
+          Projection: [
+            "EquipCode", "EquipName"
+          ]
         }
-        if (!this.falg) {
-          this.changeList()
+      }
+      getEquipBelongs(param, res => {
+        this.options = this.formatOptions(res.Content)
+        if (this.value) {
+          this.changeVal(this.value)
         }
-      });
+      })
     },
-    changeArr(arr) {
+    //格式化options数据
+    formatOptions(arr) {
       let data = [];
-      arr.map(item => {
-        if (item.content && item.content.length) {
-          data = data.concat(this.changeArr(item.content))
-        } else {
-          data.push(item)
-        }
-      });
+      arr.map(t => {
+        let temp = {};
+        temp.code = t.EquipCode;
+        temp.facility = t.EquipName;
+        data.push(temp)
+      })
       return data;
     },
-
-    pushData(content) {
-      this.content = content
-      if (this.options.length) {
-        this.falg = true
-        this.changeList()
-      } else {
-        this.falg = false
-      }
-    },
-
-    changeList() {
+    //过滤
+    filterForOptions() {
       this.options = this.options.filter(item => {
         if (this.content.indexOf(item.code) > -1) {
           return item
         }
-        // item.disabled = true
-        // this.content.map(child => {
-        //   if (item.code == child) {
-        //     item.disabled = false
-        //   }
-        // })
       })
     }
   }

+ 3 - 0
src/components/ledger/lib/system.vue

@@ -80,6 +80,9 @@ export default {
     getAllData(){
       getEqCode().then(res => {
         this.options = this.changeArr(res.data.Content)
+        if (this.value) {
+          this.changeVal(this.value)
+        }
       })
     },
     changeArr(arr) {

+ 18 - 35
src/views/ledger/facility/index.vue

@@ -19,7 +19,12 @@ import floorCascader from "@/components/ledger/lib/floorCascader";
 import myCascader from "@/components/ledger/lib/cascader";
 import hansonTable from "@/components/ledger/handsontables/device";
 import tableTransfers from "@/components/ledger/tableTransfers";
-import { getNumber, getFamilyList, getSpaceName, getGraphyId, getEquipmentFamily } from "@/api/scan/request"
+import {
+  getSpaceName,
+  getGraphyId,
+  getEquipmentFamily,
+  countEquip
+} from "@/api/scan/request"
 import {
   mapGetters,
   mapActions
@@ -69,7 +74,7 @@ export default {
     this.param.ProjId = this.projectId
     this.param.secret = this.secret
     this.getProjName()
-
+    this.getCount()
     let deviceId = this.$route.query.deviceId;
     if (deviceId) {
       this.$nextTick(() => {
@@ -82,6 +87,7 @@ export default {
       this.param.ProjId = this.projectId
       this.param.secret = this.secret
       this.getProjName()
+      this.getCount()
     }
   },
   methods: {
@@ -103,9 +109,12 @@ export default {
       })
     },
     close(val) {
-      this.getEqCode()
-      if (val && this.$refs.cascader)
+      // this.getEqCode()
+      this.getCount()
+      if (val && this.$refs.cascader){
         this.$refs.cascader.changeVal([val.code])
+      }
+        this.$refs.cascader.getData()
       //   this.$refs.tableMain.getHeaderData(this.param);
     },
     getEqCode() {
@@ -114,33 +123,13 @@ export default {
         this.getGraphyId()
       })
     },
-    getFamilyList() {
-      let param = {
-        ProjId: this.param.ProjId,
-        secret: this.param.secret,
-        data: { type: "Eq" }
-      }
-      getFamilyList(param, res => {
-        if (this.$refs.cascader) {
-          this.$refs.cascader.pushData(res.Content)
-        }
-
+    //获取统计数量
+    getCount() {
+      let param = {}
+      countEquip(param, res => {
+        this.mess.name[0].num = res.Count
       })
     },
-    //获取header的list
-    getNumber() {
-      let param = {
-        ProjId: this.param.ProjId,
-        secret: this.param.secret,
-        data: { type: "Eq" }
-      }
-      getNumber(param, res => {
-        this.mess.name[0].num = res.content.count
-        this.mess.name[1].num = res.content.bindingCount
-        this.getFamilyList()
-      })
-    },
-
     getGraphyId() {
       let param = {
         ProjId: this.param.ProjId,
@@ -152,7 +141,6 @@ export default {
           this.graphyId = res.data.graph_id
           if (this.$refs.tableMain)
             this.$refs.tableMain.setGraphyId(this.graphyId, this.assetGroupList);
-          this.getNumber()
         } else {
           this.$message.error("请求错误:" + res.data.ResultMsg)
         }
@@ -173,8 +161,6 @@ export default {
       if (!!this.param.deviceId) {
         if (this.$refs.tableMain)
           this.$refs.tableMain.getHeaderData(this.param);
-      } else {
-        return;
       }
     },
 
@@ -185,10 +171,7 @@ export default {
       if (!!value) {
         if (this.$refs.tableMain)
           this.$refs.tableMain.getHeaderData(this.param);
-      } else {
-        return;
       }
-
     }
   }
 };