瀏覽代碼

故障诊断和预警分析的增加导出功能

mw_666 3 年之前
父節點
當前提交
51eb6ebc7e
共有 3 個文件被更改,包括 35 次插入22 次删除
  1. 13 20
      src/views/malfunctionDiagnose/index.vue
  2. 21 1
      src/views/sampleDatabase/warning/index.vue
  3. 1 1
      src/views/warn/gfgj.vue

+ 13 - 20
src/views/malfunctionDiagnose/index.vue

@@ -193,7 +193,7 @@ export default {
           },
           {
             name: "操作",
-            field: "",
+            field: "cz",
             is_num: false,
             is_light: false,
             template() {
@@ -294,32 +294,25 @@ export default {
 		return jsonData.map(v => filterVal.map(j => v[j]));
 	},
 	export() {
-	// 	let that = this;
-	// 	const {export_json_to_excel} = require('@tools/excel/Export2Excel.js'); // 注意这个Export2Excel路径      
-	// 	let tHeader = []; // 上面设置Excel的表格第一行的标题       
-	// 	let filterVal = []; // 上面的index、nickName、name是tableData里对象的属性key值
+		let that = this;
+		const {export_json_to_excel} = require('@tools/excel/Export2Excel.js'); // 注意这个Export2Excel路径      
+		let tHeader = []; // 上面设置Excel的表格第一行的标题       
+		let filterVal = []; // 上面的index、nickName、name是tableData里对象的属性key值
 	
-	// 	that.tableData.column.forEach(ele => {
-	// 		tHeader.push(ele.name);
-	// 		filterVal.push(ele.field);
-	// 	});
-	// 	var list = [];
-	// 	that.tableData.data.forEach((i, index) => {
-	// 		list.push(i);
-	// 	})
-	// 	list.push(that.tableDataEnd)
-	// 	const data = that.formatJson(filterVal, list);
-	// 	export_json_to_excel(tHeader, data, '导出的Excel'); // 最后一个是表名字
+		that.tableData.column.forEach(ele => {
+			if(ele.field != 'cz'){
+				tHeader.push(ele.name);
+				filterVal.push(ele.field);
+			}
+		});
+		const data = that.formatJson(filterVal, that.tableData.data);
+		export_json_to_excel(tHeader, data, '故障诊断'); // 最后一个是表名字
 	},
   },
 
   created() {
     this.requestData();
   },
-
-  mounted() {},
-
-  unmounted() {},
 };
 </script>
 

+ 21 - 1
src/views/sampleDatabase/warning/index.vue

@@ -34,6 +34,8 @@
 				</div>
 				<div class="query-actions">
 					<button class="btn" @click="query">查询</button>
+					<button class="btn green" @click="">导入</button>
+					<button class="btn" @click="export">导出</button>
 				</div>
 			</div>
 		</div>
@@ -342,7 +344,25 @@
 					this.active = false;
 					this.wtId = [];
 				}
-			}
+			},
+			formatJson(filterVal, jsonData) {
+				return jsonData.map(v => filterVal.map(j => v[j]));
+			},
+			export() {
+				let that = this;
+				const {export_json_to_excel} = require('@tools/excel/Export2Excel.js'); // 注意这个Export2Excel路径      
+				let tHeader = []; // 上面设置Excel的表格第一行的标题       
+				let filterVal = []; // 上面的index、nickName、name是tableData里对象的属性key值
+			
+				that.tableData.column.forEach(ele => {
+					if(ele.field != 'cz'){
+						tHeader.push(ele.name);
+						filterVal.push(ele.field);
+					}
+				});
+				const data = that.formatJson(filterVal, that.tableData.data);
+				export_json_to_excel(tHeader, data, '预警分析'); // 最后一个是表名字
+			},
 		},
 		watch: {
 			wpId() {

+ 1 - 1
src/views/warn/gfgj.vue

@@ -177,7 +177,7 @@
 					baseURL: "http://192.168.1.18:8075/",
 					subUrl: "alarm/history/page",
 					data: {
-						category1: "windturbine",
+						category1: "GF",
 						stationid: this.wpId,
 						starttime: this.startDate,
 						endtime: this.endDate,