Browse Source

报表分页

kukuasir@vip.qq.com 1 year ago
parent
commit
e8bc599a69
1 changed files with 62 additions and 13 deletions
  1. 62 13
      src/views/equip-management/report/list.vue

+ 62 - 13
src/views/equip-management/report/list.vue

@@ -548,13 +548,13 @@ export default {
 				user_id: "",
 				boxes: [],
 				district: "",
-
 				room_block: "", //幢
 				room_unit: "", //单元
 				room_score: "" //号
 			},
 			total: 0,
-			dataSource: [], // 数据源
+			dataSource: [], // 原始数据源
+			pageData: [],  // 分页后的数据
 			tableData: [],
 			argsList: [],
 			selection: [],  // 选中的数据
@@ -702,8 +702,6 @@ export default {
 				target: document.querySelector('#container')
 			});
 			var params = {
-				page_index: this.queryParams.page_index,
-				page_size: this.queryParams.page_size,
 				project_name: this.queryParams.project_name,
 				box_name: this.queryParams.box_name,
 				online_status: this.queryParams.online_status,
@@ -717,11 +715,8 @@ export default {
 				let data = resp.data || {};
 				let result = data.result || {};
 				this.total = result.count;
-				this.dataSource = result.data || [];
-				// 展开所有项目下的设备及单机
-				this.tableData = expandAllNodes(this.dataSource);
-				let dataSolve = mergeTableRows(this.tableData, this.mergeColums);
-				this.tableData = dataSolve;
+				this.filterDataSource(result.data || []);
+				this.genTableData();
 				console.log('>>> tableData: ', this.tableData);
 				loading.close();
 			}).catch(err => {
@@ -737,6 +732,52 @@ export default {
 				console.log('[args/list]请求错误: ', err);
 			});
 		},
+		/** 本地过滤数据 */
+		filterDataSource(data) {
+			/*
+			const filterHpSuTemp = (this.extraParams.hpSuTempMax > this.extraParams.hpSuTempMin);
+			const filterDhDewPoint = (this.extraParams.dhDewPointMax > this.extraParams.dhDewPointMin);
+			const filterHexSuTemp = (this.extraParams.hexSuTempMax > this.extraParams.hexSuTempMin);
+			for (let i = 0; i < data.length; i++) {
+				const element = data[i];
+				// if (filterHpSuTemp && this.hpSuTempIsInRange())
+			}
+			*/
+			this.dataSource = data;
+		},
+		/** 计算主机供水温度属性值是否在范围内 */
+		hpSuTempIsInRange(ele) {
+			const hpSuTempMin = this.extraParams.hpSuTempMin;
+			const hpSuTempMax = this.extraParams.hpSuTempMax;
+			return ele.host_su_temp >= hpSuTempMin && ele.host_su_temp <= hpSuTempMax;
+		},
+		/** 计算新风送风露点属性值是否在范围内 */
+		dhDewPointIsInRange(ele) {
+			const dhDewPointMin = this.extraParams.dhDewPointMin;
+			const dhDewPointMax = this.extraParams.dhDewPointMax;
+			return ele.nt_dew_point >= dhDewPointMin && ele.nt_dew_point <= dhDewPointMax;
+		},
+		/** 计算换热站供水温度属性值是否在范围内 */
+		hexSuTempIsInRange(ele) {
+			const hexSuTempMin = this.extraParams.hexSuTempMin;
+			const hexSuTempMax = this.extraParams.hexSuTempMax;
+			return ele.hex_su_temp >= hexSuTempMin && ele.hex_su_temp <= hexSuTempMax;
+		},
+		/** 生成tableData */
+		genTableData() {
+			this.pageData = [];
+			const start = (this.queryParams.page_index - 1) * this.queryParams.page_size;
+			const end = Math.min(this.queryParams.page_index * this.queryParams.page_size, this.dataSource.length);
+			for (let index = start; index < end; index++) {
+				const element = this.dataSource[index];
+				this.pageData.push(element);
+			}
+			// 展开所有项目下的设备及单机
+			this.tableData = expandAllNodes(this.pageData);
+			let dataSolve = mergeTableRows(this.tableData, this.mergeColums);
+			this.tableData = dataSolve;
+			console.log('>>> tableData: ', this.tableData);
+		},
 		/** 数据行合并 */
 		objectSpanMethod({ row, column, rowIndex, columnIndex }) {
 			if (columnIndex == 0 || columnIndex == 1) {
@@ -765,7 +806,7 @@ export default {
 		},
 		/** 获取对应设备下的末端列表 */
 		getDatasByRow(row, prop) {
-			let project = this.dataSource.find(p => p.projectName === row.projectName);
+			let project = this.pageData.find(p => p.projectName === row.projectName);
 			if (project) {
 				let box = project.boxList.find(b => b.box_id === row.boxId);
 				if (!box) {
@@ -811,7 +852,7 @@ export default {
 			this.nameset = Array.from(new Set(projectNames));
 			let projList = [];
 			this.nameset.forEach(name => {
-				let project = this.dataSource.find(d => d.projectName === name);
+				let project = this.pageData.find(d => d.projectName === name);
 				projList.push(project);
 			})
 			this.selection = projList;
@@ -819,11 +860,19 @@ export default {
 		/** 分页切换 */
 		handleSizeChange(val) {
 			this.queryParams.page_size = val;
-			this.getProjects();
+			if (this.dataSource.length) {
+				this.genTableData();
+			} else {
+				this.getProjects();
+			}
 		},
 		handleCurrentChange(val) {
 			this.queryParams.page_index = val;
-			this.getProjects();
+			if (this.dataSource.length) {
+				this.genTableData();
+			} else {
+				this.getProjects();
+			}
 		},
 		handleClickMore(row, category) {
 			if (category === 'host') {