From bc2747387df0693aa46a55bb556985aaf881d843 Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: 星期三, 24 八月 2022 19:18:32 +0800
Subject: [PATCH] 导入
---
src/views/summaryPotentialSafetyHzards/index.vue | 68 +++++++++++++++++++++------------
1 files changed, 43 insertions(+), 25 deletions(-)
diff --git a/src/views/summaryPotentialSafetyHzards/index.vue b/src/views/summaryPotentialSafetyHzards/index.vue
index a647499..43c0d9a 100644
--- a/src/views/summaryPotentialSafetyHzards/index.vue
+++ b/src/views/summaryPotentialSafetyHzards/index.vue
@@ -98,6 +98,7 @@
v-model="time"
type="daterange"
range-separator="至"
+ value-format="yyyy-MM-dd"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
@@ -106,16 +107,16 @@
<el-button class="btn" size="small" type="primary" @click="queryData"
>汇总
</el-button>
- <el-button class="btn" size="small" type="primary" @click="close()"
+ <el-button class="btn" size="small" type="primary" @click="exportData()"
>导出Excel
</el-button>
</el-form-item>
</div>
</el-form>
- <el-table
- :data="tableData"
- v-loading="loading"
- style="width: 100%">
+ <el-table id="out-table"
+ :data="tableData"
+ v-loading="loading"
+ style="width: 100%">
<el-table-column align="center" label="众泰煤焦化-安全隐患台帐">
<el-table-column
prop="y_label"
@@ -125,6 +126,7 @@
</el-table-column>
<el-table-column
v-for="item in tableData[0].items"
+ :key="item.x_label"
:label="item.x_label"
align="center">
<template slot-scope="scope">
@@ -157,6 +159,8 @@
} from "@/api/sgyhpczl/initSelect";
import {danger_summary} from "@/api/sgyhpczl/summaryPotentialSafetyHzards";
+import FileSaver from "file-saver";
+import XLSX from "xlsx";
export default {
name: "index",
@@ -205,6 +209,7 @@
YHJBList: [],
YHZTList: [],
loading: false,
+ searchData:{},
startDate: "",
endDate: "",
}
@@ -331,6 +336,8 @@
}
selectData.push(timeSearchCloumn)
requestData.query_condition = selectData;
+ this.searchData = requestData;
+ console.log(this.searchData)
this.loading = true;
danger_summary(requestData).then(res => {
this.loading = false;
@@ -378,30 +385,41 @@
},
showYHList(row, item) {
- var searchData = {};
- searchData[this.form.x_axis] = item.x_label;
- searchData[this.form.y_axis] = row.y_label;
- let requestData = {};
- let selectData = []
- for (const queryElement in this.form) {
- if (queryElement != "x_axis" && queryElement != "y_axis") {
- if (this.form[queryElement] != null && this.form[queryElement] != '') {
- let searchCloumn = {
- "field": queryElement,
- "value": this.form[queryElement].join(','),
- "type": "IN"
- }
- selectData.push(searchCloumn);
- }
- } else {
- requestData[queryElement] = this.form[queryElement];
- }
- }
- searchData.query_condition = selectData;
+ var searchData = this.searchData;
+ searchData.x_label = item.x_label;
+ searchData.y_label = row.y_label;
this.$router.push({
path: "/summaryList",
query: {"searchData": searchData}
})
+ },
+ exportData() {
+ var xlsxParam = {raw: true};
+ /* 从表生成工作簿对象 */
+ var wb = XLSX.utils.table_to_book(
+ document.querySelector("#out-table"),
+ xlsxParam
+ );
+ /* 获取二进制字符串作为输出 */
+ var wbout = XLSX.write(wb, {
+ bookType: "xlsx",
+ bookSST: true,
+ type: "array",
+ });
+ try {
+ FileSaver.saveAs(
+ //Blob 对象表示一个不可变、原始数据的类文件对象。
+ //Blob 表示的不一定是JavaScript原生格式的数据。
+ //File 接口基于Blob,继承了 blob 的功能并将其扩展使其支持用户系统上的文件。
+ //返回一个新创建的 Blob 对象,其内容由参数中给定的数组串联组成。
+ new Blob([wbout], {type: "application/octet-stream"}),
+ //设置导出文件名称
+ "安全隐患汇总.xlsx"
+ );
+ } catch (e) {
+ if (typeof console !== "undefined") console.log(e, wbout);
+ }
+ return wbout;
}
}
--
Gitblit v1.9.2