| | |
| | | <template> |
| | | <div class="system-edit-user-container"> |
| | | <el-dialog |
| | | :title="titles" |
| | | v-model="isShowDialog" |
| | | width="50%" |
| | | draggable |
| | | :fullscreen="full" |
| | | :close-on-click-modal="false" |
| | | @close="resetForm(ruleFormRef)" |
| | | > |
| | | <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button> |
| | | <el-form ref="ruleFormRef" :model="ruleForm" size="default" label-width="120px" :disabled="disabled"> |
| | | <el-row :gutter="35"> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="预案名称" prop="name"> |
| | | <el-input v-model="ruleForm.name" placeholder="请填写队伍名称"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="适用部门" prop="responsibleDepartment"> |
| | | <el-tree-select |
| | | v-model="responsibleDepartment" |
| | | :data="newTreeList" |
| | | class="w100" |
| | | clearable |
| | | :props="propse" |
| | | multiple |
| | | :render-after-expand="false" |
| | | check-strictly |
| | | check-on-click-node |
| | | placeholder="请选择" |
| | | @change="changeDepartment" |
| | | /> |
| | | <el-divider /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="预案类型" prop="type"> |
| | | <el-select v-model="ruleForm.type" class="w100" placeholder="请选择"> |
| | | <el-option label="综合应急预案" value="1"></el-option> |
| | | <el-option label="现场处置方案" value="2"></el-option> |
| | | <el-option label="专项应急预案" value="3"></el-option> |
| | | <el-option label="其他预案" value="4"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="危险源关联" prop="associatedDanger"> |
| | | <el-select v-model="ruleForm.associatedDanger" class="w100" placeholder="请选择"> |
| | | <el-option label="是" :value="false"></el-option> |
| | | <el-option label="否" :value="true"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="预案级别" prop="level"> |
| | | <el-select v-model="ruleForm.level" class="w100" placeholder="请选择"> |
| | | <el-option label="公司级" value="1"></el-option> |
| | | <el-option label="分厂级" value="2"></el-option> |
| | | <el-option label="车间级" value="3"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="编写人" prop="authorId"> |
| | | <el-input v-model="ruleForm.authorName" placeholder="请选择" class="input-with-select"> |
| | | <template #append> |
| | | <el-button :icon="Search" @click="openUser" /> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="编写部门" prop="authorDeptId"> |
| | | <el-tree-select |
| | | v-model="ruleForm.authorDeptId" |
| | | :data="newTreeList" |
| | | class="w100" |
| | | :props="propse" |
| | | clearable |
| | | :render-after-expand="false" |
| | | placeholder="请选择" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="发布实施日期" prop="releaseDate"> |
| | | <el-date-picker |
| | | v-model="ruleForm.releaseDate" |
| | | type="datetime" |
| | | class="w100" |
| | | placeholder="选择日期时间" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="应急队伍" prop="emergencyTeam"> |
| | | <el-input v-model="ruleForm.teamName" placeholder="请选择" class="input-with-select"> |
| | | <template #append> |
| | | <el-button :icon="Search" @click="daiInpt(0)" /> |
| | | </template> |
| | | </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="相关附件"> |
| | | <uploaderFile :fileList="fileList" :systemName="'EMERGENCY'" :disabled="disabled" |
| | | @successUploader="successUploader"></uploaderFile> |
| | | </el-form-item> |
| | | </el-col> |
| | | <!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">--> |
| | | <!-- <el-form-item label="区域名称" prop="areaName">--> |
| | | <!-- <el-input--> |
| | | <!-- v-model="ruleForm.areaName"--> |
| | | <!-- placeholder="请选择"--> |
| | | <!-- class="input-with-select"--> |
| | | <!-- >--> |
| | | <!-- <template #append>--> |
| | | <!-- <el-button :icon="Search" @click="regionsDialog"/>--> |
| | | <!-- </template>--> |
| | | <!-- </el-input>--> |
| | | <!-- </el-form-item>--> |
| | | <!-- </el-col>--> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="resetForm(ruleFormRef)" size="default">关闭</el-button> |
| | | <el-button size="default" type="primary" v-if="disabled == true ? false : true" @click="submitForm(titles, ruleFormRef)">确定</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | <CheckTemplate ref="Shows" @SearchUser="SearchUser" /> |
| | | <DailogSearchUserManger ref="userRef" @SearchUser="onUser" /> |
| | | <RegionsDialog ref="openRef" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { ref, defineComponent, onMounted } from 'vue'; |
| | | |
| | | import type { UploadUserFile, FormInstance } from 'element-plus'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { Search, FullScreen } from '@element-plus/icons-vue'; |
| | | import DailogSearchUserManger from '/@/components/DailogSearchUserManger/index.vue'; |
| | | import CheckTemplate from '/@/components/checkTemplate/index.vue'; |
| | | import RegionsDialog from '/@/components/regionsDialog/index.vue'; |
| | | import { emergencyPlanApi } from '/@/api/contingencyManagement/emergencyPlan'; |
| | | import { goalManagementApi } from '/@/api/goalManagement'; |
| | | import uploaderFile from '/@/components/uploaderFile/index.vue'; |
| | | export default defineComponent({ |
| | | name: 'openAdd', |
| | | components: { |
| | | CheckTemplate, |
| | | DailogSearchUserManger, |
| | | RegionsDialog, |
| | | uploaderFile |
| | | }, |
| | | setup(prop, { emit }) { |
| | | const isShowDialog = ref(false); |
| | | const ruleFormRef = ref<FormInstance>(); |
| | | const ruleForm = ref({ |
| | | name: '', // 预案名称 |
| | | type: '', //预案类型 |
| | | associatedDanger: '', // 危险源关联 |
| | | level: '', // 预案级别 |
| | | authorUid: '', // 编写人 |
| | | authorName: '', |
| | | authorDeptId: '', // 编写部门 |
| | | releaseDate: '', // 发布实施日期 |
| | | fileList: [], |
| | | areaList: [], //区域列表 |
| | | teamList: [], |
| | | // teamId: '', //应急队伍 |
| | | deptList: [], |
| | | }); |
| | | const titles = ref(); |
| | | const disabled = ref(); |
| | | |
| | | // 打开弹窗 |
| | | const openDialog = (title: string, id: number, type: boolean) => { |
| | | isShowDialog.value = true; |
| | | titles.value = title; |
| | | disabled.value = type; |
| | | if (title == '查看应急预案管理' || title == '修改应急预案管理') { |
| | | emergencyPlanApi() |
| | | .seeEmergencyTeam(id) |
| | | .then((res) => { |
| | | if (res.data.code == 200) { |
| | | ruleForm.value = res.data.data; |
| | | ruleForm.value.teamName = '' |
| | | responsibleDepartment.value = [] |
| | | if(res.data.data.teamList){ |
| | | for(var a = 0;a<res.data.data.teamList.length;a++){ |
| | | ruleForm.value.teamName+=res.data.data.teamList[a].teamName+';' |
| | | } |
| | | } |
| | | if(res.data.data.deptList){ |
| | | for(var a = 0;a<res.data.data.deptList.length;a++){ |
| | | |
| | | responsibleDepartment.value.push(res.data.data.deptList[a].departmentId) |
| | | } |
| | | } |
| | | fileList.value = (res.data.data.fileList?res.data.data.fileList:[]) |
| | | initFileListData() |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | const initFileListData = async () => { |
| | | for(var a = 0;a<fileList.value.length;a++){ |
| | | fileList.value[a].name = fileList.value[a].fileName |
| | | } |
| | | } |
| | | // 上传成功组装数据 |
| | | const successUploader = (list) =>{ |
| | | fileList.value = list |
| | | const formFileList = [] |
| | | for(var a = 0;a<fileList.value.length;a++){ |
| | | formFileList.push( |
| | | { |
| | | fileName:fileList.value[a].fileName, |
| | | fileUrl:'' |
| | | } |
| | | ) |
| | | } |
| | | ruleForm.value.fileList = formFileList |
| | | } |
| | | //日期选择器 |
| | | const releaseDate = ref(''); |
| | | // 上传附件 |
| | | const fileList = ref([]); |
| | | //el-tree-select回显 |
| | | const propse = { |
| | | label: 'depName', |
| | | children: 'children', |
| | | }; |
| | | const newTreeList = []; |
| | | //得到部门树 |
| | | const department = async () => { |
| | | await goalManagementApi() |
| | | .getTreedepartment() |
| | | .then((res) => { |
| | | if (res.data.code == 200) { |
| | | data.value = res.data.data; |
| | | getTreeList(res.data.data, newTreeList); |
| | | } else { |
| | | ElMessage.error(res.data.msg); |
| | | } |
| | | }); |
| | | }; |
| | | // 递归树状数据且修改字段名 |
| | | const getTreeList = (treeList, newTreeList) => { |
| | | treeList.map((c) => { |
| | | let tempData = { |
| | | depName: c.depName, |
| | | value: c.depId, |
| | | children: [], |
| | | }; |
| | | if (c.children && c.children.length > 0) { |
| | | tempData.children = []; |
| | | getTreeList(c.children, tempData.children); |
| | | } |
| | | newTreeList.push(tempData); |
| | | }); |
| | | }; |
| | | onMounted(() => { |
| | | department(); |
| | | }); |
| | | const changeDepartment = (e) => { |
| | | var temList = []; |
| | | for (var a = 0; a < e.length; a++) { |
| | | temList.push({ |
| | | departmentId: e[a], |
| | | }); |
| | | } |
| | | ruleForm.value.deptList = temList; |
| | | console.log(ruleForm); |
| | | }; |
| | | //定义树形下拉框 |
| | | const responsibleDepartment = ref([]); |
| | | const data = ref(); |
| | | |
| | | const submitForm = async (title: string, formEl: FormInstance | undefined) => { |
| | | if(!ruleForm.value.fileList){ |
| | | ruleForm.value.fileList = [] |
| | | } |
| | | if (title == '新建应急预案管理') { |
| | | if (!formEl) return; |
| | | await formEl.validate((valid, fields) => { |
| | | if (valid) { |
| | | isShowDialog.value = false; |
| | | delete ruleForm.value.teamName |
| | | emergencyPlanApi() |
| | | .addEmergencyPlan(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 { |
| | | console.log('error submit!', fields); |
| | | } |
| | | }); |
| | | } else if (title == '修改应急预案管理') { |
| | | if (!formEl) return; |
| | | await formEl.validate((valid, fields) => { |
| | | if (valid) { |
| | | isShowDialog.value = false; |
| | | delete ruleForm.value.teamName |
| | | emergencyPlanApi() |
| | | .editEmergencyTeam(ruleForm.value) |
| | | .then((res) => { |
| | | if (res.data.code == 200) { |
| | | ElMessage({ |
| | | showClose: true, |
| | | message: '修改成功', |
| | | type: 'success', |
| | | }); |
| | | emit('myAdd', true); |
| | | } else { |
| | | ElMessage({ |
| | | showClose: true, |
| | | message: res.data.msg, |
| | | type: 'error', |
| | | }); |
| | | emit('myAdd', true); |
| | | } |
| | | formEl.resetFields(); |
| | | }); |
| | | } else { |
| | | console.log('error submit!', fields); |
| | | } |
| | | }); |
| | | formEl.resetFields(); |
| | | ruleForm.value = { |
| | | name: '', // 预案名称 |
| | | type: '', //预案类型 |
| | | associatedDanger: '', // 危险源关联 |
| | | level: '', // 预案级别 |
| | | authorUid: '', // 编写人 |
| | | authorName: '', |
| | | authorDeptId: '', // 编写部门 |
| | | releaseDate: '', // 发布实施日期 |
| | | fileList: [], |
| | | // teamId: '', //应急队伍ID |
| | | areaList: [], //区域列表 |
| | | teamList: [], |
| | | deptList: [], |
| | | }; |
| | | } |
| | | }; |
| | | const resetForm = (formEl: FormInstance | undefined) => { |
| | | isShowDialog.value = false; |
| | | if (!formEl) return; |
| | | formEl.resetFields(); |
| | | ruleForm.value = {}; |
| | | fileList.value = [] |
| | | }; |
| | | // 应急队伍弹窗 |
| | | const Shows = ref(); |
| | | const daiInpt = (data: any) => { |
| | | Shows.value.openDailog(data); |
| | | }; |
| | | const SearchUser = (val: any) => { |
| | | let arr = []; |
| | | ruleForm.value.teamList = []; |
| | | for (let i = 0; i < val.length; i++) { |
| | | arr.push(val[i].teamName); |
| | | ruleForm.value.teamList.push({ |
| | | teamId: val[i].id, |
| | | }); |
| | | } |
| | | ruleForm.value.teamName = arr.toString(); |
| | | }; |
| | | // 选择区域弹窗 |
| | | const openRef = ref(); |
| | | const regionsDialog = () => { |
| | | openRef.value.openDailog(); |
| | | }; |
| | | // 打开用户选择弹窗 |
| | | const userRef = ref(); |
| | | const openUser = () => { |
| | | userRef.value.openDailog(); |
| | | }; |
| | | //回显 |
| | | const onUser = (e: any) => { |
| | | ruleForm.value.authorUid = e[0].uid; |
| | | ruleForm.value.authorName = e[0].realName; |
| | | }; |
| | | //全屏 |
| | | const full = ref(false); |
| | | const toggleFullscreen = () => { |
| | | if (full.value == false) { |
| | | full.value = true; |
| | | } else { |
| | | full.value = false; |
| | | } |
| | | }; |
| | | return { |
| | | openDialog, |
| | | fileList, |
| | | responsibleDepartment, |
| | | data, |
| | | Search, |
| | | releaseDate, |
| | | // treeSelect, |
| | | // trees, |
| | | propse, |
| | | department, |
| | | daiInpt, |
| | | Shows, |
| | | SearchUser, |
| | | submitForm, |
| | | openUser, |
| | | userRef, |
| | | regionsDialog, |
| | | openRef, |
| | | toggleFullscreen, |
| | | FullScreen, |
| | | full, |
| | | titles, |
| | | disabled, |
| | | emit, |
| | | isShowDialog, |
| | | ruleFormRef, |
| | | ruleForm, |
| | | resetForm, |
| | | onUser, |
| | | newTreeList, |
| | | changeDepartment, |
| | | successUploader, |
| | | initFileListData |
| | | }; |
| | | }, |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | .textarea { |
| | | height: 168px !important; |
| | | } |
| | | .textarea ::v-deep .el-textarea__inner { |
| | | height: 168px !important; |
| | | } |
| | | ::v-deep .el-table__cell { |
| | | font-weight: 400; |
| | | } |
| | | .el-divider--horizontal { |
| | | height: 0; |
| | | margin: 0; |
| | | border-top: transparent; |
| | | } |
| | | .el-select { |
| | | width: 100%; |
| | | } |
| | | </style> |