From fd285d6245ddd54c2eef8237eb878f573d665f94 Mon Sep 17 00:00:00 2001 From: Your Name <123456> Date: 星期四, 07 七月 2022 18:27:39 +0800 Subject: [PATCH] lct --- src/views/doublePreventSystem/riskLevelManage/riskControlMeasure/components/riskControlMeasureDialog.vue | 390 ++++++++++++++++++++++++++++++++----------------------- 1 files changed, 228 insertions(+), 162 deletions(-) diff --git a/src/views/doublePreventSystem/riskLevelManage/riskControlMeasure/components/riskControlMeasureDialog.vue b/src/views/doublePreventSystem/riskLevelManage/riskControlMeasure/components/riskControlMeasureDialog.vue index 466935b..71b95a8 100644 --- a/src/views/doublePreventSystem/riskLevelManage/riskControlMeasure/components/riskControlMeasureDialog.vue +++ b/src/views/doublePreventSystem/riskLevelManage/riskControlMeasure/components/riskControlMeasureDialog.vue @@ -1,198 +1,264 @@ <template> <div class="system-add-menu-container"> <el-dialog :title="title" v-model="isRiskControlMeasureDialog" width="600px"> - <el-form :model="riskControlMeasureForm" :rules="riskControlMeasureFormRules" ref="riskControlMeasureFormRef" size="default" label-width="160px"> + <el-form + :model="riskControlMeasureForm" + :rules="riskControlMeasureFormRules" + ref="riskControlMeasureFormRef" + size="default" + label-width="160px" + > <el-row :gutter="35"> <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> - <el-form-item label="安全风险分析对象编码" prop="riskCode"> - <el-input class="input-length" v-model="riskControlMeasureForm.riskCode" placeholder="请输入安全风险分析对象编码"></el-input> - </el-form-item> - </el-col> - <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> - <el-form-item label="安全风险分析单元名称" prop="riskUnitName"> - <el-input class="input-length" v-model="riskControlMeasureForm.riskUnitName" placeholder="请输入安全风险分析单元名称"></el-input> - </el-form-item> - </el-col> - <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> - <el-form-item label="生产装置名称" prop="produceDeviceId"> - <el-input class="input-length" v-model="riskControlMeasureForm.produceDeviceId" placeholder="请输入生产装置名称" clearable></el-input> - </el-form-item> - </el-col> - <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> - <el-form-item label="责任部门" prop="liableDepId"> - <el-cascader - :options="departmentList" - :props="{ emitPath: false, checkStrictly: true, value: 'id', label: 'name' }" - placeholder="请选择部门" - clearable - filterable - style="width:85%" - v-model="riskControlMeasureForm.liableDepId" - > - </el-cascader> - </el-form-item> - </el-col> - <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> - <el-form-item label="责任人" prop="liablePersonId"> - <el-select class="input-length" v-model="riskControlMeasureForm.liablePersonId" placeholder="请选择风险等级" clearable filterable> + <el-form-item label="风险事件名称" prop="riskEventId"> + <el-select class="input-length" v-model="riskControlMeasureForm.riskEventId" placeholder="请选择风险事件" clearable> <el-option - v-for="item in levelList" - :key="item.id" - :label="item.name" - :value="item.id" + v-for="item in allSafetyRiskEventData" + :key="item.id" + :label="item.riskEventName" + :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="controlMeasureCode"> + <el-input + class="input-length" + v-model="riskControlMeasureForm.controlMeasureCode" + placeholder="请输入风险措施编码" + ></el-input> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="管控方式" prop="controlType"> + <el-select class="input-length" v-model="riskControlMeasureForm.controlType" placeholder="请选择管控方式" clearable> + <el-option v-for="item in controlTypeList" :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="checkContent"> + <el-input + class="input-length" + type="textarea" + :rows="3" + v-model="riskControlMeasureForm.checkContent" + placeholder="请输入管控内容" + clearable + > + </el-input> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="管控措施分类1" prop="classify1"> + <el-select + class="input-length" + v-model="riskControlMeasureForm.classify1" + @change="changeClassifyTwoList" + placeholder="请选择管控方式" + clearable + > + <el-option v-for="item in classifyOneList" :key="item.id" :label="item.riskMeasureName" :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="管控措施分类2" prop="classify2"> + <el-select class="input-length" v-model="riskControlMeasureForm.classify2" placeholder="请选择管控方式" clearable> + <el-option v-for="item in classifyTwoList" :key="item.id" :label="item.riskMeasureName" :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="管控措施分类3" prop="classify3"> + <el-input class="input-length" v-model="riskControlMeasureForm.classify3" placeholder="请选择管控方式" clearable> + </el-input> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="措施说明" prop="measureDesc"> + <el-input + class="input-length" + type="textarea" + :rows="3" + v-model="riskControlMeasureForm.measureDesc" + placeholder="请输入措施说明" + clearable + > + </el-input> </el-form-item> </el-col> </el-row> </el-form> <template #footer> - <span class="dialog-footer"> - <el-button @click="isRiskControlMeasureDialog = !isRiskControlMeasureDialog" size="default">取 消</el-button> - <el-button type="primary" @click="submitRiskControlMeasureDialog" size="default">确 实</el-button> - </span> + <span class="dialog-footer"> + <el-button @click="isRiskControlMeasureDialog = !isRiskControlMeasureDialog" size="default">取 消</el-button> + <el-button type="primary" @click="submitRiskControlMeasureDialog" v-throttle size="default">确 实</el-button> + </span> </template> </el-dialog> </div> </template> <script lang="ts"> - interface stateType{ - isRiskControlMeasureDialog:Boolean, - riskControlMeasureForm:{ - riskCode: string | null, - riskUnitName: string | null, - liablePersonId: number | null, - liableDepId: number | null, - produceDeviceId: number | null, - }, - title: string, - departmentList: [], - levelList: Array<levelListState>, - riskControlMeasureFormRules:{} - } - interface levelListState { +interface stateType { + isRiskControlMeasureDialog: Boolean; + riskControlMeasureForm: { + riskEventId: number | null; + controlMeasureCode: string | null; + controlType: number | null; + checkContent: string | null; + classify1: number | null; + classify2: number | null; + classify3: string | null; + measureDesc: string | null; + }; + title: string; + controlTypeList: Array<controlTypeListType>; + classifyOneList: []; + classifyTwoList: Array<classifyTwoType>; + classifyTwoListAll: []; + allSafetyRiskEventData: []; + riskControlMeasureFormRules: {}; +} +interface classifyTwoType { + id: number; + riskMeasureName: string; +} +interface controlTypeListType {} - } - import { reactive, toRefs, ref} from 'vue' - import { riskControlMeasureApi } from '/@/api/doublePreventSystem/riskControlMeasure'; - import { ElMessage } from 'element-plus'; - export default { - name: "riskControlMeasureDialog", - setup(props, context) { - const riskControlMeasureFormRef = ref(); - const state = reactive<stateType>({ - title:'', - departmentList: [], - isRiskControlMeasureDialog: false, - levelList:[{id:1,name:'低风险'},{id:2,name:'一般风险'},{id:3,name:'较大风险'},{id:4,name:'重大风险'},], - riskControlMeasureForm: { - riskCode: null, - riskUnitName: null, - liablePersonId: null, - liableDepId: null, - produceDeviceId: null, - }, - riskControlMeasureFormRules:{ - riskCode: [ - { required: true, message: '请填写安全风险分析对象编码', trigger: 'blur' }, - ], - riskUnitName: [ - { required: true, message: '请填写安全风险分析单元名称', trigger: 'blur' }, - ], - liableDepId: [ - { required: true, message: '请选择责任部门', trigger: 'change' }, - ], - liablePersonId: [ - { required: true, message: '请选择责任人', trigger: 'change' }, - ], - produceDeviceId: [ - { required: true, message: '请选择生产装置', trigger: 'change' }, - ], - } +import { reactive, toRefs, ref } from 'vue'; +import { riskControlMeasureApi } from '/@/api/doublePreventSystem/riskControlMeasure'; +import { ElMessage } from 'element-plus'; +export default { + name: 'riskControlMeasureDialog', + setup(props: any, context: any) { + const riskControlMeasureFormRef = ref(); + const state = reactive<stateType>({ + title: '', + controlTypeList: [ + { id: 1, name: '自动化监控' }, + { id: 2, name: '隐患排查' } + ], + classifyOneList: [], + classifyTwoList: [], + classifyTwoListAll: [], + allSafetyRiskEventData: [], + isRiskControlMeasureDialog: false, + riskControlMeasureForm: { + riskEventId: null, + controlMeasureCode: null, + controlType: null, + checkContent: null, + classify1: null, + classify2: null, + classify3: null, + measureDesc: null + }, + riskControlMeasureFormRules: { + riskCode: [{ required: true, message: '请填写安全风险分析对象编码', trigger: 'blur' }], + riskUnitName: [{ required: true, message: '请填写安全风险分析单元名称', trigger: 'blur' }], + liableDepId: [{ required: true, message: '请选择责任部门', trigger: 'change' }], + liablePersonId: [{ required: true, message: '请选择责任人', trigger: 'change' }], + produceDeviceId: [{ required: true, message: '请选择生产装置', trigger: 'change' }] + } + }); + //打开模态框 + const openSafetyRiskEventDialog = (type: string, value: object, allSafetyRiskEventData: [], classifyOneList: [], classifyTwoList: []) => { + state.isRiskControlMeasureDialog = true; + state.allSafetyRiskEventData = JSON.parse(JSON.stringify(allSafetyRiskEventData)); + state.classifyOneList = JSON.parse(JSON.stringify(classifyOneList)); + state.classifyTwoListAll = JSON.parse(JSON.stringify(classifyTwoList)); + state.classifyTwoList = []; + setTimeout(() => { + riskControlMeasureFormRef.value.clearValidate(); }); + if (type === '新增') { + state.title = '新增风险管控措施'; + state.riskControlMeasureForm = { + riskEventId: null, + controlMeasureCode: null, + controlType: null, + checkContent: null, + classify1: null, + classify2: null, + classify3: null, + measureDesc: null + }; + } else { + state.title = '修改风险管控措施'; + state.riskControlMeasureForm = JSON.parse(JSON.stringify(value)); + } + }; - //打开模态框 - const openSafetyRiskEventDialog = (type: string, value: object, department: []) => { - state.isRiskControlMeasureDialog = true; - state.departmentList = department; - setTimeout(() => { - riskControlMeasureFormRef.value.clearValidate() - }) - if(type === '新增'){ - state.title = '新增生产装置'; - state.riskControlMeasureForm = { - riskCode: null, - riskUnitName: null, - liablePersonId: null, - liableDepId: null, - produceDeviceId: null, - }; - }else{ - state.title = '修改生产装置'; - state.riskControlMeasureForm = JSON.parse(JSON.stringify(value)); - } - }; + const changeClassifyTwoList = () => { + debugger; + state.riskControlMeasureForm.classify2 = null; + state.classifyTwoList = []; + state.classifyTwoList = state.classifyTwoListAll.filter((item: any) => item.parentId === state.riskControlMeasureForm.classify1); + }; - //新增修改提交 - const submitRiskControlMeasureDialog = async () => { - riskControlMeasureFormRef.value.validate( async (valid: Boolean) => { - if(valid){ - if(state.title === '新增生产装置'){ - let res = await riskControlMeasureApi().addRiskControlMeasure(state.riskControlMeasureForm); - if(res.data.code === '200'){ - ElMessage({ - type:'success', - message:'生产装置新增成功', - duration:2000 - }); - state.isRiskControlMeasureDialog = false; - context.emit('refreshRiskControlMeasure'); - }else{ - ElMessage({ - type:'warning', - message:res.data.msg - }); - } - }else{ - let res = await riskControlMeasureApi().modRiskControlMeasure(state.riskControlMeasureForm); - if(res.data.code === '200'){ - ElMessage({ - type:'success', - message:'生产装置修改成功', - duration:2000 + //新增修改提交 + const submitRiskControlMeasureDialog = async () => { + riskControlMeasureFormRef.value.validate(async (valid: Boolean) => { + if (valid) { + if (state.title === '新增风险管控措施') { + let res = await riskControlMeasureApi().addRiskControlMeasure(state.riskControlMeasureForm); + if (res.data.code === '200') { + ElMessage({ + type: 'success', + message: '风险管控措施新增成功', + duration: 2000 }); state.isRiskControlMeasureDialog = false; context.emit('refreshRiskControlMeasure'); - }else{ - ElMessage({ - type:'warning', - message:res.data.msg - }); - } + } else { + ElMessage({ + type: 'warning', + message: res.data.msg + }); } - }else{ - ElMessage({ - type:'warning', - message:'请完善基本信息', - }); + } else { + let res = await riskControlMeasureApi().modRiskControlMeasure(state.riskControlMeasureForm); + if (res.data.code === '200') { + ElMessage({ + type: 'success', + message: '风险管控措施修改成功', + duration: 2000 + }); + state.isRiskControlMeasureDialog = false; + context.emit('refreshRiskControlMeasure'); + } else { + ElMessage({ + type: 'warning', + message: res.data.msg + }); + } } - }) - } + } else { + ElMessage({ + type: 'warning', + message: '请完善基本信息' + }); + } + }); + }; - return{ - ...toRefs(state), - riskControlMeasureFormRef, - submitRiskControlMeasureDialog, - openSafetyRiskEventDialog, - }; - } + return { + ...toRefs(state), + riskControlMeasureFormRef, + changeClassifyTwoList, + submitRiskControlMeasureDialog, + openSafetyRiskEventDialog + }; } +}; </script> <style scoped> -.input-length{ - width:85%; +.input-length { + width: 85%; } </style> -- Gitblit v1.9.2