| | |
| | | <template> |
| | | <div class="system-edit-user-container"> |
| | | <el-dialog :title="titles" v-model="isShowDialog" width="50%" draggable :fullscreen="full" :close-on-click-modal="false"> |
| | | <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="ruleForm.responsibleDepartment" |
| | | :data="data" |
| | | multiple |
| | | :render-after-expand="false" |
| | | :props="propse" |
| | | clearable |
| | | show-checkbox |
| | | check-strictly |
| | | check-on-click-node |
| | | placeholder="请选择" |
| | | /> |
| | | <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" |
| | | check-strictly |
| | | :data="data" |
| | | 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.emergencyTeam" 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="相关附件"> |
| | | <el-upload |
| | | v-model:file-list="fileList" |
| | | class="upload-demo" |
| | | action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" |
| | | :on-change="handleChange" |
| | | > |
| | | <el-button type="primary">点击上传</el-button> |
| | | <template #tip> |
| | | <div class="el-upload__tip">添加相关附件</div> |
| | | </template> |
| | | </el-upload> |
| | | </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'; |
| | | |
| | | export default defineComponent({ |
| | | name: 'openAdd', |
| | | components: { |
| | | CheckTemplate, |
| | | DailogSearchUserManger, |
| | | RegionsDialog, |
| | | }, |
| | | setup(prop, { emit }) { |
| | | const isShowDialog = ref(false); |
| | | const ruleFormRef = ref<FormInstance>(); |
| | | const ruleForm = ref({ |
| | | name: '', // 预案名称 |
| | | type: '', //预案类型 |
| | | associatedDanger: '', // 危险源关联 |
| | | level: '', // 预案级别 |
| | | authorUid: '', // 编写人 |
| | | authorName: '', |
| | | authorDeptId: '', // 编写部门 |
| | | releaseDate: '', // 发布实施日期 |
| | | fileList: [ |
| | | // { |
| | | // fileUrl: 'url', |
| | | // fileName: 'name', |
| | | // }, |
| | | ], |
| | | emergencyTeam: '', //应急队伍 |
| | | areaList: [], //区域列表 |
| | | teamList: [], |
| | | deptList: [], |
| | | abolishStatus: false, |
| | | }); |
| | | 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; |
| | | let arr = []; |
| | | for (let i = 0; i < ruleForm.value.teamList.length; i++) { |
| | | arr.push(ruleForm.value.teamList[i].emergencyTeam); |
| | | } |
| | | ruleForm.value.emergencyTeam = arr.toString(); |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | //日期选择器 |
| | | const releaseDate = ref(''); |
| | | // 上传附件 |
| | | const fileList = ref<UploadUserFile[]>([]); |
| | | //部门树 |
| | | const department = () => { |
| | | goalManagementApi() |
| | | .getTreedepartment() |
| | | .then((res) => { |
| | | if (res.data.code == 200) { |
| | | data.value = res.data.data; |
| | | } else { |
| | | ElMessage.error(res.data.msg); |
| | | } |
| | | }); |
| | | }; |
| | | const treeSelect = ref(); |
| | | // const trees = ref(); |
| | | const propse = { |
| | | label: 'depName', |
| | | children: 'children', |
| | | value: 'depId', |
| | | }; |
| | | onMounted(() => { |
| | | department(); |
| | | }); |
| | | //定义树形下拉框 |
| | | const responsibleDepartment = ref(); |
| | | const data = ref(); |
| | | |
| | | const submitForm = async (title: string, formEl: FormInstance | undefined) => { |
| | | if (title == '新建应急预案管理') { |
| | | if (!formEl) return; |
| | | await formEl.validate((valid, fields) => { |
| | | if (valid) { |
| | | isShowDialog.value = false; |
| | | 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; |
| | | 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: [ |
| | | // { |
| | | // fileUrl: 'url', |
| | | // fileName: 'name', |
| | | // }, |
| | | ], |
| | | emergencyTeam: '', //应急队伍 |
| | | areaList: [], //区域列表 |
| | | teamList: [ |
| | | ], |
| | | deptList: [], |
| | | abolishStatus: false, |
| | | }; |
| | | } |
| | | }; |
| | | const resetForm = (formEl: FormInstance | undefined) => { |
| | | isShowDialog.value = false; |
| | | if (!formEl) return; |
| | | formEl.resetFields(); |
| | | }; |
| | | // 应急队伍弹窗 |
| | | const Shows = ref(); |
| | | const daiInpt = (data: any) => { |
| | | Shows.value.openDailog(data); |
| | | }; |
| | | const SearchUser = (val: any) => { |
| | | let arr = []; |
| | | for (let i = 0; i < val.length; i++) { |
| | | arr.push(val[i].teamName); |
| | | ruleForm.value.teamList.push({ |
| | | userUid: val[i].uid, |
| | | emergencyTeam: val[i].teamName, |
| | | }); |
| | | } |
| | | ruleForm.value.emergencyTeam = 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, |
| | | }; |
| | | }, |
| | | }); |
| | | </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> |