Selaa lähdekoodia

修改曹莉提交的bug

lry 5 kuukautta sitten
vanhempi
commit
1b6ed17355

+ 43 - 3
reado-app/App.vue

@@ -2,9 +2,13 @@
 	import {
 		getToken
 	} from './utils/auth.js'
+	import {
+		getDayTime,
+		timeToDate
+	} from '@/utils/date.js'
 	export default {
 		onLaunch: function() {
-			console.log('App Launch')
+			//console.log('App Launch')
 			const token = getToken()
 			if (token) {
 				// #ifdef APP-PLUS
@@ -28,12 +32,48 @@
 					}
 				})
 			}
+			//定时器获得用户的报警信息
+			setInterval(function(){
+				let dDate = getDayTime();
+				let queryParams={
+					startDate:'',
+					endDate:''
+				}
+				queryParams.startDate = timeToDate(dDate[0])
+				queryParams.endDate = timeToDate(dDate[1])
+				uni.$http.get('/mobileAlarm/loadAllAlarmData', queryParams).then(res => {
+					const data = res.data
+					if (data.code === 200) {
+						console.log(data)
+					}
+				})
+			},60000)
+			//定时器获取未读报警数量
+			setInterval(function(){
+				uni.$http.get('/mobileAlarm/getNotReadAlarmUserLogCount').then(res => {
+					const data = res.data
+					if (data.code === 200) {
+						if(data.data.notReadCount>0){
+							uni.setTabBarBadge({
+								index:2,
+								text:data.data.notReadCount + ''
+							})
+						}else{
+							uni.removeTabBarBadge({
+								index:2
+							})
+						}
+						
+					}
+				})
+			},5000)
 		},
 		onShow: function() {
-			console.log('App Show')
+			//console.log('App Show')
+			
 		},
 		onHide: function() {
-			console.log('App Hide')
+			//console.log('App Hide')
 		}
 	}
 </script>

+ 23 - 0
reado-app/components/cycharts/cyChart.vue

@@ -543,4 +543,27 @@
 		font-weight: bold;
 		color: #606266;
 	}
+	
+	.uni-table-td {
+	    display: table-cell;
+	    padding: 8px 10px;
+	    font-size: 14px;
+	    border-bottom: 1px #0a48d9 solid;
+		border-right: 1px #0a48d9 solid;
+	    font-weight: 400;
+	    color: #606266;
+	    line-height: 23px;
+	    box-sizing: border-box;
+	}
+	.uni-table-th {
+	    padding: 12px 10px;
+	    display: table-cell;
+	    box-sizing: border-box;
+	    font-size: 14px;
+	    font-weight: bold;
+	    color: #909399;
+		border-top: 1px #0a48d9 solid;
+		border-right: 1px #0a48d9 solid;
+	    border-bottom: 1px #0a48d9 solid;
+	}
 </style>

+ 35 - 15
reado-app/pages/message/index.vue

@@ -11,14 +11,14 @@
 							</view>
 					</view>
 					<view class="msg-row">
-						<image src="@/static/image/bj3.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
+						<image src="@/static/image/bj4.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
 							alt="">
 							<view class="msg-content">
 								类型 :{{item.alarmType}}
 							</view>
 					</view>
 					<view class="msg-row">
-						<image src="@/static/image/bj4.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
+						<image src="@/static/image/bj3.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
 							alt="">
 							<view class="msg-content">
 								时间 :{{item.alarmTime}}
@@ -31,6 +31,13 @@
 								报警描述 :<text style="font-weight: normal;">{{item.alarmText}}</text>
 							</view>
 					</view>
+					<view class="msg-row" v-if="item.itemId!=0">
+						<image src="@/static/image/bj5.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
+							alt="">
+							<view class="msg-content">
+								报警值 :<text style="font-weight: normal;">{{item.alarmValue}}</text>
+							</view>
+					</view>
 					<view class="msg-row">
 						<u-button type="primary" size="small" class="cl" @click="handleMsg(item)">查看详情</u-button>
 					</view>
@@ -104,39 +111,52 @@
 					limit: 20
 				},
 				// 列表数据
-				msgList: []
+				msgList: [],
+				isload:false,
+				pageCounts:0,
 			};
 		},
 		onShow() {
 			this.queryParams.limit = 20
-			this.getMsgList()
+			//this.loadAllAlarmData()
+			this.getMsgList(true)
 			uni.pageScrollTo({
 				scrollTop: 0,
 				duration: 0
 			})
 		},
 		onPullDownRefresh() {
-			this.queryParams.limit = 20
-			this.getMsgList()
+			//console.log('onPullDownRefresh')
+			this.queryParams.page = 1
+			this.getMsgList(true)
 		},
 		onReachBottom() {
-			this.queryParams.limit += 10
-			this.getMsgList()
+			//console.log('onReachBottom')
+			if(this.queryParams.page > this.pageCounts){
+				this.isload = true
+			}else{
+				this.queryParams.page = this.queryParams.page + 1
+				this.getMsgList(false)
+				this.isload = false
+			}
 		},
 		methods: {
 			// 获取消息数据
-			getMsgList() {
+			getMsgList(isCover) {
 				if((this.queryParams.startDate==null) || (this.queryParams.endDate==null)){
 					let dDate = getDayTime();
-					
 					this.queryParams.startDate = timeToDate(dDate[0])
 					this.queryParams.endDate = timeToDate(dDate[1])
 				}
-				console.log(this.queryForm)
-				uni.$http.get('/mobileAlarm/queryAllAlarmData', this.queryParams).then(res => {
+				uni.$http.get('/mobileAlarm/queryUserAlarmData', this.queryParams).then(res => {
 					const data = res.data
 					if (data.code === 200) {
-						this.msgList = data.data
+						this.pageCounts = data.data.count / this.queryForm.limit
+						if(isCover){
+							this.msgList = data.data.userAlarmLogList
+						}else{
+							this.msgList = this.msgList.concat(data.data.userAlarmLogList)
+						}
 						uni.stopPullDownRefresh()
 					}
 				})
@@ -190,9 +210,9 @@
 			//确认按钮查询
 			handelQuery() {
 				//如果没有选择时间,默认当天的起止时间
-				
+				this.queryParams.page = 1
 				this.queryForm = false;
-				this.getMsgList();
+				this.getMsgList(true);
 			},
 		}
 	}

+ 3 - 1
reado-app/pages/message/msg-detail/index.vue

@@ -23,7 +23,7 @@
 					<view class="title">{{data.alarmText}}</view>
 				</view>
 				<view>
-					<u-button type="primary" size="small" class="cl" @click="queryChart" v-if="data.itemId>0" >查看点位实时曲线</u-button>
+					<u-button type="primary" size="small" class="cl" @click="queryChart" v-if="data.itemId>0 && showbtn" >查看点位实时曲线</u-button>
 				</view>
 				<view v-if="showChart">
 					<web-view :src="src" style="top:300px;width:100%;height: 500px;"></web-view>
@@ -51,6 +51,7 @@
 				src:'',
 				dataStr: null,
 				showChart:false,
+				showbtn:true,
 				data:{
 					
 				}
@@ -75,6 +76,7 @@
 				this.src =
 					`/static/webview/datachart-wv.html?idList=${id_List}&startTime=${startTime}&endTime=${endTime}`
 				this.showChart = true
+				this.showbtn = false
 			},
 		}
 	}

+ 432 - 0
reado-app/pages/reportForm/data-item - 副本.vue

@@ -0,0 +1,432 @@
+<template>
+	<view class="data">
+		<view class="data-screen" @click="openScreen" style="padding-right:40rpx">
+			<image class="screen-img" src="@/static/image/sx.png" alt="">
+				<text>筛选</text>
+		</view>
+		<view class="echarts">
+			<view v-if="monthQuery" class="query-screen">
+				<view>
+					数据组
+				</view>
+				<div style="margin: 20px 0;">
+					<uni-data-select v-model="dataValue" :localdata="datasList" @change="dataValueChange"
+						placeholder="请选择数据组"
+						style="placeholder-style: font-size: 16px; color: #909399;"></uni-data-select>
+				</div>
+				<view>
+					点位
+				</view>
+				<zqs-select :list="dataItem" :multiple="true" label-key="label" value-key="value"
+					v-model="queryParams.idList" @search="searchItem" @confirm="confirmItem" clearable
+					placeholder="请选择点位" title="选择点位">
+
+				</zqs-select>
+				<view class="month">
+					<view :class="monthCurrent===item.current?'month-select':'month-item'" v-for="item in monthList"
+						:key="item.current" @click="monthChange(item.current)">
+						{{item.name}}
+					</view>
+				</view>
+				<uni-datetime-picker v-model="range" type="datetimerange" start-placeholder="起始时间"
+					end-placeholder="终止时间" @change="handelDate" return-type="timestamp" />
+				<view class="month-btn">
+					<u-button class="reset" style="width:200rpx" @click="reset">重置</u-button>
+					<u-button type="primary" style="width:200rpx" @click="handelQuery">确认</u-button>
+				</view>
+			</view>
+			<view class="modal" v-if="monthQuery"></view>
+			<u-empty v-if="!service.length" class="empty" icon="../../static/data.png" text="暂无数据">
+			</u-empty>
+		</view>
+	
+			<!-- #ifdef H5 -->
+			<web-view v-if="service.length" :src="src" style="border: none;width:100%;height:900px;"
+				:fullscreen="false">
+			</web-view>
+			<!--  #endif -->
+		
+
+	</view>
+</template>
+
+<script>
+	import zqsSelectVue from '../../components/zqs-select/zqs-select.vue'
+	import {
+		getLastWeek,
+		getLastMonth,
+		getLast3Month,
+		getLast6Month
+	} from '@/utils/date.js'
+	var wv;
+	export default {
+		components: {
+			zqsSelectVue
+		},
+		data() {
+			return {
+				webviewStyles: {
+					progress: {
+						color: '#FF3333'
+					}
+				},
+				// 查询参数
+				queryParams: {
+					idList: [],
+					startTime: null,
+					endTime: null,
+				},
+				// 日期选择
+				range: [],
+				// 时间选择
+				monthList: [{
+						name: '近一周',
+						current: 0
+					},
+					{
+						name: '近1个月',
+						current: 1
+					},
+					{
+						name: '近3个月',
+						current: 2
+					},
+					{
+						name: '近6个月',
+						current: 3
+					}
+				],
+				monthCurrent: 0,
+				monthQuery: false,
+				// 图表数据
+				service: [],
+				serviceTime: [],
+				// 数据组数据
+				datasList: [],
+				dataValue: null,
+				// 数据项数据
+				dataItem: [],
+				dataItem_Save: [],
+				selItem: [],
+				itemReadName: null,
+				src: '',
+				windowInfo: null
+			}
+		},
+		watch: {
+			monthCurrent: {
+				handler(val) {
+					switch (val) {
+						case 1:
+							this.range = getLastMonth()
+							break;
+						case 2:
+							this.range = getLast3Month()
+							break;
+						case 3:
+							this.range = getLast6Month()
+							break;
+						default:
+							this.range = getLastWeek()
+							break;
+					}
+					this.handelDate(this.range)
+				},
+				immediate: true
+			}
+		},
+		mounted() {
+			this.getUserData()
+			this.range = getLastWeek()
+			// this.src =
+			// 	`/static/webview/dataItem-wv.html?idList=[19366]&startTime=2024-10-24 15:00:00&endTime=2024-10-24 23:59:59`
+			uni.getSystemInfo({
+				success: (res) => {
+					this.windowInfo = res;
+					//this.createWvAndLoadUrl(this.src);
+				}
+			});
+		},
+		beforeDestroy() {
+			//关闭webview对象
+			if (wv) {
+				wv.close()
+			}
+		},
+		methods: {
+			createWvAndLoadUrl(url) {
+				// #ifdef APP-PLUS
+				wv = plus.webview.create(url, "webview", {
+					top: this.windowInfo.statusBarHeight + 150,
+					scalable: true,
+					height: this.windowInfo.windowHeight - this.windowInfo.statusBarHeight - 96
+				})
+				// console.log('--------------------------------------------')
+				// console.log(this.$parent.toJSON())
+				// console.log('--------------------------------------------')
+				var currentWebview = this.$parent.$scope.$getAppWebview();
+				currentWebview.append(wv);
+				setTimeout(function() {
+					console.log(wv.getStyle())
+				}, 1000);
+				// #endif 
+			},
+			// 打开筛选
+			openScreen() {
+				this.monthQuery = !this.monthQuery
+			},
+			// 切换时间
+			monthChange(current) {
+				this.monthCurrent = current
+			},
+			//点位搜索
+			searchItem(val) {
+				//模糊搜索
+				const regex = new RegExp(val, "i");
+				this.dataItem = this.dataItem_Save.filter(item => regex.test(item.label));
+			},
+			//确认点位
+			confirmItem(val) {
+				//console.log(val)
+				//console.log(this.selItem)
+			},
+			//获取当前登录人所有数据组
+			getUserData() {
+				uni.$http.get('/itemGroup/getAllItemGroup', {
+					page: 1,
+					limit: 9999
+				}).then(res => {
+					const data = res.data
+					if (data.code === 200) {
+						console.log(data)
+						this.datasList = data.data.itemGroupList.map(item => {
+							return {
+								text: item.groupName,
+								value: item.id
+							}
+						})
+					} else {
+
+					}
+				})
+			},
+			//通过id获取数据组
+			getDataListById(id) {
+				uni.$http.get('/itemGroup/getItemGroupById', {
+					id: id,
+				}).then(res => {
+					const data = res.data
+					if (data.code === 200) {
+						this.dataItem = data.data.itemList.map(item => {
+							return {
+								label: item.modbusConfig ? item.itemName : item.itemReadName,
+								value: item.id
+							}
+						});
+						this.dataItem_Save = this.dataItem
+					}
+				})
+			},
+			//确认按钮查询
+			handelQuery() {
+				// 临时当前时间,需要改成选择时间----开始
+				var date = new Date()
+				var timestr = date.getHours() < 10 ? ('0' + date.getHours()) : date.getHours()
+				timestr += ':'
+				timestr += date.getMinutes() < 10 ? ('0' + date.getMinutes()) : date.getMinutes()
+				timestr += ':'
+				timestr += date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds()
+				// 临时当前时间,需要改成选择时间----结束
+				//console.log(this.queryParams.idList)
+				if (this.queryParams.idList.length == 0) {
+					uni.showToast({
+						title: '请选择点位',
+						duration: 2000,
+						icon: "error"
+					});
+					return;
+				} else if (this.queryParams.idList.length > 6) {
+					uni.showToast({
+						title: '只能选择6个点位',
+						duration: 2000,
+						icon: "error"
+					});
+					return;
+				}
+				uni.$http.get('/itemGroup/getItemListValue', this.queryParams).then(res => {
+					const data = res.data
+					if (data.code === 200) {
+						const {
+							idList,
+							startTime,
+							endTime
+						} = this.queryParams
+						//console.log(JSON.stringify(idList))
+						let id_List = idList.map(temp=>temp).join(',');
+						this.src =
+							`/static/webview/dataItem-wv.html?idList=${id_List}&startTime=${startTime}&endTime=${endTime}`
+						this.createWvAndLoadUrl(this.src);
+						if (data.data) {
+							const {
+								valueList,
+								valueTimeList
+							} = data.data
+							const service = [{
+								// name: this.itemName,
+								name: this.itemReadName,
+								data: valueList
+							}]
+							this.service = service
+							this.serviceTime = valueTimeList
+						} else {
+							this.service = []
+							this.serviceTime = []
+						}
+					} else {
+						uni.showToast({
+							title: data.msg,
+							duration: 2000,
+							icon: "error"
+						});
+					}
+				})
+				this.monthQuery = false
+			},
+			//选择日期
+			handelDate(date) {
+				this.queryParams.startTime = this.resolvingDate(date[0])
+				this.queryParams.endTime = this.resolvingDate(date[1])
+			},
+			resolvingDate(date) {
+				if (!date) {
+					return;
+				}
+				//date是传入的时间
+				let d = new Date(date);
+
+				let month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1);
+				let day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate();
+				let hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours();
+				let min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes();
+				let sec = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds();
+
+				let times;
+				times = d.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + sec;
+				return times
+			},
+			//重置按钮
+			reset() {
+				this.queryParams = {
+					idList: null,
+					startTime: null,
+					endTime: null,
+				}
+				this.dataValue = null
+				this.monthCurrent = 0
+				this.monthQuery = false
+			},
+			//选择数据组
+			dataValueChange(val) {
+				this.getDataListById(val)
+			},
+			itemChange(val) {
+				const item = this.dataItem.find(item => {
+					return item.value === val
+				})
+				this.itemReadName = item.text
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	
+	iframe {
+		border: none;
+	}
+	.webviewstyle {
+		height: 100%;
+		width: 100%;
+		top: 400px;
+		border: none;
+	}
+
+	.webview_style>uni-web-view>iframe {
+		border: none;
+	}
+
+	.data {
+		margin-top: 40rpx;
+		height: 50vh;
+
+		.data-screen {
+			text-align: right;
+
+			.screen-img {
+				width: 40rpx;
+				height: 40rpx;
+			}
+		}
+	}
+
+	.uni-select__input-placeholder {
+		font-size: 14px;
+		color: red;
+	}
+
+	.echarts {
+		position: relative;
+
+		.query-screen {
+			width: 96vw;
+			padding: 0 20rpx;
+			background: #ffffff;
+			position: absolute;
+			top: 0;
+			z-index: 999;
+
+			.month {
+				display: flex;
+				justify-content: space-between;
+				align-items: center;
+				font-size: 28rpx;
+				margin: 40rpx 0;
+
+				.month-item {
+					padding: 10rpx 20rpx;
+					background: #ECECEC;
+					color: #000000;
+					border-radius: 12rpx;
+				}
+
+				.month-select {
+					padding: 10rpx 20rpx;
+					border-radius: 12rpx;
+					background: #289BFF;
+					color: #ffffff;
+				}
+			}
+
+			.month-btn {
+				display: flex;
+				justify-content: space-around;
+				margin-top: 40rpx;
+				margin-bottom: 40rpx;
+
+				.reset {
+					background: #EAF4FF;
+					color: #469DED;
+					border: 1px solid #A3B8CB;
+				}
+			}
+		}
+	}
+
+	.modal {
+		width: 100%;
+		height: 76vh;
+		background: rgba(0, 0, 0, 0.5);
+		position: absolute;
+		top: 0;
+	}
+</style>

+ 7 - 8
reado-app/pages/reportForm/report-query.vue

@@ -2,11 +2,12 @@
 	<view class="query-box">
 		<view class="query">
 			<u-search placeholder="请输入报表名称" v-model="queryParams.reportTableName" :show-action="false" shape="square"
-				clearabled @search="search" @clear="clear" search-icon="../../static/image/search.png">
+				clearabled @search="search" @clear="clear" search-icon="../../static/image/search.png" 
+				>
 			</u-search>
 			<view class="screen" @click="search">
-				<image class="screen-img" src="@/static/image/sx.png" alt="">
-					<view>筛选</view>
+				<image class="screen-img" src="@/static/image/sx.png" alt="" style="width: 20px;height: 20px;">
+				<text>筛选</text>
 			</view>
 		</view>
 		<view class="list-box">
@@ -166,17 +167,15 @@
 			padding: 0 40rpx;
 			display: flex;
 			justify-content: space-around;
+			/* flex-direction: row; */
 			align-items: center;
-
-
 			.screen {
 				display: flex;
 				align-items: center;
 				margin-left: 30rpx;
-
 				.screen-img {
-					width: 40rpx;
-					height: 40rpx;
+					width: 40px;
+					height: 40px;
 				}
 			}
 		}

BIN
reado-app/static/image/bj1.png


BIN
reado-app/static/image/bj2.png


BIN
reado-app/static/image/bj3.png


BIN
reado-app/static/image/bj4.png


BIN
reado-app/static/image/bj5.png


+ 2 - 0
reado-app/static/webview/datachart-wv.html

@@ -140,8 +140,10 @@
 								let	valueList=[],valueTimeList=[];
 								if(res.data.length>0){
 									valueTimeList = res.data[0].dataTimeList;
+									valueTimeList = valueTimeList.map(v=>v.substring(0,19))
 									let service=[]
 									for(let dataList of res.data){
+										dataList.dataValueList = dataList.dataValueList.map(v=>v.substring(0,v.indexOf(".") + 3))
 										let seriesData = {
 											type:'line',
 											name:dataList.describe!=null ? dataList.describe:dataList.itemReadName,