Browse Source

fix query building bug and modify systemdialog

haojianlong 5 years ago
parent
commit
9eefd5f731

+ 13 - 11
src/components/dialogs/changeRea.vue

@@ -16,7 +16,9 @@
           <el-table :data="tableData" style="width: 100%" height="300px">
             <el-table-column label="资产名称">
               <template slot-scope="scope">
-                <el-radio :label="scope.row.EquipID">{{scope.row.EquipLocalName || scope.row.EquipName}}</el-radio>
+                <el-radio :label="scope.row.EquipID" :ref="scope.row.EquipID" :value="scope.row.EquipLocalName || scope.row.EquipName">
+                  {{scope.row.EquipLocalName || scope.row.EquipName}}
+                </el-radio>
               </template>
             </el-table-column>
             <el-table-column label="本地编码">
@@ -46,7 +48,7 @@
 <script>
 import myPagination from "@/components/ledger/lib/myPagination";
 import paramDetails from "@/components/dialogs/list/paramDetails"
-import { getBillPropList, getEquipmentFamily, getSpaceFloor, getBussines2, upDateTableMain, queryProperty } from "@/api/scan/request"
+import { getSpaceFloor, queryProperty } from "@/api/scan/request"
 import floorCascader from "@/components/ledger/lib/floorCascader";
 import { mapGetters, mapActions } from "vuex"
 export default {
@@ -118,7 +120,7 @@ export default {
     //确认选择
     clickTrue() {
       if (this.radio) {
-        this.$emit('changeProperty', this.radio);
+        this.$emit('changeProperty', { PropertyId: this.radio, LinkEquipLocalName: this.$refs[this.radio].value });
         this.dialog.changeRea = false;
       } else {
         this.$message("请先选择资产")
@@ -166,20 +168,20 @@ export default {
     getPropertyData() {
       let param = {
         Filters: `EquipmentId isNull;Family="${this.category.assetType}"`,
-        PageNumber: 1,
-        PageSize: 50
+        PageNumber: this.page.currentPage,
+        PageSize: this.page.size
       }
       //建筑id
-      if (this.mess.buildId && this.mess.buildId != "all") {
-        param.Filters += `;buildingId='${this.mess.buildId}'`
-      } else if (this.mess.buildId == "noKnow") {
+      if (this.mess.buildId == "noKnow") {
         param.Filters += `;buildingId isNull`
+      } else if (this.mess.buildId && this.mess.buildId != "all") {
+        param.Filters += `;buildingId='${this.mess.buildId}'`
       }
       //楼层id
-      if (this.mess.floorId && this.mess.floorId != "all") {
-        param.Filters += `;floorId='${this.mess.floorId}'`
-      } else if (this.mess.floorId == "noKnow") {
+      if (this.mess.floorId == "noKnow") {
         param.Filters += `;floorId isNull`
+      } else if (this.mess.floorId && this.mess.floorId != "all") {
+        param.Filters += `;floorId='${this.mess.floorId}'`
       }
       //名称和编码
       if (this.search) {

+ 98 - 117
src/components/dialogs/list/systemType.vue

@@ -6,19 +6,30 @@
     <div>
       <div id="systemType">
         <div class="title-search query-form" style="padding: 10px;margin-bottom: 10px;" v-if="type != 'read' ">
-          <el-input placeholder="输入名称或编码进行查询" v-model="search" size="small" style="width:300px; margin-right:10px" clearable></el-input>
-          <el-button size="small" @click="searchChecked">查找</el-button>
+          <el-row>
+            <el-col :span="10">
+              <span>系统所属建筑</span>
+              <el-select v-model="buildId" placeholder="请选择">
+                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
+                </el-option>
+              </el-select>
+            </el-col>
+            <el-col :span="14">
+              <el-input placeholder="输入名称或编码进行查询" v-model="search" size="small" style="width:300px; margin-right:10px" clearable></el-input>
+              <el-button size="small" @click="getTableData">查找</el-button>
+            </el-col>
+          </el-row>
         </div>
         <el-table class='data-table' border :data="tableData" @selection-change="handleSelectionChange" style="width: 100%" ref="multipleTable">
           <el-table-column v-if="type != 'read' " type="selection" :reserve-selection="true" :disabled="true" width="55"></el-table-column>
           <el-table-column label="系统名称" header-align='center'>
-            <template slot-scope="scope">{{scope.row.infos.SysLocalName || scope.row.infos.SysName}}</template>
+            <template slot-scope="scope">{{scope.row.SysLocalName || scope.row.SysName}}</template>
           </el-table-column>
           <el-table-column label="本地编码" header-align='center'>
-            <template slot-scope="scope">{{scope.row.infos.SysLocalID || '--'}}</template>
+            <template slot-scope="scope">{{scope.row.SysLocalID || '--'}}</template>
           </el-table-column>
           <el-table-column label="专业" header-align='center'>
-            <template slot-scope="scope">{{getName(scope.row.category)}}</template>
+            <template slot-scope="scope">{{scope.row.MajorName}}</template>
           </el-table-column>
           <el-table-column label="详情" header-align='center' width="100" align="center">
             <template slot-scope="scope">
@@ -39,13 +50,7 @@
 </template>
 <script>
 import myPagination from "@/components/ledger/lib/myPagination";
-import {
-  getLib,
-  getAllbusiness,
-  getEqCode,
-  getRelation,
-  queryLinkSys
-} from "@/api/scan/request"
+import { queryLinkSys, getSpaceFloor } from "@/api/scan/request"
 import tools from "@/utils/scan/tools"
 import { mapGetters } from 'vuex'
 export default {
@@ -65,10 +70,7 @@ export default {
       type: String,
       default: ""
     },
-    infos: {
-      type: String,
-      default: ""
-    },
+    device: {},
     type: {
       type: String,
       default: "read"
@@ -87,29 +89,65 @@ export default {
       multipleSelection: [],
       changeData: [],
       iframeSrc: "",
-      iframeShow: false
+      iframeShow: false,
+      buildId: 'all', //查询条件
+      options: [], //系统所属建筑
     };
   },
   computed: {
-    ...mapGetters("layout", [
-      "projectId",
-      "secret",
-      "userId"
-    ])
+    ...mapGetters("layout", ["projectId", "secret", "userId"])
   },
   mounted() { },
   methods: {
-    searchChecked() {
-      let data = []
-      this.allData.map(item => {
-        if (item.category.indexOf(this.search) > -1 || (item.infos.SysLocalName && item.infos.SysLocalName.indexOf(this.search) > -1)) {
-          data.push(item)
+    //获取查询条件-建筑
+    getData() {
+      let param = {
+        ProjId: this.projectId,
+        secret: this.secret,
+      }
+      getSpaceFloor(param).then(res => {
+        if (res.data.Result == 'success') {
+          let data = this.changeArr(res.data.Content)
+          data.unshift({
+            value: "all",
+            label: "全部"
+          }, {
+              value: "noKnow",
+              label: "未明确建筑的设备"
+            })
+          this.options = data
+        } else {
+          this.$message.error(res.data.ResultMsg)
+        }
+      }).catch(err => {
+        this.$message.error(err)
+      })
+    },
+    //将数组转换成optiosn格式
+    changeArr(arr) {
+      return arr.map(item => {
+        if (item.floors && item.floors.length && this.type == "yes") {
+          return {
+            value: item.id,
+            label: item.infos.BuildLocalName,
+            children: item.floors.map(i => {
+              return {
+                value: i.id,
+                label: i.infos.FloorLocalName,
+                FloorSequenceID: i.infos.FloorSequenceID
+              }
+            })
+          }
+        } else {
+          return {
+            value: item.id,
+            label: item.infos.BuildLocalName,
+            children: null,
+            isChilren: 1,
+          }
         }
       })
-      this.tableData = data
-      this.changeData = this.multipleSelection
     },
-
     handleSelectionChange(val) {
       this.multipleSelection = val;
       if (this.changeData.length) {
@@ -142,92 +180,6 @@ export default {
       }
     },
 
-    getName(code) {
-      if (!!code) {
-        let codeC = code.substring(0, 2), name = ""
-        this.systemList.map(item => {
-          if (item.code == codeC) {
-            name = item.class
-          }
-        })
-        return name
-      } else {
-        return "--"
-      }
-    },
-
-    //获取设备族
-    getEquipmentFamily() {
-      getEqCode().then(res => {
-        if (res.data.Result == "success") {
-          this.systemList = res.data.Content
-          this.getData()
-        } else {
-          this.$message.error("请求错误" + res.data.ResultMsg)
-        }
-      }).catch(_ => {
-        this.$message.error("请求错误")
-      })
-    },
-
-    getData() {
-      let param = param = {
-        ProjId: this.projectId,
-        secret: this.secret,
-        data: {
-          criteria: {
-            type: ["Sy"]
-          }
-        }
-      }
-      getAllbusiness(param).then(res => {
-        if (res.data.Result == "success") {
-          if (this.type == "read" && !!this.infos) {
-            this.getRelation(res.data.Content)
-          } else {
-            this.allData = res.data.Content
-            this.tableData = res.data.Content
-            console.log(this.$refs, "refs", this.list, "list", this.graphyId, "graphy")
-            this.$refs.multipleTable.clearSelection();
-            this.getSelected(this.list, this.allData)
-          }
-        } else {
-          this.$message.error("请求错误:" + res.data.ResultMsg)
-        }
-      }).catch(_ => {
-        this.$message.error("请求错误")
-      })
-    },
-
-    //查询id对应系统
-    getRelation(table) {
-      getRelation({
-        ProjId: this.projectId,
-        secret: this.secret,
-        criterias: {
-          criteria: {
-            "to_id": this.infos,
-            "graph_id": this.graphyId
-          }
-        }
-      }).then(Response => {
-        let data = Response.data.Content
-        if (Response.data.Result == "success") {
-          if (table && table.length && data && data.length) {
-            let lastData = tools.getSameItems(table, "id", data, "from_id")
-            console.log(lastData)
-            this.tableData = lastData
-          } else {
-            this.tableData = []
-          }
-        } else {
-          this.$message.error("请求错误" + Response.data.ResultMsg)
-        }
-      }).catch(_ => {
-        this.$message.error("请求错误")
-      })
-    },
-
     //设置默认选中项
     getSelected(list, all) {
       let map = []
@@ -255,6 +207,29 @@ export default {
         "&type=1&code=" +
         infos.category.substring(2, 4);
       this.iframeShow = true;
+    },
+
+    //根据设备类型-查询系统关联专业
+    getTableData() {
+      let param = {
+        Filters: `category="${this.device.deviceId.substring(0, 2)}"`,
+        PageNumber: 1,
+        PageSize: 100
+      }
+      //建筑id
+      if(this.buildId == "noKnow"){
+        param.Filters += `;buildingId isNull`
+      }else if(this.buildId && this.buildId != "all"){
+        param.Filters += `;buildingId='${this.buildId}'`
+      }
+      //输入的查询条件
+      if (this.search) {
+        param.Filters += `;SysLocalName contain "${this.search}" or SysLocalID contain "${this.search}"`
+      }
+      queryLinkSys(param, res => {
+        this.allData = res.Content
+        this.tableData = res.Content
+      })
     }
   },
   watch: {
@@ -262,9 +237,15 @@ export default {
       deep: true,
       handler: function () {
         if (this.dialog.systemType) {
-          this.getEquipmentFamily()
+          this.getData()
+          this.getTableData()
         }
       }
+    },
+    projectId() {
+      this.buildId = 'all';
+      this.options = [];
+      this.getData()
     }
   }
 };

+ 26 - 68
src/components/ledger/handsontables/device.vue

@@ -47,14 +47,15 @@
         暂无数据
       </p>
     </div>
-    <!-- 关联的系统 -->
-    <system-type :infos="systemId" :graphyId="graphyId" :dialog="myDialog" :type="onlyRead?'read':'edit'" @change="changeSystemType"></system-type>
 
     <div v-show="mess.deviceId && tableData && tableData.length" v-loading="loading" id="handsontable" ref="handsontable"></div>
     <div v-show="mess.deviceId && tableData && tableData.length" class="right">
       <my-pagination @change="getTableData" :page="page"></my-pagination>
     </div>
     <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog>
+    <!-- 关联的系统 -->
+    <system-type :device="mess" :dialog="myDialog" :type="onlyRead?'read':'edit'" @change="changeSystemType"></system-type>
+    <!-- 关联资产 -->
     <change-rea @changeProperty="changeProperty" :dialog="myDialog" :category="deviceType"></change-rea>
     <look-pic :dialog="myDialog" :keysArr="picsArr"></look-pic>
     <!-- 新增设备 -->
@@ -172,15 +173,14 @@ export default {
         changeRea: false,//关联资产
         lookPic: false,//图片查看
       },
-      row: null,//被修改的row
-      filesArr: [],//保存临时的文件key
+      row: null, //被修改的row
+      filesArr: [], //保存临时的文件key
       messKey: null,
-      imgsArr: [],//临时保存的图片key数组
-      picsArr: [],//临时设备图片keys数组
+      imgsArr: [], //临时保存的图片key数组
+      picsArr: [], //临时设备图片keys数组
       projId: "",
       copyMain: null,
       graphyId: null,
-      systemId: null,
       assetGroupList: [],
       iframeSrc: "",
       id: 0,
@@ -189,9 +189,9 @@ export default {
       showType: 'all',
       allMess: true,
       linkNameFalg: false,
-      qrcodeUrl: "",//二维码图片地址
+      qrcodeUrl: "", //二维码图片地址
       loading: false,
-      deviceType: {},
+      deviceType: {}, //族3位编码及名称
       floorData: []
     };
   },
@@ -205,10 +205,6 @@ export default {
     }
   },
   methods: {
-    //只读-编辑
-    changeRead() {
-      this.getHeaderData(this.mess)
-    },
     //触发父组件change
     getClose(val) {
       this.$emit("close", val)
@@ -244,16 +240,16 @@ export default {
           PageNumber: this.page.currentPage,
           Filters: `category='${this.mess.deviceId}'`
         }
-        if (this.mess.buildId && this.mess.buildId != "all") {
-          param.Filters += `;buildingId='${this.mess.buildId}'`
-        } else if (this.mess.buildId == "noKnow") {
+        if (this.mess.buildId == "noKnow") {
           param.Filters += `;buildingId isNull`
+        } else if (this.mess.buildId && this.mess.buildId != "all") {
+          param.Filters += `;buildingId='${this.mess.buildId}'`
         }
 
-        if (this.mess.floorId && this.mess.floorId != "all") {
-          param.Filters += `;floorId='${this.mess.floorId}'`
-        } else if (this.mess.floorId == "noKnow") {
+        if (this.mess.floorId == "noKnow") {
           param.Filters += `;floorId isNull`
+        } else if (this.mess.floorId && this.mess.floorId != "all") {
+          param.Filters += `;floorId='${this.mess.floorId}'`
         }
         getEquipTableCon(param, res => {
           this.loading = false;
@@ -582,7 +578,6 @@ export default {
       let val = this.hot.colToProp(row.col);
       this.row = row.row;
       this.messKey = val;
-      this.systemId = infos.EquipID;
       switch (val) {
         //操作
         case 'caozuo':
@@ -731,18 +726,8 @@ export default {
     },
     //如果选择供应商之后
     supplierChange(data) {
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierWeb", data.website);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierContactor", data.man);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierPhone", data.phone);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierFax", data.fox);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierEmail", data.email);
-      for (let key in data) {
-        if (key == "venderId") {
-          data[key] = data[key] + "-" + data.name;
-          this.utilToKey(key, "venderId", data, "DPSupplierID");
-        }
-      }
+      tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name)
+      tools.setDataForKey(this.tableData[this.row], "DPSupplierID", data.venderId)
     },
     supplyChange(data) {
       let changeData = { id: data }
@@ -762,50 +747,24 @@ export default {
     },
     //选择型号修改
     firmChange(data) {
-      tools.setDataForKey(this.tableData[this.row], "DPSpecificationID", data.specificationId);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brand);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Manufacturer", data.venderName);
-      for (let key in data) {
-        if (key == "venderId") {
-          data[key] = data[key] + "-" + data.name + "/" + data.brand;
-          this.utilToKey(key, "venderId", data, "DPManufacturerID");
-        }
-      }
+      tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brand)
+      tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
+      tools.setDataForKey(this.tableData[this.row], "DPManufacturerID", data.venderId)
     },
     //保险商变更
     changeInsurer(data) {
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.InsurerEmail", data.email);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.InsurerFax", data.fox);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.InsurerPhone", data.phone);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.InsurerContactor", data.man);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.InsurerWeb", data.website);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name);
-      for (let key in data) {
-        if (key == "venderId") {
-          data[key] = data[key] + "-" + data.name;
-          this.utilToKey(key, "venderId", data, "DPInsurerID");
-        }
-      }
+      tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name)
+      tools.setDataForKey(this.tableData[this.row], "DPInsurerID", data.venderId)
     },
     //维修商变更
     changeMaintainer(data) {
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.MaintainerWeb", data.website);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.MaintainerContactor", data.man);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.MaintainerPhone", data.phone);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.MaintainerFax", data.fox);
-      tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.MaintainerEmail", data.email);
-      for (let key in data) {
-        if (key == "venderId") {
-          data[key] = data[key] + "-" + data.name;
-          this.utilToKey(key, "venderId", data, "DPMaintainerID");
-        }
-      }
+      tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name)
+      tools.setDataForKey(this.tableData[this.row], "DPMaintainerID", data.venderId)
     },
     //修改关联的资产
     changeProperty(val) {
-      this.setDataToMain(val, 'PropertyId', this.row);
+      this.setDataToMain(val.PropertyId, 'PropertyId', this.row);
+      this.setDataToMain(val.LinkEquipLocalName, 'LinkEquipLocalName', this.row);
     },
     //上传文件弹窗触发事件
     fileChange(keys) {
@@ -832,7 +791,6 @@ export default {
     setDataToMain(data, key, row) {
       if (!!data && data != '--') {
         if (!!this.tableData[row]) {
-          //falg确定每个的是否有值
           tools.setDataForKey(this.tableData[row], key, data);
           this.handleUpdataTable([[row, key, null, data]], "edit");
         } else {

+ 1 - 1
src/views/ledger/facility/addfacility.vue

@@ -310,7 +310,7 @@ export default {
           await createEquip([params], res => {
             if (i == newData.length - 1) {
               this.$router.push({
-                path: "/ledger/partsmanage",
+                path: "/ledger/facility",
                 query: { deviceId: this.category.deviceId }
               });
               session.remove("deviceAddData")