安全风险

master
Lion 4 years ago
parent f3838acc0c
commit 2c72301036

@ -0,0 +1,45 @@
import request from '@/utils/request'
export function listtask(params) {
return request({
url: '/api/admin/risk/index',
method: 'get',
params:params
})
}
export function store(data) {
return request({
url: '/api/admin/risk/store',
method: 'post',
data
})
}
export function save(data) {
return request({
url: '/api/admin/risk/save',
method: 'post',
data
})
}
export function del(id) {
return request({
url: '/api/admin/risk/destroy',
method: 'get',
params: {
id
}
})
}
export function get(id) {
return request({
url: '/api/admin/risk/show',
method: 'get',
params: {
id
}
})
}

@ -24,6 +24,11 @@
<Button ghost size="small" @click="edit(scope.row)" type="primary"
style="margin-left: 10px;">编辑</Button>
<Button ghost size="small" @click="del(scope.row)" type="error" style="margin-left: 10px;">删除</Button>
</div>
<div v-else-if="column.type=='level'" v-for="hazard in parameters.hazardLevel">
<div v-if='scope.row[column.field]==hazard.id'>
{{hazard.value}}
</div>
</div>
<div v-else>{{scope.row[column.field]}}</div>
</template>
@ -56,7 +61,7 @@
<el-col :span="8">
<el-form-item label="危险源等级" prop="level" label-position="right">
<el-select v-model="form.level" placeholder="请选择危险源等级" style="width: 100%">
<el-option v-for="item in parameters.accidentLevel" :key="item.id" :label="item.value"
<el-option v-for="item in parameters.hazardLevel" :key="item.id" :label="item.value"
:value="item.id">
</el-option>
</el-select>
@ -90,15 +95,6 @@
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
</el-form-item>
<!-- <el-form-item label="科室" prop="department_list">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">
</el-checkbox>
<div style="margin: 15px 0;"></div>
<el-checkbox-group v-model="form.department_list" @change="handleCheckedDeptChange">
<el-checkbox v-for="dept in deptOptions" :label="dept.id" :key="dept.id">{{dept.name}}</el-checkbox>
</el-checkbox-group>
</el-form-item> -->
</el-form>
</el-scrollbar>
</div>
@ -138,12 +134,9 @@
Tinymce
},
data() {
return {
checkAll: false,
isIndeterminate: true,
return {
parameters: {
accidentType: [],
accidentLevel: []
hazardLevel: []
},
paginations: {
page: 1,
@ -209,7 +202,6 @@
trigger: 'blur'
}],
},
indexUrl: "/api/admin/risk/hazardindex",
tableHeight: 900,
searchFields: {
KeyWord: ""
@ -235,7 +227,7 @@
{
field: "level",
title: "等级",
type: "string",
type: "level",
width: 180,
align: "center"
},
@ -276,20 +268,6 @@
reject(error)
})
},
handleCheckAllChange(val) {
console.log(val)
let options = [];
for (var m of this.deptOptions) {
options.push(m.id);
}
this.form.department_list = val ? options : [];
this.isIndeterminate = false;
},
handleCheckedDeptChange(value) {
let checkedCount = value.length;
this.checkAll = checkedCount === this.deptOptions.length;
this.isIndeterminate = checkedCount > 0 && checkedCount < this.deptOptions.length;
},
initLoad() {
var that = this;
var clientHeight = document.documentElement.clientHeight
@ -299,13 +277,8 @@
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
that.tableHeight = tableHeight;
//
getparameteritem("accidentLevel").then(res => {
this.parameters.accidentLevel = res.detail;
});
//
getparameteritem("accidentType").then(res => {
this.parameters.accidentType = res.detail;
getparameteritem("hazardLevel").then(res => {
this.parameters.hazardLevel = res.detail;
});
},
handleCurrentChange(page) {
@ -345,14 +318,8 @@
});
}
},
show(obj) {
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
this.dialogViewVisible = true;
this.info(obj);
},
info(obj) {
var that = this;
var that = this;
get(obj.id).then(res => {
let result = Object.assign(that.form, res);
that.form = result;

@ -1,8 +1,436 @@
<template>
</template>
<template>
<div class="container">
<!-- 查询配置 -->
<div style="padding: 0px 20px">
<div ref="lxHeader">
<LxHeader icon="md-apps" text="危险源信息" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content"></div>
<slot>
<div>
<Input style="width: 200px; margin-right: 10px" v-model="searchFields.KeyWord" placeholder="关键字搜索" />
<Button type="primary" @click="load" style="margin-left: 10px">查询</Button>
<Button type="primary" @click="edit()" style="margin-left: 10px">新增</Button>
</div>
</slot>
</LxHeader>
</div>
<div ref="lxTable">
<el-table :data="tableData" :height="tableHeight" style="width: 100%">
<el-table-column type="index" width="50" align="center"> </el-table-column>
<el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in columns"
:label="column.title" :width="column.width">
<template slot-scope="scope">
<div v-if="column.type=='opt'">
<Button ghost size="small" @click="edit(scope.row)" type="primary"
style="margin-left: 10px;">编辑</Button>
<Button ghost size="small" @click="del(scope.row)" type="error" style="margin-left: 10px;">删除</Button>
</div>
<div v-else-if="column.type=='level'" v-for="risklevel in parameters.riskLevel">
<div v-if='scope.row[column.field]==risklevel.id'>
{{risklevel.value}}
</div>
</div>
<div v-else-if="column.type=='type'" v-for="risktype in parameters.riskType">
<div v-if='scope.row[column.field]==risktype.id'>
{{risktype.value}}
</div>
</div>
<div v-else>{{scope.row[column.field]}}</div>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination @current-change="handleCurrentChange" :current-page="paginations.page"
:page-size="paginations.page_size" background layout="prev, pager, next" :total="paginations.total">
</el-pagination>
</div>
</div>
</div>
<el-dialog title="基础信息" :visible.sync="dialogFormVisible" fullscreen width="90%">
<div class="dialogConcent" :style="{height:clientHeight+'px'}">
<el-scrollbar style="flex: 1">
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
<el-row>
<el-col :span="8">
<el-form-item label="风险类别" prop="type" label-position="right">
<el-select v-model="form.type" placeholder="请选择风险类别" style="width: 100%">
<el-option v-for="item in parameters.riskType" :key="item.id" :label="item.value"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8" :offset="4">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请填写名称" autocomplete="off"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-form-item class="longtext" label="风险分析综述(至少包括人身事故/财产损失和环境破坏)" prop="overview">
<el-input type="textarea" :rows="3" v-model="form.overview" placeholder="请填写风险分析综述" autocomplete="off"></el-input>
</el-form-item>
<el-form-item class="longtext" label="控制措施描述(包括工程技术措施/个人防护措施等)" prop="measure">
<el-input type="textarea" :rows="3" v-model="form.measure" placeholder="请填写控制措施描述" autocomplete="off"></el-input>
</el-form-item>
<el-row>
<el-col :span="8">
<el-form-item label="控制级别" prop="level" label-position="right">
<el-select v-model="form.level" placeholder="请选择控制级别" style="width: 100%">
<el-option v-for="item in parameters.riskLevel" :key="item.id" :label="item.value"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item class="longtext" label="备注" prop="remark">
<el-input type="textarea" :rows="3" v-model="form.remark" placeholder="请填写备注" autocomplete="off"></el-input>
</el-form-item>
<div style="padding: 20px 0px;" class="form-sub-title">
<span>详细信息
</span>
</div>
<div class="table-tree tableswidth">
<div style="display: flex;justify-content: flex-end;margin-right: 20px;margin-bottom: 10px;">
<Button type="primary" @click="addRow()" size="small" style="margin-left: 10px;" ghost>新增参数</Button>
</div>
<el-table :data="this.form.details_list" height="400" class="v-table" style="width: 100%;margin-bottom: 20px;">
<el-table-column type="index" align="center">
</el-table-column>
<script>
</script>
<el-table-column prop="element" label="危险因素" width="320px">
<template slot-scope="scope">
<el-input v-model="scope.row.element" />
</el-input>
</template>
</el-table-column>
<el-table-column prop="evaluate_way" align="center" label="评价方法" width="480px">
<template slot-scope="scope">
<el-input v-model="scope.row.evaluate_way" />
</el-input>
</template>
</el-table-column>
<el-table-column prop="level" align="center" label="风险等级" width="200px">
<template slot-scope="scope">
<el-select v-model="scope.row.level" placeholder="请选择风险等级" style="width: 100%">
<el-option v-for="item in parameters.riskInfoLevel" :key="item.id" :label="item.value"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="操作" width="120px" align="center">
<template slot-scope="scope">
<Button type="error" @click="delRow(scope.$index)" size="small" style="margin-left: 10px;"
ghost>删除</Button>
</template>
</el-table-column>
</el-table>
</div>
</el-form>
</el-scrollbar>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="resetForm('form')"> </el-button>
<el-button type="primary" v-preventReClick @click="submitForm('form')"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getToken
} from '@/utils/auth'
import LxHeader from "@/components/LxHeader/index.vue";
import Tinymce from '@/components/Tinymce'
import {
save,
store,
del,
get,
listtask
} from "../../api/risk/riskindex.js";
import {
getparameteritem
} from "../../api/system/dictionary.js";
export default {
components: {
LxHeader,
Tinymce
},
data() {
return {
checkAll: false,
isIndeterminate: true,
infoFormVisible:false,
parameters: {
riskLevel: [],
riskType:[],
riskInfoLevel:[]
},
paginations: {
page: 1,
page_size: 15,
total: 0
},
tableHeight: 0,
dialogFormVisible: false,
formLabelWidth: "120px",
clientHeight: 0,
form: {
type: "",
name: "",
overview: "",
measure: "",
level: "",
remark: "",
details_list: [{
element:"",
evaluate_way:"",
level:""
}],
},
//
searchFields: {
KeyWord: ""
},
details_list: [],
tableData: [],
rules: {
type: [{
required: true,
message: '请选择风险类别',
trigger: 'blur'
}],
name: [{
required: true,
message: '请输入名称',
trigger: 'blur'
}],
overview: [{
required: true,
message: '请输入风险分析综述',
trigger: 'blur'
}],
measure: [{
required: true,
message: '请输入控制措施描述',
trigger: 'blur'
}],
level: [{
required: true,
message: '请选择控制级别',
trigger: 'blur'
}],
remark: [{
message: '请输入备注',
trigger: 'blur'
}],
},
columns: [{
field: "type",
title: "风险类别",
type: "type"
},
{
field: "name",
title: "名称",
type: "string",
width: 180
},
{
field: "overview",
title: "风险分析综述",
type: "string",
width: 180
},
{
field: "measure",
title: "控制措施描述",
width: 180,
},
{
field: "level",
title: "控制等级",
type: "level",
width: 180
<style>
},
{
field: "created_at",
title: "创建信息",
type: "string",
width: 180,
align: "center"
},
{
field: "操作",
title: "操作",
width: 220,
type: "opt",
}
]
}
},
created() {
this.initLoad();
this.load();
},
methods: {
addRow() {
var len = this.form.details_list.length;
this.form.details_list.push({
element:"",
evaluate_way:"",
level:""
});
},
delRow(index) {
this.form.details_list.splice(index, 1);
},
initLoad() {
var that = this;
var clientHeight = document.documentElement.clientHeight
var lxHeader_height = 96.5; //
var paginationHeight = 37; //
var topHeight = 50; //
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
that.tableHeight = tableHeight;
//
getparameteritem("riskLevel").then(res => {
this.parameters.riskLevel = res.detail;
});
//
getparameteritem("riskType").then(res => {
this.parameters.riskType = res.detail;
});
//
getparameteritem("riskInfoLevel").then(res => {
this.parameters.riskInfoLevel = res.detail;
});
},
handleCurrentChange(page) {
this.paginations.page = page;
this.load();
},
load() {
listtask({
page: this.paginations.page,
page_size: this.paginations.page_size,
}).then(response => {
this.tableData = response.data;
this.paginations.total = response.total;
}).catch(error => {
console.log(error)
reject(error)
})
},
del(obj) {
var that = this;
if (obj) {
this.$Modal.confirm({
title: '确认要删除数据?',
onOk: () => {
del(obj.id).then(response => {
this.$Message.success('操作成功');
that.load();
}).catch(error => {
console.log(error)
reject(error)
})
},
onCancel: () => {
//this.$Message.info('Clicked cancel');
}
});
}
},
info(obj) {
var that = this;
get(obj.id).then(res => {
let result = Object.assign(that.form, res);
that.form = result;
that.form.details_list = result.details;
}).catch(error => {
//reject(error)
})
},
edit(obj) {
this.form = this.$options.data().form;
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
if (obj) {
var that = this;
that.info(obj);
} else {}
this.dialogFormVisible = true;
},
submitForm(formName) {
var that = this;
this.$refs[formName].validate((valid) => {
if (valid) {
if (that.form.id) {
that.form.id = that.form.id;
save(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
} else {
store(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
}
} else {
this.$Message.error('数据校验失败');
console.log('error submit!!');
return false;
}
});
},
resetForm(formName) {
var that = this;
this.$refs[formName].resetFields();
that.dialogFormVisible = false;
},
}
}
</script>
<style>
.dialogConcent {
overflow-y: auto;
}
.longtext{
margin-left:43px;
}
.longtext label{
float:none;
text-align: left;
}
.longtext .el-form-item__content{
margin-left:0!important;
width:80%;
}
.tableswidth table{
width:100%!important;
}
</style>

Loading…
Cancel
Save