Browse Source

完善租户和竖井的功能及一些bug的修复

zhangyu 5 years ago
parent
commit
4546a38c0c

+ 2 - 2
src/api/scan/request.js

@@ -751,7 +751,7 @@ export function getCenoteTableData(param, success) {
 
 //添加竖井信息
 export function createCenoteTableData(param, success) {
-    let url = `${baseUrl}/datacenter/shaft/create?projectId=${param.ProjId}&secret=${param.secret}`
+    let url = `${baseUrl}/datacenter/shaft/batchCreate?projectId=${param.ProjId}&secret=${param.secret}`
     let data = param.data
     http.postJson(url, data, success)
 }
@@ -793,7 +793,7 @@ export function getRentTableData(param, success) {
 
 //创建租户信息
 export function createRentTableData(param, success) {
-    let url = `${baseUrl}/datacenter/tenant/create?projectId=${param.ProjId}&secret=${param.secret}`
+    let url = `${baseUrl}/datacenter/tenant/batchCreate?projectId=${param.ProjId}&secret=${param.secret}`
     let data = param.data
     http.postJson(url, data, success)
 }

+ 3 - 1
src/components/ledger/lib/cenoteType.vue

@@ -52,7 +52,9 @@ export default {
       let param = {
         ProjId: this.projectId,
         secret: this.secret,
-        data: {}
+        data: {
+          ProjectId: this.projectId
+        }
       }
       await getCenoteType (param, res => {
         var data = res.Content;

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

@@ -51,6 +51,7 @@
                 this.options = [];
                 this.param.ProjId = this.projectId
                 this.getData()
+                this.changeCascader(['all'])
             }
         },
         methods: {

+ 1 - 1
src/framework/style/layout.scss

@@ -44,7 +44,7 @@ body {
         /* 水平上对齐 */
         .page-sidebar-wrapper {
             width: $pageSidebarWidth;
-            overflow: auto;
+            // overflow: auto;
             flex-grow: 0;
             flex-shrink: 0;
         }

+ 8 - 1
src/router/system.js

@@ -40,6 +40,7 @@ import dialogDevice from '@/views/ledger/facility/addfacility'
 import propertyLedger from '@/views/ledger/property/index'
 import dialogSystem from '@/views/ledger/property/addproperty'
 import cenotelist from '@/views/ledger/cenotelist/index' //竖井清单
+import cenoteadd from '@/views/ledger/cenotelist/cenoteadd/index' //添加竖井
 import auth from '@/views/system/auth'
 import noUser from '@/views/system/nouser'
 
@@ -200,6 +201,12 @@ export default [
                 meta: { keepAlive: false, breadcrumbs: [{ label: '台账管理', path: '/ledger/facility' }, { label: '竖井清单' }] }
             },
             {
+                path: 'cenoteadd',
+                name: 'cenoteadd',
+                component: cenoteadd,
+                meta: { keepAlive: false, breadcrumbs: [{ label: '台账管理', path: '/ledger/facility' }, { label: '竖井清单', path: '/ledger/cenotelist' }, { label: '添加竖井' }] }
+            },
+            {
                 path: 'dimension',
                 name: 'Dasboard',
                 component: Dasboard,
@@ -251,7 +258,7 @@ export default [
                 path: 'rentadd',
                 name: 'rentadd',
                 component: rentadd,
-                meta: { keepAlive: false, breadcrumbs: [{ label: '租户管理', path: '/rent/rentlist' }, { label: '添加租户' }] }
+                meta: { keepAlive: false, breadcrumbs: [{ label: '租户管理', path: '/rent/rentlist' }, { label: '租户清单', path: '/rent/rentlist' }, { label: '添加租户' }] }
             }
         ]
     },

+ 18 - 14
src/utils/authutils.js

@@ -54,21 +54,25 @@ export default {
                 if (to.meta.breadcrumbs) {
                     store.dispatch('setBreadcrumb', to.meta.breadcrumbs)
                 }
-                // if((from = "/rent/rentadd" && session.get("isRentSave") == false)) { //判断新增信息是否保存
-                //     console.log(MessageBox)
-                //     debugger;
-                //     MessageBox.$confirm("新增信息未保存,离开将丢失新增信息,是否继续?", "提示", {
-                //         confirmButtonText: '确定',
-                //         cancelButtonText: '取消',
-                //         type: 'warning'
-                //     }).then(() => {
-                //         next()
-                //     }).catch(() => {
-                //         next(false)
-                //     })
-                // } else {
+                if(
+                    (from.path == "/rent/rentadd" && session.get("rentAddData") && session.get("rentAddData").length) ||
+                    (from.path == "/ledger/cenoteadd" && session.get("cenoteAddData") && session.get("cenoteAddData").length)
+                ) { //判断新增信息是否保存
+                    MessageBox.confirm("新增信息未保存,离开将丢失新增信息,是否继续?", "提示", {
+                        confirmButtonText: '确定',
+                        cancelButtonText: '取消',
+                        type: 'warning'
+                    }).then(() => {
+                        let arr = from.path.split("/")
+                        let srt = arr[arr.length - 1].slice(0,-3)
+                        session.remove(`${srt}AddData`)
+                        next()
+                    }).catch(() => {
+                        next(false)
+                    })
+                } else {
                     next()
-                // }
+                }
             }
             return true
         }

+ 315 - 0
src/views/ledger/cenotelist/cenoteadd/index.vue

@@ -0,0 +1,315 @@
+<template>
+  <div id="deviceList">
+    <el-row class="right">
+      <!-- <span style="float:left;">当前选择的部件类型:{{page.total || '--'}}</span> -->
+      <span>增加</span>
+      <el-input v-model="addNum" style="width:40px;" size="small"></el-input>
+      <span>个竖井</span>
+      <el-button @click="handleAddTableRow">增加</el-button>
+    </el-row>
+    <div class="tableBox">
+      <div class="center middle_sty" style="flex:2;" v-show="tableData && !tableData.length">
+        <p>
+          <i class="iconwushuju 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">创建竖井</el-button>
+    </el-row>
+  </div>
+</template>
+<script>
+import tools from "@/utils/scan/tools"
+import handsonUtils from "@/utils/hasontableUtils"
+import showTools from "@/utils/handsontable/notShow"
+import text from "@/utils/handsontable/mainText"
+import session from "@/framework/utils/storage"
+
+import handsonTable from "@/components/common/handsontable"
+import { getCenoteTableHeader, createCenoteTableData } from "@/api/scan/request"
+import { mapGetters, mapActions } from "vuex";
+export default {
+  components: {
+    handsonTable
+  },
+  data() {
+    return {
+      addNum: 1,
+      shaftId: "",//要操作的竖井id
+      isTableRightShow: false,
+      relationids: "",
+      onlyRead: false,
+      allMess: true,
+      tableHeader: [],
+      tableData: session.get("cenoteAddData")? session.get("cenoteAddData").length? session.get("cenoteAddData"): [{}]: [{}],
+      copyTableData: []
+    };
+  },
+  computed: {
+    ...mapGetters("layout", [
+        "projectId",
+        "secret",
+        "userId"
+    ])
+  },
+  created() {
+    this.getTableHeader()
+  },
+  // watch: {
+
+  // },
+  methods: {
+    // 获取表头数据(初始化表格)
+    async getTableHeader() {
+      let param = {
+        ProjId: this.projectId,
+        secret: this.secret,
+        data: {
+          "CollectFlag": this.allMess
+        }
+      }
+      await getCenoteTableHeader(param, res => {
+        this.tableHeader = res.Content
+        this.initTable()
+      })
+    },
+    // 创建竖井数据
+    async handleCreateTableData() {
+      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
+        }
+      })
+      if(!newData.length) {
+        this.$message("创建信息为空,请录入信息后再创建!")
+        return
+      }
+      const params = {
+        ProjId: this.projectId,
+        secret: this.secret,
+        data: newData
+      }
+      await createCenoteTableData(params, (res) => {
+        this.$message.success("添加成功!")
+        session.remove("cenoteAddData")
+        this.$router.push({ name: 'cenotelist'})
+      })
+    },
+    // 删除表格行
+    handleDeleteTableRow() {
+      this.$message.success("删除成功")
+      this.formaTableData()
+    },
+    // 添加行
+    handleAddTableRow() {
+      let addRowLength = this.addNum
+      for(let i = 0; i < addRowLength; i++){
+        this.tableData.push({})
+      }
+      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("cenoteAddData", newData)
+    },
+    //关闭右侧关联元空间输入按钮
+    handleCloseRight() {
+      this.isTableRightShow = false
+    },
+    formatHeaderData(list) {//格式化表头显示的数据
+      let arr = tools.copyArr(list)
+      arr.map((item) => {
+        item.Visible = true
+      })
+      let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "E1", "F1", "F2", "L", "L1", "L2", "N2", "X"]
+      if (!this.onlyRead) {
+        readArr.push("Own")
+      }
+      let data = showTools.changeHeader(arr, readArr, this.onlyRead, false, this.allMess)
+      // data.unshift("关联的元空间");
+      return data;
+    },
+    formatHeaderType(list) {//格式化表头头映射的数据
+      let arr = tools.copyArr(list);
+      arr.map((item) => { //缺少信息点
+        item.Visible = true
+      })
+      let data = showTools.showHeaderTypes(arr, this.onlyRead, false, this.allMess)
+      // data.unshift({
+      //   data: "SpaceCount",
+      //   readOnly: this.onlyRead
+      // })
+      return data;
+    },
+    initTable() {//实例化表格
+      let settings = {
+        data: this.tableData,
+        colHeaders: this.formatHeaderData(this.tableHeader),
+        columns: this.formatHeaderType(this.tableHeader),
+        rowHeights: 30,
+        maxRows: this.tableData.length,
+        contextMenu: {
+          items: {
+            remove_row: {
+              name: "删除竖井"
+            }
+          }
+        },
+        // 事件
+        afterChange: this.handleUpdataTable, //修改后
+        afterFilter: this.trimmedRows, //排序前
+        afterRemoveRow: this.handleDeleteTableRow, //右键删除
+        afterOnCellMouseDown: this.handleTdClick //鼠标点击
+      };
+      this.$nextTick(() => {
+        console.log(this.$refs.table);
+        this.tableExample = this.$refs.table.init(settings);
+      });
+    },
+    //获取到了正确的信息
+    getInfors(infos, row) {
+      //其他的开始判断
+      let val = this.tableExample.colToProp(row.col);
+      this.row = row.row //要操作的列号
+      this.messKey = val //要操作的列类型
+      //点击关联的元空间
+      // if (val === "SpaceCount") {
+      //   this.isTableRightShow = true;
+      // }
+    },
+    //表格点击事件
+    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 = hot.getPlugin('trimRows').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 || [];
+      // var DataArray = new Array();
+
+      // for (var i = 0; i < plugin.length; i++) {
+      //     // 通过行号获取数据
+      //     DataArray.push(this.tableExample.getSourceDataAtRow(plugin[i]));
+      // }
+    },
+    //去除数组中相同的元素
+    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;
+    }
+  }
+};
+</script>
+<style lang="less" scoped>
+#deviceList {
+  overflow: hidden;
+  height: 100%;
+  background-color: #fff;
+  padding: 10px;
+  position: relative;
+  .right {
+    background: #fff;
+  }
+  .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: 2;
+    }
+    .tableRight {
+      flex: 1;
+      // display: none;
+      border-left: 1px solid #dadada;
+      padding: 5px 15px;
+      margin-right: 5px;
+      box-shadow: 0px 1px 5px 0px rgba(59, 66, 84, 0.15);
+      .table_right_box::after{
+        display: block;
+        content: "";
+        clear: both;
+      }
+      .close_right {
+        float: right;
+        cursor: pointer;
+      }
+    }
+  }
+  .create_button{
+    margin-top: 10px;
+  }
+}
+</style>

+ 24 - 161
src/views/ledger/cenotelist/index.vue

@@ -5,8 +5,7 @@
     </div>
     <el-row class="right">
       <span style="float:left;">当前筛选条件下共{{page.total || '--'}}设备</span>
-      <el-checkbox v-show="onlyRead" v-model="allMess" @change="getTableHeader">只看要采集的信息</el-checkbox>
-      <el-select v-model="onlyRead" @change="getTableHeader">
+      <el-select v-model="onlyRead" @change="getTableHeader" style="width:100px;margin-right:10px;vertical-align:bottom;">
         <el-option
           v-for="item in options"
           :key="item.value"
@@ -14,7 +13,11 @@
           :value="item.value">
         </el-option>
       </el-select>
-      <el-button @click="createTableData">添加竖井</el-button>
+      <div v-show="onlyRead" style="width:200px;display:inline-block;text-align:left;color:gray;">
+        <span>只看要采集的信息</span>
+        <el-checkbox v-model="allMess" @change="getTableHeader"></el-checkbox>
+      </div>
+      <el-button @click="handleCreateTableData">添加竖井</el-button>
       <el-button @click="getTableHeader">刷新</el-button>
       <el-button v-show="!onlyRead" @click="undo">撤销</el-button>
     </el-row>
@@ -68,7 +71,7 @@ import text from "@/utils/handsontable/mainText"
 
 import cenoteType from "@/components/ledger/lib/cenoteType";
 import handsonTable from "@/components/common/handsontable";
-import { getCenoteType, getCenoteTableHeader, getCenoteTableData, updataCenoteTableData, deleteCenoteTableData, saveCenoteRelateSpace, createCenoteTableData } from "@/api/scan/request"
+import { getCenoteTableHeader, getCenoteTableData, updataCenoteTableData, deleteCenoteTableData, saveCenoteRelateSpace } from "@/api/scan/request"
 import { mapGetters, mapActions } from "vuex";
 export default {
   components: {
@@ -79,7 +82,6 @@ export default {
     return {
       cenoteId: "",//竖井类型id
       shaftId: "",//要操作的竖井id
-      cenoteTypeList: [],
       isTableRightShow: false,
       spaceList: "",
       options: [{
@@ -100,8 +102,7 @@ export default {
       },
       tableData: [],
       copyTableData: [],
-      assetGroupList: [],
-      graphyId: null
+      tableExample:null
     };
   },
   computed: {
@@ -112,7 +113,6 @@ export default {
     ])
   },
   created() {
-    this.getCenoteTypeData()
     this.getTableHeader()
   },
   // watch: {
@@ -121,21 +121,6 @@ export default {
   //     }
   // },
   methods: {
-    // 获取竖井类型
-    async getCenoteTypeData() {
-      let param = {
-        ProjId: this.projectId,
-        secret: this.secret,
-        data: {}
-      }
-      await getCenoteType (param, res => {
-        let data = res.Content
-        this.cenoteTypeList = data.map((item) => {
-          item.Code = item.ID
-          return item
-        })
-      })
-    },
     // 获取表头数据(初始化表格)
     async getTableHeader() {
       let param = {
@@ -171,33 +156,6 @@ export default {
         }
       })
     },
-    // 添加竖井信息
-    async createTableData() {
-      const params = {
-        ProjId: this.projectId,
-        secret: this.secret,
-        data: {}
-      }
-      createCenoteTableData(params, (res) => {
-        let id = res.Id
-        if (this.tableData.length) {
-            let data = this.tableExample.getSourceData()
-            data.unshift({
-                ShaftID: id
-            })
-            this.tableExample.loadData(data)
-            this.tableExample.updateSettings({
-                maxRows: data.length
-            })
-        } else {
-            this.tableData = [{
-                ShaftID: id
-            }]
-            this.initTable()
-        }
-        this.$message.success("添加成功!")
-      })
-    },
     // 修改表格内容
     async updateTableData(data, change) {
       let param = {
@@ -205,9 +163,15 @@ export default {
         secret: this.secret,
         data: {
           Content: [],
-          Projection: data[0]? Object.keys(data[0]): []
+          Projection: []
         }
       };
+      //生成要修改字段列表
+      change.map((item) => {
+        if(item[1] && param.data.Projection.indexOf(item[1] != -1)) {
+          param.data.Projection.push(item[1])
+        }
+      })
       //生成对应修改数据
       data.map((item, index) => {
         let key = change[index][1]
@@ -242,25 +206,9 @@ export default {
         this.getTableHeader()
       })
     },
-    // 添加竖井数据
+    // 添加竖井
     handleCreateTableData() {
-      if (this.tableData.length) {
-          let data = this.tableExample.getSourceData()
-          data.unshift({
-              
-          })
-          this.tableExample.loadData(data)
-          this.tableExample.updateSettings({
-              maxRows: data.length
-          })
-          this.createTableData()
-      } else {
-          this.tableData = [{
-              
-          }]
-          this.initTable()
-          this.createTableData()
-      }
+      this.$router.push({ name: 'cenoteadd'})
     },
     // 删除表格行
     handleDeleteTableRow() {
@@ -375,7 +323,7 @@ export default {
         },
         // 事件
         afterChange: this.handleUpdataTable, //修改后
-        afterFilter: this.trimmedRows, //排序前
+        // afterFilter: this.trimmedRows, //排序前
         afterRemoveRow: this.handleDeleteTableRow, //右键删除
         afterOnCellMouseDown: this.handleTdClick //鼠标点击
       };
@@ -456,96 +404,7 @@ export default {
         }
       }
       return a;
-    },
-    // getProjName() {
-    //   let param = {
-    //     list: [{ id: this.param.ProjId }],
-    //     perjectId: this.param.ProjId,
-    //     secret: this.param.secret,
-    //   }
-      // getSpaceName(param).then(res => {
-      //   if (res.data.Result == "success") {
-      //     this.mess.perjectName = res.data.Content[0].infos.ProjLocalName
-      //     this.getEqCode()
-      //   } else {
-      //     this.$message.error("请求失败:" + res.data.ResultMsg)
-      //   }
-      // }).catch(_ => {
-      //   this.$message.error("请求失败")
-      // })
-    // },
-    close(val) {
-      this.getEqCode()
-      console.log(val)
-      if(this.$refs.cascader)
-      this.$refs.cascader.changeVal([val.code])
-      //   this.$refs.tableMain.getHeaderData(this.param);
-    },
-    getEqCode() {
-      getEquipmentFamily(res => {
-        this.assetGroupList = res.Content
-        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)
-          }
-        
-      })
-    },
-    //获取header的list
-    // getNumber() {
-    //   let param = {
-    //     ProjId: this.param.ProjId,
-    //     secret: this.param.secret,
-    //     data: { type: "Eq" }
-    //   }
-    //   getNumber(param, res => {
-    //     console.log(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,
-        secret: this.param.secret,
-        type: "SystemEquip"
-      }
-      getGraphyId(param).then(res => {
-        if (res.data.Result == "success") {
-          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)
-        }
-      }).catch(_ => {
-        this.$message.error("请求错误")
-      })
-    },
-
-    //修改设备族
-    changeDevice(value) {
-      this.param.deviceId = value.code
-      this.param.name = value.facility
-      if (!!value) {
-          if(this.$refs.tableMain)
-        this.$refs.tableMain.getHeaderData(this.param);
-      } else {
-        return;
-      }
-    },
+    }
   }
 };
 </script>
@@ -553,8 +412,12 @@ export default {
 #deviceList {
   overflow: hidden;
   height: 100%;
-  background-color: #f6f6f6;
+  background-color: #fff;
+  padding: 10px;
   position: relative;
+  .right {
+    background: #fff;
+  }
   .search-header {
     overflow: hidden;
     padding:0 10px 10px 10px;

+ 29 - 110
src/views/rent/rentlist/index.vue

@@ -1,13 +1,11 @@
 <template>
   <div id="deviceList">
-    <div class="search-header">
+    <!-- <div class="search-header">
       <floor-cascader @change="changeFloor"></floor-cascader>
-      <!-- <cenote-type @change="changeFloor"></cenote-type> -->
-    </div>
+    </div> -->
     <el-row class="right">
       <span style="float:left;">当前筛选条件下共{{page.total || '--'}}租户</span>
-      <el-checkbox v-show="onlyRead" v-model="allMess" @change="getTableHeader">只看要采集的信息</el-checkbox>
-      <el-select v-model="onlyRead" @change="getTableHeader">
+      <el-select v-model="onlyRead" @change="getTableHeader" style="width:100px;margin-right:10px;vertical-align:bottom;">
         <el-option
           v-for="item in options"
           :key="item.value"
@@ -15,6 +13,10 @@
           :value="item.value">
         </el-option>
       </el-select>
+      <div v-show="onlyRead" style="width:200px;display:inline-block;text-align:left;color:gray;">
+        <span>只看要采集的信息</span>
+        <el-checkbox v-model="allMess" @change="getTableHeader"></el-checkbox>
+      </div>
       <el-button @click="handleCreateTableData">添加租户</el-button>
       <el-button @click="getTableHeader">刷新</el-button>
       <el-button v-show="!onlyRead" @click="undo">撤销</el-button>
@@ -100,9 +102,7 @@ export default {
         total: 0
       },
       tableData: [],
-      copyTableData: [],
-      assetGroupList: [],
-      graphyId: null
+      copyTableData: []
     };
   },
   computed: {
@@ -115,11 +115,11 @@ export default {
   created() {
     this.getTableHeader()
   },
-  // watch: {
-  //     projectId() {
-  //         this.param.ProjId = this.projectId;
-  //     }
-  // },
+  watch: {
+      projectId() {
+        this.getTableHeader()
+      }
+  },
   methods: {
     // 获取表头数据(初始化表格)
     async getTableHeader() {
@@ -177,9 +177,15 @@ export default {
         secret: this.secret,
         data: {
           Content: [],
-          Projection: data[0]? Object.keys(data[0]): []
+          Projection: []
         }
       };
+      //生成要修改字段列表
+      change.map((item) => {
+        if(item[1] && param.data.Projection.indexOf(item[1] != -1)) {
+          param.data.Projection.push(item[1])
+        }
+      })
       //生成对应修改数据
       data.map((item, index) => {
         let key = change[index][1]
@@ -227,12 +233,10 @@ export default {
       let param = {
         ProjId: this.projectId,
         secret: this.secret,
-        data: {
-          idList: []
-        }
+        data: []
       }
       params.map(item => {
-        param.data.idList.push(item.TenantID)
+        param.data.push(item.TenantID)
       })
       this.$confirm("此操作将删除租户,是否继续?", "提示", {
         confirmButtonText: '确定',
@@ -434,96 +438,7 @@ export default {
         }
       }
       return a;
-    },
-    // getProjName() {
-    //   let param = {
-    //     list: [{ id: this.param.ProjId }],
-    //     perjectId: this.param.ProjId,
-    //     secret: this.param.secret,
-    //   }
-      // getSpaceName(param).then(res => {
-      //   if (res.data.Result == "success") {
-      //     this.mess.perjectName = res.data.Content[0].infos.ProjLocalName
-      //     this.getEqCode()
-      //   } else {
-      //     this.$message.error("请求失败:" + res.data.ResultMsg)
-      //   }
-      // }).catch(_ => {
-      //   this.$message.error("请求失败")
-      // })
-    // },
-    close(val) {
-      this.getEqCode()
-      console.log(val)
-      if(this.$refs.cascader)
-      this.$refs.cascader.changeVal([val.code])
-      //   this.$refs.tableMain.getHeaderData(this.param);
-    },
-    getEqCode() {
-      getEquipmentFamily(res => {
-        this.assetGroupList = res.Content
-        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)
-          }
-        
-      })
-    },
-    //获取header的list
-    // getNumber() {
-    //   let param = {
-    //     ProjId: this.param.ProjId,
-    //     secret: this.param.secret,
-    //     data: { type: "Eq" }
-    //   }
-    //   getNumber(param, res => {
-    //     console.log(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,
-        secret: this.param.secret,
-        type: "SystemEquip"
-      }
-      getGraphyId(param).then(res => {
-        if (res.data.Result == "success") {
-          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)
-        }
-      }).catch(_ => {
-        this.$message.error("请求错误")
-      })
-    },
-
-    //修改设备族
-    changeDevice(value) {
-      this.param.deviceId = value.code
-      this.param.name = value.facility
-      if (!!value) {
-          if(this.$refs.tableMain)
-        this.$refs.tableMain.getHeaderData(this.param);
-      } else {
-        return;
-      }
-    },
+    }
   }
 };
 </script>
@@ -531,8 +446,12 @@ export default {
 #deviceList {
   overflow: hidden;
   height: 100%;
-  background-color: #f6f6f6;
+  background-color: #fff;
+  padding: 10px;
   position: relative;
+  .right {
+    background: #fff;
+  }
   .search-header {
     overflow: hidden;
     padding:0 10px 10px 10px;
@@ -540,7 +459,7 @@ export default {
   }
   .tableBox {
     display: flex;
-    height: calc(100% - 140px);
+    height: calc(100% - 95px);
     margin-top: 10px;
     .tableLeft {
       flex: 2;

+ 43 - 31
src/views/rent/rentlist/rentadd/index.vue

@@ -18,7 +18,7 @@
         <handson-table ref="table"></handson-table>
       </div>
     </div>
-    <el-row class="center">
+    <el-row class="center create_button">
       <el-button type="primary" size="medium" @click="handleCreateTableData">创建租户</el-button>
     </el-row>
   </div>
@@ -39,20 +39,14 @@ export default {
   },
   data() {
     return {
-      buildId: null,//建筑id
-      floorId: null,//楼层id
       addNum: 1,
-      cenoteId: "",//租户类型id
-      shaftId: "",//要操作的租户id
       isTableRightShow: false,
       relationids: "",
       onlyRead: false,
       allMess: true,
       tableHeader: [],
-      tableData: session.get("rentAddData")? session.get("rentAddData"): [{}],
-      copyTableData: [],
-      assetGroupList: [],
-      graphyId: null
+      tableData: session.get("rentAddData")? session.get("rentAddData").length? session.get("rentAddData"): [{}]: [{}],
+      copyTableData: []
     };
   },
   computed: {
@@ -85,10 +79,25 @@ export default {
     },
     // 创建租户数据
     async handleCreateTableData() {
+      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
+        }
+      })
+      if(!newData.length) {
+        this.$message("创建信息为空,请录入信息后再创建!")
+        return
+      }
       const params = {
         ProjId: this.projectId,
         secret: this.secret,
-        data: this.tableData
+        data: newData
       }
       await createRentTableData(params, (res) => {
         this.$message.success("添加成功!")
@@ -99,7 +108,7 @@ export default {
     // 删除表格行
     handleDeleteTableRow() {
       this.$message.success("删除成功")
-      session.set("rentAddData", this.tableData)
+      this.formaTableData()
     },
     // 添加行
     handleAddTableRow() {
@@ -107,30 +116,27 @@ export default {
       for(let i = 0; i < addRowLength; i++){
         this.tableData.push({})
       }
-      session.set("rentAddData", this.tableData)
       this.initTable()
+      this.formaTableData()
     },
     //修改
     handleUpdataTable(changeData, source) {
-      if (!this.onlyRead) {
-        if (changeData) {
-          let trimmedArr = this.trimmedRows();
-          let param = handsonUtils.getParam(changeData, source, this.tableExample, trimmedArr);
-          let data = [];
-          for (let i = 0; i < param.length; i++) {
-            data.push(param[i]);
-          }
-
-          // 存在data进行修改请求
-          if (data && data.length) {
-            data.map((item, index) => {
-              let key = changeData[index][1]
-              item[key] = item[key] != ""? item[key]: null
-            });
+      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("rentAddData", this.tableData)
+      })
+      session.set("rentAddData", newData)
     },
     //关闭右侧关联元空间输入按钮
     handleCloseRight() {
@@ -192,7 +198,6 @@ export default {
       let val = this.tableExample.colToProp(row.col);
       this.row = row.row //要操作的列号
       this.messKey = val //要操作的列类型
-      this.shaftId = infos.ShaftID //要操作的数据id
       //点击关联的元空间
       // if (val === "SpaceCount") {
       //   this.isTableRightShow = true;
@@ -267,8 +272,12 @@ export default {
 #deviceList {
   overflow: hidden;
   height: 100%;
-  background-color: #f6f6f6;
+  background-color: #fff;
+  padding: 10px;
   position: relative;
+  .right {
+    background: #fff;
+  }
   .search-header {
     overflow: hidden;
     padding:0 10px 10px 10px;
@@ -299,5 +308,8 @@ export default {
       }
     }
   }
+  .create_button{
+    margin-top: 10px;
+  }
 }
 </style>