|
@@ -870,6 +870,7 @@
|
|
|
* @param {Object} rowIndex
|
|
* @param {Object} rowIndex
|
|
|
*/
|
|
*/
|
|
|
open_close_airs(roomIndex, rowIndex, row, open_close) {
|
|
open_close_airs(roomIndex, rowIndex, row, open_close) {
|
|
|
|
|
+ // console.log(roomIndex, rowIndex, row, open_close);
|
|
|
// console.log(this.currentData.rooms[roomIndex].tableData[rowIndex]);
|
|
// console.log(this.currentData.rooms[roomIndex].tableData[rowIndex]);
|
|
|
// console.log(row);
|
|
// console.log(row);
|
|
|
let air_ip = this.currentData.rooms[roomIndex].tableData[rowIndex].ip;
|
|
let air_ip = this.currentData.rooms[roomIndex].tableData[rowIndex].ip;
|
|
@@ -911,7 +912,8 @@
|
|
|
this.$set(this.airsLoading[roomIndex], 'loading', false);
|
|
this.$set(this.airsLoading[roomIndex], 'loading', false);
|
|
|
}).catch((err) => {
|
|
}).catch((err) => {
|
|
|
// console.log(err);
|
|
// console.log(err);
|
|
|
- this.$message.error(err.message)
|
|
|
|
|
|
|
+ // this.$message.error(err.message)
|
|
|
|
|
+ this.$set(this.airsLoading[roomIndex], 'loading', false);
|
|
|
})
|
|
})
|
|
|
} else if (open_close == 'close') {
|
|
} else if (open_close == 'close') {
|
|
|
this.$set(this.airsLoading[roomIndex], 'loading', true);
|
|
this.$set(this.airsLoading[roomIndex], 'loading', true);
|
|
@@ -948,7 +950,8 @@
|
|
|
this.$set(this.airsLoading[roomIndex], 'loading', false);
|
|
this.$set(this.airsLoading[roomIndex], 'loading', false);
|
|
|
}).catch((err) => {
|
|
}).catch((err) => {
|
|
|
// console.log(err);
|
|
// console.log(err);
|
|
|
- this.$message.error(err.message)
|
|
|
|
|
|
|
+ // this.$message.error(err.message)
|
|
|
|
|
+ this.$set(this.airsLoading[roomIndex], 'loading', false);
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -1171,8 +1174,14 @@
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
* 获取房间数据
|
|
* 获取房间数据
|
|
|
|
|
+ * @param {Object} school
|
|
|
|
|
+ * @param {Object} build
|
|
|
|
|
+ * @param {Object} floors
|
|
|
|
|
+ * @param {Object} room
|
|
|
|
|
+ * @param {Object} index
|
|
|
*/
|
|
*/
|
|
|
get_room_airs_data(school, build, floors, room, index) {
|
|
get_room_airs_data(school, build, floors, room, index) {
|
|
|
|
|
+ // console.log(school, build, floors, room, index);
|
|
|
let param = {
|
|
let param = {
|
|
|
school: school,
|
|
school: school,
|
|
|
build: build,
|
|
build: build,
|
|
@@ -1314,9 +1323,9 @@
|
|
|
* @param {Object} rooms
|
|
* @param {Object} rooms
|
|
|
*/
|
|
*/
|
|
|
louceng_click(e, id, label, rooms) {
|
|
louceng_click(e, id, label, rooms) {
|
|
|
- this.listLoading = true
|
|
|
|
|
- let ids = id.split('|')
|
|
|
|
|
- let labels = label.split('|')
|
|
|
|
|
|
|
+ this.listLoading = true;
|
|
|
|
|
+ let ids = id.split('|');
|
|
|
|
|
+ let labels = label.split('|');
|
|
|
// console.log(ids);
|
|
// console.log(ids);
|
|
|
// console.log(labels);
|
|
// console.log(labels);
|
|
|
// console.log(rooms);
|
|
// console.log(rooms);
|
|
@@ -1342,35 +1351,172 @@
|
|
|
addDevice: '',
|
|
addDevice: '',
|
|
|
title_any_where: '',
|
|
title_any_where: '',
|
|
|
clickElement: e.target
|
|
clickElement: e.target
|
|
|
- }
|
|
|
|
|
|
|
+ };
|
|
|
// 点击的楼层id
|
|
// 点击的楼层id
|
|
|
- this.louceng_click_id = ids[0]
|
|
|
|
|
|
|
+ this.louceng_click_id = ids[0];
|
|
|
// 填充数据
|
|
// 填充数据
|
|
|
- this.currentData.school = labels[2]
|
|
|
|
|
- this.currentData.building = labels[1]
|
|
|
|
|
- this.currentData.floor = labels[0]
|
|
|
|
|
- this.currentData.allRooms = rooms
|
|
|
|
|
|
|
+ this.currentData.school = labels[2];
|
|
|
|
|
+ this.currentData.building = labels[1];
|
|
|
|
|
+ this.currentData.floor = labels[0];
|
|
|
// 给右侧窗口标题赋值
|
|
// 给右侧窗口标题赋值
|
|
|
- this.currentData.title_any_where = this.currentData.school + '-' + this.currentData.building +
|
|
|
|
|
- '-' + this
|
|
|
|
|
- .currentData.floor
|
|
|
|
|
|
|
+ this.currentData.title_any_where = this.currentData.school + '-' + this.currentData
|
|
|
|
|
+ .building + '-' + this.currentData.floor;
|
|
|
|
|
+ // 获取开机、关机、异常的房间,空的不显示
|
|
|
|
|
+ this.open_close_abnormal(this.currentData.school, this.currentData.building, this.currentData.floor,
|
|
|
|
|
+ rooms);
|
|
|
|
|
+ // 某层房间空调数
|
|
|
|
|
+ this.getRoomsAndAirs(this.currentData.school, this.currentData.building, this.currentData.floor);
|
|
|
|
|
+ // 某层空调开启和异常统计
|
|
|
|
|
+ this.getOpeningAndAbnomal(this.currentData.school, this.currentData.building, this.currentData
|
|
|
|
|
+ .floor);
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ this.listLoading = false;
|
|
|
|
|
+ }, 500);
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取开机、关机、异常房间数
|
|
|
|
|
+ * @param {Object} school
|
|
|
|
|
+ * @param {Object} build
|
|
|
|
|
+ * @param {Object} floors
|
|
|
|
|
+ * @param {Object} rooms
|
|
|
|
|
+ */
|
|
|
|
|
+ open_close_abnormal(school, build, floors, rooms) {
|
|
|
|
|
+ let _this = this,
|
|
|
|
|
+ len = rooms.length;
|
|
|
|
|
+ for (var i = 0; i < len; i++) {
|
|
|
|
|
+ // 延时执行
|
|
|
|
|
+ (function(t, school, build, floors, room, len) { // 注意这里是形参
|
|
|
|
|
+ setTimeout(function() {
|
|
|
|
|
+ _this.get_rooms(t, school, build, floors, room, len)
|
|
|
|
|
+ }, 50 * t); // 还是0.05执行一次,不是累加的
|
|
|
|
|
+ })(i, school, build, floors, rooms[i], len - 1); // 注意这里是实参,这里把要用的参数传进去
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取房间数量
|
|
|
|
|
+ * @param {Object} school
|
|
|
|
|
+ * @param {Object} build
|
|
|
|
|
+ * @param {Object} floors
|
|
|
|
|
+ * @param {Object} room
|
|
|
|
|
+ */
|
|
|
|
|
+ get_rooms(index, school, build, floors, room, len) {
|
|
|
|
|
+ // console.log(index, school, build, floors, room, len);
|
|
|
|
|
+ if (this.btnActive == 'all') {
|
|
|
|
|
+ this.currentData.allRooms.push(room);
|
|
|
|
|
+ if (index == len) {
|
|
|
|
|
+ // console.log(this.currentData);
|
|
|
|
|
+ this.pagination_showData()
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ let param = {
|
|
|
|
|
+ school: school,
|
|
|
|
|
+ build: build,
|
|
|
|
|
+ floors: floors,
|
|
|
|
|
+ dom: room
|
|
|
|
|
+ }
|
|
|
|
|
+ getRoomAirs(param).then((res) => {
|
|
|
|
|
+ // console.log(res);
|
|
|
|
|
+ if (typeof res.code == 'undefined' || res.code == '') {
|
|
|
|
|
+ // this.$message.error('返回数据格式问题,code未获取到!')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ let data = res.data
|
|
|
|
|
+ // 有设备数据
|
|
|
|
|
+ if (typeof data !== 'undefined' && data !== '') {
|
|
|
|
|
+ let tmpTableData = []
|
|
|
|
|
+ for (var i = 0; i < data.length; i++) {
|
|
|
|
|
+ let room = {}
|
|
|
|
|
+ let param = this.btnActive
|
|
|
|
|
+ if (param == 'all') {
|
|
|
|
|
+ room = {
|
|
|
|
|
+ name: data[i].air_name, // 名称
|
|
|
|
|
+ ip: data[i].air_ip, // 空调ip或id
|
|
|
|
|
+ building: data[i].build, // 楼栋
|
|
|
|
|
+ device: data[i].air_config, // 空调配置
|
|
|
|
|
+ userTime: data[i].duration_use, // 使用时长
|
|
|
|
|
+ alarmStatus: data[i].is_normal == 1 ? '正常' : '异常', // 是否正常
|
|
|
|
|
+ onOffStatus: data[i].is_on, // 是否开启
|
|
|
|
|
+ userName: data[i].cao, // 操作员
|
|
|
|
|
+ contact: '待接口返回,待优化' // 联系方式
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (param == 'powerOn' && data[i].is_on == '1') {
|
|
|
|
|
+ room = {
|
|
|
|
|
+ name: data[i].air_name, // 名称
|
|
|
|
|
+ ip: data[i].air_ip, // 空调ip或id
|
|
|
|
|
+ building: data[i].build, // 楼栋
|
|
|
|
|
+ device: data[i].air_config, // 空调配置
|
|
|
|
|
+ userTime: data[i].duration_use, // 使用时长
|
|
|
|
|
+ alarmStatus: data[i].is_normal == 1 ? '正常' : '异常', // 是否正常
|
|
|
|
|
+ onOffStatus: data[i].is_on, // 是否开启
|
|
|
|
|
+ userName: data[i].cao, // 操作员
|
|
|
|
|
+ contact: '待接口返回,待优化' // 联系方式
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (param == 'powerOff' && data[i].is_on == '0') {
|
|
|
|
|
+ room = {
|
|
|
|
|
+ name: data[i].air_name, // 名称
|
|
|
|
|
+ ip: data[i].air_ip, // 空调ip或id
|
|
|
|
|
+ building: data[i].build, // 楼栋
|
|
|
|
|
+ device: data[i].air_config, // 空调配置
|
|
|
|
|
+ userTime: data[i].duration_use, // 使用时长
|
|
|
|
|
+ alarmStatus: data[i].is_normal == 1 ? '正常' : '异常', // 是否正常
|
|
|
|
|
+ onOffStatus: data[i].is_on, // 是否开启
|
|
|
|
|
+ userName: data[i].cao, // 操作员
|
|
|
|
|
+ contact: '待接口返回,待优化' // 联系方式
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (param == 'abnormal' && data[i].is_normal == '0') {
|
|
|
|
|
+ room = {
|
|
|
|
|
+ name: data[i].air_name, // 名称
|
|
|
|
|
+ ip: data[i].air_ip, // 空调ip或id
|
|
|
|
|
+ building: data[i].build, // 楼栋
|
|
|
|
|
+ device: data[i].air_config, // 空调配置
|
|
|
|
|
+ userTime: data[i].duration_use, // 使用时长
|
|
|
|
|
+ alarmStatus: data[i].is_normal == 1 ? '正常' : '异常', // 是否正常
|
|
|
|
|
+ onOffStatus: data[i].is_on, // 是否开启
|
|
|
|
|
+ userName: data[i].cao, // 操作员
|
|
|
|
|
+ contact: '待接口返回,待优化' // 联系方式
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (JSON.stringify(room) !== '{}') {
|
|
|
|
|
+ // 每个房间的设备循环添加
|
|
|
|
|
+ tmpTableData.push(room)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (tmpTableData.length > 0) {
|
|
|
|
|
+ this.currentData.allRooms.push(room)
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // this.$message.warning(room + ' 没有设备的数据!')
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error('异常!请检查数据!')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (index == len) {
|
|
|
|
|
+ // console.log(this.currentData);
|
|
|
|
|
+ this.pagination_showData()
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch((err) => {
|
|
|
|
|
+ // console.log(err);
|
|
|
|
|
+ this.$message.error(err.message)
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分页显示数据
|
|
|
|
|
+ */
|
|
|
|
|
+ pagination_showData() {
|
|
|
// 赋值分页数据
|
|
// 赋值分页数据
|
|
|
- this.pagination.total = rooms.length
|
|
|
|
|
- // 最后一页删除后已经空了,则显示前一页
|
|
|
|
|
- let size = Math.ceil(this.pagination.total / 4)
|
|
|
|
|
|
|
+ this.pagination.total = this.currentData.allRooms.length;
|
|
|
|
|
+ // 最后一页删除后已经空了,则显示前一页或第1页
|
|
|
|
|
+ let size = Math.ceil(this.pagination.total / 4);
|
|
|
if (size != 0 && this.pagination.currentPage > size) {
|
|
if (size != 0 && this.pagination.currentPage > size) {
|
|
|
- this.pagination.currentPage = size
|
|
|
|
|
|
|
+ this.pagination.currentPage = size;
|
|
|
}
|
|
}
|
|
|
// 进行分页处理
|
|
// 进行分页处理
|
|
|
- this.roomDataPagination(this.pagination.currentPage, this.pagination.pageSize, this.currentData
|
|
|
|
|
- .allRooms,
|
|
|
|
|
- this.currentData.school, this.currentData.building, this.currentData.floor);
|
|
|
|
|
- // 某层房间空调数
|
|
|
|
|
- this.getRoomsAndAirs(this.currentData.school, this.currentData.building, this.currentData.floor)
|
|
|
|
|
- // 某层空调开启和异常统计
|
|
|
|
|
- this.getOpeningAndAbnomal(this.currentData.school, this.currentData.building, this.currentData
|
|
|
|
|
- .floor)
|
|
|
|
|
- this.listLoading = false
|
|
|
|
|
|
|
+ this.roomDataPagination(this.pagination.currentPage, this.pagination.pageSize, this
|
|
|
|
|
+ .currentData.allRooms, this.currentData.school, this.currentData.building, this
|
|
|
|
|
+ .currentData.floor);
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
* 某层空调开启和异常统计
|
|
* 某层空调开启和异常统计
|
|
@@ -1439,6 +1585,7 @@
|
|
|
* @param {Object} rooms
|
|
* @param {Object} rooms
|
|
|
*/
|
|
*/
|
|
|
roomDataPagination(currentPage, pageSize, rooms, school, build, floors) {
|
|
roomDataPagination(currentPage, pageSize, rooms, school, build, floors) {
|
|
|
|
|
+ // console.log(currentPage, pageSize, rooms, school, build, floors);
|
|
|
let startRecord = (currentPage - 1) * pageSize
|
|
let startRecord = (currentPage - 1) * pageSize
|
|
|
// 避免最后一页不满4个的情况
|
|
// 避免最后一页不满4个的情况
|
|
|
let len = rooms.length
|
|
let len = rooms.length
|
|
@@ -1699,17 +1846,17 @@
|
|
|
},
|
|
},
|
|
|
// 主题部分按钮的单击事件
|
|
// 主题部分按钮的单击事件
|
|
|
top_btn_click(param) {
|
|
top_btn_click(param) {
|
|
|
- this.btnActive = param
|
|
|
|
|
|
|
+ this.btnActive = param;
|
|
|
if (param == 'all') {
|
|
if (param == 'all') {
|
|
|
- this.currentData.clickElement.click()
|
|
|
|
|
|
|
+ this.currentData.clickElement.click();
|
|
|
} else if (param == 'powerOn') {
|
|
} else if (param == 'powerOn') {
|
|
|
- this.currentData.clickElement.click()
|
|
|
|
|
|
|
+ this.currentData.clickElement.click();
|
|
|
} else if (param == 'powerOff') {
|
|
} else if (param == 'powerOff') {
|
|
|
- this.currentData.clickElement.click()
|
|
|
|
|
|
|
+ this.currentData.clickElement.click();
|
|
|
} else if (param == 'abnormal') {
|
|
} else if (param == 'abnormal') {
|
|
|
- this.currentData.clickElement.click()
|
|
|
|
|
|
|
+ this.currentData.clickElement.click();
|
|
|
} else {
|
|
} else {
|
|
|
- this.$message.error('出现位置错误!');
|
|
|
|
|
|
|
+ this.$message.error('点击按钮出错!');
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|