From cd92b35c810d6a762e9c30b896c38928e2d2d87a Mon Sep 17 00:00:00 2001 From: zhaojiale <631455805@qq.com> Date: 星期一, 15 八月 2022 14:41:19 +0800 Subject: [PATCH] 事故快报与应急队伍修改 --- src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue | 104 +++++++++++++++++++------- src/views/contingencyManagement/contingency/component/openAdd.vue | 112 ++++++++++++++++++--------- 2 files changed, 150 insertions(+), 66 deletions(-) diff --git a/src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue b/src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue index 4e7f072..51af58b 100644 --- a/src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue +++ b/src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue @@ -55,7 +55,7 @@ <el-radio :label="false">否</el-radio> </el-radio-group> <el-button v-if="ruleForm.casualties" type="primary" style="margin-left: 20px" - :icon="Edit" @click="openDai" round plain /> + :icon="Edit" @click="openDai(ruleFormRef)" round plain /> </el-form-item> </el-col> <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> @@ -120,7 +120,7 @@ import { reactive, ref, defineComponent, defineEmits, onMounted } from 'vue'; import type { UploadUserFile, FormInstance, FormRules } from 'element-plus'; -import { ElMessage } from 'element-plus'; +import { ElMessage,ElMessageBox, } from 'element-plus'; import { Search, FullScreen, Edit } from '@element-plus/icons-vue'; import NumberOfCasualties from '/@/views/accidentManagementSystem/accidentExpress/component/numberOfCasualties.vue'; import UserSelections from '/@/components/userSelections/index.vue'; @@ -317,27 +317,37 @@ await formEl.validate((valid, fields) => { if (valid) { isShowDialog.value = false; - ruleForm.value.id = null; - accidentManagementSystemApi() - .accidentAdd(ruleForm.value) - .then((res) => { - if (res.data.code == 200) { - ElMessage({ - showClose: true, - message: res.data.msg, - type: 'success', - }); - emit('myAdd', true); - } else { - ElMessage({ - showClose: true, - message: res.data.msg, - type: 'error', - }); - emit('myAdd', true); - } - formEl.resetFields(); + if(ruleForm.value.id==null||ruleForm.value.id==''){ + ruleForm.value.id = null; + accidentManagementSystemApi() + .accidentAdd(ruleForm.value) + .then((res) => { + if (res.data.code == 200) { + ElMessage({ + showClose: true, + message: res.data.msg, + type: 'success', + }); + emit('myAdd', true); + } else { + ElMessage({ + showClose: true, + message: res.data.msg, + type: 'error', + }); + emit('myAdd', true); + } + formEl.resetFields(); + }); + }else { + ElMessage({ + showClose: true, + message: '添加成功', + type: 'success', }); + emit('myAdd', true); + } + } else { console.log('error submit!', fields); } @@ -403,13 +413,51 @@ console.log('tag', ruleForm); }; const ShowUser = ref(); - const openDai = () => { + const openDai = async (formEl: FormInstance | undefined) => { if(ruleForm.value.id==null||ruleForm.value.id==''){ - ElMessage({ - showClose: true, - message: '请先添加事故快报', - type: 'info', - }); + if(!ruleForm.value.fileList){ + ruleForm.value.fileList = [] + } + if (!formEl) return; + await formEl.validate((valid, fields) => { + if (valid) { + // isShowDialog.value = false; + ElMessageBox.confirm('确认添加此事故快报?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + .then(() => { + accidentManagementSystemApi() + .accidentAdd(ruleForm.value) + .then((res) => { + if (res.data.code == 200) { + ElMessage({ + showClose: true, + message: res.data.msg, + type: 'success', + }); + ruleForm.value.id = res.data.data.id + ShowUser.value.openDialog(ruleForm.value.id, disabled.value); + } else { + ElMessage({ + showClose: true, + message: res.data.msg, + type: 'error', + }); + } + }); + }) + .catch(() => {}); + } else { + console.log('error submit!', fields); + } + }); + // ElMessage({ + // showClose: true, + // message: '请先添加事故快报', + // type: 'info', + // }); }else { ShowUser.value.openDialog(ruleForm.value.id, disabled.value); } diff --git a/src/views/contingencyManagement/contingency/component/openAdd.vue b/src/views/contingencyManagement/contingency/component/openAdd.vue index a36d5c7..2d9e986 100644 --- a/src/views/contingencyManagement/contingency/component/openAdd.vue +++ b/src/views/contingencyManagement/contingency/component/openAdd.vue @@ -62,7 +62,7 @@ <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick"> <el-tab-pane label="应急队伍人员" name="first" > - <el-button type="primary" size="default" @click="onAddEmergencyPersonnel" :disabled="disabled">新增 + <el-button type="primary" size="default" @click="onAddEmergencyPersonnel(ruleFormRef)" :disabled="disabled">新增 </el-button> <el-table :data="tableData" @@ -161,7 +161,6 @@ }); const titles = ref(); const disabled = ref(); - const peopleInsertBtn = ref(false) const teamId = ref() // 打开弹窗 const openDialog = (title: string, id: number, type: boolean) => { @@ -169,12 +168,6 @@ titles.value = title; disabled.value = type; teamId.value = id - //如果是新增 无法添加人员 - if(title == '新建应急队伍管理'){ - peopleInsertBtn.value = true - }else{ - peopleInsertBtn.value = false - } if (title == '查看应急队伍管理' || title == '修改应急队伍管理') { contingencyApi() .seeEmergencyTeam(id) @@ -334,26 +327,35 @@ await formEl.validate((valid, fields) => { if (valid) { isShowDialog.value = false; - contingencyApi() - .addEmergencyTeam(ruleForm.value) - .then((res) => { - if (res.data.code == 200) { - ElMessage({ - showClose: true, - message: res.data.msg, - type: 'success', - }); - emit('myAdd', true); - } else { - ElMessage({ - showClose: true, - message: res.data.msg, - type: 'error', - }); - emit('myAdd', true); - } - formEl.resetFields(); + if(teamId.value==null||teamId.value==''){ + contingencyApi() + .addEmergencyTeam(ruleForm.value) + .then((res) => { + if (res.data.code == 200) { + ElMessage({ + showClose: true, + message: res.data.msg, + type: 'success', + }); + emit('myAdd', true); + } else { + ElMessage({ + showClose: true, + message: res.data.msg, + type: 'error', + }); + emit('myAdd', true); + } + formEl.resetFields(); + }); + }else { + ElMessage({ + showClose: true, + message: '添加成功', + type: 'success', }); + emit('myAdd', true); + } } else { console.log('error submit!', fields); } @@ -413,17 +415,52 @@ const tableData = ref([]); //添加队伍负责人弹窗 const addRef = ref(); - const onAddEmergencyPersonnel = () => { - //未添加队伍 无法修改人员 - if(peopleInsertBtn.value == true){ - ElMessage({ - showClose: true, - message: '请先添加应急队伍', - type: 'warning', - }); - }else { - addRef.value.openDialog('新建应急队伍人员','',teamId.value); + const onAddEmergencyPersonnel = async (formEl: FormInstance | undefined) => { + if(!ruleForm.value.fileList){ + ruleForm.value.fileList = [] } + if (!formEl) return; + await formEl.validate((valid, fields) => { + if (valid) { + // isShowDialog.value = false; + if(teamId.value == ''||teamId.value==null){ + ElMessageBox.confirm('确认添加此应急队伍?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + .then(() => { + contingencyApi() + .addEmergencyTeam(ruleForm.value) + .then((res) => { + if (res.data.code == 200) { + ElMessage({ + showClose: true, + message: res.data.msg, + type: 'success', + }); + teamId.value = res.data.data.id + addRef.value.openDialog('新建应急队伍人员','',teamId.value); + } else { + ElMessage({ + showClose: true, + message: res.data.msg, + type: 'error', + }); + } + }); + }) + .catch(() => {}); + + }else { + addRef.value.openDialog('新建应急队伍人员','',teamId.value); + } + + + } else { + console.log('error submit!', fields); + } + }); }; // 请求列表数据 const listApi = async () => { @@ -508,7 +545,6 @@ onEdit, onRowDel, department, - peopleInsertBtn, teamId, newTreeList, successUploader, -- Gitblit v1.9.2