Browse Source

系统台账增加筛选

qule 3 years ago
parent
commit
691fc94429

+ 2 - 6
src/components/old-adm/ledger/components/handsontables/system.vue

@@ -75,7 +75,6 @@
             <el-row>
                 <div class="row_class">
                     <my-cascader ref="cascader" @change="changeAddType" :all="true"></my-cascader>
-                    <el-checkbox v-model="checked">仅项目交付范围内</el-checkbox>
                 </div>
                 
             </el-row>
@@ -386,6 +385,7 @@ export default {
          * 切换信息点查看类型
          */
         handleChangeShowType() {
+            console.log(123)
             this.showInfoList = [];
             this.initTable();
         },
@@ -858,9 +858,5 @@ export default {
         font-size: 12px;
     }
 }
-.row_class {
-    display: flex;
-    justify-content: space-around;
-    align-items: center;
-}
+
 </style>

+ 14 - 14
src/components/old-adm/ledger/components/lib/buildfloorCascader.vue

@@ -5,7 +5,7 @@
 // import { buildingQuery } from "@/api/scan/request";
 // import { buildingQuery } from '@/api/object/build';
 import Builder from "@/controller/old-adm/buildController";
-const { buildingQuery } = Builder;
+// const { buildingQuery } = Builder;
 
 export default {
   data() {
@@ -28,7 +28,7 @@ export default {
   },
 
   methods: {
-    getCascader() {
+    async getCascader() {
       let param = {
         cascade: [
           { name: "floor", orders: "floorSequenceID desc" }
@@ -37,19 +37,19 @@ export default {
         pageNumber: 1,
         pageSize: 50
       }
-      buildingQuery(param, res => {
-        res.content.map(t => {
-          if (t.floor && t.floor.length) {
-            t.floor = t.floor.map(item => {
-              if (item.id == this.FloorID) return
-              item.BuildID = item.id
-              item.BuildLocalName = item.localName || item.name
-              return item
-            }).filter(it => it)
-          }
-        })
-        this.options = res.content
+      const res = await Builder.buildingQuery(param)
+      res.content.map(t => {
+        if (t.floor && t.floor.length) {
+          t.floor = t.floor.map(item => {
+            if (item.id == this.FloorID) return
+            item.BuildID = item.id
+            item.BuildLocalName = item.localName || item.name
+            return item
+          }).filter(it => it)
+        }
       })
+      this.options = res.content
+      
     },
     getSelectedNodes() {
       let nodes = this.$refs.elCascader.getCheckedNodes();

+ 26 - 21
src/components/old-adm/ledger/components/lib/system.vue

@@ -1,13 +1,15 @@
 <template>
-  <div id="cascaderMap">
-    <span class="buildFloor" style="padding-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.classCode" :label="item.categoryName"
-                 :value="item.classCode"></el-option>
-    </el-select>
-    <!-- <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 id="cascaderMap" :style="{'justify-content': all ? 'space-around' : ''}">
+    <div>
+      <span class="buildFloor" style="padding:0 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.classCode" :label="item.categoryName"
+                  :value="item.classCode"></el-option>
+      </el-select>
+    </div>
+    
+    <el-checkbox v-if='all' v-model="isDelivery" @change="deliverChange" >仅项目交付范围内</el-checkbox>
   </div>
 </template>
 <script>
@@ -39,10 +41,12 @@ export default {
     return {
       value: [],
       options: [],
+      full_options: [],
       props: {
         value: "classCode",
         label: "categoryName"
-      }
+      },
+      isDelivery: true
     };
   },
   created() {
@@ -64,9 +68,6 @@ export default {
         this.getData();
       }
     },
-    setValue(val) {
-      this.value = val
-    },
     //修改val
     changeVal(val) {
       let value = {}
@@ -89,8 +90,8 @@ export default {
       }
       try {
         const res = await  queryLinkSys(param);
-        console.log({res})
-        this.options = res.content;
+        this.options = this.changeArr(res.content)
+        // console.log({res})
         if (this.value && this.options.find(item => item.classCode === this.value)) {
           this.changeVal(this.value)
         } else {
@@ -107,9 +108,8 @@ export default {
         type: 'system'
       }
       const res = await queryPhysicsAllType(param);
-      
-      
-      this.options = this.changeArr(res.content)
+      this.full_options = this.changeArr(res.content);
+      this.options = this.isDelivery ? this.full_options.filter(item => item?.isDelivery) : this.full_options
       if (this.value && this.options.find(item => item.classCode === this.value)) {
         this.changeVal(this.value)
       } else {
@@ -122,16 +122,21 @@ export default {
       arr.forEach(item => {
         data.push({ classCode: item.classCode || item.code, categoryName: item.categoryName || item.name });
       });
-      console.log(data, 'data')
+      // console.log(data, 'data')
       return data;
+    },
+    deliverChange(val) {
+
+      this.options = val ? this.full_options.filter(item => item?.isDelivery) : this.full_options
     }
   }
 };
 </script>
 <style lang="less" scoped>
 #cascaderMap {
-  float: left;
-  margin-left: 10px;
+  display: flex;
+  // justify-content: space-around;
+  align-items: center;
 
   .buildFloor {
     color: #999999;

+ 483 - 0
src/components/old-adm/ledger/system/addsystem.vue

@@ -0,0 +1,483 @@
+<template>
+  <div id="deviceList">
+    <el-row class="right">
+      <el-col span="4">
+        <span style="float:left;">当前选择的系统类型:{{ category.categoryName }}</span>
+      </el-col>
+      
+      <el-col span="20" style="text-align: right">
+        <el-select v-model="showType" @change="initTable" style="width:125px;margin-right:10px;vertical-align:bottom;">
+          <el-option v-for="item in showTypes" :key="item.value" :label="item.label" :value="item.value"></el-option>
+        </el-select>
+        <span>增加</span>
+        <el-input-number v-model="addNum" :controls="false" style="width:50px;" :min="1" :max="50"></el-input-number>
+        <span>个{{ category.categoryName }}</span>
+        <el-button @click="handleAddTableRow">增加</el-button>
+      </el-col>
+    </el-row>
+    <div class="tableBox">
+      <div class="center middle_sty" style="flex:2;" v-show="tableData && !tableData.length">
+        <p>
+          <i class="icon-wushuju iconfont"></i>
+          暂无数据
+        </p>
+      </div>
+      <div class="tableLeft" v-show="tableData && tableData.length">
+        <handson-table ref="table"></handson-table>
+      </div>
+    </div>
+    <el-row class="center">
+      <el-button type="primary" size="medium" @click="handleCreateTableData" class="create_button" :disabled="createDisable">创建系统</el-button>
+    </el-row>
+		<!-- 上传图片组件 -->
+		<upload-img-dialog :read="onlyRead ? true : false" @changeFile="imgChange" :keysArr="imgsArr" firmDataType="row" :dialog="myDialog"></upload-img-dialog>
+    <!-- 关联楼层 -->
+    <editSysfloor ref="editFloor" @relateSuccess="relateSuccess" :isCreate="true"></editSysfloor>
+    <!-- 多选枚举类型维护 -->
+   <menum :dialog="myDialog" :updateInfoData="updateInfoData" :updateInput="updateInput" @change="handleChangeMenum"></menum>
+  </div>
+</template>
+<script>
+import tools from "@/utils/old-adm/scan/tools";
+import showTools from "@/utils/old-adm/handsontable/notShow";
+import text from "@/utils/old-adm/handsontable/mainText";
+import session from "@/utils/storageUtil";
+
+import editSysfloor from "@/components/old-adm/ledger/components/lib/editSysFloor";
+import uploadImgDialog from "@/components/old-adm/dialogs/list/uploadImgDialog"
+import handsonTable from "@/components/old-adm/common/handsontable";
+import Dict from "@/controller/old-adm/dicController";
+
+import Scan from '@/controller/old-adm/ScanController'
+import { mapGetters, mapActions } from "vuex";
+import BuildController from "@/controller/old-adm/buildController"
+import menum from "@/components/old-adm/dialogs/list/menum";
+
+const { getDataDictionary } = Dict
+const { createSystemBuildFloor }  = Scan
+export default {
+  components: {
+    handsonTable,
+    menum,
+    editSysfloor,
+		uploadImgDialog
+  },
+  data() {
+    return {
+      addNum: 1,
+      onlyRead: false,
+      showTypes: [
+        { value: "Visible", label: '只看采集信息' },
+        { value: "all", label: '全部' }
+      ],
+      tableHeader: [],
+      tableData: session.get("systemAddData")
+        ? session.get("systemAddData").length
+          ? session.get("systemAddData")
+          : [{}]
+        : [{}],
+      copyTableData: [],
+      category: "", //当前设备类
+      myDialog: {
+        qrcode: false, //二维码弹窗
+        uploadFiles: false, //上传文件
+        uploadImgs: false, //上传单个图片
+        pic: false, //多个图片
+        addDevice: false,
+        systemType: false,
+        details: false, //详情页
+        changeRea: false,
+        lookPic: false, //图片查看
+        menum: false, //临时多选枚举类型信息点
+      },
+      inputMap: {
+        flowBuild: {
+          editable: true,
+          code: "flowBuild",
+          name: "建筑楼层",
+          path: "flowBuild",
+          category: 'STATIC',
+          dataType: "ENUM"
+        }
+      }, //信息点和输入方式映射表
+      qrcodeUrl: "", //二维码图片地址
+      filesArr: [], //保存临时的文件key
+      imgsArr: [], //临时保存的图片key数组
+      picsArr: [], //临时设备图片keys数组
+      systemId: null,
+      graphyId: null,
+      id: 0,
+      showType: this.$route.query.showType,
+      EquipmentList: [],
+      createDisable: false,
+      updateInfoData: {}, //当前信息点信息
+      updateInfoPoint: "", //临时维护信息点键
+      updateInput: "", //临时维护信息点值
+    };
+  },
+  computed: {
+    ...mapGetters("layout", ["projectId", "secret", "userId"])
+  },
+  created() {
+    this.category = this.$route.query;
+    this.getBuildData();
+    this.getTableHeader();
+  },
+  methods: {
+    //获取建筑数据
+    getBuildData() {
+      let param = {
+        pageNumber: 1,
+        pageSize: 1000,
+        projection: [
+          "id",
+          "localName"
+        ]
+      }
+      const res = BuildController.buildingQuery(param);
+        let data = res.content.map(t => {
+          return {
+            Code: t.id,
+            Name: t.localName,
+          }
+        })
+        data.unshift({ Code: '', Name: '未明确建筑' })
+        this.buildingData = data;
+      
+    },
+    // 获取表头数据(初始化表格)
+    async getTableHeader() {
+      let params = {
+        orders: "sort asc, name desc",
+        pageNumber: 1,
+        pageSize: 1000,
+        type: this.category.category
+      };
+      await getDataDictionary(params, res => {
+        this.tableHeader = res.content;
+        this.tableHeader.forEach(item => {
+            if (item.path) {
+              this.inputMap[item.path] = item;
+            }
+        })
+        this.initTable();
+      });
+    },
+    // 创建设备数据
+    async handleCreateTableData() {
+      let params = {}
+      let newData = this.tableData.filter(item => {
+        let keys = Object.keys(item);
+        keys.map(key => {
+          //将值为空字符串的属性删除
+          if (item[key] == "") {
+            delete item[key];
+          }
+        });
+        let newK = Object.keys(item)
+        if (newK.length) {
+          return item;
+        }
+      });
+      if (!newData.length) {
+        this.$message("创建信息为空,请录入信息后再创建!");
+        return;
+      }
+      let flag = false;
+      newData.map(item => {
+        if (!item.localName) {
+          flag = true;
+        }
+        item.classCode = this.category.category
+      })
+      if (flag) {
+        this.$message.info("存在系统的本地名称为空,请检查")
+        return;
+      }
+      params.content = newData
+      this.createDisable = true;
+      createSystemBuildFloor(params, res => {
+        this.createDisable = false;
+        this.$message.success('创建成功')
+        session.remove("systemAddData")
+        this.$router.push({
+          name: "systemlist",
+          params: { SysType: this.category.category }
+        });
+      })
+    },
+    // 删除表格行
+    handleDeleteTableRow(a,b,c,d) {
+      if (d && d === 'ContextMenu.removeRow') {
+				this.$message.success("删除成功");
+    		this.formaTableData();
+			}
+    },
+    // 添加行
+    handleAddTableRow() {
+      let addRowLength = this.addNum;
+      for (let i = 0; i < addRowLength; i++) {
+        this.tableData.push({});
+      }
+      this.initTable();
+      this.formaTableData();
+    },
+    //修改
+    handleUpdataTable(changeData, source) {
+      this.formaTableData();
+    },
+    //保存去掉空字段的新增数据
+    formaTableData() {
+      let newData = this.tableData.filter(item => {
+        let keys = Object.keys(item);
+        keys.map(key => {
+          //将值为空字符串的属性删除
+          if (item[key] == "") {
+            delete item[key];
+          }
+        });
+        if (keys.length && Object.keys(item).length) {
+          return item;
+        }
+      });
+      session.set("systemAddData", newData);
+    },
+    //格式化表头显示的数据
+    formatHeaderData(list) {
+      let arr = tools.copyArr(list);
+      let data = showTools.headerTextFilter(arr, 'system', this.onlyRead, this.showType);
+      data.unshift("所属建筑楼层");
+      return data;
+    },
+    formatHeaderType(list) {
+      //格式化表头头映射的数据
+      let arr = tools.copyArr(list);
+      let data = showTools.headerTypeFilter(arr, 'system', this.onlyRead, this.showType);
+      data.unshift({
+        data: "buildingFloorInfoList",
+        renderer: text.sysInBuildFloor
+      });
+      return data;
+    },
+    initTable() {
+      //实例化表格
+      let settings = {
+        data: this.tableData,
+        colHeaders: this.formatHeaderData(this.tableHeader),
+        columns: this.formatHeaderType(this.tableHeader),
+        rowHeights: 30,
+        fillHandle: 'vertical', //允许纵向填充
+        maxRows: this.tableData.length,
+        contextMenu: this.onlyRead ? false : {
+          items: {
+            remove_row: {
+              name: "删除该系统"
+            }
+          }
+        },
+        autoColumnSize: true,
+        language: "zh-CN",
+        manualColumnResize: true,
+        manualColumnMove: true,
+        // 事件
+        afterChange: this.handleUpdataTable, //修改后
+        afterFilter: this.trimmedRows, //排序前
+        afterRemoveRow: this.handleDeleteTableRow, //右键删除
+        afterOnCellMouseDown: this.handleTdClick //鼠标点击
+      };
+      this.$nextTick(() => {
+        this.tableExample = this.$refs.table.init(settings);
+      });
+    },
+    //去除数组中相同的元素
+    array_diff(a, b) {
+      for (var i = 0; i < b.length; i++) {
+        for (var j = 0; j < a.length; j++) {
+          if (a[j] == b[i]) {
+            a.splice(j, 1);
+            j = j - 1;
+          }
+        }
+      }
+      return a;
+    },
+    //表格点击事件
+    handleTdClick(el, rowArr) {
+      //点击的是表头
+      if (rowArr.row < 0) {
+        return;
+      }
+      //被筛选过后的数组
+      let trimmedArr = this.trimmedRows();
+      //是否启用了排序
+      let isSort = this.tableExample.getPlugin("columnSorting").isSorted();
+      if (trimmedArr.length && isSort) {
+        let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
+          .__arrayMap;
+        let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
+        this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
+      } else if (isSort) {
+        //排序后的数组
+        let sortArr = this.tableExample.getPlugin("columnSorting").rowsMapper
+          .__arrayMap;
+        let infos = this.tableData[sortArr[rowArr.row]];
+        this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
+      } else if (trimmedArr.length) {
+        let infos = this.tableData[trimmedArr[rowArr.row]];
+        this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col });
+      } else {
+        let infos = this.tableData[rowArr.row];
+        this.getInfors(infos, rowArr);
+      }
+    },
+    //获取被筛选掉的行号
+    trimmedRows() {
+      var plugin = this.tableExample.getPlugin("trimRows").trimmedRows;
+      let dataLength = this.tableData.length;
+      let dataArr = new Array();
+      for (let i = 0; i < dataLength; i++) {
+        dataArr.push(i);
+      }
+      if (plugin.length <= 0) {
+        dataArr = undefined;
+      } else {
+        dataArr = this.array_diff(dataArr, plugin);
+      }
+      return dataArr || [];
+    },
+    getInfors(infos, row) {
+      let val = this.tableExample.colToProp(row.col);
+      let inputData = this.inputMap[val];
+      this.row = row.row;
+      this.messKey = val;
+      switch (val) {
+        //操作
+        case 'caozuo':
+          // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
+          this.$message("开发中...")
+          break;
+        //设备二维码图片
+        // case 'EquipQRCode':
+        // case "defaultQRCode":
+        //   this.qrcodeUrl = this.tableData[row.row].EquipQRCode;
+        //   if (!!this.qrcodeUrl) {
+        //     this.myDialog.qrcode = true;
+        //   } else {
+        //     this.$message("此设备没有设备二维码");
+        //   }
+        //   break;
+        //关联设备数量
+        case 'count':
+          if (!this.onlyRead) {
+            this.myDialog.relevance = true
+          }
+          break;
+        //所属建筑楼层
+        case 'buildingFloorInfoList':
+          if (!this.onlyRead) {
+            this.$refs.editFloor.showDialog(this.tableData[row.row]);
+          }
+          break;
+				//系统图(F2)
+        case "infos.systemChart":
+          let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
+          this.imgsArr = SSPPdata ? SSPPdata : [];
+          this.myDialog.uploadImgs = true;
+          return false;
+        default:
+          break;
+      }
+      // 维护多选枚举值
+      if (!this.onlyRead && inputData.dataType == "MENUM") {
+        this.updateInfoData = inputData;
+        this.updateInfoPoint = val;
+        this.updateInput = tools.dataForKey(this.tableData[row.row], val);
+        this.myDialog.menum = true;
+        return false;
+      }
+      if (!this.onlyRead && !inputData.editable) {
+        this.$confirm('该信息点的值为自动生成,不可人工维护!', '提示', {
+            confirmButtonText: '我知道了',
+            showCancelButton: false,
+            type: 'warning',
+            center: true
+        }).then(() => {
+            return false;
+        });
+      }
+    },
+    //多选枚举类型值修改
+    handleChangeMenum(newValue) {
+        tools.setDataForKey(
+        this.tableData[this.row],
+        this.updateInfoPoint,
+        newValue
+      );
+      this.handleUpdataTable(
+        [[this.row, this.updateInfoPoint, null, newValue]],
+        "edit"
+      );
+      this.myDialog.menum = false;
+      this.updateInput = "";
+    },
+	//上传图片弹窗触发事件
+    imgChange(keys) {
+		this.setDataToMain(keys, this.messKey, this.row);
+    },
+    //建筑楼层
+    relateSuccess(data) {
+      this.tableData[this.row].buildingFloorInfoList = data
+      this.tableExample.render()
+    },
+		//判断是否有值,有值赋值
+    setDataToMain(data, key, row) {
+		if (!!data && data != "--") {
+        if (!!this.tableData[row]) {
+          tools.setDataForKey(this.tableData[row], key, data);
+          this.handleUpdataTable([[row, key, null, data]], "edit");
+        } else {
+          this.tableData[row] = {};
+          tools.setDataForKey(this.tableData[row], key, data);
+        }
+      } else {
+        tools.setDataForKey(this.tableData[row], key, "");
+      }
+    }
+  }
+};
+</script>
+<style lang="less" scoped>
+#deviceList {
+  overflow: hidden;
+  height: 100%;
+  background-color: #fff;
+  padding: 10px;
+  position: relative;
+
+  .right {
+    background: #fff;
+    padding: 16px;
+    line-height: 32px;
+  }
+
+  .search-header {
+    overflow: hidden;
+    padding: 0 10px 10px 10px;
+    border-bottom: 1px solid #bcbcbc;
+  }
+
+  .tableBox {
+    display: flex;
+    height: calc(100% - 100px);
+    margin-top: 10px;
+
+    .tableLeft {
+      flex: 1;
+    }
+  }
+
+  .create_button {
+    padding-top: 10px;
+  }
+}
+</style>

+ 12 - 0
src/controller/old-adm/ScanController.ts

@@ -417,6 +417,18 @@ class ScanController {
       params
     );
   }
+  /**
+   * @description: 创建系统---处理建筑楼层(一对多)
+   * @param {*}
+   * @return {*}
+   */  
+  static async createSystemBuildFloor(params, fn) {
+    const res = await this.http.postRequest(
+      object_pre + '/general-system/create-bd-fl',
+      params
+    )
+    return fn ? fn(res) : res
+  }
 }
 
 export default ScanController;

+ 12 - 0
src/controller/old-adm/dicController.ts

@@ -57,6 +57,18 @@ class Dic {
     );
     return fn ? fn(res) : res;
   }
+  /**
+   * @description: 查询项目下类型的信息点
+   * @param {*}
+   * @return {*}
+   */  
+  static async getDataDictionary(params, fn) {
+    const res = await Dic.http.postRequest(
+      dict_pre + '/query',
+      params,
+    )
+    return fn ? fn(res) : res
+  }
 }
 
 export default Dic;

+ 13 - 0
src/router/system.js

@@ -12,6 +12,7 @@ import deviceDetails from "@/components/old-adm/ledger/facility/details/index";
 import deviceadd from '@/components/old-adm/ledger/facility/addfacility'
 // 系统台账
 import systemLedger from '@/components/old-adm/ledger/system/index';
+import systemadd from '@/components/old-adm/ledger/system/addsystem'
 import batchPointAssets from '@/components/old-adm/ledger/facility/batchPoint' //批量维护设备位置
 import buildFloor from '@/components/old-adm/ready/buildfloor/index'
 import repetitionGraphy from '@/components/old-adm/ready/buildfloor/repetitionGraphy'
@@ -111,6 +112,18 @@ export default [
         component: systemLedger,
       },
       {
+        path: '/ledger/systemadd',
+        name: 'systemadd',
+        component: systemadd,
+        meta: {
+          keepAlive: false,
+          breadcrumbs: [{label: '台账管理', path: '/ledger/facility'}, {
+            label: '系统台账',
+            path: '/ledger/list'
+          }, {label: '添加系统'}]
+        }
+      },
+      {
         path: '/relation/overview',
         name: "全部关系总览",
         component: overView,