From 4e27705d66a69199b336c7f7f608f06dbd1d81fa Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: Tue, 07 Jun 2022 15:47:46 +0800
Subject: [PATCH] 'lct'
---
src/views/doublePreventAction/riskLevelManage/event/index.vue | 41 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/src/views/doublePreventAction/riskLevelManage/event/index.vue b/src/views/doublePreventAction/riskLevelManage/event/index.vue
index 93f1019..f032f45 100644
--- a/src/views/doublePreventAction/riskLevelManage/event/index.vue
+++ b/src/views/doublePreventAction/riskLevelManage/event/index.vue
@@ -13,6 +13,7 @@
</div>
<el-button class="filter-item" style="margin-left: 10px;margin-top: 10px" type="primary" icon="el-icon-refresh" @click="refreshHandle">搜索</el-button>
<el-button class="filter-item" style="margin-left: 10px;margin-top: 10px" type="primary" icon="el-icon-plus" @click="showRiskEvent('','新增')">新增</el-button>
+ <el-button class="filter-item" style="margin-left: 10px;margin-top: 10px" type="primary" @click="exportToExcel">导出</el-button>
</div>
<div class="table_content">
<el-table
@@ -89,7 +90,7 @@
import { mapGetters } from 'vuex'
import { computePageCount } from '@/utils'
import { addRiskEvent, deleteRiskEvent, getRiskEventList, updateRiskEvent } from '@/api/riskLevelManage'
- import {getAnalyseUnitList} from "../../../../api/riskLevelManage";
+ import {exportAnalyseUnit, exportRiskEvent, getAnalyseUnitList} from "../../../../api/riskLevelManage";
export default {
name: 'index',
filters: {
@@ -269,6 +270,44 @@
})
})
},
+
+ exportToExcel() {
+ exportRiskEvent(this.listQuery.filter).then(res=>{
+ if (res.data.code === '200') {
+ if(res.data.result === null ||res.data.result === [] || res.data.result.length === 0){
+ this.$message({
+ type:'warning',
+ message:'无数据可导出'
+ })
+ }
+ else{
+ let allData = res.data.result
+ import('@/vendor/Export2Excel').then((excel) => {
+ const tHeader = [
+ '安全风险分析单元名称',
+ '安全风险事件名称',
+ ]
+ const filterVal = [
+ 'riskUnitName',
+ 'riskEventName',
+ ]
+ const data = this.formatJson(filterVal, allData)
+ excel.export_json_to_excel({
+ header: tHeader,
+ data,
+ filename: '安全风险事件数据'
+ })
+ })
+
+ }
+ }
+ })
+ },
+
+ formatJson(filterVal, jsonData) {
+ return jsonData.map(v => filterVal.map(j => v[j]))
+ },
+
refreshHandle(){
this.getRiskEventData()
},
--
Gitblit v1.9.2