From c433d38d542619adebde935238e34fe387d1a590 Mon Sep 17 00:00:00 2001 From: Your Name <123456> Date: 星期二, 14 六月 2022 14:19:47 +0800 Subject: [PATCH] Merge branch 'master' of https://sinanoaq.cn:8888/r/ztqt --- src/views/doublePreventAction/riskLevelManage/controlAction/index.vue | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 105 insertions(+), 15 deletions(-) diff --git a/src/views/doublePreventAction/riskLevelManage/controlAction/index.vue b/src/views/doublePreventAction/riskLevelManage/controlAction/index.vue index 8a03eab..a2de204 100644 --- a/src/views/doublePreventAction/riskLevelManage/controlAction/index.vue +++ b/src/views/doublePreventAction/riskLevelManage/controlAction/index.vue @@ -19,6 +19,8 @@ </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="showRiskControlMeasureForm('','新增')" v-show="showCurrent">新增</el-button> + <el-button class="filter-item" style="margin-left: 10px;margin-top: 10px" type="primary" @click="showImportDialog()">导入</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 @@ -35,6 +37,13 @@ > <el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column> <el-table-column label="安全风险事件名称" prop="riskEventId" align="center"> + <template slot-scope="scope"> + <div v-for="item in riskEventList"> + <div v-if="item.id === scope.row.riskEventId"> + {{item.riskEventName}} + </div> + </div> + </template> </el-table-column> <el-table-column label="管控方式" prop="dataSrc" align="center"> </el-table-column> @@ -145,18 +154,17 @@ import { mapGetters } from 'vuex' import { computePageCount } from '@/utils' import { addRiskControlMeasure, deleteRiskControlMeasure, getRiskControlMeasureList, updateRiskControlMeasure } from '@/api/riskLevelManage' - import {getClassify, getRiskEventList} from "../../../../api/riskLevelManage"; + import { + exportRiskControlMeasure, + getClassify, + getRiskEventList, importAnalyseUnit, importRiskControlMeasure + } from "../../../../api/riskLevelManage"; import {dictionaryAllItems} from "../../../../api/dictionary"; + import {parseError} from "../../../../utils/messageDialog"; + const exampleFile = require('@/assets/example/riskControlMeasure.xlsx') export default { name: 'index', filters: { - parseMain(type){ - if(type === 1){ - return "是" - }else if(type === 0){ - return "否" - } - }, }, computed: { ...mapGetters([ @@ -183,6 +191,7 @@ title:'', company:'', code:'', + importDialogFormVisible:false, riskControlMeasureVisible:false, riskControlMeasureFormRules:{ riskEventId: [{ required: true, message: '安全风险事件名称不能为空', trigger: 'change' }], @@ -391,6 +400,85 @@ }) }) }, + + viewHandle() { + window.open(exampleFile, '_blank') + }, + + showImportDialog(){ + this.importDialogFormVisible = true + }, + + importToTable(){ + const formData = new FormData() + const files = this.$refs['importLabInput'].files + if (files && files.length > 0) { + formData.append('file', files[0]) + } + importRiskControlMeasure(formData).then((response) => { + const res = response.data + if (res.code == 200) { + this.importDialogFormVisible = false + this.$message({ + message: '导入成功', + type: 'success' + }) + this.getAnalyseUnitData() + } else { + parseError({ error: res.message, vm: this }) + } + }).catch((error) => { + parseError({ error: error, vm: this }) + }) + }, + + exportToExcel() { + exportRiskControlMeasure(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 = [ + '安全风险事件名称', + '管控方式', + '管控方式描述', + '管控措施分类1', + '管控措施分类2', + '管控措施分类3', + '隐患排查内容', + ] + const filterVal = [ + 'riskEventName', + 'dataSrc', + 'riskMeasureDesc', + 'classify1', + 'classify2', + 'classify3', + 'troubleshootContent', + ] + 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.getRiskControlMeasureData() }, @@ -406,16 +494,18 @@ ifShowButton (value){ this.showCurrent = false this.showOther = true - // this.$refs.table.clearSelection() - // value.forEach(row => { - // this.$refs.table.toggleRowSelection(this.riskControlMeasureData.find(item => { - // return row.id === item.id - // }) , this.riskControlMeasureData.find(item => {return row.id === item.id}) === undefined ? false :true) - // }) + this.listQuery.pageSize = 1000 + this.getRiskControlMeasureData() + this.$refs.table.clearSelection() + value.forEach(row => { + this.$refs.table.toggleRowSelection(this.riskControlMeasureData.find(item => { + return row.id === item.id + }) , this.riskControlMeasureData.find(item => {return row.id === item.id}) === undefined ? false :true) + }) + }, handleSelectionChange(val){ - debugger this.riskControlMeasureIdList = val }, -- Gitblit v1.9.2