Procházet zdrojové kódy

添加通过未关联设备和资产批量创建资产

zhangyu před 5 roky
rodič
revize
4996297669

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

@@ -951,6 +951,24 @@ export function propertyLinkEq(param, success) {
     http.postJson(url, param, success)
 }
 
+//查询设备或部件
+export function queryPartsDie(param, success) {
+    let url = `${baseUrl}/equip-component/equip-query/pagequery`;
+    http.postJson(url, param, success)
+}
+
+//根据条件查询项目下设备部件数量
+export function countPartsDie(param, success) {
+    let url = `${baseUrl}/equip-component/equip-query/count`;
+    http.postJson(url, param, success)
+}
+
+//根据设备或部件批量创建资产
+export function createPropertys(param, success) {
+    let url = `${baseUrl}/equip-component/equip-query/creat-propertys`;
+    http.postJson(url, param, success)
+}
+
 //根据条件查询统计数量
 export function countProperty(param, success) {
     let url = `${baseUrl}/datacenter/property/count`;

+ 112 - 26
src/components/ledger/handsontables/assets.vue

@@ -47,18 +47,25 @@
     <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog>
     <look-pic :dialog="myDialog" :keysArr="picsArr"></look-pic>
     <!-- 新增资产 -->
-    <el-dialog title="确定新增资产类型" :visible.sync="myDialog.addDevice" width="30%">
+    <el-dialog class="add-assets" :title="showAddByDie?'未关联资产的设备批量创建资产':'确定新增资产类型'" @close="showAddByDie = false" :visible.sync="myDialog.addDevice" width="670px">
       <el-row>
-        <my-cascader ref="cascader" @change="changeCader"></my-cascader>
+        <my-cascader v-show="!showAddByDie" ref="cascader" @change="changeCader"></my-cascader>
+        <die-cascader v-show="showAddByDie" ref="dieCascader" :Family="addData.Family" @change="changeDevice"></die-cascader>
+        <floor-cascader v-show="showAddByDie" @change="changeFloor"></floor-cascader>
+        <div class="die-text" v-show="showAddByDie">当前筛选条件下有<span class="die-num">{{dieNum}}</span>个设备可批量创建资产。</div>
+        <el-link v-show="showAddByDie && dieNum" type="primary" :underline="false" @click="toDetaiPage" style="margin-left:10px;">查看详情</el-link>
       </el-row>
       <span slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="toAddDevice">下 一 步</el-button>
+        <el-button v-show="!showAddByDie" type="primary" @click="toAddbyDie">批量创建</el-button>
+        <el-button v-show="!showAddByDie" type="primary" @click="toAddDevice">手动添加</el-button>
+        <el-button v-show="showAddByDie" type="primary" @click="showAddByDie = false">返回</el-button>
+        <el-button v-show="showAddByDie" type="primary" :disabled="dieNum == 0" @click="createByDie">批量创建</el-button>
       </span>
     </el-dialog>
   </div>
 </template>
 <script>
-import { getDataDictionary, queryProperty, propertyLinkEq, updateProperty, deleteProperty, upDateTableMain, delProperty, getEquipmentFamily } from "@/api/scan/request";
+import { getDataDictionary, queryProperty, propertyLinkEq, updateProperty, deleteProperty, upDateTableMain, delProperty, getEquipmentFamily, countPartsDie, createPropertys } from "@/api/scan/request";
 
 import tools from "@/utils/scan/tools"
 import handsonUtils from "@/utils/scan/hasontableUtils"
@@ -80,6 +87,8 @@ import picDialog from "@/components/business_space/dialogs/list/picDialog"
 import myPagination from "@/components/common/myPagination"
 import dialogAssets from "@/components/ledger/addDialog/dialogAssets"
 import myCascader from "@/components/ledger/lib/assets"
+import floorCascader from "@/components/ledger/lib/floorCascader"
+import dieCascader from "@/components/ledger/lib/partsDieList"
 import { mapGetters, mapActions } from "vuex"
 //图片查看
 import lookPic from "@/components/ledger/lib/lookImages"
@@ -106,6 +115,8 @@ export default {
     myPagination,
     // dialogAssets,
     myCascader,
+    floorCascader,
+    dieCascader,
     detailsDialog,
     lookPic
   },
@@ -171,7 +182,14 @@ export default {
       deviceType: {}, //族3位编码及名称
       floorData: [],
       curDevice: '',//当前点击的资产id
-      addData: {} //添加资产选择的资产类型
+      showAddByDie: false,//是否显示通过设备添加资产页面
+      addData: {}, //添加资产选择的资产类型
+      numParams: { // 查询设备部件数量条件
+        category:'',
+        buildingId:'',
+        floorId:''
+      },
+      dieNum: 0 // 查询设备部件数量
     };
   },
   methods: {
@@ -297,26 +315,6 @@ export default {
         });
       }
     },
-    //显示楼层信息
-    // changeAssetsFalg() {
-    //   if (this.showFlowBuild) {
-    //     this.showFlowBuild = false
-    //     this.getTableData()
-    //   } else {
-    //     this.$confirm('<p>维护资产所在建筑楼层后,对后续数据影响较大,如业务空间中的所在关系or其他?暂未梳理明白……</p><p>后续要修改设备所属建筑楼层,只能通过模型中的待建模清单操作</p>', '提示', {
-    //       dangerouslyUseHTMLString: true,
-    //       confirmButtonText: '就要维护资产所属建筑楼层',
-    //       cancelButtonText: '暂时不搞了',
-    //       confirmButtonClass: 'confirmButtonClass',
-    //       cancelButtonClass: 'cancelButtonClass'
-    //     }).then(_ => {
-    //       this.showFlowBuild = true
-    //       this.initTable()
-    //     }).catch(_ => {
-    //       this.$message("取消")
-    //     })
-    //   }
-    // },
     //撤回
     undo() {
       this.hot.undo();
@@ -334,20 +332,90 @@ export default {
         })
       }
     },
-    //下一步
+    //手动创建
     toAddDevice() {
       if (this.addData.Family) {
         this.$router.push({
           path: "/ledger/propertyadd",
           query: this.addData
         });
+      } else {
+        this.$message("请选择设备族")
+      }
+    },
+    //显示通过部件或设备创建资产页
+    toAddbyDie() {
+      if (this.addData.Family) {
+        this.showAddByDie = true
+      } else {
+        this.$message("请选择设备族")
+      }
+    },
+    //格式化条件
+    formatFilter() {
+      let param = {
+        Filters: `category='${this.numParams.category}'`
+      }
+
+      if (this.numParams.buildId == "noKnow") {
+        param.Filters += `;buildingId isNull`
+      } else if (this.numParams.buildId && this.numParams.buildId != "all") {
+        param.Filters += `;buildingId='${this.numParams.buildId}'`
+      }
+
+      if (this.numParams.floorId == "noKnow") {
+        param.Filters += `;floorId isNull`
+      } else if (this.numParams.floorId && this.numParams.floorId != "all") {
+        param.Filters += `;floorId='${this.numParams.floorId}'`
       }
+
+      return param
+    },
+    //批量添加
+    createByDie() {
+      let param = this.formatFilter()
+      createPropertys(param, res => {
+        this.myDialog.addDevice = false
+        this.$message.success("创建成功!")
+      })
+    },
+    //获取未关联资产的设备或部件数量
+    getNumDie() {
+      let param = this.formatFilter()
+      countPartsDie(param, res => {
+        this.dieNum = res.Count
+      })
+    },
+    //查看详情
+    toDetaiPage() {
+      
     },
     //选择设备类型-添加资产
     changeCader(val) {
       this.addData.Family = val.code;
       this.addData.name = val.facility;
     },
+    //选择设备或部件
+    changeDevice(val) {
+      if(val.code) {
+        this.numParams.category = val.code
+      } else {
+        this.numParams.category = ''
+      }
+      this.getNumDie()
+    },
+    //选择建筑楼层
+    changeFloor(value) {
+      if (value[0]) {
+        this.numParams.buildId = value[0]
+      }
+      if (value[1]) {
+        this.numParams.floorId = value[1]
+      } else {
+        this.numParams.floorId = ''
+      }
+      this.getNumDie()
+    },
     //下载
     download() {
       if (!this.onlyRead) {
@@ -860,6 +928,24 @@ export default {
     font-size: 12px;
   }
 }
+.add-assets{
+  .el-dialog__body{
+    height: 130px;
+    .die-text{
+      margin-left: 10px;
+      font-weight: bold;
+      clear: both;
+      padding-top: 30px;
+      padding-bottom: 10px;
+      .die-num{
+        width: 100px;
+        text-align: center;
+        display: inline-block;
+        border-bottom: 1px solid #333;
+      }
+    }
+  }
+}
 .cancelButtonClass {
   width: 180px;
 }

+ 2 - 1
src/components/ledger/lib/floorCascader.vue

@@ -1,6 +1,6 @@
 <template>
     <div id="buildFloor">
-        <span class="buildFloor" style="margin-right: 12px;">所属建筑楼层</span>
+        <span class="buildFloor" style="margin-right: 12px;">建筑楼层</span>
         <el-cascader placeholder="请选择建筑楼层" :options="options" v-model="value" filterable size="small" :style="isWidth ? '' : 'width:160px;'" @change="changeCascader"></el-cascader>
     </div>
 </template>
@@ -126,6 +126,7 @@
 </script>
 <style lang="less" scoped>
     #buildFloor {
+        margin-left: 10px;
         float: left;
         .buildFloor {
             color: #999999;

+ 132 - 0
src/components/ledger/lib/partsDieList.vue

@@ -0,0 +1,132 @@
+<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>
+  </div>
+</template>
+<script>
+import { mapGetters } from 'vuex';
+import { getEqCode, getEquipBelongs, queryPartsDie } from "@/api/scan/request";
+export default {
+  name: "getCode",
+  props: {
+    isWidth: {
+      type: Boolean,
+      default: true
+    },
+    Family: {
+      type: String,
+      default: '',
+    }
+  },
+  computed: {
+    ...mapGetters("layout", ["projectId"])
+  },
+  data() {
+    return {
+      value: [""],
+      options: [],
+      props: {
+        value: "code",
+        label: "facility"
+      },
+      falg: true,
+      content: []
+    };
+  },
+  created() { },
+  watch: {
+    projectId() {
+      this.value = [''];
+      this.getAllData()
+    },
+    Family(val) {
+      if(val != "") {
+        this.getAllData();
+      }
+    }
+  },
+  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 param = {
+        Distinct: true,
+        PageNumber: 1,
+        PageSize: 500,
+        Projection: [
+          "Category"
+        ]
+      }
+      queryPartsDie(param, res => {
+        this.content = res.Content
+        this.filterForOptions()
+        let val = this.options.length?[this.options[0].code]:[""]
+        this.changeVal(val)
+      })
+    },
+    //获取物理世界所有设备类型
+    getAllData() {
+      let param = {
+        data: {
+          Filters: `Family='${this.Family}'`,
+          Distinct: true,
+          Orders: "EquipName asc",
+          PageNumber: 1,
+          PageSize: 500,
+          Projection: [
+            "EquipCode", "EquipName"
+          ]
+        }
+      }
+      getEquipBelongs(param, res => {
+        this.options = this.formatOptions(res.Content)
+        this.getData()
+      })
+    },
+    //格式化options数据
+    formatOptions(arr) {
+      let data = [];
+      arr.map(t => {
+        let temp = {};
+        temp.code = t.EquipCode;
+        temp.facility = t.EquipName;
+        data.push(temp)
+      })
+      return data;
+    },
+    //过滤
+    filterForOptions() {
+      this.options = this.options.filter(item => {
+        if (this.content.find(value => value.Category == item.code)) {
+          return item
+        }
+      })
+    }
+  }
+};
+</script>
+<style lang="less" scoped>
+#cascaderMap {
+  float: left;
+  margin-left: 10px;
+  .buildFloor {
+    color: #999999;
+    font-size: 14px;
+  }
+}
+</style>

+ 1 - 3
src/utils/handsontable/fillterField.js

@@ -28,9 +28,7 @@ const data = {
     ]
   },
   property:{ //资产
-    onlyRead: [
-      "BIMID"
-    ],
+    onlyRead: [],
     edit: [
       "EquipID",
       "EquipName",

+ 82 - 76
src/utils/handsontable/notShow.js

@@ -5,10 +5,10 @@ import fieldData from "@/utils/handsontable/fillterField"
 let InputModeArr = ["A1", "A2", "B1", "C5", "D1", "D2", "E1", "L", "L1", "L2", "F1", "F2", "M", "Own"]
 //在编辑模式下并且勾选隐藏自动填充的信息点不显示的字段
 let noShowArr = [
-        "Specification",
-        "ServiceLife"
-    ]
-    //在编辑模式下不显示的字段
+    "Specification",
+    "ServiceLife"
+]
+//在编辑模式下不显示的字段
 let cantShow = [
     "EquipQRCode",
     "EquipID",
@@ -47,27 +47,27 @@ let cantShow = [
 
 //台账编辑页面不显示的厂商信息
 let firmArr = [
-    "Brand",//品牌
-    "Specification",//设备型号
-    "Manufacturer",//生产厂家
-    "Supplier",//供应商单位名称
-    "SupplierContactor",//供应商联系人
-    "SupplierPhone",//供应商联系电话
-    "SupplierEmail",//供应商电子邮件
-    "SupplierWeb",//供应商网址
-    "SupplierFax",//供应商传真
-    "Maintainer",//维修商单位名称
-    "MaintainerContactor",//维修商联系人
-    "MaintainerPhone",//维修商联系电话
-    "MaintainerEmail",//维修商电子邮件
-    "MaintainerWeb",//维修商网址
-    "MaintainerFax",//维修商传真
-    "Insurer",//保险公司名称
-    "InsurerContactor",//保险公司联系人
-    "InsurerPhone",//保险公司联系电话
-    'InsurerEmail',//保险公司电子邮件
-    "InsurerWeb",//保险公司网址
-    "InsurerFax"//保险公司传真
+    "Brand", //品牌
+    "Specification", //设备型号
+    "Manufacturer", //生产厂家
+    "Supplier", //供应商单位名称
+    "SupplierContactor", //供应商联系人
+    "SupplierPhone", //供应商联系电话
+    "SupplierEmail", //供应商电子邮件
+    "SupplierWeb", //供应商网址
+    "SupplierFax", //供应商传真
+    "Maintainer", //维修商单位名称
+    "MaintainerContactor", //维修商联系人
+    "MaintainerPhone", //维修商联系电话
+    "MaintainerEmail", //维修商电子邮件
+    "MaintainerWeb", //维修商网址
+    "MaintainerFax", //维修商传真
+    "Insurer", //保险公司名称
+    "InsurerContactor", //保险公司联系人
+    "InsurerPhone", //保险公司联系电话
+    'InsurerEmail', //保险公司电子邮件
+    "InsurerWeb", //保险公司网址
+    "InsurerFax" //保险公司传真
     // "DPManufacturerID",//品牌型号Id
     // "DPSupplierID",//供应商信息Id
     // "DPMaintainerID",//维修商信息Id
@@ -93,23 +93,23 @@ let cutArr = [{
 }]
 
 let newData = [{
-        name: "品牌型号",
-        code: "DPManufacturerID",
-        num: 2,
-    }, {
-        name: "供应商信息",
-        code: "DPSupplierID",
-        num: 8
-    }, {
-        name: "维修商信息",
-        code: "DPMaintainerID",
-        num: 35
-    }, {
-        name: "保险公司信息",
-        code: "DPInsurerID",
-        num: 42
-    }]
-    //创建部件固定不显示-管理部件固定不显示(即编辑模式)
+    name: "品牌型号",
+    code: "DPManufacturerID",
+    num: 2,
+}, {
+    name: "供应商信息",
+    code: "DPSupplierID",
+    num: 8
+}, {
+    name: "维修商信息",
+    code: "DPMaintainerID",
+    num: 35
+}, {
+    name: "保险公司信息",
+    code: "DPInsurerID",
+    num: 42
+}]
+//创建部件固定不显示-管理部件固定不显示(即编辑模式)
 let partsAddNoShow = [
     'EquipID',
     'EquipName',
@@ -220,7 +220,7 @@ const showTools = {
             scound = 0,
             three = 0,
             four = 0
-        arr.find(function(value, index, arr) {
+        arr.find(function (value, index, arr) {
             if (
                 (value.InfoPointName == "品牌" ||
                     value.InfoPointName == "设备型号" ||
@@ -360,8 +360,8 @@ const showTools = {
                             type: "numeric",
                             numericFormat: {
                                 pattern: "0,0.00"
-                                    // culture: 'de-DE' // use this for EUR (German),
-                                    // more cultures available on http://numbrojs.com/languages.html
+                                // culture: 'de-DE' // use this for EUR (German),
+                                // more cultures available on http://numbrojs.com/languages.html
                             }
                         };
                     } else if (item.InputMode == "C5") {
@@ -417,7 +417,7 @@ const showTools = {
             } else {
                 return false
             }
-            
+
 
         }).filter(item => item);
         return data
@@ -498,8 +498,8 @@ const showTools = {
                             type: "numeric",
                             numericFormat: {
                                 pattern: "0,0.00"
-                                    // culture: 'de-DE' // use this for EUR (German),
-                                    // more cultures available on http://numbrojs.com/languages.html
+                                // culture: 'de-DE' // use this for EUR (German),
+                                // more cultures available on http://numbrojs.com/languages.html
                             }
                         };
                     } else if (item.InputMode == "C5") {
@@ -876,8 +876,11 @@ const showTools = {
      * @param {*} taizhang 是否是台账类型
      * 
      */
-    headerTextFilter (arr, type, onlyRead, showType, taizhang = false) {
+    headerTextFilter(arr, type, onlyRead, showType, taizhang = false) {
         let data = arr.map(item => {
+            if (type == "property" && item.FirstTag == "RunParam") { //资产台账不显示运行参数
+                return undefined
+            }
             if (onlyRead) { //只读模式
                 if (!showTools.filterUnshow(onlyRead, type, item.InfoPointCode)) { //过滤固定不显示字段
                     return undefined
@@ -915,8 +918,11 @@ const showTools = {
         }).filter(d => d)
         return data
     },
-    headerTypeFilter (arr, type, onlyRead, showType, taizhang = false) {
+    headerTypeFilter(arr, type, onlyRead, showType, taizhang = false) {
         let data = arr.map(item => {
+            if (type == "property" && item.FirstTag == "RunParam") { //资产台账不显示运行参数
+                return undefined
+            }
             if (onlyRead) { //只读模式
                 if (!showTools.filterUnshow(onlyRead, type, item.InfoPointCode)) { //过滤固定不显示字段
                     return undefined
@@ -949,19 +955,18 @@ const showTools = {
                 } else {
                     return undefined
                 }
-
             }
         }).filter(d => d)
         return data
     },
-    isUnit (item) {
+    isUnit(item) {
         if (!item.Unit || item.Unit == "") {
             return item.InfoPointName;
         } else {
             return item.InfoPointName + "(" + item.Unit + ")";
         }
     },
-    textFormat (item, onlyRead) {
+    textFormat(item, onlyRead) {
         if (item.InfoPointCode == "EquipQRCode") {
             return {
                 data: item.Path,
@@ -1034,16 +1039,16 @@ const showTools = {
                 readOnly: onlyRead,
                 correctFormat: true
             };
-        } else if ( item.InputMode == "A3" ||
-                    item.InputMode == "A4" ||
-                    item.InputMode == "B1" || 
-                    item.InputMode == "B2" ||
-                    item.InputMode == "F1" ||
-                    item.InputMode == "F2" ||
-                    item.InputMode == "L1" ||
-                    item.InputMode == "L2" ||
-                    item.InputMode == "L" ||
-                    item.InputMode == "M" ) { //文本输入
+        } else if (item.InputMode == "A3" ||
+            item.InputMode == "A4" ||
+            item.InputMode == "B1" ||
+            item.InputMode == "B2" ||
+            item.InputMode == "F1" ||
+            item.InputMode == "F2" ||
+            item.InputMode == "L1" ||
+            item.InputMode == "L2" ||
+            item.InputMode == "L" ||
+            item.InputMode == "M") { //文本输入
             return {
                 data: item.Path,
                 readOnly: onlyRead
@@ -1055,7 +1060,7 @@ const showTools = {
             }
         }
     },
-    inputModeFilter (item, onlyRead) {
+    inputModeFilter(item, onlyRead) {
         if (item.InfoPointCode == "EquipQRCode") {
             return {
                 data: item.Path,
@@ -1142,16 +1147,16 @@ const showTools = {
                 readOnly: !item.Editable,
                 correctFormat: true
             };
-        } else if ( item.InputMode == "A3" ||
-                    item.InputMode == "A4" ||
-                    item.InputMode == "B1" || 
-                    item.InputMode == "B2" ||
-                    item.InputMode == "F1" ||
-                    item.InputMode == "F2" ||
-                    item.InputMode == "L1" ||
-                    item.InputMode == "L2" ||
-                    item.InputMode == "L" ||
-                    item.InputMode == "M" ) { //文本输入
+        } else if (item.InputMode == "A3" ||
+            item.InputMode == "A4" ||
+            item.InputMode == "B1" ||
+            item.InputMode == "B2" ||
+            item.InputMode == "F1" ||
+            item.InputMode == "F2" ||
+            item.InputMode == "L1" ||
+            item.InputMode == "L2" ||
+            item.InputMode == "L" ||
+            item.InputMode == "M") { //文本输入
             return {
                 data: item.Path,
                 readOnly: !item.Editable
@@ -1164,7 +1169,8 @@ const showTools = {
         }
     },
     filterUnshow: (onlyRead, type, code) => {
-        let falg = true, data = fieldData[type]
+        let falg = true,
+			data = fieldData[type]
         if (onlyRead) {
             data.onlyRead.map(item => {
                 if (item == code) {
@@ -1192,4 +1198,4 @@ const showTools = {
     }
 }
 
-export default showTools
+export default showTools

+ 2 - 1
src/views/ledger/property/addproperty.vue

@@ -177,11 +177,12 @@ export default {
 			}
 			
 			await createPropertyData(newData, res => {
+        this.$message.success("添加成功!")
+        session.remove("propertyAddData")
 				this.$router.push({
 					path: "/ledger/property",
 					query: { Family: this.category.Family }
 				})
-				session.remove("propertyAddData")
 			})
     },
     // 删除表格行

+ 0 - 0
src/views/ledger/property/addpropertys.vue