浏览代码

修改设备列表为分页查询

soobin 2 年之前
父节点
当前提交
831404df07
共有 3 个文件被更改,包括 248 次插入211 次删除
  1. 205 205
      pages/Charts/equipmentStatistics.vue
  2. 21 2
      pages/User/equipmentStatusList.vue
  3. 22 4
      pages/User/merchantList.vue

+ 205 - 205
pages/Charts/equipmentStatistics.vue

@@ -341,7 +341,7 @@
 		},
 
 		methods: {
-			...mapActions('chart', ['getProvince', 'getProvinceAll', 'getEquipmentStatistics', 'getMainStatistics',
+			...mapActions('chart', ['getEquipmentStatistics', 'getMainStatistics',
 				'getMachineNum'
 			]),
 			async init() {
@@ -432,46 +432,46 @@
 
 				return this.getStatisticsData(chartType);
 			},
-			initDateRang2(day, chartType) {
-				const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
-				if (chartType === 'day') {
-					this.startDate5 = dateUtils.formateDate(day, 'yyyy/MM/dd');
-				}
-				if (chartType === 'week') {
-					this.startDate6 = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
-					this.endDate6 = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
-				}
-				if (chartType === 'month') {
-					this.startDate7 = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
-					this.endDate7 = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
-				}
-				if (chartType === 'year') {
-					this.startDate8 = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
-					this.endDate8 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
-				}
+			// initDateRang2(day, chartType) {
+			// 	const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
+			// 	if (chartType === 'day') {
+			// 		this.startDate5 = dateUtils.formateDate(day, 'yyyy/MM/dd');
+			// 	}
+			// 	if (chartType === 'week') {
+			// 		this.startDate6 = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
+			// 		this.endDate6 = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
+			// 	}
+			// 	if (chartType === 'month') {
+			// 		this.startDate7 = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
+			// 		this.endDate7 = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
+			// 	}
+			// 	if (chartType === 'year') {
+			// 		this.startDate8 = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
+			// 		this.endDate8 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
+			// 	}
 
-				return this.getProvinceData(chartType);
-			},
-			initDateRang3(day, chartType) {
-				const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
-				if (chartType === 'day') {
-					this.startDate9 = dateUtils.formateDate(day, 'yyyy/MM/dd');
-				}
-				if (chartType === 'week') {
-					this.startDate10 = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
-					this.endDate10 = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
-				}
-				if (chartType === 'month') {
-					this.startDate11 = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
-					this.endDate11 = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
-				}
-				if (chartType === 'year') {
-					this.startDate12 = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
-					this.endDate12 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
-				}
+			// 	return this.getProvinceData(chartType);
+			// },
+			// initDateRang3(day, chartType) {
+			// 	const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
+			// 	if (chartType === 'day') {
+			// 		this.startDate9 = dateUtils.formateDate(day, 'yyyy/MM/dd');
+			// 	}
+			// 	if (chartType === 'week') {
+			// 		this.startDate10 = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
+			// 		this.endDate10 = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
+			// 	}
+			// 	if (chartType === 'month') {
+			// 		this.startDate11 = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
+			// 		this.endDate11 = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
+			// 	}
+			// 	if (chartType === 'year') {
+			// 		this.startDate12 = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
+			// 		this.endDate12 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
+			// 	}
 
-				return this.getProvinceAllData(chartType);
-			},
+			// 	return this.getProvinceAllData(chartType);
+			// },
 			/**上一个 */
 			pre(chartType) {
 				let day;
@@ -691,177 +691,177 @@
 						}
 					});
 			},
-			getProvinceData(chartType) {
-				const param = {
-					'chartType': chartType
-				};
-				if (chartType == 'day') {
-					param['startDate'] = this.startDate5;
-					param['endDate'] = this.startDate5;
-				}
-				if (chartType == 'week') {
-					param['startDate'] = this.startDate6;
-					param['endDate'] = this.endDate6;
-				}
-				if (chartType == 'month') {
-					param['startDate'] = this.startDate7;
-					param['endDate'] = this.endDate7;
-				}
-				if (chartType == 'year') {
-					param['startDate'] = this.startDate8;
-					param['endDate'] = this.endDate8;
-				}
-				if (this.adminId) { // 子组件,则拿传过来的参
-					param['adminId'] = this.adminId;
-				} else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
-					param['adminId'] = this.loginUser['id'];
-				}
-				if (this.equipmentId) {
-					param['equipmentId'] = this.equipmentId;
-				}
+			// getProvinceData(chartType) {
+			// 	const param = {
+			// 		'chartType': chartType
+			// 	};
+			// 	if (chartType == 'day') {
+			// 		param['startDate'] = this.startDate5;
+			// 		param['endDate'] = this.startDate5;
+			// 	}
+			// 	if (chartType == 'week') {
+			// 		param['startDate'] = this.startDate6;
+			// 		param['endDate'] = this.endDate6;
+			// 	}
+			// 	if (chartType == 'month') {
+			// 		param['startDate'] = this.startDate7;
+			// 		param['endDate'] = this.endDate7;
+			// 	}
+			// 	if (chartType == 'year') {
+			// 		param['startDate'] = this.startDate8;
+			// 		param['endDate'] = this.endDate8;
+			// 	}
+			// 	if (this.adminId) { // 子组件,则拿传过来的参
+			// 		param['adminId'] = this.adminId;
+			// 	} else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
+			// 		param['adminId'] = this.loginUser['id'];
+			// 	}
+			// 	if (this.equipmentId) {
+			// 		param['equipmentId'] = this.equipmentId;
+			// 	}
 
-				return this.getProvince(param)
-					.then(data => {
-						uni.stopPullDownRefresh();
-						if (param['chartType'] == 'day') {
-							canvaColumn5 = this.initChart2('canvaColumn5', data);
-						}
-						if (param['chartType'] == 'week') {
-							canvaColumn6 = this.initChart2('canvaColumn6', data);
-						}
-						if (param['chartType'] == 'month') {
-							canvaColumn7 = this.initChart2('canvaColumn7', data);
-						}
-						if (param['chartType'] == 'year') {
-							canvaColumn8 = this.initChart2('canvaColumn8', data);
-						}
+			// 	return this.getProvince(param)
+			// 		.then(data => {
+			// 			uni.stopPullDownRefresh();
+			// 			if (param['chartType'] == 'day') {
+			// 				canvaColumn5 = this.initChart2('canvaColumn5', data);
+			// 			}
+			// 			if (param['chartType'] == 'week') {
+			// 				canvaColumn6 = this.initChart2('canvaColumn6', data);
+			// 			}
+			// 			if (param['chartType'] == 'month') {
+			// 				canvaColumn7 = this.initChart2('canvaColumn7', data);
+			// 			}
+			// 			if (param['chartType'] == 'year') {
+			// 				canvaColumn8 = this.initChart2('canvaColumn8', data);
+			// 			}
 
-					}, _ => {
-						uni.stopPullDownRefresh();
-						if (param['chartType'] == 'day') {
-							canvaColumn5 = this.initChart2('canvaColumn5', {
-								categories: ['暂无数据'],
-								series: [{
-									name: '平均销售额',
-									data: [0]
-								}]
-							});
-						}
-						if (param['chartType'] == 'week') {
-							canvaColumn6 = this.initChart2('canvaColumn6', {
-								categories: ['暂无数据'],
-								series: [{
-									name: '平均销售额',
-									data: [0]
-								}]
-							});
-						}
-						if (param['chartType'] == 'month') {
-							canvaColumn7 = this.initChart2('canvaColumn7', {
-								categories: ['暂无数据'],
-								series: [{
-									name: '平均销售额',
-									data: [0]
-								}]
-							});
-						}
-						if (param['chartType'] == 'year') {
-							canvaColumn8 = this.initChart2('canvaColumn8', {
-								categories: ['暂无数据'],
-								series: [{
-									name: '平均销售额',
-									data: [0]
-								}]
-							});
-						}
-					});
-			},
+			// 		}, _ => {
+			// 			uni.stopPullDownRefresh();
+			// 			if (param['chartType'] == 'day') {
+			// 				canvaColumn5 = this.initChart2('canvaColumn5', {
+			// 					categories: ['暂无数据'],
+			// 					series: [{
+			// 						name: '平均销售额',
+			// 						data: [0]
+			// 					}]
+			// 				});
+			// 			}
+			// 			if (param['chartType'] == 'week') {
+			// 				canvaColumn6 = this.initChart2('canvaColumn6', {
+			// 					categories: ['暂无数据'],
+			// 					series: [{
+			// 						name: '平均销售额',
+			// 						data: [0]
+			// 					}]
+			// 				});
+			// 			}
+			// 			if (param['chartType'] == 'month') {
+			// 				canvaColumn7 = this.initChart2('canvaColumn7', {
+			// 					categories: ['暂无数据'],
+			// 					series: [{
+			// 						name: '平均销售额',
+			// 						data: [0]
+			// 					}]
+			// 				});
+			// 			}
+			// 			if (param['chartType'] == 'year') {
+			// 				canvaColumn8 = this.initChart2('canvaColumn8', {
+			// 					categories: ['暂无数据'],
+			// 					series: [{
+			// 						name: '平均销售额',
+			// 						data: [0]
+			// 					}]
+			// 				});
+			// 			}
+			// 		});
+			// },
 
-			getProvinceAllData(chartType) {
-				const param = {
-					'chartType': chartType
-				};
-				if (chartType == 'day') {
-					param['startDate'] = this.startDate9;
-					param['endDate'] = this.startDate9;
-				}
-				if (chartType == 'week') {
-					param['startDate'] = this.startDate10;
-					param['endDate'] = this.endDate10;
-				}
-				if (chartType == 'month') {
-					param['startDate'] = this.startDate11;
-					param['endDate'] = this.endDate11;
-				}
-				if (chartType == 'year') {
-					param['startDate'] = this.startDate12;
-					param['endDate'] = this.endDate12;
-				}
-				if (this.adminId) { // 子组件,则拿传过来的参
-					param['adminId'] = this.adminId;
-				} else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
-					param['adminId'] = this.loginUser['id'];
-				}
-				if (this.equipmentId) {
-					param['equipmentId'] = this.equipmentId;
-				}
+			// getProvinceAllData(chartType) {
+			// 	const param = {
+			// 		'chartType': chartType
+			// 	};
+			// 	if (chartType == 'day') {
+			// 		param['startDate'] = this.startDate9;
+			// 		param['endDate'] = this.startDate9;
+			// 	}
+			// 	if (chartType == 'week') {
+			// 		param['startDate'] = this.startDate10;
+			// 		param['endDate'] = this.endDate10;
+			// 	}
+			// 	if (chartType == 'month') {
+			// 		param['startDate'] = this.startDate11;
+			// 		param['endDate'] = this.endDate11;
+			// 	}
+			// 	if (chartType == 'year') {
+			// 		param['startDate'] = this.startDate12;
+			// 		param['endDate'] = this.endDate12;
+			// 	}
+			// 	if (this.adminId) { // 子组件,则拿传过来的参
+			// 		param['adminId'] = this.adminId;
+			// 	} else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
+			// 		param['adminId'] = this.loginUser['id'];
+			// 	}
+			// 	if (this.equipmentId) {
+			// 		param['equipmentId'] = this.equipmentId;
+			// 	}
 
-				return this.getProvinceAll(param)
-					.then(data => {
-						uni.stopPullDownRefresh();
-						if (param['chartType'] == 'day') {
-							canvaColumn9 = this.initChart3('canvaColumn9', data);
-						}
-						if (param['chartType'] == 'week') {
-							canvaColumn10 = this.initChart3('canvaColumn10', data);
-						}
-						if (param['chartType'] == 'month') {
-							canvaColumn11 = this.initChart3('canvaColumn11', data);
-						}
-						if (param['chartType'] == 'year') {
-							canvaColumn12 = this.initChart3('canvaColumn12', data);
-						}
+			// 	return this.getProvinceAll(param)
+			// 		.then(data => {
+			// 			uni.stopPullDownRefresh();
+			// 			if (param['chartType'] == 'day') {
+			// 				canvaColumn9 = this.initChart3('canvaColumn9', data);
+			// 			}
+			// 			if (param['chartType'] == 'week') {
+			// 				canvaColumn10 = this.initChart3('canvaColumn10', data);
+			// 			}
+			// 			if (param['chartType'] == 'month') {
+			// 				canvaColumn11 = this.initChart3('canvaColumn11', data);
+			// 			}
+			// 			if (param['chartType'] == 'year') {
+			// 				canvaColumn12 = this.initChart3('canvaColumn12', data);
+			// 			}
 
-					}, _ => {
-						uni.stopPullDownRefresh();
-						if (param['chartType'] == 'day') {
-							canvaColumn9 = this.initChart3('canvaColumn9', {
-								categories: ['暂无数据'],
-								series: [{
-									name: '销售额',
-									data: [0]
-								}]
-							});
-						}
-						if (param['chartType'] == 'week') {
-							canvaColumn10 = this.initChart3('canvaColumn10', {
-								categories: ['暂无数据'],
-								series: [{
-									name: '销售额',
-									data: [0]
-								}]
-							});
-						}
-						if (param['chartType'] == 'month') {
-							canvaColumn11 = this.initChart3('canvaColumn11', {
-								categories: ['暂无数据'],
-								series: [{
-									name: '销售额',
-									data: [0]
-								}]
-							});
-						}
-						if (param['chartType'] == 'year') {
-							canvaColumn12 = this.initChart3('canvaColumn12', {
-								categories: ['暂无数据'],
-								series: [{
-									name: '销售额',
-									data: [0]
-								}]
-							});
-						}
-					});
-			},
+			// 		}, _ => {
+			// 			uni.stopPullDownRefresh();
+			// 			if (param['chartType'] == 'day') {
+			// 				canvaColumn9 = this.initChart3('canvaColumn9', {
+			// 					categories: ['暂无数据'],
+			// 					series: [{
+			// 						name: '销售额',
+			// 						data: [0]
+			// 					}]
+			// 				});
+			// 			}
+			// 			if (param['chartType'] == 'week') {
+			// 				canvaColumn10 = this.initChart3('canvaColumn10', {
+			// 					categories: ['暂无数据'],
+			// 					series: [{
+			// 						name: '销售额',
+			// 						data: [0]
+			// 					}]
+			// 				});
+			// 			}
+			// 			if (param['chartType'] == 'month') {
+			// 				canvaColumn11 = this.initChart3('canvaColumn11', {
+			// 					categories: ['暂无数据'],
+			// 					series: [{
+			// 						name: '销售额',
+			// 						data: [0]
+			// 					}]
+			// 				});
+			// 			}
+			// 			if (param['chartType'] == 'year') {
+			// 				canvaColumn12 = this.initChart3('canvaColumn12', {
+			// 					categories: ['暂无数据'],
+			// 					series: [{
+			// 						name: '销售额',
+			// 						data: [0]
+			// 					}]
+			// 				});
+			// 			}
+			// 		});
+			// },
 			initChart(canvasId, chartData) {
 				return new uCharts({
 					$this: _self,

+ 21 - 2
pages/User/equipmentStatusList.vue

@@ -102,7 +102,7 @@
 				<image class="img" src="../../static/img/green.png"></image>
 				<font class="wenziT">{{$t('equipmentStatusList.green')}}</font>
 			</view>
-			<view class="titlelist" style="position: relative;" v-for="equipment in merchantList[0].equipmentList"
+			<view class="titlelist" style="position: relative;" v-for="equipment in equipmentList"
 				:key="equipment.id">
 				<span class="status-css" :class="equipment.hasTodayAlarm===true?statusError : statusNormal"></span>
 				<uni-collapse-item :title="getEquipmentTitle(equipment)">
@@ -339,6 +339,7 @@
 				merchantList: [{
 					equipmentList: []
 				}],
+				equipmentList: [],
 				extraIcon: {
 					color: '#4cd964',
 					size: '22',
@@ -357,17 +358,28 @@
 				editBtn:true,
 				sleepDesc:null,
 				descShow:false,
+				onReach:true,
 			}
 		},
 		computed: {
 			...mapState(['loginUser']),
 		},
 		onPullDownRefresh() {
+			this.globalUser.offset = 1;
+			this.globalUser.limit = 20;
 			this.getEquipmentListData();
 		},
+		onReachBottom() {
+			if(this.onReach) {
+				this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
+				this.getEquipmentListData();
+			}
+		},
 		onShow() {
 			this.input = this.input + 1;
 			this.globalUser = uni.getStorageSync("globalUser");
+			this.globalUser.offset = 1;
+			this.globalUser.limit = 20;
 			uni.setNavigationBarTitle({
 				title: this.$t('equipmentStatusList.title')
 			});
@@ -377,7 +389,9 @@
 			});
 			var token = uni.getStorageSync("token");
 			if (token.length > 1) {
-				this.getEquipmentListData();
+				if(this.equipmentList.length === 0) {
+					this.getEquipmentListData();						
+				}
 			} else {
 				uni.reLaunch({
 					url: '../Login/Login',
@@ -397,6 +411,11 @@
 				this.getEquipmentListByUser(this.globalUser)
 					.then(data => {
 						this.merchantList = data;
+						if(data[0].equipmentList.length === 0) {
+							this.onReach = false;
+						}
+						this.equipmentList.push(...data[0].equipmentList);
+						console.log(this.equipmentList);
 						var listName = data[0].equipmentList;
 						var times = new Map;
 						if (this.input == 1) {

+ 22 - 4
pages/User/merchantList.vue

@@ -2,11 +2,11 @@
 <template>
 	<view class="">
 		<view v-if="id!=1">
-			<view v-if="merchantList[0].equipmentList.length>0">
+			<view v-if="equipmentList.length>0">
 				<uni-collapse :accordion="true">
 					<uni-list>
 						<uni-list-item :title="$t('merchantList.total')" @click="openByAdmin(merchantList[0].name,merchantList[0].id)" />
-						<view class="titlelist" v-for="equipment in merchantList[0].equipmentList" :key="equipment.id">
+						<view class="titlelist" v-for="equipment in equipmentList" :key="equipment.id">
 							<uni-list-item :title="getEquipmentTitle(equipment)" @click="openByEquipment(merchantList[0].name,equipment.id)" />
 						</view>
 					</uni-list>
@@ -45,6 +45,7 @@
 				merchantList: [{
 					equipmentList: []
 				}],
+				equipmentList: [],
 				extraIcon: {
 					color: '#4cd964',
 					size: '22',
@@ -52,20 +53,31 @@
 				},
 				id: null,
 				pname:null,
-				list: []
+				list: [],
+				onReach:true,
 			}
 		},
 		computed: {
 			...mapState(['loginUser']),
 		},
+		onReachBottom() {
+			if(this.onReach) {
+				this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
+				this.getEquipmentListData();
+			}
+		},
 		onShow() {
 			uni.setNavigationBarTitle({title: this.$t('merchantList.title')});
 			uni.setTabBarItem({ index: 1,text: this.$t('tabs.tab2')});
 			this.globalUser = uni.getStorageSync("globalUser");
 			this.id = this.globalUser.id;
+			this.globalUser.offset = 1;
+			this.globalUser.limit = 20;
 			var token = uni.getStorageSync("token");
 			if (token.length>1) {
-				this.getEquipmentListData();
+				if(this.equipmentList.length === 0) {
+					this.getEquipmentListData();						
+				}
 			}else{
 				uni.reLaunch({
 					url: '../Login/Login',
@@ -73,6 +85,8 @@
 			}
 		},
 		onPullDownRefresh() {
+			this.globalUser.offset = 1;
+			this.globalUser.limit = 20;
 			this.getEquipmentListData();
 		},
 		methods: {
@@ -149,6 +163,10 @@
 					this.getEquipmentListByUser(this.globalUser)
 					.then(data => {
 						this.merchantList = data;
+						if(data[0].equipmentList.length === 0) {
+							this.onReach = false;
+						}
+						this.equipmentList.push(...data[0].equipmentList);
 						var listName = data[0].equipmentList;
 						var listId = data[0].id;
 						if(listId!=null && listId!='1'){