Sfoglia il codice sorgente

修改首页统计图请求数量 修改数据项查询日期格式

Zt 1 anno fa
parent
commit
9d0a4e3dfc

+ 25 - 21
reado-app/pages/homePage/index.vue

@@ -1,24 +1,26 @@
 <template>
 	<view>
-		<view v-if="echartsType==='pie'">
-			<view class="title" v-if="echartsData">
-				{{echartsData.chartName}}
+		<view v-for="item in echartsData" :key="item.id">
+			<view v-if="item.chartType==='pie'">
+				<view class="title" v-if="echartsData.length">
+					{{item.chartName}}
+				</view>
+				<pieEcharts :echartsData="item" />
 			</view>
-			<pieEcharts :echartsData="echartsData" />
-		</view>
-		<view v-if="echartsType==='bar'">
-			<view class="title" v-if="echartsData">
-				{{echartsData.chartName}}
+			<view v-if="item.chartType==='bar'">
+				<view class="title" v-if="echartsData.length">
+					{{item.chartName}}
+				</view>
+				<barEcharts :echartsData="item" />
 			</view>
-			<barEcharts :echartsData="echartsData" />
-		</view>
-		<view v-if="echartsType==='line'">
-			<view class="title" v-if="echartsData">
-				{{echartsData.chartName}}
+			<view v-if="item.chartType==='line'">
+				<view class="title" v-if="echartsData.length">
+					{{item.chartName}}
+				</view>
+				<lineEcharts :echartsData="item" />
 			</view>
-			<lineEcharts :echartsData="echartsData" v-if="echartsData" />
 		</view>
-		<u-empty text="暂无数据" icon="../../static/data.png" v-if="!echartsData"></u-empty>
+		<u-empty text="暂无数据" icon="../../static/data.png" v-if="!echartsData.length"></u-empty>
 	</view>
 </template>
 
@@ -39,9 +41,7 @@
 					limit: 999
 				},
 				//图表数据
-				echartsData: null,
-				//图表类型
-				echartsType: null
+				echartsData: []
 			}
 		},
 		onShow() {
@@ -53,7 +53,12 @@
 				uni.$http.get('/chart/getAllOkChart', this.queryParams).then(res => {
 					const data = res.data
 					if (data.code === 200) {
-						this.getChartData(data.data.reportTableList[0].id)
+						const {
+							reportTableList
+						} = data.data
+						reportTableList.map(item => {
+							this.getChartData(item.id)
+						})
 					}
 				})
 			},
@@ -63,8 +68,7 @@
 				}).then(res => {
 					const data = res.data
 					if (data.code === 200) {
-						this.echartsData = data.data
-						this.echartsType = data.data.chartType
+						this.echartsData.push(data.data)
 					}
 				})
 			}

+ 33 - 20
reado-app/pages/reportForm/data-item.vue

@@ -21,8 +21,8 @@
 						{{item.name}}
 					</view>
 				</view>
-				<uni-datetime-picker v-model="range" type="daterange" start-placeholder="起始时间" end-placeholder="终止时间"
-					@change="handelDate" return-type="timestamp" />
+				<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>
@@ -88,6 +88,28 @@
 				dataItem: []
 			}
 		},
+		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()
@@ -100,24 +122,12 @@
 			// 切换时间
 			monthChange(current) {
 				this.monthCurrent = current
-				switch (current) {
-					case 1:
-						this.range = getLastMonth()
-						break;
-					case 2:
-						this.range = getLast3Month()
-						break;
-					case 3:
-						this.range = getLast6Month()
-						break;
-					default:
-						this.range = getLastWeek()
-						break;
-				}
 			},
 			//获取当前登录人所有数据组
 			getUserData() {
-				uni.$http.get('/itemGroup/getAllItemGroup').then(res => {
+				uni.$http.get('/itemGroup/getAllItemGroup', {
+					readMode: 0
+				}).then(res => {
 					const data = res.data
 					if (data.code === 200) {
 						this.datasList = data.data.map(item => {
@@ -131,7 +141,10 @@
 			},
 			//通过id获取数据组
 			getDataListById(id) {
-				uni.$http.get('/itemGroup/getItemGroupById/' + id).then(res => {
+				uni.$http.get('/itemGroup/getItemGroupById', {
+					id: id,
+					itemType: 1
+				}).then(res => {
 					const data = res.data
 					if (data.code === 200) {
 						this.dataItem = data.data.itemList.map(item => {
@@ -153,8 +166,8 @@
 				timestr += ':'
 				timestr += date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds()
 				// 临时当前时间,需要改成选择时间----结束
-				this.queryParams.startTime = this.resolvingDate2(this.range[0]) + ' ' + timestr
-				this.queryParams.endTime = this.resolvingDate2(this.range[1]) + ' ' + timestr
+				// this.queryParams.startTime = this.resolvingDate2(this.range[0]) + ' ' + timestr
+				// this.queryParams.endTime = this.resolvingDate2(this.range[1]) + ' ' + timestr
 				uni.$http.get('/itemGroup/itemDataQuery', this.queryParams).then(res => {
 					const data = res.data
 					if (data.code === 200) {

+ 8 - 0
reado-app/utils/date.js

@@ -26,6 +26,8 @@ export function getLastWeek() {
 	} else {
 		dateObj[0] = year + '-' + month + '-' + (day - 7);
 	}
+	dateObj[0] = Date.parse(dateObj[0] += ' 00:00:00')
+	dateObj[1] = Date.parse(dateObj[1] += ' 00:00:00')
 	return dateObj;
 }
 
@@ -62,6 +64,8 @@ export function getLastMonth() {
 			}
 		}
 	}
+	dateObj[0] = Date.parse(dateObj[0] += ' 00:00:00')
+	dateObj[1] = Date.parse(dateObj[1] += ' 00:00:00')
 	return dateObj;
 }
 
@@ -103,6 +107,8 @@ export function getLast3Month() {
 			}
 		}
 	}
+	dateObj[0] = Date.parse(dateObj[0] += ' 00:00:00')
+	dateObj[1] = Date.parse(dateObj[1] += ' 00:00:00')
 	return dateObj;
 }
 
@@ -144,5 +150,7 @@ export function getLast6Month() {
 			}
 		}
 	}
+	dateObj[0] = Date.parse(dateObj[0] += ' 00:00:00')
+	dateObj[1] = Date.parse(dateObj[1] += ' 00:00:00')
 	return dateObj;
 }