webpackJsonp([63],{

/***/ "/LsX":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });

// EXTERNAL MODULE: ./node_modules/babel-runtime/core-js/map.js
var map = __webpack_require__("ifoU");
var map_default = /*#__PURE__*/__webpack_require__.n(map);

// EXTERNAL MODULE: ./node_modules/babel-runtime/helpers/defineProperty.js
var defineProperty = __webpack_require__("bOdI");
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);

// EXTERNAL MODULE: ./node_modules/babel-runtime/regenerator/index.js
var regenerator = __webpack_require__("Xxa5");
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);

// EXTERNAL MODULE: ./node_modules/babel-runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__("exGp");
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);

// EXTERNAL MODULE: ./src/api/index.js + 5 modules
var api = __webpack_require__("gyMJ");

// EXTERNAL MODULE: ./src/utils/util.js
var util = __webpack_require__("oFuF");

// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/views/boYu/byRoom.vue




//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//



/* harmony default export */ var byRoom = ({
  name: "byRoom",
  data: function data() {
    return {
      manufacturerList: [{ //设备类型选择
        "label": "GX1000_lock",
        "productID": "GX1000_LOCK",
        "value": 101
      }, {
        "label": "ZG_lock",
        "productID": "ZG_LOCK",
        "value": 201
      }, {
        "label": "ZG_ble_lock",
        "productID": "ZG_LOCK",
        "value": 221
      }, {
        "label": "YS_LOCK",
        "productID": "YS_LOCK",
        "value": 701
      }],
      editVisible: false, //添加设备弹窗显示控制
      paginationConfig: 'total, sizes, prev, pager, next, jumper',
      pageNum: 1, //页码
      pageSize: 100, //每页数量
      pageTotal: 0, //总数量
      tableData: [], //设备列表
      options: [],
      options2: [],
      options3: [],
      search: {
        deviceNum: '', //设备名称
        roomName: '', //房间名称
        storeId: 's202201280338',
        unitId: '',
        floorId: '',
        buildingId: ''
      },
      form: { //添加设备参数
        did: '', //设备id
        roomId: '' //房间id
      },
      deviceList: [],
      roomList: [],
      selctRoom: { roomId: '' },
      updateStstus: false,
      optionsOne: []
    };
  },
  mounted: function mounted() {
    this.searchRoom('', 'building');
    this.getBYRoom();
    this.getDeviceList();
  },

  methods: {
    // 重置搜索
    resetSearch: function resetSearch() {
      this.search = {
        deviceNum: '', //设备名称
        roomName: '', //房间名称
        storeId: 's202201280338',
        unitId: '',
        floorId: '',
        buildingId: ''
      };
    },

    // 搜索房间
    searchRoom: function searchRoom(e, key) {
      var _this = this;

      console.log(e, key);
      var data = {
        code: "by/roomField",
        data: {
          field: key
        }
      };
      Object(api["g" /* httpPost */])(data, this.$api.sendCommand).then(function (res) {
        if (res.success) {
          if (key == 'store') {
            // res.data.map(li=>{
            //   li.label = li.storeName
            //   li.value = li.storeId
            // })
            // this.options = res.data
          } else if (key == 'building') {
            res.data.map(function (li) {
              li.label = li.buildingName;
              li.value = li.buildingId;
            });
            _this.options = res.data;
          } else if (key == 'unit') {
            res.data.map(function (li) {
              li.label = li.unitName;
              li.value = li.unitId;
            });
            _this.options2 = res.data;
          } else if (key == 'floor') {
            res.data.map(function (li) {
              li.label = li.floorName;
              li.value = li.floorId;
            });
            _this.options3 = res.data;
          }
        }
      });
    },

    // 同步房源
    byListRoomMethods: function byListRoomMethods() {
      var _this2 = this;

      var data = {
        code: "by/byListRoom",
        data: {
          pageNum: this.pageNum,
          pageSize: 500
        }
      };
      Object(api["g" /* httpPost */])(data, this.$api.sendCommand).then(function (res) {
        if (res.success) {
          _this2.getBYRoom();
        }
      });
    },

    // 获取设备列表
    getDeviceList: function getDeviceList() {
      var _this3 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee() {
        var data;
        return regenerator_default.a.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                data = {
                  code: "lockDevice/list",
                  data: {
                    pageNum: _this3.pageNum,
                    pageSize: 500
                  }
                };

                Object(api["g" /* httpPost */])(data, _this3.$api.sendCommand).then(function (res) {
                  if (res.success) {
                    res.data.list.map(function (li) {
                      li.label = li.deviceNum;
                      li.value = li.deviceNum;
                    });
                    _this3.deviceList = res.data.list;
                  }
                });

              case 2:
              case "end":
                return _context.stop();
            }
          }
        }, _callee, _this3);
      }))();
    },

    // 选择绑定设备
    selectDevice: function selectDevice(e) {
      // this.determineMethods('did',e)
    },

    // 绑定设备
    addDevice: function addDevice(index, row) {
      this.selctRoom = row;
      this.editVisible = true;
      this.determineMethods('roomId', row.roomId);
    },

    // 判断是否有绑定设备
    determineMethods: function determineMethods(key, id) {
      var _this4 = this;

      var data = {
        code: "by/roomLockList",
        data: {
          pageNum: 1,
          pageSize: 500,
          para: defineProperty_default()({}, key, id)
        }
      };
      Object(api["g" /* httpPost */])(data, this.$api.sendCommand).then(function (res) {
        if (res.success) {
          if (res.data.list.length > 0) {
            _this4.form.did = res.data.list[0].did;
            _this4.form.roomId = res.data.list[0].roomId;
            _this4.updateStstus = true;
            _this4.$message.error('该房间/设备已绑定');
          }
        }
      });
    },

    // 获取泊寓房源
    getBYRoom: function getBYRoom() {
      var _this5 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee2() {
        var content, results, total, page, i, newResults;
        return regenerator_default.a.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                content = [];

                console.log(_this5.form);
                _context2.next = 4;
                return _this5.getRoomList();

              case 4:
                results = _context2.sent;

                _this5.pageTotal = results.total;
                _this5.tableData = results.list;
                content = content.concat(results.list);

                if (!results) {
                  _context2.next = 25;
                  break;
                }

                content = content.concat(results.list);
                total = results.total; //获取总条数

                page = Math.ceil(total / _this5.pageSize); //计算需要多少页

                if (!(page > 1)) {
                  _context2.next = 23;
                  break;
                }

                i = 2;

              case 14:
                if (!(i <= page)) {
                  _context2.next = 23;
                  break;
                }

                _this5.pageNum = i; //更改页码
                _context2.next = 18;
                return _this5.getRoomList();

              case 18:
                newResults = _context2.sent;

                //将第2、3、4...页数据放入content数组中
                content = content.concat(newResults.list);

              case 20:
                i++;
                _context2.next = 14;
                break;

              case 23:
                _context2.next = 25;
                return _this5.processingData(content);

              case 25:
              case "end":
                return _context2.stop();
            }
          }
        }, _callee2, _this5);
      }))();
    },
    getRoomList: function getRoomList() {
      var _this6 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee3() {
        var para, paraObject, data;
        return regenerator_default.a.wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                para = {
                  storeId: _this6.search.storeId,
                  buildingId: _this6.search.buildingId,
                  unitId: _this6.search.unitId,
                  floorId: _this6.search.floorId,
                  roomName: _this6.search.roomName
                };
                paraObject = util["a" /* default */].validObject(para);
                data = {
                  code: "by/listRoom",
                  data: {
                    pageNum: _this6.pageNum,
                    pageSize: _this6.pageSize,
                    para: paraObject
                  }
                };
                return _context3.abrupt("return", Object(api["g" /* httpPost */])(data, _this6.$api.sendCommand).then(function (res) {
                  if (res.success) {
                    return res.data;
                  }
                }));

              case 4:
              case "end":
                return _context3.stop();
            }
          }
        }, _callee3, _this6);
      }))();
    },
    processingData: function processingData(data) {
      var _this7 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee4() {
        var arr, arr1, arr2, arr3, result, result1, result2, result3;
        return regenerator_default.a.wrap(function _callee4$(_context4) {
          while (1) {
            switch (_context4.prev = _context4.next) {
              case 0:
                _this7.roomList = data;
                data.map(function (li) {
                  li.label = li.roomName;
                  li.value = li.roomId;
                });
                _context4.next = 4;
                return _this7.unique(data, 'storeId');

              case 4:
                arr = _context4.sent;
                _context4.next = 7;
                return _this7.unique(data, 'buildingId');

              case 7:
                arr1 = _context4.sent;
                _context4.next = 10;
                return _this7.unique(data, 'unitId');

              case 10:
                arr2 = _context4.sent;
                _context4.next = 13;
                return _this7.unique(data, 'floorId');

              case 13:
                arr3 = _context4.sent;
                _context4.next = 16;
                return _this7.mergeData(arr3, data, 'floorId', 'floorName');

              case 16:
                result = _context4.sent;
                _context4.next = 19;
                return _this7.mergeData(arr2, result, 'unitId', 'unitName');

              case 19:
                result1 = _context4.sent;
                _context4.next = 22;
                return _this7.mergeData(arr1, result1, 'buildingId', 'buildingName');

              case 22:
                result2 = _context4.sent;
                _context4.next = 25;
                return _this7.mergeData(arr, result2, 'storeId', 'storeName');

              case 25:
                result3 = _context4.sent;

                _this7.optionsOne = result3;

              case 27:
              case "end":
                return _context4.stop();
            }
          }
        }, _callee4, _this7);
      }))();
    },
    mergeData: function mergeData(arr, arr1, key, label) {
      var _this8 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee5() {
        var result;
        return regenerator_default.a.wrap(function _callee5$(_context5) {
          while (1) {
            switch (_context5.prev = _context5.next) {
              case 0:
                result = [];

                arr.map(function (li) {
                  var result1 = arr1.filter(function (item) {
                    return item[key] == li[key];
                  });
                  var obj = {
                    label: li[label],
                    value: li[key],
                    buildingId: li.buildingId,
                    buildingName: li.buildingName,
                    floorId: li.floorId,
                    floorName: li.floorName,
                    roomId: li.roomId,
                    roomName: li.roomName,
                    storeId: li.storeId,
                    storeName: li.storeName,
                    unitId: li.unitId,
                    unitName: li.unitName,
                    children: result1
                  };
                  result.push(obj);
                });
                return _context5.abrupt("return", result);

              case 3:
              case "end":
                return _context5.stop();
            }
          }
        }, _callee5, _this8);
      }))();
    },
    unique: function unique(arr, attrName) {
      var _this9 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee6() {
        var res;
        return regenerator_default.a.wrap(function _callee6$(_context6) {
          while (1) {
            switch (_context6.prev = _context6.next) {
              case 0:
                res = new map_default.a();
                return _context6.abrupt("return", arr.filter(function (a) {
                  return !res.has(a[attrName]) && res.set(a[attrName], 1);
                }));

              case 2:
              case "end":
                return _context6.stop();
            }
          }
        }, _callee6, _this9);
      }))();
    },
    check: function check(data, list) {
      var _this10 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee7() {
        return regenerator_default.a.wrap(function _callee7$(_context7) {
          while (1) {
            switch (_context7.prev = _context7.next) {
              case 0:
                data.forEach(function (item) {
                  if (item.children && item.children.length > 0) {
                    _this10.check(item.children, list);
                  } else {
                    list.push(item);
                  }
                });
                return _context7.abrupt("return", list);

              case 2:
              case "end":
                return _context7.stop();
            }
          }
        }, _callee7, _this10);
      }))();
    },

    // 搜索选择房源
    checkNode: function checkNode(e) {
      var _this11 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee8() {
        var tableData, _tableData;

        return regenerator_default.a.wrap(function _callee8$(_context8) {
          while (1) {
            switch (_context8.prev = _context8.next) {
              case 0:
                if (e.length < 4) {
                  _this11.$message.error('请选择到楼层');
                }
                if (e.length == 4) {
                  tableData = [];

                  _this11.roomList.map(function (li) {
                    if (li.floorId == e[e.length - 1]) {
                      tableData.push(li);
                    }
                  });
                  _this11.tableData = tableData;
                }
                if (e.length == 5) {
                  _tableData = [];

                  _this11.roomList.map(function (li) {
                    if (li.roomId == e[e.length - 1]) {
                      _tableData.push(li);
                    }
                  });
                  _this11.tableData = _tableData;
                }

              case 3:
              case "end":
                return _context8.stop();
            }
          }
        }, _callee8, _this11);
      }))();
    },

    // 添加设备选择房源
    checkNodeOne: function checkNodeOne(e) {
      if (e.length < 5) {
        this.$message.error('请选择房间');
      } else {
        this.form.roomId = e[e.length - 1];
        // this.determineMethods('roomId',e[e.length-1])
      }
    },

    //   搜索
    searchMethods: function searchMethods() {},

    //   推送设备
    pushDeviceMethods: function pushDeviceMethods() {},

    //   添加设备
    addDeviceMethods: function addDeviceMethods() {
      var _this12 = this;

      if (this.form.did == '') {
        this.$message.error('请选择设备');
      } else if (this.form.roomId == '') {
        this.$message.error('请选择房间');
      } else {
        if (!this.updateStstus) {
          var data = {
            code: "by/addDevice",
            data: {
              did: this.form.did,
              roomId: this.form.roomId
            }
          };
          Object(api["g" /* httpPost */])(data, this.$api.sendCommand).then(function (res) {
            if (res.success) {
              _this12.editVisible = false;
              _this12.$message.success('添加成功');
              _this12.form = {
                did: '',
                roomId: ''
              };
              _this12.updateStstus = false;
            } else {
              var message = res.msg ? res.msg : res.message;
              _this12.$message.error("\u66F4\u65B0\u5931\u8D25: " + message);
            }
          });
        } else {
          var _data = {
            code: "by/updateDevice",
            data: {
              did: this.form.did,
              roomId: this.form.roomId
            }
          };
          Object(api["g" /* httpPost */])(_data, this.$api.sendCommand).then(function (res) {
            if (res.success) {
              _this12.editVisible = false;
              _this12.$message.success('更新成功');
              _this12.form = {
                did: '',
                roomId: ''
              };
              _this12.updateStstus = false;
            } else {
              var message = res.msg ? res.msg : res.message;
              _this12.$message.error("\u66F4\u65B0\u5931\u8D25: " + message);
            }
          });
        }
      }
    },

    //   选择设备列表
    handleSelectionChange: function handleSelectionChange(val) {
      console.log(val);
    },

    // 设备每页数量
    handleSizeChange: function handleSizeChange(val) {
      this.pageSize = val;
      this.getBYRoom();
    },

    // 选择页码
    handlePageChange: function handlePageChange(val) {
      this.pageNum = val;
      this.getBYRoom();
    }
  }
});
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-6264d985","hasScoped":true,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/views/boYu/byRoom.vue
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"my-2 mx-2"},[_c('el-cascader',{ref:"cascader",staticClass:"width-200-px my-2 mr-2",attrs:{"options":_vm.optionsOne,"size":"small","props":{ checkStrictly: true },"clearable":true},on:{"change":_vm.checkNode}}),_vm._v(" "),_c('el-select',{attrs:{"size":"small","clearable":"","placeholder":"请选择楼栋"},on:{"change":function($event){return _vm.searchRoom($event,'unit')}},model:{value:(_vm.search.buildingId),callback:function ($$v) {_vm.$set(_vm.search, "buildingId", $$v)},expression:"search.buildingId"}},_vm._l((_vm.options),function(item){return _c('el-option',{key:item.value,attrs:{"label":item.label,"value":item.value}})}),1),_vm._v(" "),_c('el-select',{attrs:{"size":"small","clearable":"","placeholder":"请选择单元"},on:{"change":function($event){return _vm.searchRoom($event,'floor')}},model:{value:(_vm.search.unitId),callback:function ($$v) {_vm.$set(_vm.search, "unitId", $$v)},expression:"search.unitId"}},_vm._l((_vm.options2),function(item){return _c('el-option',{key:item.value,attrs:{"label":item.label,"value":item.value}})}),1),_vm._v(" "),_c('el-select',{attrs:{"size":"small","placeholder":"请选择楼层","clearable":""},model:{value:(_vm.search.floorId),callback:function ($$v) {_vm.$set(_vm.search, "floorId", $$v)},expression:"search.floorId"}},_vm._l((_vm.options3),function(item){return _c('el-option',{key:item.value,attrs:{"label":item.label,"value":item.value}})}),1),_vm._v(" "),_c('el-input',{staticClass:"width-200-px my-2 mr-2",attrs:{"size":"small","placeholder":"房间名称","clearable":""},model:{value:(_vm.search.roomName),callback:function ($$v) {_vm.$set(_vm.search, "roomName", $$v)},expression:"search.roomName"}}),_vm._v(" "),_c('el-button',{attrs:{"type":"primary","size":"small"},on:{"click":_vm.getBYRoom}},[_vm._v("搜 索")]),_vm._v(" "),_c('el-button',{attrs:{"type":"primary","size":"small"},on:{"click":_vm.resetSearch}},[_vm._v("重置搜索")]),_vm._v(" "),_c('el-button',{attrs:{"type":"primary","size":"small"},on:{"click":_vm.byListRoomMethods}},[_vm._v("同步房源")]),_vm._v(" "),_c('el-table',{ref:"multipleTable",staticClass:"table",attrs:{"data":_vm.tableData,"border":"","stripe":"","height":"600","header-cell-class-name":"table-header","empty-text":"无"},on:{"selection-change":_vm.handleSelectionChange}},[_c('el-table-column',{attrs:{"type":"selection","width":"55"}}),_vm._v(" "),_c('el-table-column',{attrs:{"prop":"storeName","label":"门店名称"}}),_vm._v(" "),_c('el-table-column',{attrs:{"prop":"buildingName","label":"楼栋名称"}}),_vm._v(" "),_c('el-table-column',{attrs:{"prop":"unitName","label":"单元名称"}}),_vm._v(" "),_c('el-table-column',{attrs:{"prop":"floorName","label":"楼层名称"}}),_vm._v(" "),_c('el-table-column',{attrs:{"prop":"roomName","label":"房间名称"}}),_vm._v(" "),_c('el-table-column',{attrs:{"label":"操作","align":"center"},scopedSlots:_vm._u([{key:"default",fn:function(scope){return [_c('el-button',{attrs:{"type":"text"},on:{"click":function($event){return _vm.addDevice(scope.$index, scope.row)}}},[_vm._v("绑定设备")])]}}])})],1),_vm._v(" "),_c('div',{staticClass:"pagination"},[_c('el-pagination',{attrs:{"current-page":_vm.pageNum,"page-sizes":[100,200,300,400,500],"page-size":_vm.pageSize,"layout":_vm.paginationConfig,"total":_vm.pageTotal},on:{"size-change":_vm.handleSizeChange,"current-change":_vm.handlePageChange}})],1),_vm._v(" "),_c('el-dialog',{attrs:{"title":"编辑","visible":_vm.editVisible,"width":"30%"},on:{"update:visible":function($event){_vm.editVisible=$event}},scopedSlots:_vm._u([{key:"footer",fn:function(){return [_c('span',{staticClass:"dialog-footer"},[_c('el-button',{attrs:{"size":"small"},on:{"click":function($event){_vm.editVisible = false}}},[_vm._v("取 消")]),_vm._v(" "),_c('el-button',{attrs:{"type":"primary","size":"small"},on:{"click":_vm.addDeviceMethods}},[_vm._v("确 定")])],1)]},proxy:true}])},[_c('el-form',{ref:"form",attrs:{"model":_vm.form,"label-width":"100px"}},[_c('el-form-item',{attrs:{"label":"设备"}},[_c('el-select',{attrs:{"size":"middle","placeholder":"请选择设备"},on:{"change":_vm.selectDevice},model:{value:(_vm.form.did),callback:function ($$v) {_vm.$set(_vm.form, "did", $$v)},expression:"form.did"}},_vm._l((_vm.deviceList),function(item){return _c('el-option',{key:item.value,attrs:{"label":item.label,"value":item.value}})}),1)],1),_vm._v(" "),_c('el-form-item',{attrs:{"label":"选择房间"}},[_c('el-cascader',{attrs:{"options":_vm.options,"size":"middle","props":{ checkStrictly: true },"clearable":""},on:{"change":_vm.checkNodeOne},model:{value:(_vm.form.roomId),callback:function ($$v) {_vm.$set(_vm.form, "roomId", $$v)},expression:"form.roomId"}})],1)],1)],1)],1)}
var staticRenderFns = []
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ var boYu_byRoom = (esExports);
// CONCATENATED MODULE: ./src/views/boYu/byRoom.vue
function injectStyle (ssrContext) {
  __webpack_require__("SMpM")
}
var normalizeComponent = __webpack_require__("VU/8")
/* script */


/* template */

/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = injectStyle
/* scopeId */
var __vue_scopeId__ = "data-v-6264d985"
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
  byRoom,
  boYu_byRoom,
  __vue_template_functional__,
  __vue_styles__,
  __vue_scopeId__,
  __vue_module_identifier__
)

/* harmony default export */ var views_boYu_byRoom = __webpack_exports__["default"] = (Component.exports);


/***/ }),

/***/ "SMpM":
/***/ (function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ })

});