Sfoglia il codice sorgente

系统详情加上参数SysType,设备类别为系统的子类别

LXXXY 5 anni fa
parent
commit
fcb2a4c0d6

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

@@ -515,7 +515,7 @@ export default {
           // this.$message("开发中...")
           this.$router.push({
             path: "/ledger/systemDetail",
-            query: { RoomID: infos.SysID, Name: infos.SysLocalName || infos.SysName }
+            query: { RoomID: infos.SysID, Name: infos.SysLocalName || infos.SysName, SysType: this.mess.deviceId }
           })
           return false
         //设备二维码图片

+ 3 - 3
src/components/ledger/system/dialog/addEquipDialog.vue

@@ -1,7 +1,7 @@
 <template>
   <el-dialog :title="title" :visible.sync="dialogVisible" width="900px" id="addEqDialog">
     <el-row class="filters">
-      <el-col :span="8" style="width:276px">
+      <el-col :span="7.5" style="width:276px">
         <el-input placeholder="输入设备名称或设备本地编码进行查询" v-model="keycode" clearable @keyup.enter.native="getTableData">
           <i slot="suffix" class="el-input__icon el-icon-search" @click="getTableData"></i>
         </el-input>
@@ -10,7 +10,7 @@
         <floor-cascader @change="changeFloor"></floor-cascader>
       </el-col>
       <el-col :span="8.5" style="padding-right:0;">
-        <my-cascader @change="changeDevice"></my-cascader>
+        <myCascader @change="changeDevice" :params="params"></myCascader>
       </el-col>
     </el-row>
 
@@ -48,7 +48,7 @@
 <script>
 import { unshaftInEq, linkEqSh } from "@/api/scan/request";
 import floorCascader from "@/components/ledger/lib/floorCascader";
-import myCascader from "@/components/ledger/lib/cascader";
+import myCascader from "@/components/ledger/system/lib/equipType";
 import { mapGetters } from "vuex";
 export default {
   components: {

+ 140 - 0
src/components/ledger/system/lib/equipType.vue

@@ -0,0 +1,140 @@
+<template>
+  <div id="cascaderMap">
+    <span class="buildFloor" style="margin-right: 12px;">设备类别</span>
+    <el-select v-model="value" placeholder="请选择" :props="props" filterable :style="isWidth ? '' : 'width:160px;'" size="small" @change="changeVal">
+      <el-option v-for="item in options" :key="item.code" :label="item.facility" :value="item.code"></el-option>
+    </el-select>
+  </div>
+</template>
+<script>
+import { mapGetters } from 'vuex';
+import { queryPhysicsAllType, queryEquip } from "@/api/scan/request";
+export default {
+  name: "getCode",
+  props: {
+    isWidth: {
+      type: Boolean,
+      default: true
+    },
+    all: {
+      type: Boolean,
+      default: false,
+    },
+    //系统
+    params: Object
+  },
+  computed: {
+    ...mapGetters("layout", ["projectId"])
+  },
+  data() {
+    return {
+      value: "",
+      options: [],
+      props: {
+        value: "code",
+        label: "facility"
+      },
+      falg: true,
+      content: []
+    };
+  },
+  created() {
+    this.getData();
+  },
+  watch: {
+    projectId() {
+      this.value = '';
+      this.getData();
+    }
+  },
+  methods: {
+    setValue(val) {
+      this.value = val
+    },
+    //修改val
+    changeVal(val) {
+      let value = {}
+      this.options.map(item => {
+        if (item.code == val) {
+          value = item
+        }
+      })
+      this.value = val
+      this.$emit("change", value)
+    },
+    //获取当前项目下的设备类型(只拿到编码-需要过滤)
+    getData() {
+      let param2 = {
+        Distinct: true,
+        PageNumber: 1,
+        PageSize: 500,
+        Projection: [
+          "Category"
+        ]
+      }
+      let param1 = 'Equipment'
+      let promise2 = new Promise((resolve, reject) => {
+        queryEquip(param2, res => {
+          resolve(res)
+        })
+      })
+      let promise1 = new Promise((resolve, reject) => {
+        queryPhysicsAllType(param1, res => {    
+          let tempArr = res.Content.filter(t => {
+            return t.ParentId == `${this.params.SysType}`
+          })
+          console.log(tempArr)
+          resolve(tempArr)
+        })
+      })
+      Promise.all([promise1, promise2]).then((res) => {
+        let allData = res[0], data = res[1]
+        console.log(allData)
+        this.options = this.formatOptions(allData)
+        console.log(this.options)
+        if (this.value) {
+          this.changeVal(this.value)
+        }
+        if (!this.all) {
+          this.content = data.Content.map(t => {
+            return t.Category
+          });
+          this.filterForOptions();
+          if (this.value) {
+            this.changeVal(this.value)
+          }
+        }
+      })
+    },
+    //格式化options数据
+    formatOptions(arr) {
+      let data = [];
+      arr.map(t => {
+        let temp = {};
+        temp.code = t.Code;
+        temp.facility = t.Name;
+        data.push(temp)
+      })
+      return data;
+    },
+    //过滤
+    filterForOptions() {
+      this.options = this.options.filter(item => {
+        if (this.content.indexOf(item.code) > -1) {
+          return item
+        }
+      })
+    }
+  }
+};
+</script>
+<style lang="less" scoped>
+#cascaderMap {
+  float: left;
+  margin-left: 10px;
+  .buildFloor {
+    color: #999999;
+    font-size: 14px;
+  }
+}
+</style>