| | |
| | | <template> |
| | | |
| | | <div class="app-container"> |
| | | <div class="filter-container"> |
| | | <div class="basic_search"> |
| | | <span>事件名称:</span> |
| | | <el-input v-model="listQuery.filter.riskEventName" style="width:200px"> |
| | | </el-input> |
| | | </div> |
| | | <div class="basic_search"> |
| | | <span>管控方式:</span> |
| | | <el-select v-model="listQuery.filter.dataSrc" clearable style="width:200px"> |
| | | <el-option |
| | | v-for="item in DataSrcList" |
| | | :key="item.id" |
| | | :value="item.text" |
| | | :label="item.text" |
| | | ></el-option> |
| | | </el-select> |
| | | </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 |
| | | v-loading="listLoading" |
| | | :key="tableKey" |
| | | @selection-change="handleSelectionChange" |
| | | :data="riskControlMeasureData" |
| | | border |
| | | fit |
| | | ref="table" |
| | | :row-key="getRowKey" |
| | | highlight-current-row |
| | | style="width: 100%;" |
| | | > |
| | | <el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column> |
| | | <el-table-column label="安全风险事件名称" prop="riskEventId" align="center" show-overflow-tooltip> |
| | | <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> |
| | | <el-table-column label="管控方式描述" prop="riskMeasureDesc" align="center" show-overflow-tooltip> |
| | | </el-table-column> |
| | | <el-table-column label="管控措施分类1" prop="classify1" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="管控措施分类2" prop="classify2" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="管控措施分类3" prop="classify3" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="隐患排查内容" prop="troubleshootContent" align="center" show-overflow-tooltip> |
| | | </el-table-column> |
| | | <el-table-column label="检查类型" prop="hazardLiablePerson" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="周期" prop="timeEffect" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="单位" prop="timeUnit" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="创建人" prop="createBy" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" prop="createTime" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="最后修改人" prop="updateBy" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="最后修改时间" prop="updateTime" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="280" class-name="small-padding fixed-width"> |
| | | <template slot-scope="scope"> |
| | | <el-button type="text" @click="giveValue(scope.row,)" v-show="showOther">选择</el-button> |
| | | <el-button type="text" @click="showRiskControlMeasureForm(scope.row,'编辑')" v-show="showCurrent">编辑</el-button> |
| | | <el-button type="text" style="color: red" @click="deleteById(scope.row)" v-show="showCurrent">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <br> |
| | | <el-pagination |
| | | v-show="recordTotal>0" |
| | | :current-page="currentPage" |
| | | :page-sizes="[10, 20, 30, 50]" |
| | | :page-size="pageSize" |
| | | :total="recordTotal" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | background |
| | | style="float:right;" |
| | | @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | /> |
| | | <br> |
| | | </div> |
| | | <el-dialog :title="title" :visible.sync="riskControlMeasureVisible" append-to-body :close-on-click-modal="false" width="600px"> |
| | | <el-form ref="riskControlMeasureForm" :rules="riskControlMeasureFormRules" :model="riskControlMeasureForm" label-position="right" label-width="160px"> |
| | | <el-form-item label="安全风险事件名称" prop="riskEventId"> |
| | | <el-select v-model="riskControlMeasureForm.riskEventId" class="analyseUnit_input"> |
| | | <el-option |
| | | v-for="item in riskEventList" |
| | | :key="item.id" |
| | | :value="item.id" |
| | | :label="item.riskEventName" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="管控方式" prop="dataSrc"> |
| | | <el-select v-model="riskControlMeasureForm.dataSrc" class="analyseUnit_input"> |
| | | <el-option |
| | | v-for="item in DataSrcList" |
| | | :key="item.id" |
| | | :value="item.text" |
| | | :label="item.text" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="管控方式描述" prop="riskMeasureDesc"> |
| | | <el-input type="textarea" :rows="4" v-model="riskControlMeasureForm.riskMeasureDesc" class="analyseUnit_input"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="管控措施分类1" prop="classify1"> |
| | | <el-select v-model="riskControlMeasureForm.classify1" class="analyseUnit_input" @change="changeClassifyTwoList()"> |
| | | <el-option |
| | | v-for="item in classifyOneList" |
| | | :key="item.id" |
| | | :value="item.name" |
| | | :label="item.name" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="管控措施分类2" prop="classify2"> |
| | | <el-select v-model="riskControlMeasureForm.classify2" class="analyseUnit_input"> |
| | | <el-option |
| | | v-for="item in classifyTwoList" |
| | | :key="item.id" |
| | | :value="item.name" |
| | | :label="item.name" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="管控措施分类3" prop="classify3"> |
| | | <el-input v-model="riskControlMeasureForm.classify3" class="analyseUnit_input"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="隐患排查内容" prop="troubleshootContent"> |
| | | <el-input type="textarea" :rows="4" v-model="riskControlMeasureForm.troubleshootContent" class="analyseUnit_input"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="周期" prop="timeEffect"> |
| | | <el-input v-model="riskControlMeasureForm.timeEffect" type="number" class="analyseUnit_input"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="单位" prop="timeUnit"> |
| | | <el-select v-model="riskControlMeasureForm.timeUnit" class="analyseUnit_input"> |
| | | <el-option |
| | | v-for="item in timeUnitList" |
| | | :key="item.id" |
| | | :value="item.name" |
| | | :label="item.name" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div align="right"> |
| | | <el-button @click="riskControlMeasureVisible = false">取消</el-button> |
| | | <el-button type="primary" @click="submitAnalyseUnit()" v-show="ifShowSelf">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <el-dialog |
| | | :visible.sync="importDialogFormVisible" |
| | | :modal-append-to-body="false" |
| | | :close-on-click-modal="false" |
| | | title="用户导入" |
| | | width="700px" |
| | | > |
| | | <el-form |
| | | ref="importForm" |
| | | label-position="right" |
| | | label-width="120px" |
| | | style="margin-left:50px;width:500px;" |
| | | element-loading-text="导入中..." |
| | | > |
| | | <el-form-item label="导入文件:"> |
| | | <input ref="importLabInput" type="file" accept=".xls, .xlsx" > |
| | | </el-form-item> |
| | | <el-form-item label="excel参考模板:"> |
| | | <el-button type="text" @click="viewHandle">下载模板</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button @click="importDialogFormVisible = false">取消</el-button> |
| | | <el-button type="primary" @click="importToTable()">导入</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { mapGetters } from 'vuex' |
| | | import { computePageCount } from '@/utils' |
| | | import { addRiskControlMeasure, deleteRiskControlMeasure, getRiskControlMeasureList, updateRiskControlMeasure } 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" |
| | | name: 'index', |
| | | filters: { |
| | | }, |
| | | computed: { |
| | | ...mapGetters([ |
| | | 'userType' |
| | | ]) |
| | | }, |
| | | data() { |
| | | return { |
| | | tableKey: 0, |
| | | riskControlMeasureData: [], |
| | | riskEventList:[], |
| | | DataSrcList:[], |
| | | classifyOneList:[], |
| | | classifyTwoList:[], |
| | | riskControlMeasureIdList:[], |
| | | timeUnitList:[{id:1,name:'小时'},{id:2,name:'天'},{id:3,name:'周'},{id:4,name:'月'},], |
| | | listLoading: false, |
| | | showCurrent:true, |
| | | showOther:false, |
| | | ifShowSelf:true, |
| | | pageSize: 10, |
| | | recordTotal: 0, |
| | | currentPage: 1, |
| | | pageTotal: 0, |
| | | title:'', |
| | | company:'', |
| | | code:'', |
| | | importDialogFormVisible:false, |
| | | riskControlMeasureVisible:false, |
| | | riskControlMeasureFormRules:{ |
| | | riskEventId: [{ required: true, message: '安全风险事件名称不能为空', trigger: 'change' }], |
| | | dataSrc: [{ required: true, message: '管控方式不能为空', trigger: 'change' }], |
| | | riskMeasureDesc: [{ required: true, message: '管控方式描述不能为空', trigger: 'blur' }], |
| | | classify1: [{ required: true, message: '管控措施分类1不能为空', trigger: 'change' }], |
| | | classify2: [{ required: true, message: '管控措施分类2不能为空', trigger: 'change' }], |
| | | troubleshootContent: [{ required: true, message: '隐患排查内容不能为空', trigger: 'change' }], |
| | | timeEffect: [{ required: true, message: '周期不能为空', trigger: 'blur' }], |
| | | timeUnit: [{ required: true, message: '单位不能为空', trigger: 'change' }], |
| | | }, |
| | | riskControlMeasureForm:{ |
| | | id: null, |
| | | riskEventId: null, |
| | | dataSrc: "", |
| | | riskMeasureDesc: "", |
| | | classify1: "", |
| | | classify2: "", |
| | | classify3: "", |
| | | troubleshootContent: "", |
| | | validFlag: true, |
| | | createTime: "", |
| | | updateTime: "", |
| | | createBy: "", |
| | | updateBy: "", |
| | | riskEvent: { |
| | | }, |
| | | timeEffect:"", |
| | | timeUnit:"", |
| | | }, |
| | | listQuery:{ |
| | | pageIndex:1, |
| | | pageSize:10, |
| | | filter:{ |
| | | riskEventName:'', |
| | | } |
| | | }, |
| | | } |
| | | }, |
| | | created() { |
| | | this.getRiskControlMeasureData() |
| | | this.getRiskEvent() |
| | | this.getDataSrcList() |
| | | this.getClassify() |
| | | }, |
| | | methods: { |
| | | async getRiskControlMeasureData(){ |
| | | this.listLoading = true |
| | | let res = await getRiskControlMeasureList(this.listQuery) |
| | | if(res.data.code === '200'){ |
| | | this.recordTotal = res.data.result.total |
| | | this.pageSize = res.data.result.size |
| | | this.pageTotal = computePageCount(res.data.result.total, res.data.result.size) |
| | | this.currentPage = res.data.result.current |
| | | this.riskControlMeasureData = res.data.result.records |
| | | }else{ |
| | | this.$message({ |
| | | message:res.data.message, |
| | | type:'warning' |
| | | }) |
| | | } |
| | | this.listLoading = false |
| | | }, |
| | | async getRiskEvent(){ |
| | | let res = await getRiskEventList({pageSize:1000,pageIndex:1,filter:{riskEventName:''}}) |
| | | if(res.data.code === '200'){ |
| | | this.riskEventList = res.data.result.records |
| | | }else{ |
| | | this.$message({ |
| | | message:res.data.message, |
| | | type:'warning' |
| | | }) |
| | | } |
| | | }, |
| | | async getClassify(){ |
| | | let res = await getClassify({pageSize:1000,pageIndex:1,filter:{riskEventName:''}}) |
| | | if(res.data.code === '200'){ |
| | | this.classifyOneList = res.data.result |
| | | }else{ |
| | | this.$message({ |
| | | message:res.data.message, |
| | | type:'warning' |
| | | }) |
| | | } |
| | | }, |
| | | async getDataSrcList(){ |
| | | const params = {} |
| | | params['dictionaryType'] = '管控方式' |
| | | let res = await dictionaryAllItems(params) |
| | | if (res.data.code === '200') { |
| | | this.DataSrcList = res.data.result |
| | | } else { |
| | | this.$message({ |
| | | type:'warning', |
| | | message:res.data.message |
| | | }) |
| | | } |
| | | }, |
| | | changeClassifyTwoList(){ |
| | | if(this.riskControlMeasureForm.classify1 === '工程技术'){ |
| | | this.classifyTwoList = this.classifyOneList[0].subClassify |
| | | this.riskControlMeasureForm.classify2 = '' |
| | | this.riskControlMeasureForm.classify3 = '' |
| | | }else if(this.riskControlMeasureForm.classify1 === '维护保养') { |
| | | this.classifyTwoList = this.classifyOneList[1].subClassify |
| | | this.riskControlMeasureForm.classify2 = '' |
| | | this.riskControlMeasureForm.classify3 = '' |
| | | }else if(this.riskControlMeasureForm.classify1 === '操作行为') { |
| | | this.classifyTwoList = this.classifyOneList[2].subClassify |
| | | this.riskControlMeasureForm.classify2 = '' |
| | | this.riskControlMeasureForm.classify3 = '' |
| | | }else { |
| | | this.classifyTwoList = this.classifyOneList[3].subClassify |
| | | this.riskControlMeasureForm.classify2 = '' |
| | | this.riskControlMeasureForm.classify3 = '' |
| | | } |
| | | }, |
| | | showRiskControlMeasureForm(value,type){ |
| | | this.riskControlMeasureVisible = true |
| | | this.$nextTick(() =>{ |
| | | this.$refs["riskControlMeasureForm"].clearValidate() |
| | | }) |
| | | if(type === '新增'){ |
| | | this.title = '新增' |
| | | this.riskControlMeasureForm = { |
| | | id: null, |
| | | riskEventId: null, |
| | | dataSrc: "", |
| | | riskMeasureDesc: "", |
| | | classify1: "", |
| | | classify2: "", |
| | | classify3: "", |
| | | troubleshootContent: "", |
| | | validFlag: true, |
| | | createTime: "", |
| | | updateTime: "", |
| | | createBy: "", |
| | | updateBy: "", |
| | | riskEvent: { |
| | | }, |
| | | timeEffect:"", |
| | | timeUnit:"", |
| | | } |
| | | }else{ |
| | | this.title = '修改' |
| | | this.riskControlMeasureForm = value |
| | | } |
| | | }, |
| | | submitAnalyseUnit(){ |
| | | this.$refs["riskControlMeasureForm"].validate((valid) => { |
| | | if(valid){ |
| | | if(this.title === '新增'){ |
| | | addRiskControlMeasure(this.riskControlMeasureForm).then((res)=>{ |
| | | if(res.data.code === '200'){ |
| | | this.riskControlMeasureVisible = false |
| | | this.getRiskControlMeasureData() |
| | | this.$notify({ |
| | | type:'success', |
| | | duration:2000, |
| | | message:'新增成功', |
| | | title:'成功' |
| | | }) |
| | | }else{ |
| | | this.$message({ |
| | | type:'warning', |
| | | message:res.data.message |
| | | }) |
| | | } |
| | | }) |
| | | }else{ |
| | | updateRiskControlMeasure(this.riskControlMeasureForm).then((res)=>{ |
| | | if(res.data.code === '200'){ |
| | | this.riskControlMeasureVisible = false |
| | | this.getRiskControlMeasureData() |
| | | this.$notify({ |
| | | type:'success', |
| | | duration:2000, |
| | | title:'成功', |
| | | message:'编辑成功' |
| | | }) |
| | | }else{ |
| | | this.$message({ |
| | | type:'warning', |
| | | message:res.data.message |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }else{ |
| | | this.$message({ |
| | | message:'请完善基本信息', |
| | | type:'warning' |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | deleteById(val){ |
| | | this.$confirm('删除此条信息,是否继续','提示',{ |
| | | confirmButtonText:'确定', |
| | | cancelButtonText:'取消', |
| | | type:'warning', |
| | | }).then(()=> { |
| | | deleteRiskControlMeasure({id:val.id}).then( ()=>{ |
| | | this.getRiskControlMeasureData() |
| | | this.$notify({ |
| | | title:'成功', |
| | | message:'删除成功', |
| | | type:'success', |
| | | duration:2000, |
| | | }) |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | 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.getRiskControlMeasureData() |
| | | } 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() |
| | | }, |
| | | handleSizeChange(val){ |
| | | this.listQuery.pageSize = val |
| | | this.getRiskControlMeasureData() |
| | | }, |
| | | handleCurrentChange(val){ |
| | | this.listQuery.pageIndex = val |
| | | this.getRiskControlMeasureData() |
| | | }, |
| | | |
| | | ifShowButton (value){ |
| | | this.showCurrent = false |
| | | this.showOther = 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){ |
| | | this.riskControlMeasureIdList = val |
| | | }, |
| | | |
| | | getRowKey(value){ |
| | | return value.id |
| | | }, |
| | | |
| | | giveValue(value){ |
| | | this.$emit('giveRiskControlId',this.riskControlMeasureIdList) |
| | | // this.$emit('giveRiskControlId',value) |
| | | }, |
| | | showMeasureDetail(value){ |
| | | this.riskControlMeasureVisible = true |
| | | this.getRiskControlMeasureData().then( ()=>{ |
| | | let riskControlMeasureForm = this.riskControlMeasureData.find(item => item.id === value.measureId) |
| | | this.riskControlMeasureForm = riskControlMeasureForm |
| | | this.$emit('closeDialog') |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | .basic_search{ |
| | | display:inline-block; |
| | | padding-bottom: 10px; |
| | | } |
| | | .analyseUnit_input{ |
| | | width:320px; |
| | | } |
| | | </style> |