<template>
|
<div class="system-add-menu-container">
|
<el-dialog :title="title" :visible.sync="isShowSafetyActionDialog" width="600px" :close-on-click-modal="false">
|
<el-form :model="safetyActionForm" :rules="safetyActionFormRules" ref="safetyActionFormRef" size="default" label-width="120px">
|
<el-row :gutter="35">
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="作业类型" prop="workType">
|
<el-select class="input-add" :disabled="!disabled" v-model="safetyActionForm.workType" placeholder="请选择作业类型" filterable clearable>
|
<el-option v-for="item in workTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="措施类型" prop="type">
|
<el-select class="input-add" :disabled="!disabled" v-model="safetyActionForm.type" placeholder="请选择措施类型" clearable filterable>
|
<el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col v-if="safetyActionForm.type === 1" :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="正确值" prop="correctVal">
|
<el-select class="input-add" :disabled="!disabled" v-model="safetyActionForm.correctVal" placeholder="请选择正确值" clearable filterable>
|
<el-option v-for="item in typeTwoList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="措施内容" prop="context">
|
<el-input class="input-add" :disabled="!disabled" :rows="3" v-model.trim="safetyActionForm.context" type="textarea" placeholder="请输入描述"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<div class="dialog-footer" v-show="disabled" align="right">
|
<el-button @click="isShowSafetyActionDialog = !isShowSafetyActionDialog" size="default">取 消</el-button>
|
<el-button type="primary" @click="submitSafetyAction" size="default">确 定</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import {safetyActionApi} from "../../../../../api/safetyAction";
|
|
export default {
|
name: 'SafetyActionDialog',
|
data(){
|
return{
|
title: '',
|
disabled: false,
|
personTime: false,
|
departmentList: [],
|
isShowSafetyActionDialog: false,
|
workTypeList: [
|
{ id: 1, name: '动火作业' },
|
{ id: 2, name: '受限空间作业' },
|
{ id: 3, name: '吊装作业' },
|
{ id: 4, name: '动土作业' },
|
{ id: 5, name: '断路作业' },
|
{ id: 6, name: '高处作业' },
|
{ id: 7, name: '临时用电作业' },
|
{ id: 8, name: '盲板抽堵作业' }
|
],
|
typeList: [
|
{ id: 1, name: '选择' },
|
{ id: 2, name: '填空' }
|
],
|
typeTwoList: [
|
{ id: 1, name: '是' },
|
{ id: 2, name: '否' }
|
],
|
safetyActionForm: {
|
workType: null,
|
type: null,
|
correctVal: null,
|
context: null
|
},
|
safetyActionFormRules: {
|
workType: [{ required: true, message: '请选择作业类型', trigger: 'change' }],
|
type: [{ required: true, message: '请选择措施类型', trigger: 'change' }],
|
correctVal: [{ required: true, message: '请选择正确值', trigger: 'change' }],
|
context: [{ required: true, message: '请填写措施内容', trigger: 'blur' }]
|
}
|
}
|
},
|
methods:{
|
showSafetyActionDialog(type, value, department) {
|
this.isShowSafetyActionDialog = true;
|
this.departmentList = department;
|
this.$nextTick(() =>{
|
this.$refs["safetyActionFormRef"].clearValidate()
|
})
|
if (type === '新增') {
|
this.disabled = true;
|
this.personTime = false;
|
this.title = '新增安全措施';
|
this.safetyActionForm = {
|
workType: null,
|
type: null,
|
correctVal: null,
|
context: null
|
};
|
} else if (type === '查看') {
|
this.disabled = false;
|
this.personTime = true;
|
this.title = '查看安全措施';
|
this.safetyActionForm = JSON.parse(JSON.stringify(value));
|
} else {
|
this.disabled = true;
|
this.personTime = false;
|
this.title = '修改安全措施';
|
this.safetyActionForm = JSON.parse(JSON.stringify(value));
|
}
|
},
|
|
submitSafetyAction() {
|
this.$refs["safetyActionFormRef"].validate(async (valid) => {
|
if (valid) {
|
if (this.title === '新增安全措施') {
|
let res = await safetyActionApi().addSafetyAction(this.safetyActionForm);
|
if (res.data.code === '200') {
|
this.$message({
|
type: 'success',
|
message: '安全措施新增成功',
|
duration: 2000
|
});
|
this.isShowSafetyActionDialog = false;
|
context.emit('refreshSafetyAction');
|
} else {
|
this.$message({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
} else {
|
let res = await safetyActionApi().modSafetyAction(this.safetyActionForm);
|
if (res.data.code === '200') {
|
this.$message({
|
type: 'success',
|
message: '安全措施改成功',
|
duration: 2000
|
});
|
this.isShowSafetyActionDialog = false;
|
context.emit('refreshSafetyAction');
|
} else {
|
this.$message({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
}
|
} else {
|
this.$message({
|
type: 'warning',
|
message: '请完善基本信息'
|
});
|
}
|
});
|
},
|
},
|
};
|
</script>
|
|
<style scoped></style>
|