Browse Source

测试的bug全部修复

程志平 3 years ago
parent
commit
a4ad999b78

+ 40 - 3
src/api/index.js

@@ -1,9 +1,46 @@
 import request from '@/utils/request'
 
-export function ceshi(data) {
+// 账户总余额
+export function totalMoney() {
 	return request({
-		url: '',
+		url: '/airManage/firstzongYu.action',
+		method: 'post'
+	})
+}
+
+// 本月充值
+export function thisMonthRecharge() {
+	return request({
+		url: '/airManage/firstqueryThisMonthRe.action',
+		method: 'post'
+	})
+}
+
+// 本月消费
+export function thisMonthConsume() {
+	return request({
+		url: '/airManage/firstqueryThisMonthCo.action',
+		method: 'post'
+	})
+}
+
+// 空调超时预警
+export function airTimeoutWarning() {
+	return request({
+		url: '/airManage/firstqueryOverTime.action',
+		method: 'post'
+	})
+}
+
+
+// 用电消费走势图
+export function getChart(forData) {
+	let data = new FormData()
+	data.append('year', forData.year)
+	
+	return request({
+		url: '/airManage/firstAirMonthT.action',
 		method: 'post',
 		data
 	})
-}
+}

+ 2 - 5
src/layout/components/Navbar.vue

@@ -62,9 +62,9 @@
 <script>
 	import {
 		mapGetters
-	} from 'vuex'
+	} from 'vuex';
 	// import Breadcrumb from '@/components/Breadcrumb'
-	import Hamburger from '@/components/Hamburger'
+	import Hamburger from '@/components/Hamburger';
 
 	export default {
 		components: {
@@ -79,9 +79,6 @@
 				week_show: ''
 			}
 		},
-		onload() {
-			
-		},
 		created() {
 			// 获取日期-星期
 			setTimeout(() => {

+ 7 - 5
src/store/modules/user.js

@@ -16,6 +16,7 @@ const getDefaultState = () => {
 	return {
 		token: getToken(),
 		name: '',
+		level: '',
 		avatar: ''
 	}
 }
@@ -32,8 +33,8 @@ const mutations = {
 	SET_NAME: (state, name) => {
 		state.name = name
 	},
-	SET_PWD: (state, pwd) => {
-		state.pwd = pwd
+	SET_LEVEL: (state, level) => {
+		state.level = level
 	},
 	SET_AVATAR: (state, avatar) => {
 		state.avatar = avatar
@@ -60,12 +61,12 @@ const actions = {
 					commit('SET_TOKEN', token)
 					setToken(token)
 					// 添加:
+					commit('SET_LEVEL', response.data[0].level)
 					commit('SET_NAME', username)
-					commit('SET_PWD', password)
 				}
 				// commit('SET_TOKEN', data.token)
 				// setToken(data.token)
-				resolve()
+				resolve(response)
 			}).catch(error => {
 				reject(error)
 			})
@@ -112,7 +113,8 @@ const actions = {
 			resetRouter()
 			commit('RESET_STATE')
 			commit('SET_NAME')
-			commit('SET_PWD')
+			commit('SET_LEVEL')
+			commit('SET_TOKEN', '')
 			resolve()
 		})
 		// 修改:下面被注释了

+ 79 - 29
src/views/accountMgr/index.vue

@@ -13,7 +13,7 @@
 					</div>
 					<div class="cell-body">
 						<el-table :data="tableData" height="560" style="width: 100%" :cell-style="cell_style"
-							:header-cell-style="header_cell_style">
+							v-loading="loading" :header-cell-style="header_cell_style">
 							<el-table-column label="序号" align="center" width="100">
 								<template slot-scope="scope">
 									<span>{{(pagination.currentPage - 1) * pagination.pageSize + scope.$index + 1}}</span>
@@ -42,11 +42,20 @@
 							</el-table-column>
 							<el-table-column label="操作" align="center">
 								<template slot-scope="scope">
-									<el-button size="mini" class="btn-table"
-										@click="edit_amount(scope.$index, scope.row)">修改</el-button>
-									<el-button size="mini" class="btn-table" type="danger"
-										@click="delete_amount(scope.$index, scope.row)">
-										删除</el-button>
+									<div v-if="currentUserLevel == 1 && scope.row.admin_name == currentUserName">
+										<el-button size="mini" class="btn-table"
+											@click="edit_amount(scope.$index, scope.row)">修改</el-button>
+										<el-button size="mini" class="btn-table" type="danger"
+											@click="delete_amount(scope.$index, scope.row)">
+											删除</el-button>
+									</div>
+									<div v-else-if="currentUserLevel == 2">
+										<el-button size="mini" class="btn-table"
+											@click="edit_amount(scope.$index, scope.row)">修改</el-button>
+										<el-button size="mini" class="btn-table" type="danger"
+											@click="delete_amount(scope.$index, scope.row)">
+											删除</el-button>
+									</div>
 								</template>
 							</el-table-column>
 						</el-table>
@@ -100,25 +109,25 @@
 		<el-dialog title="修改账号" custom-class="modify-account-class" :visible.sync="dialogModifyAcountFormVisible"
 			:close-on-click-modal="false" :close-on-press-escape="false" @close="modify_account_dialog_close">
 			<el-form :model="formModifyAcount" ref="modifyAccountForm" :rules="modifyAccountFormRules">
-				<el-form-item label="用户名:" :label-width="formLabelWidth" :required="true">
+				<el-form-item label="用户名:" :label-width="formLabelWidth" :required="true" prop="username">
 					<el-input v-model="formModifyAcount.username" autocomplete="off" placeholder="请输入用户名" readonly
 						maxlength="10"></el-input>
 				</el-form-item>
-				<el-form-item label="手机号:" :label-width="formLabelWidth" :required="true">
+				<el-form-item label="手机号:" :label-width="formLabelWidth" :required="true" prop="phone">
 					<el-input v-model="formModifyAcount.phone" autocomplete="off" placeholder="请输入手机号" maxlength="11">
 					</el-input>
 				</el-form-item>
-				<el-form-item label="密 码:" :label-width="formLabelWidth" :required="true" prop="password">
+				<el-form-item label="密 码:" :label-width="formLabelWidth" prop="password">
 					<el-input v-model="formModifyAcount.password" type="password" autocomplete="off" placeholder="请输入密码"
 						maxlength="16">
 					</el-input>
 				</el-form-item>
-				<el-form-item label="确认密码:" :label-width="formLabelWidth" :required="true" prop="confirmPassword">
+				<el-form-item label="确认密码:" :label-width="formLabelWidth" prop="confirmPassword">
 					<el-input v-model="formModifyAcount.confirmPassword" type="password" autocomplete="off"
 						placeholder="请输入确认密码" maxlength="16">
 					</el-input>
 				</el-form-item>
-				<el-form-item label="角 色:" :label-width="formLabelWidth" :required="true">
+				<el-form-item label="角 色:" :label-width="formLabelWidth" :required="true" prop="checkedRole">
 					<el-checkbox-group v-model="formModifyAcount.checkedRole" :min="0" :max="1">
 						<el-checkbox v-for="(role, index) in formModifyAcount.roles" :label="role" :key="role">{{role}}
 						</el-checkbox>
@@ -150,12 +159,16 @@
 
 <script>
 	import {
+		mapGetters
+	} from 'vuex';
+	import {
 		getTableData,
 		addAccount,
 		modifyAccount,
 		deleteAccount
-	} from '@/api/accountMgr'
-	const roleOptions = ['管理员', '超级管理员']
+	} from '@/api/accountMgr';
+	// const roleOptions = ['管理员', '超级管理员']
+	const roleOptions = ['管理员']
 	export default {
 		data() {
 			var checkUserName = (rule, value, callback) => {
@@ -163,9 +176,9 @@
 					return callback(new Error('请输入用户名)'));
 				}
 				setTimeout(() => {
-					var reg = /^\w{6,16}$/
+					var reg = /^[a-zA-Z0-9\u4e00-\u9fa5]{6,16}$/
 					if (!reg.test(value)) {
-						callback(new Error('必须为6-16个非空白字符或数字!'));
+						callback(new Error('必须为6-16个汉字、数字或字母!'));
 					} else {
 						callback();
 					}
@@ -212,6 +225,36 @@
 					}
 				}, 100);
 			}
+			var checkPwd_modify = (rule, value, callback) => {
+				if (value) {
+					setTimeout(() => {
+						var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/
+						if (!reg.test(value)) {
+							callback(new Error('密码至少包含 数字和英文,长度6-16'));
+						} else {
+							callback();
+						}
+					}, 100);
+				} else {
+					callback();
+				}
+			}
+			var checkConfirmPwd_modify = (rule, value, callback) => {
+				if (value) {
+					setTimeout(() => {
+						var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/
+						if (!reg.test(value)) {
+							callback(new Error('确认密码至少包含 数字和英文,长度6-16'));
+						} else if (this.formAddAcount.password !== this.formAddAcount.confirmPassword) {
+							callback(new Error('确认密码与密码不一致!'));
+						} else {
+							callback();
+						}
+					}, 100);
+				} else {
+					callback();
+				}
+			}
 			var checkRole = (rule, value, callback) => {
 				if (!(value.length > 0)) {
 					callback(new Error('请选择角色'));
@@ -220,6 +263,10 @@
 				}
 			}
 			return {
+				// 当前用户名
+				currentUserName: this.$store.state.user.name,
+				// 当前用户的权限
+				currentUserLevel: this.$store.state.user.level,
 				dialogAddAcountFormVisible: false, // 添加账号对话框显示与隐藏
 				formAddAcount: { // 添加账号对话框 数据
 					phone: '',
@@ -227,16 +274,16 @@
 					password: '',
 					confirmPassword: '',
 					comment: '',
-					checkedRole: [],
+					checkedRole: ['管理员'],
 					roles: roleOptions
 				},
 				addAccountFormRules: {
-					phone: [{
-						validator: checkPhone
-					}],
 					username: [{
 						validator: checkUserName
 					}],
+					phone: [{
+						validator: checkPhone
+					}],
 					password: [{
 						validator: checkPwd
 					}],
@@ -259,17 +306,17 @@
 					roles: roleOptions
 				},
 				modifyAccountFormRules: {
-					phone: [{
-						validator: checkPhone
-					}],
 					username: [{
 						validator: checkUserName
 					}],
+					phone: [{
+						validator: checkPhone
+					}],
 					password: [{
-						validator: checkPwd
+						validator: checkPwd_modify
 					}],
 					confirmPassword: [{
-						validator: checkConfirmPwd
+						validator: checkConfirmPwd_modify
 					}],
 					checkedRole: [{
 						validator: checkRole
@@ -300,7 +347,8 @@
 					pageSize: 10,
 					currentPage: 1,
 					total: 0
-				}
+				},
+				loading: true
 			}
 		},
 		created() {
@@ -315,6 +363,7 @@
 			 * 获取账号列表数据
 			 */
 			get_table_data() {
+				this.loading = true
 				let data = {
 					page: this.pagination.currentPage,
 					rows: this.pagination.pageSize
@@ -339,7 +388,8 @@
 				}).catch((err) => {
 					// console.log(err);
 					this.$message.error(err.message)
-				})
+				});
+				this.loading = false
 			},
 			/**
 			 * 删除账号
@@ -420,7 +470,7 @@
 								this.$message.error('返回数据格式问题,code未获取到!')
 								return
 							}
-				
+
 							if (res.code == 200) {
 								this.get_table_data()
 								this.dialogModifyAcountFormVisible = false
@@ -445,7 +495,7 @@
 						this.$message.error('返回数据格式问题,code未获取到!')
 						return
 					}
-				
+
 					if (res.code == 200) {
 						this.get_table_data()
 						this.dialog_delete_account = false
@@ -468,7 +518,7 @@
 					password: '',
 					confirmPassword: '',
 					comment: '',
-					checkedRole: [],
+					checkedRole: ['管理员'],
 					roles: roleOptions
 				}
 			},

+ 7 - 4
src/views/consumptionRecord/index.vue

@@ -37,7 +37,7 @@
 								</el-select>
 							</el-form-item>
 						</el-form>
-						<el-table :data="tableData" height="510" style="width: 100%" :cell-style="cell_style"
+						<el-table :data="tableData" height="510" style="width: 100%" :cell-style="cell_style" v-loading="loading"
 							:header-cell-style="header_cell_style">
 							<el-table-column label="序号" align="center" width="90">
 								<template slot-scope="scope">
@@ -154,7 +154,8 @@
 					currentPage: 1,
 					pageSize: 9,
 					total: 0
-				}
+				},
+				loading: true
 			}
 		},
 		created() {
@@ -181,7 +182,7 @@
 
 					if (res.code == 200) {
 						this.$message.success('下载成功!')
-						let xls = 'http://demo.xwsyjjy.com' + res.downurl
+						let xls = 'https://chtech.ncjti.edu.cn/air-conditioner-control/' + res.downurl
 						window.open(xls)
 					} else {
 						this.$message.error('返回的数据异常!')
@@ -217,6 +218,7 @@
 			 * 获取消费记录,表格数据
 			 */
 			get_table_data(param) {
+				this.loading = true
 				let data = {
 					page: this.pagination.currentPage,
 					rows: this.pagination.pageSize
@@ -252,7 +254,8 @@
 				}).catch((err) => {
 					// console.log(err);
 					this.$message.error(err.message)
-				})
+				});
+				this.loading = false
 			},
 			/**
 			 * 获取3个数据

+ 259 - 183
src/views/index/index.vue

@@ -2,31 +2,31 @@
 	<div class="app-container">
 		<el-row>
 			<el-col :span="8">
-				<div class="cell cell-row1">
+				<div class="cell cell-row1" v-loading="showTotalMoney.loading">
 					<div class="cell-title">账户余额</div>
-					<div class="cell-time">截止时间为2022/06/22 17:20:20</div>
+					<div class="cell-time">截止时间为 {{ showTotalMoney.time }}</div>
 					<div class="cell-bottom">
-						<div class="cell-bottom-amount">5869.00</div>
+						<div class="cell-bottom-amount">{{ showTotalMoney.amount.toFixed(2) }}</div>
 						<div class="rmb1">¥</div>
 					</div>
 				</div>
 			</el-col>
 			<el-col :span="8">
-				<div class="cell cell-row1">
+				<div class="cell cell-row1" v-loading="showThisMonthRecharge.loading">
 					<div class="cell-title">本月充值</div>
-					<div class="cell-time">截止时间为2022/06/22 17:20:20</div>
+					<div class="cell-time">截止时间为 {{ showThisMonthRecharge.time }}</div>
 					<div class="cell-bottom">
-						<div class="cell-bottom-amount">5869.00</div>
+						<div class="cell-bottom-amount">{{ showThisMonthRecharge.amount.toFixed(2) }}</div>
 						<div class="rmb2">¥</div>
 					</div>
 				</div>
 			</el-col>
 			<el-col :span="8">
-				<div class="cell cell-row1">
+				<div class="cell cell-row1" v-loading="showThisMonthConsume.loading">
 					<div class="cell-title">本月消费</div>
-					<div class="cell-time">截止时间为2022/06/22 17:20:20</div>
+					<div class="cell-time">截止时间为 {{ showThisMonthConsume.time }}</div>
 					<div class="cell-bottom">
-						<div class="cell-bottom-amount">5869.00</div>
+						<div class="cell-bottom-amount">{{ showThisMonthConsume.amount.toFixed(2) }}</div>
 						<div class="rmb3">¥</div>
 					</div>
 				</div>
@@ -40,11 +40,10 @@
 							<img src="../../icons/images/index/zoushi.png" alt="">
 							<span>用电消费走势图</span>
 						</div>
-						<el-select v-model="value" placeholder="请选择" class="select-year">
-							<el-option v-for="item in options" :key="item.value" :label="item.label"
-								:value="item.value">
-							</el-option>
-						</el-select>
+						<el-date-picker v-model="showEchartsDate" @change="echartsDate_change" class="select-year"
+							type="year" :picker-options="pickerOptions" :clearable="false" :editable="false"
+							value-format="yyyy" placeholder="年份">
+						</el-date-picker>
 						<div id="main-echart" class="line-echart"></div>
 					</el-card>
 				</div>
@@ -57,7 +56,8 @@
 							<span>超时预警</span>
 						</div>
 						<el-table :data="yujing_tableData" height="350" stripe :cell-style="cell_style"
-							:header-cell-style="header_cell_style" style="width: 100%">
+							v-loading="airTimeoutWarning_loading" :header-cell-style="header_cell_style"
+							style="width: 100%">
 							<el-table-column prop="deviceId" label="设备号" align="center">
 							</el-table-column>
 							<el-table-column prop="warningTime" label="告警时间" align="center">
@@ -128,6 +128,13 @@
 </template>
 
 <script>
+	import {
+		totalMoney,
+		thisMonthRecharge,
+		thisMonthConsume,
+		airTimeoutWarning,
+		getChart
+	} from '@/api/index';
 	import * as echarts from 'echarts/core';
 	import {
 		TitleComponent,
@@ -153,6 +160,35 @@
 	export default {
 		data() {
 			return {
+				// 账户总余额
+				showTotalMoney: {
+					time: '0000/00/00 00:00:00',
+					amount: 0.00,
+					loading: false
+				},
+				// 本月充值
+				showThisMonthRecharge: {
+					time: '0000/00/00 00:00:00',
+					amount: 0.00,
+					loading: false
+				},
+				// 本月消费
+				showThisMonthConsume: {
+					time: '0000/00/00 00:00:00',
+					amount: 0.00,
+					loading: false
+				},
+				// 空调超时预警
+				airTimeoutWarning_loading: false,
+				// 选择年份范围
+				pickerOptions: {
+					disabledDate(time) {
+						return (
+							time.getFullYear() < "2021" || time.getFullYear() > new Date().getFullYear()
+						);
+					}
+				},
+				showEchartsDate: new Date().getFullYear() + '',
 				// 表格单元格样式
 				cell_style: {
 					color: '#1A202B',
@@ -166,83 +202,12 @@
 					'font-size': '18px',
 					'font-family': 'Microsoft YaHei-3970(82674968)'
 				},
-				options: [{
-					value: '0',
-					label: '2022年'
-				}, {
-					value: '1',
-					label: '2021年'
-				}],
-				value: '0', // 下拉列表的值
 				// 预警表格数据
-				yujing_tableData: [{
-					deviceId: '1.5P挂机01',
-					warningTime: '2022-06-23 17:15:15',
-					operator: '朱秀平',
-					serviceTime: '05:25:26',
-					contact: '13688955689'
-				}, {
-					deviceId: '1.5P挂机01',
-					warningTime: '2022-06-23 17:15:15',
-					operator: '朱秀平',
-					serviceTime: '05:25:26',
-					contact: '13688955689'
-				}, {
-					deviceId: '1.5P挂机01',
-					warningTime: '2022-06-23 17:15:15',
-					operator: '朱秀平',
-					serviceTime: '05:25:26',
-					contact: '13688955689'
-				}, {
-					deviceId: '1.5P挂机01',
-					warningTime: '2022-06-23 17:15:15',
-					operator: '朱秀平',
-					serviceTime: '05:25:26',
-					contact: '13688955689'
-				}, {
-					deviceId: '1.5P挂机01',
-					warningTime: '2022-06-23 17:15:15',
-					operator: '朱秀平',
-					serviceTime: '05:25:26',
-					contact: '13688955689'
-				}, {
-					deviceId: '1.5P挂机01',
-					warningTime: '2022-06-23 17:15:15',
-					operator: '朱秀平',
-					serviceTime: '05:25:26',
-					contact: '13688955689'
-				}, {
-					deviceId: '1.5P挂机01',
-					warningTime: '2022-06-23 17:15:15',
-					operator: '朱秀平',
-					serviceTime: '05:25:26',
-					contact: '13688955689'
-				}],
+				yujing_tableData: [],
 				// 业务表格数据
 				yewu_tableData: [{
 					desc: '朱秀平电费充值',
 					dataTime: '2022-06-23 17:15:15'
-				}, {
-					desc: '朱秀平电费充值',
-					dataTime: '2022-06-23 17:15:15'
-				}, {
-					desc: '朱秀平电费充值',
-					dataTime: '2022-06-23 17:15:15'
-				}, {
-					desc: '朱秀平电费充值',
-					dataTime: '2022-06-23 17:15:15'
-				}, {
-					desc: '朱秀平电费充值',
-					dataTime: '2022-06-23 17:15:15'
-				}, {
-					desc: '朱秀平电费充值',
-					dataTime: '2022-06-23 17:15:15'
-				}, {
-					desc: '朱秀平电费充值',
-					dataTime: '2022-06-23 17:15:15'
-				}, {
-					desc: '朱秀平电费充值',
-					dataTime: '2022-06-23 17:15:15'
 				}],
 				// 状态表格数据
 				zhuangtai_tableData: [{
@@ -252,62 +217,6 @@
 					adminBuilding: '26/56',
 					stuCenter: '26/56',
 					library: '26/56'
-				}, {
-					floor: '1F',
-					scienceBuilding: '26/56',
-					teachBuilding: '26/56',
-					adminBuilding: '26/56',
-					stuCenter: '26/56',
-					library: '26/56'
-				}, {
-					floor: '1F',
-					scienceBuilding: '26/56',
-					teachBuilding: '26/56',
-					adminBuilding: '26/56',
-					stuCenter: '26/56',
-					library: '26/56'
-				}, {
-					floor: '1F',
-					scienceBuilding: '26/56',
-					teachBuilding: '26/56',
-					adminBuilding: '26/56',
-					stuCenter: '26/56',
-					library: '26/56'
-				}, {
-					floor: '1F',
-					scienceBuilding: '26/56',
-					teachBuilding: '26/56',
-					adminBuilding: '26/56',
-					stuCenter: '26/56',
-					library: '26/56'
-				}, {
-					floor: '1F',
-					scienceBuilding: '26/56',
-					teachBuilding: '26/56',
-					adminBuilding: '26/56',
-					stuCenter: '26/56',
-					library: '26/56'
-				}, {
-					floor: '1F',
-					scienceBuilding: '26/56',
-					teachBuilding: '26/56',
-					adminBuilding: '26/56',
-					stuCenter: '26/56',
-					library: '26/56'
-				}, {
-					floor: '1F',
-					scienceBuilding: '26/56',
-					teachBuilding: '26/56',
-					adminBuilding: '26/56',
-					stuCenter: '26/56',
-					library: '26/56'
-				}, {
-					floor: '1F',
-					scienceBuilding: '26/56',
-					teachBuilding: '26/56',
-					adminBuilding: '26/56',
-					stuCenter: '26/56',
-					library: '26/56'
 				}],
 				// 折线图数据
 				option: {
@@ -317,7 +226,7 @@
 					legend: {
 						y: 'bottom',
 						x: 'center',
-						data: ['1.5P', '2P', '3P', '天花机']
+						data: []
 					},
 					grid: {
 						top: '10%',
@@ -337,60 +246,227 @@
 					xAxis: {
 						type: 'category',
 						boundaryGap: false,
-						data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
+						data: []
 					},
 					yAxis: {
 						name: '元',
 						type: 'value'
 					},
-					series: [{
-							name: '1.5P',
-							type: 'line',
-							stack: 'Total',
-							data: [120, 132, 101, 134, 90, 230, 210]
-						},
-						{
-							name: '2P',
-							type: 'line',
-							stack: 'Total',
-							data: [220, 182, 191, 234, 290, 330, 310]
-						},
-						{
-							name: '3P',
-							type: 'line',
-							stack: 'Total',
-							data: [150, 232, 201, 154, 190, 330, 410]
-						},
-						{
-							name: '天花机',
-							type: 'line',
-							stack: 'Total',
-							data: [820, 932, 901, 934, 1290, 1330, 1320]
-						}
-					]
-				},
-
+					series: []
+				}
 			}
 		},
-		mounted() {
-			this.initCharts();
+		created() {
+			// 获取总金额
+			this.getTotalMoney()
+			// 本月充值
+			this.getThisMonthRecharge()
+			// 本月消费
+			this.getThisMonthConsume()
+			// 空调超时预警
+			this.getAirTimeoutWarning()
+			// 用电消费走势图
+			this.getChart()
 		},
 		methods: {
 			/**
+			 * 获取折线图数据
+			 */
+			getChart() {
+				this.echart_loading = true
+
+				getChart({
+					year: this.showEchartsDate
+				}).then((res) => {
+					// console.log(res);
+					if (typeof res.code == 'undefined' || res.code == '') {
+						this.$message.error('返回数据格式问题,code未获取到!');
+						return;
+					}
+					
+					if (res.code == 200) {
+						let tmp = res.monthT.sort((a, b) => {
+							return a.month.localeCompare(b.month)
+						});
+						let legend_data = []
+						let xAxis_data = []
+						let series = []
+						for (var i = 0; i < tmp.length; i++) {
+							if (legend_data.indexOf(tmp[i].air_config) == -1) {
+								legend_data.push(tmp[i].air_config)
+
+								series.push({
+									name: tmp[i].air_config,
+									type: 'line',
+									stack: 'Total',
+									data: []
+								});
+							}
+
+							if (xAxis_data.indexOf(tmp[i].month) == -1) {
+								xAxis_data.push(tmp[i].month)
+							}
+						}
+
+						for (var i = 0; i < xAxis_data.length; i++) {
+							for (var j = 0; j < tmp.length; j++) {
+								for (var k = 0; k < series.length; k++) {
+									if (tmp[j].month == xAxis_data[i] && tmp[j].air_config == series[k].name) {
+										series[k].data.push(tmp[j].num)
+									}
+								}
+							}
+						}
+
+						for (var i = 0; i < xAxis_data.length; i++) {
+							xAxis_data[i] = xAxis_data[i].split('-')[1]
+						}
+						// 初始化图表数据
+						this.option.legend.data = legend_data
+						this.option.xAxis.data = xAxis_data
+						this.option.series = series
+					} else {
+						this.option.legend.data = []
+						this.option.xAxis.data = []
+						this.option.series = []
+						this.$message.error('用电消费走势图返回的数据异常!');
+					}
+					// 初始化图表
+					this.initCharts();
+				}).catch((err) => {
+					// console.log(err);
+					this.$message.error(err.message)
+				});
+
+				this.echart_loading = false
+			},
+			/**
+			 * 选择年份改变了
+			 */
+			echartsDate_change() {
+				// console.log(this.showEchartsDate);
+				this.getChart()
+			},
+			/**
+			 * 空调超时预警
+			 */
+			getAirTimeoutWarning() {
+				this.airTimeoutWarning_loading = true
+
+				airTimeoutWarning().then((res) => {
+					// console.log(res);
+					if (typeof res.code == 'undefined' || res.code == '') {
+						this.$message.error('返回数据格式问题,code未获取到!');
+						return;
+					}
+					if (res.code == 200) {
+						this.yujing_tableData = [];
+						for (var i = 0; i < res.monthT.length; i++) {
+							this.yujing_tableData.push({
+								deviceId: res.monthT[i].dom + ' ' + res.monthT[i].air_name + ' ' + res
+									.monthT[i].air_config,
+								warningTime: res.monthT[i].time,
+								operator: res.monthT[i].user_name,
+								serviceTime: res.monthT[i].auto_time,
+								contact: res.monthT[i].phone
+							})
+						}
+					} else {
+						// this.$message.error('空调超时预警返回的数据异常!');
+					}
+				}).catch((err) => {
+					// console.log(err);
+					this.$message.error(err.message)
+				});
+
+				this.airTimeoutWarning_loading = false
+			},
+			/**
+			 * 本月消费
+			 */
+			getThisMonthConsume() {
+				this.showThisMonthConsume.loading = true
+
+				thisMonthConsume().then((res) => {
+					// console.log(res);
+					if (typeof res.code == 'undefined' || res.code == '') {
+						this.$message.error('返回数据格式问题,code未获取到!')
+						return
+					}
+
+					if (res.code == 200) {
+						this.showThisMonthConsume.time = res.time
+						this.showThisMonthConsume.amount = res.zongCo.tong
+					} else {
+						this.$message.error('本月消费返回的数据异常!')
+					}
+				}).catch((err) => {
+					// console.log(err);
+					this.$message.error(err.message)
+				});
+
+				this.showThisMonthConsume.loading = false
+			},
+			/**
+			 * 本月充值
+			 */
+			getThisMonthRecharge() {
+				this.showThisMonthRecharge.loading = true
+
+				thisMonthConsume().then((res) => {
+					// console.log(res);
+					if (typeof res.code == 'undefined' || res.code == '') {
+						this.$message.error('返回数据格式问题,code未获取到!')
+						return
+					}
+
+					if (res.code == 200) {
+						this.showThisMonthRecharge.time = res.time
+						this.showThisMonthRecharge.amount = res.zongCo.tong
+					} else {
+						this.$message.error('本月充值返回的数据异常!')
+					}
+				}).catch((err) => {
+					// console.log(err);
+					this.$message.error(err.message)
+				});
+
+				this.showThisMonthRecharge.loading = false
+			},
+			/**
+			 * 获取总金额
+			 */
+			getTotalMoney() {
+				this.showTotalMoney.loading = true
+
+				totalMoney().then((res) => {
+					// console.log(res);
+					if (typeof res.code == 'undefined' || res.code == '') {
+						this.$message.error('返回数据格式问题,code未获取到!')
+						return
+					}
+
+					if (res.code == 200) {
+						this.showTotalMoney.time = res.time
+						this.showTotalMoney.amount = res.zongYu.tong
+					} else {
+						this.$message.error('获取总金额返回的数据异常!')
+					}
+				}).catch((err) => {
+					// console.log(err);
+					this.$message.error(err.message)
+				});
+
+				this.showTotalMoney.loading = false
+			},
+			/**
 			 * 初始化折线图
 			 */
 			initCharts() {
 				// 基于准备好的dom,初始化echarts实例
 				var myChart = echarts.init(document.getElementById('main-echart'));
 				// 绘制图表
-				this.setOption(myChart)
-			},
-			/**
-			 * 向折线图赋值,开始展示数据
-			 * @param {Object} myChart
-			 */
-			setOption(myChart) {
-				myChart.setOption(this.option);
+				myChart.setOption(this.option, true);
 			},
 			// 表格某些列样式改变
 			handle_cell_style({
@@ -536,7 +612,7 @@
 							right: 20px;
 							top: 68px;
 							width: 100px;
-							z-index: 9999;
+							z-index: 1;
 						}
 
 						.line-echart {

+ 18 - 21
src/views/login/index.vue

@@ -46,7 +46,7 @@
 	import {
 		login
 	} from '@/api/user'
-	
+
 	export default {
 		name: 'Login',
 		data() {
@@ -59,7 +59,7 @@
 			}
 			const validatePassword = (rule, value, callback) => {
 				if (value.length < 6) {
-					callback(new Error('请输入密码'))
+					callback(new Error('请输入密码,不小于6位'))
 				} else {
 					callback()
 				}
@@ -112,28 +112,25 @@
 				this.$refs.loginForm.validate(valid => {
 					if (valid) {
 						this.loading = true
-						// login(this.loginForm).then((res) => {
-							// if (typeof res !== 'undefined' && res.code == 200) {
-								this.$store.dispatch('user/login', this.loginForm).then(() => {
+						this.$store.dispatch('user/login', this.loginForm)
+							.then((res) => {
+								if (res.code == 200) {
 									this.$router.push({
 										path: this.redirect || '/'
-									})
-									this.loading = false
-								}).catch((err) => {
-									// console.log(err);
-									// this.$message.error(err.message)
-									this.loading = false
-								})
-							// } else {
-							// 	this.$message.error(res.message)
-							// }
-							// this.loading = false
-						// }).catch((err) => {
-						// 	this.$message.error(err.message)
-						// })
+									});
+									this.$message.success(res.message);
+								} else {
+									this.$message.error(res.message);
+								}
+								this.loading = false;
+							}).catch((err) => {
+								// console.log(err);
+								this.$message.error(err.message);
+								this.loading = false;
+							});
 					} else {
-						this.$message.error('请输入账号或密码!')
-						return false
+						// this.$message.error('请输入账号或密码!');
+						return false;
 					}
 				})
 			}

+ 7 - 4
src/views/rechargeRecord/index.vue

@@ -37,7 +37,7 @@
 								</el-select>
 							</el-form-item>
 						</el-form>
-						<el-table :data="tableData" height="510" style="width: 100%" :cell-style="cell_style"
+						<el-table :data="tableData" height="510" style="width: 100%" :cell-style="cell_style" v-loading="loading"
 							:header-cell-style="header_cell_style">
 							<el-table-column label="序号" align="center" width="100">
 								<template slot-scope="scope">
@@ -139,7 +139,8 @@
 					currentPage: 1,
 					pageSize: 9,
 					total: 0
-				}
+				},
+				loading: true
 			}
 		},
 		created() {
@@ -166,7 +167,7 @@
 
 					if (res.code == 200) {
 						this.$message.success('下载成功!')
-						let xls = 'http://demo.xwsyjjy.com' + res.downurl
+						let xls = 'https://chtech.ncjti.edu.cn/air-conditioner-control/' + res.downurl
 						window.open(xls)
 					} else {
 						this.$message.error('返回的数据异常!')
@@ -220,6 +221,7 @@
 			 * 获取消费记录,表格数据
 			 */
 			get_table_data(param) {
+				this.loading = true
 				let data = {
 					page: this.pagination.currentPage,
 					rows: this.pagination.pageSize
@@ -255,7 +257,8 @@
 				}).catch((err) => {
 					// console.log(err);
 					this.$message.error(err.message)
-				})
+				});
+				this.loading = false
 			},
 			/**
 			 * 搜索

+ 39 - 15
src/views/serveAC/index.vue

@@ -1,7 +1,7 @@
 <template>
 	<div class="app-container">
 		<el-row>
-			<el-col :span="4" class="nav-class">
+			<el-col :span="4" class="nav-class" v-loading="navLoading">
 				<div class="nav-box">
 					<div class="item-school" v-for="(item0, index0) in navData" :key="index0">
 						<div class="school" @click="school_toggle(item0.id, item0.label)">
@@ -19,7 +19,8 @@
 							</div>
 							<div class="item-louceng" v-for="(item2, index2) in item1.children" :key="index2"
 								:style="{display: item1.isShow ? '' : 'none'}">
-								<div class="louceng" :class="louceng_click_id == item2.id ? 'louceng-clicked' : '' "
+								<div :id="`louceng${index0}${index1}${index2}`" class="louceng"
+									:class="louceng_click_id == item2.id ? 'louceng-clicked' : '' "
 									@click="louceng_click($event, item2.id + '|' + item1.id + '|' + item0.id, item2.label + '|' + item1.label + '|'+ item0.label, item2.rooms)">
 									{{item2.label}}
 								</div>
@@ -52,7 +53,7 @@
 							<el-button type="primary" @click="add_room">新增房间</el-button>
 						</div>
 					</div>
-					<div class="cell-body">
+					<div class="cell-body" v-loading="listLoading">
 						<div class="cell-body-top-btns">
 							<el-button :class="btnActive == 'all' ? 'btn-active':'btn-no-active'" type="primary"
 								size="medium" round @click="top_btn_click('all')">全部</el-button>
@@ -402,7 +403,7 @@
 				</el-form-item>
 				<el-form-item label="楼层:" :label-width="formLabelWidth" prop="floor" :required="true">
 					<el-input v-model="form_add_louceng.floor" autocomplete="off" placeholder="请输入楼层名称"
-						ref="ref_louceng" maxlength="10"></el-input>
+						ref="ref_louceng" maxlength="3"></el-input>
 				</el-form-item>
 			</el-form>
 			<div slot="footer" class="dialog-footer">
@@ -569,9 +570,9 @@
 					return callback(new Error('请输入楼层名称'));
 				}
 				setTimeout(() => {
-					var reg = /^[1-9][楼|层]{1,3}$/
+					var reg = /^[1-9][0-9]?[楼]{1,3}$/
 					if (!reg.test(value)) {
-						callback(new Error('数字+楼或层,如:1楼 或者 1层'));
+						callback(new Error('1到2位数字+楼,不能0打头,如:1楼 或 99楼'));
 					} else {
 						callback();
 					}
@@ -802,13 +803,22 @@
 				delAir: {
 					deleteAirIp: '',
 					room: ''
-				}
-
+				},
+				navLoading: false, // 加载
+				listLoading: false
 			}
 		},
 		created() {
 			// 获取消费记录,表格数据
 			this.get_loudong_data()
+			// 默认选中第一个房间
+			let auto_click = setInterval(() => {
+				let louchen_first = document.getElementById("louceng000");
+				if (louchen_first !== null) {
+					louchen_first.click();
+					clearInterval(auto_click);
+				}
+			}, 200);
 		},
 		mounted() {
 			document.getElementsByClassName("el-pagination__jump")[0].childNodes[0].nodeValue = "跳至";
@@ -936,14 +946,16 @@
 			 * 获取楼栋信息
 			 */
 			get_loudong_data() {
+				this.navLoading = true;
+
 				getBuildingData().then((res) => {
 					// console.log(res);
 					if (typeof res.code == 'undefined' || res.code == '') {
-						this.$message.error('返回数据格式问题,code未获取到!')
-						return
+						this.$message.error('返回数据格式问题,code未获取到!');
+						return;
 					}
 					// 校区
-					let school = JSON.parse(res.data)
+					let school = JSON.parse(res.data);
 					// console.log('school', school);
 					if (typeof school !== 'undefined' && school !== '') {
 						this.navData = []
@@ -989,7 +1001,9 @@
 				}).catch((err) => {
 					// console.log(err);
 					this.$message.error(err.message)
-				})
+				});
+
+				this.navLoading = false;
 			},
 			/**
 			 * 获取房间数据
@@ -1136,6 +1150,7 @@
 			 * @param {Object} rooms
 			 */
 			louceng_click(e, id, label, rooms) {
+				this.listLoading = true
 				let ids = id.split('|')
 				let labels = label.split('|')
 				// console.log(ids);
@@ -1176,6 +1191,11 @@
 					.currentData.floor
 				// 赋值分页数据
 				this.pagination.total = rooms.length
+				// 最后一页删除后已经空了,则显示前一页
+				let size = Math.ceil(this.pagination.total / 4)
+				if (size != 0 && 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);
@@ -1183,6 +1203,7 @@
 				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
 			},
 			/**
 			 * 某层空调开启和异常统计
@@ -1633,6 +1654,7 @@
 			 * @param {Object} val
 			 */
 			currentPageChange(val) {
+				this.listLoading = true;
 				// console.log('当前页:' + val);
 				// 清理一下当前数据中的rooms
 				this.currentData.rooms = [{
@@ -1647,10 +1669,11 @@
 				}, {
 					room: '',
 					tableData: []
-				}]
-				this.pagination.currentPage = val
+				}];
+				this.pagination.currentPage = val;
 				this.roomDataPagination(this.pagination.currentPage, this.pagination.pageSize, this.currentData.allRooms,
-					this.currentData.school, this.currentData.building, this.currentData.floor)
+					this.currentData.school, this.currentData.building, this.currentData.floor);
+				this.listLoading = false;
 			},
 			/**
 			 * 设置表格单元格样式
@@ -1915,6 +1938,7 @@
 						}
 
 						.el-row {
+							height: 286px;
 
 							.el-col {
 

+ 75 - 7
src/views/systemSet/index.vue

@@ -29,6 +29,16 @@
 								<el-input v-model="formData.start_tiao" maxlength="2" placeholder="请输入金额"></el-input>
 								<span>元,不能开启空调</span>
 							</el-form-item>
+							<el-form-item prop="overtime">
+								<span>空调使用超过</span>
+								<el-input v-model="formData.overtime" maxlength="2" placeholder="请输入小时数"></el-input>
+								<span>小时预警</span>
+							</el-form-item>
+							<el-form-item prop="end_jian">
+								<span>开启空调后</span>
+								<el-input v-model="formData.end_jian" maxlength="2" placeholder="请输入秒数"></el-input>
+								<span>秒可以关闭</span>
+							</el-form-item>
 							<el-form-item prop="send_jian">
 								<span>每隔</span>
 								<el-input v-model="formData.send_jian" maxlength="2" placeholder="请输入小时数"></el-input>
@@ -37,7 +47,7 @@
 							<el-form-item prop="send_start">
 								<span>每天</span>
 								<el-time-picker :editable="false" v-model="formData.send_start" :picker-options="{
-										    start: '00:00',step: '00:01',end: '23:59'
+										    start: '00:00:00',step: '00:00:01',end: '23:59:59'
 									}" value-format="HH:mm:ss" placeholder="请输入时间" :clearable="false">
 								</el-time-picker>
 								<span>为截止时间,系统自动发送通知给操作员</span>
@@ -84,12 +94,40 @@
 				if (!value) {
 					return callback(new Error('不能为空'));
 				}
+				if (this.formData.send_jian == 0 && this.formData.send_start == '00:00:00') {
+					return callback(new Error('给操作员发信息,不能都为0!'));
+				}
 				setTimeout(() => {
-					var reg = /^(\d{1,})$/
+					var reg = /^[1-9]\d*|0$/
 					if (!reg.test(value)) {
-						callback(new Error('请输入整数值'));
-					} else if (value < 1 || value > 10) {
-						callback(new Error('范围在1-10'));
+						callback(new Error('请输入整数或0'));
+					} else if (value < 0 || value > 10) {
+						callback(new Error('范围在0-10'));
+					} else {
+						callback();
+					}
+				}, 100);
+			}
+			var checkStart = (rule, value, callback) => {
+				if (!value) {
+					return callback(new Error('不能为空'));
+				}
+				if (this.formData.send_jian == 0 && this.formData.send_start == '00:00:00') {
+					callback(new Error('给操作员发信息,不能都为0!'));
+				} else {
+					callback();
+				}
+			}
+			var checkSecond = (rule, value, callback) => {
+				if (!value) {
+					return callback(new Error('不能为空'));
+				}
+				setTimeout(() => {
+					var reg = /^[1-9]\d*|0$/
+					if (!reg.test(value)) {
+						callback(new Error('请输入整数或0'));
+					} else if (value < 8 || value > 59) {
+						callback(new Error('范围在8-59'));
 					} else {
 						callback();
 					}
@@ -108,6 +146,21 @@
 					}
 				}, 100);
 			}
+			var checkOverTime = (rule, value, callback) => {
+				if (!value) {
+					return callback(new Error('不能为空'));
+				}
+				setTimeout(() => {
+					var reg = /^[1-9]\d*$/
+					if (!reg.test(value)) {
+						callback(new Error('请输入整数或0'));
+					} else if (value < 2 || value > 12) {
+						callback(new Error('范围在2-12'));
+					} else {
+						callback();
+					}
+				}, 100);
+			}
 			return {
 				formData: {
 					noOne: '', // 半小时不足1小时
@@ -118,6 +171,8 @@
 					send_start: '',
 					phone: '',
 					state: 1,
+					end_jian: 12,
+					overtime: 6
 				},
 				currentPage: 1,
 				rows: 6,
@@ -135,8 +190,17 @@
 					send_jian: [{
 						validator: checkTime
 					}],
+					send_start: [{
+						validator: checkStart
+					}],
+					end_jian: [{
+						validator: checkSecond
+					}],
 					phone: [{
 						validator: checkPhone
+					}],
+					overtime: [{
+						validator: checkOverTime
 					}]
 				}
 			}
@@ -161,10 +225,12 @@
 					this.formData.one = r.one
 					this.formData.isauto = r.isauto == 1 ? true : false
 					this.formData.start_tiao = r.start_tiao
-					this.formData.send_jian = r.send_jian
+					this.formData.send_jian = r.send_jian + ''
 					this.formData.send_start = r.send_start
 					this.formData.phone = r.phone
 					this.formData.state = r.state
+					this.formData.end_jian = r.end_jian
+					this.formData.overtime = r.overtime
 				}).catch((err) => {
 					// console.log(err);
 					this.$message.error(err.message)
@@ -186,7 +252,9 @@
 							send_jian: this.formData.send_jian,
 							send_start: this.formData.send_start,
 							phone: this.formData.phone,
-							state: this.formData.state
+							state: this.formData.state,
+							end_jian: this.formData.end_jian,
+							overtime: this.formData.overtime
 						}
 						// 开始发送更新配置请求
 						updateSet(params).then((res) => {

+ 12 - 6
src/views/userMgr/index.vue

@@ -28,7 +28,7 @@
 							</el-form-item>
 						</el-form>
 						<el-table :data="tableData" height="510" style="width: 100%" :cell-style="cell_style"
-							:header-cell-style="header_cell_style">
+							v-loading="loading" :header-cell-style="header_cell_style">
 							<el-table-column label="序号" align="center" width="100">
 								<template slot-scope="scope">
 									<span>{{(pagination.currentPage - 1) * pagination.pageSize + scope.$index + 1}}</span>
@@ -71,8 +71,8 @@
 							</el-table-column>
 							<el-table-column label="操作" align="center">
 								<template slot-scope="scope">
-									<el-button size="mini" class="btn-table" @click="recharge(scope.$index, scope.row)">
-										充值</el-button>
+									<el-button v-if="currentUserLevel == 2" size="mini" class="btn-table"
+										@click="recharge(scope.$index, scope.row)">充值</el-button>
 								</template>
 							</el-table-column>
 						</el-table>
@@ -246,6 +246,8 @@
 				}, 100);
 			}
 			return {
+				// 当前用户的权限
+				currentUserLevel: this.$store.state.user.level,
 				// 弹出对话框数据
 				dialogChongzhiVisible: false,
 				form: {
@@ -317,7 +319,8 @@
 					color: '#1A202B',
 					'font-size': '18px',
 					'font-family': 'Microsoft YaHei-3970(82674968)'
-				}
+				},
+				loading: true
 			}
 		},
 		created() {
@@ -395,7 +398,7 @@
 
 					if (res.code == 200) {
 						this.$message.success('下载成功!')
-						let xls = 'http://demo.xwsyjjy.com' + res.downurl
+						let xls = 'https://chtech.ncjti.edu.cn/air-conditioner-control/' + res.downurl
 						window.open(xls)
 					} else {
 						this.$message.error(res.message)
@@ -500,6 +503,7 @@
 			 * 获取用户列表数据
 			 */
 			get_user_list(param) {
+				this.loading = true
 				let data = {
 					page: this.pagination.currentPage,
 					rows: this.pagination.pageSize
@@ -529,7 +533,9 @@
 				}).catch((err) => {
 					// console.log(err);
 					this.$message.error(err.message)
-				})
+				});
+				// loading结束
+				this.loading = false
 			},
 			/**
 			 * 查询