| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="filter-container"> |
| | | <!-- <div class="basic_search">--> |
| | | <!-- <span>巡检开始时间:</span>--> |
| | | <!-- <el-date-picker v-model="listQuery.startTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="开始时间"></el-date-picker>--> |
| | | <!-- </div>--> |
| | | <!-- <div class="basic_search">--> |
| | | <!-- <span>巡检结束时间:</span>--> |
| | | <!-- <el-date-picker v-model="listQuery.endTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="结束时间"></el-date-picker>--> |
| | | <!-- </div>--> |
| | | <div class="basic_search"> |
| | | <span>巡检开始时间:</span> |
| | | <el-date-picker v-model="listQuery.startTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="开始时间"></el-date-picker> |
| | | </div> |
| | | <div class="basic_search"> |
| | | <span>巡检结束时间:</span> |
| | | <el-date-picker v-model="listQuery.endTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="结束时间"></el-date-picker> |
| | | </div> |
| | | <div class="basic_search"> |
| | | <span>风险源名称:</span> |
| | | <el-input v-model="listQuery.name" class="analyseUnit_input"> |
| | | <span>生产装置名称:</span> |
| | | <el-input v-model="listQuery.produceDeviceName" class="analyseUnit_box"> |
| | | </el-input> |
| | | </div> |
| | | <div class="basic_search"> |
| | | <span>风险类型:</span> |
| | | <el-select v-model="listQuery.type"> |
| | | <el-option |
| | | v-for="item in typeList" |
| | | :key="item.id" |
| | | :value="item.id" |
| | | :label="item.name" |
| | | ></el-option> |
| | | </el-select> |
| | | </div> |
| | | <div class="basic_search"> |
| | | <span>风险等级:</span> |
| | | <el-select v-model="listQuery.level"> |
| | | <el-select v-model="listQuery.riskLevel"> |
| | | <el-option |
| | | v-for="item in levelList" |
| | | :key="item.id" |
| | |
| | | ></el-option> |
| | | </el-select> |
| | | </div> |
| | | <div class="basic_search"> |
| | | <span>状态:</span> |
| | | <el-select v-model="listQuery.status"> |
| | | <el-option |
| | | v-for="item in statusList" |
| | | :key="item.id" |
| | | :value="item.id" |
| | | :label="item.name" |
| | | ></el-option> |
| | | </el-select> |
| | | </div> |
| | | <!-- <div class="basic_search">--> |
| | | <!-- <span>状态:</span>--> |
| | | <!-- <el-select v-model="listQuery.status">--> |
| | | <!-- <el-option--> |
| | | <!-- v-for="item in statusList"--> |
| | | <!-- :key="item.id"--> |
| | | <!-- :value="item.id"--> |
| | | <!-- :label="item.name"--> |
| | | <!-- ></el-option>--> |
| | | <!-- </el-select>--> |
| | | <!-- </div>--> |
| | | <div class="basic_search"> |
| | | <span>所属部门名称:</span> |
| | | <el-select v-model="listQuery.depId"> |
| | | <el-option |
| | | v-for="item in departmentList" |
| | | :key="item.id" |
| | | :value="item.department" |
| | | :value="item.id" |
| | | :label="item.department" |
| | | ></el-option> |
| | | </el-select> |
| | | </div> |
| | | <div class="basic_search"> |
| | | <span>区域位置:</span> |
| | | <el-input v-model="listQuery.location" class="analyseUnit_input"> |
| | | </el-input> |
| | | </div> |
| | | <!-- <div class="basic_search">--> |
| | | <!-- <span>区域位置:</span>--> |
| | | <!-- <el-input v-model="listQuery.location" class="analyseUnit_box">--> |
| | | <!-- </el-input>--> |
| | | <!-- </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="showRiskSourceForm('','新增')">新增</el-button> |
| | | </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="showRiskSourceForm('','新增')">新增</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" |
| | |
| | | highlight-current-row |
| | | style="width: 100%;" |
| | | > |
| | | <el-table-column label="风险源名称" prop="name" align="center"> |
| | | <el-table-column type="index" label="序号" width="60" /> |
| | | <el-table-column prop="produceDeviceName" label="生产装置名称" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="depName" label="所属部门" show-overflow-tooltip> |
| | | </el-table-column> |
| | | <el-table-column label="点位类型" prop="type" align="center"> |
| | | <el-table-column prop="riskLevel" label="风险等级" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.type | parseType}} |
| | | <el-tag :type="scope.row.riskLevel === 1 ? 'success' : scope.row.riskLevel === 2 ? 'info' : scope.row.riskLevel === 3 ? 'warning' : 'danger'"> |
| | | {{ parseNumber(scope.row.riskLevel, '风险等级') }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="风险等级" prop="level" align="center"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.level | parseLevel}} |
| | | <el-table-column prop="location" label="区域位置" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="status" label="状态" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag :type="scope.row.status === 1 ? 'primary' : 'warning'"> |
| | | {{ parseNumber(scope.row.status, '状态') }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="可能导致的主要事故类型" prop="accidentDesc" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="区域位置" prop="location" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="所属单位" prop="depName" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="创建人" prop="createUname" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" prop="createTime" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="最后修改人" prop="editUname" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="最后修改时间" prop="editTime" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="状态" prop="status" align="center"> |
| | | <template slot-scope="scope"> |
| | | <div v-for="item in statusList"> |
| | | <div v-show="item.id === scope.row.status"> |
| | | <el-tag :type="scope.row.status === 1 ? 'success' : (scope.row.status === 2 ? 'warning' : 'danger')">{{item.name}}</el-tag> |
| | | </div> |
| | | </div> |
| | | </template>> |
| | | </el-table-column> |
| | | <el-table-column prop="createByUserName" label="创建人" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="gmtCreate" label="创建时间" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="lastEditUserName" label="最后修改人" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="gmtModitify" label="最后修改时间" show-overflow-tooltip></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="showRiskSourceForm(scope.row,'编辑')">编辑</el-button> |
| | |
| | | <br> |
| | | <el-pagination |
| | | v-show="recordTotal>0" |
| | | :current-page="currentPage" |
| | | :current-page="listQuery.pageIndex" |
| | | :page-sizes="[10, 20, 30, 50]" |
| | | :page-size="pageSize" |
| | | :page-size="listQuery.pageSize" |
| | | :total="recordTotal" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | background |
| | |
| | | </div> |
| | | <el-dialog :title="title" :visible.sync="riskSourceVisible" :modal-append-to-body="false" :close-on-click-modal="false" width="600px"> |
| | | <el-form ref="riskSourceForm" :rules="riskSourceFormRules" :model="riskSourceForm" label-position="right" label-width="165px"> |
| | | <el-form-item label="风险源名称" prop="name"> |
| | | <el-input v-model="riskSourceForm.name" class="analyseUnit_input"> |
| | | <el-form-item label="生产装置名称" prop="produceDeviceName"> |
| | | <el-input v-model="riskSourceForm.produceDeviceName" class="analyseUnit_input" placeholder="请输入生产装置名称"> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="风险源类型" prop="type"> |
| | | <el-select v-model="riskSourceForm.type" class="analyseUnit_input"> |
| | | <el-form-item label="所属部门" prop="depId"> |
| | | <el-select v-model="riskSourceForm.depId" class="analyseUnit_input" placeholder="请选择所属部门"> |
| | | <el-option |
| | | v-for="item in typeList" |
| | | v-for="item in departmentList" |
| | | :key="item.id" |
| | | :value="item.id" |
| | | :label="item.name" |
| | | :label="item.department" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="风险等级" prop="level"> |
| | | <el-select v-model="riskSourceForm.level" class="analyseUnit_input"> |
| | | <el-form-item label="风险等级" prop="riskLevel"> |
| | | <el-select v-model="riskSourceForm.riskLevel" class="analyseUnit_input" placeholder="请选择风险等级"> |
| | | <el-option |
| | | v-for="item in levelList" |
| | | :key="item.id" |
| | |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="可能导致事故的主要原因" prop="accidentDesc"> |
| | | <el-input v-model="riskSourceForm.accidentDesc" class="analyseUnit_input"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="区域位置" prop="location"> |
| | | <el-input v-model="riskSourceForm.location" class="analyseUnit_input"></el-input> |
| | | <el-input v-model="riskSourceForm.location" class="analyseUnit_input" placeholder="请填写区域位置"> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="所属部门" prop="depId"> |
| | | <el-select v-model="riskSourceForm.depId" class="analyseUnit_input"> |
| | | <el-option |
| | | v-for="item in departmentList" |
| | | :key="item.id" |
| | | :value="item.id" |
| | | :label="item.department" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | </el-form> |
| | | <div align="right"> |
| | | <el-button @click="riskSourceVisible = false">取消</el-button> |
| | | <el-button type="primary" @click="submitRiskSourceForm()">确认</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> |
| | |
| | | import { computePageCount } from '@/utils' |
| | | import { getRiskSourceList , addRiskSource , updateRiskSource , deleteById } from '@/api/riskSource' |
| | | import {getAllDepartment, getDepartmentList} from "../../../../api/departmentManage"; |
| | | import {deleteRiskSource, exportRiskSource, importRiskSource} from "../../../../api/riskSource"; |
| | | import {parseError} from "../../../../utils/messageDialog"; |
| | | const exampleFile = require('@/assets/example/riskSource.xlsx') |
| | | export default { |
| | | name: 'index', |
| | | filters: { |
| | |
| | | title:'', |
| | | company:'', |
| | | code:'', |
| | | importDialogFormVisible:false, |
| | | riskSourceVisible:false, |
| | | riskSourceFormRules:{ |
| | | name: [{ required: true, message: '风险名称不能为空', trigger: 'blur' }], |
| | | produceDeviceName: [{ required: true, message: '请填写生产装置名称', trigger: 'blur' }], |
| | | depId: [{ required: true, message: '请选择部门', trigger: 'change' }], |
| | | riskLevel: [{ required: true, message: '请选择风险等级', trigger: 'change' }], |
| | | location: [{ required: true, message: '请填写区域位置', trigger: 'blur' }] |
| | | }, |
| | | riskSourceForm:{ |
| | | accidentDesc: "", |
| | | produceDeviceName: '', |
| | | depId: null, |
| | | editUid: null, |
| | | id: null, |
| | | level: null, |
| | | location: "", |
| | | name: "", |
| | | type: null |
| | | riskLevel: null, |
| | | location: '' |
| | | }, |
| | | listQuery:{ |
| | | startTime:'', |
| | | endTime:'', |
| | | type:'', |
| | | status:'', |
| | | level:'', |
| | | depId:'', |
| | | depName:'', |
| | | location:'', |
| | | pageIndex:1, |
| | | pageSize:10, |
| | | name:'', |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | riskLevel: null, |
| | | status: 1, |
| | | depId:null, |
| | | produceDeviceName: null |
| | | }, |
| | | } |
| | | }, |
| | |
| | | this.listLoading = true |
| | | let res = await getRiskSourceList(this.listQuery) |
| | | if(res.data.code === '200'){ |
| | | this.recordTotal =JSON.parse(res.data.message).totalCount |
| | | this.pageSize = JSON.parse(res.data.message).pageSize |
| | | this.pageTotal = computePageCount(this.recordTotal, this.pageSize) |
| | | this.currentPage = JSON.parse(res.data.message).pageIndex |
| | | this.riskSourceData = res.data.result |
| | | this.recordTotal = res.data.count |
| | | this.riskSourceData = res.data.data |
| | | }else{ |
| | | this.$message({ |
| | | message:res.data.message, |
| | |
| | | message:res.data.message, |
| | | type:'warning' |
| | | }) |
| | | if(res.data.code === '50001'){ |
| | | this.riskSourceData = [] |
| | | } |
| | | } |
| | | }, |
| | | parseNumber (value,type) { |
| | | if (type === '风险等级') { |
| | | return this.levelList.find((item) => item.id === value).name; |
| | | } else if (type === '状态') { |
| | | return this.statusList.find((item) => item.id === value).name; |
| | | } |
| | | }, |
| | | showRiskSourceForm(value,type){ |
| | |
| | | if(type === '新增'){ |
| | | this.title = '新增' |
| | | this.riskSourceForm = { |
| | | accidentDesc: "", |
| | | produceDeviceName: '', |
| | | depId: null, |
| | | editUid: null, |
| | | id: null, |
| | | level: null, |
| | | location: "", |
| | | name: "", |
| | | type: null |
| | | riskLevel: null, |
| | | location: '' |
| | | } |
| | | }else{ |
| | | this.title = '编辑' |
| | | for( let key in this.riskSourceForm){ |
| | | this.riskSourceForm[key] = JSON.parse(JSON.stringify(value))[key] |
| | | } |
| | | this.riskSourceForm.id = JSON.parse(JSON.stringify(value)).id |
| | | } |
| | | }, |
| | | submitRiskSourceForm(){ |
| | |
| | | cancelButtonText:'取消', |
| | | type:'warning', |
| | | }).then(()=> { |
| | | deleteAnalyseUnit({id:val.id}).then( ()=>{ |
| | | this.getRiskSourceData() |
| | | this.$notify({ |
| | | title:'成功', |
| | | message:'删除成功', |
| | | type:'success', |
| | | duration:2000, |
| | | }) |
| | | deleteRiskSource({id:val.id}).then( (res)=>{ |
| | | if(res.data.code === '200'){ |
| | | this.getRiskSourceData() |
| | | this.$notify({ |
| | | title:'成功', |
| | | message:'删除成功', |
| | | type:'success', |
| | | duration:2000, |
| | | }) |
| | | }else{ |
| | | this.$message({ |
| | | type:'warning', |
| | | message:res.data.message |
| | | }) |
| | | } |
| | | |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | |
| | | 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]) |
| | | } |
| | | importRiskSource(formData).then((response) => { |
| | | const res = response.data |
| | | if (res.code == 200) { |
| | | this.importDialogFormVisible = false |
| | | this.$message({ |
| | | message: '导入成功', |
| | | type: 'success' |
| | | }) |
| | | this.getRiskSourceData() |
| | | } else { |
| | | parseError({ error: res.message, vm: this }) |
| | | } |
| | | }).catch((error) => { |
| | | parseError({ error: error, vm: this }) |
| | | }) |
| | | }, |
| | | |
| | | exportToExcel() { |
| | | exportRiskSource(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 = [ |
| | | 'name', |
| | | 'level', |
| | | 'accidentDesc', |
| | | 'location', |
| | | 'depName', |
| | | ] |
| | | 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.listQuery.pageIndex = 1 |
| | | this.getRiskSourceData() |
| | | }, |
| | | handleSizeChange(val){ |
| | |
| | | padding-bottom: 10px; |
| | | } |
| | | .analyseUnit_input{ |
| | | width:90%; |
| | | } |
| | | .analyseUnit_box{ |
| | | width:200px; |
| | | } |
| | | </style> |