| | |
| | | <template> |
| | | <div class="system-edit-user-container"> |
| | | <el-dialog |
| | | :title="titles" |
| | | v-model="isShowDialog" |
| | | width="40%" |
| | | draggable |
| | | :fullscreen="full" |
| | | @close="resetForm(ruleFormRef)" |
| | | > |
| | | <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button> |
| | | <el-form |
| | | ref="ruleFormRef" |
| | | :model="ruleForm" |
| | | size="default" |
| | | :rules="rules" |
| | | :disabled="disabled" |
| | | label-width="90px"> |
| | | <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="请选择" |
| | | 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="jobNumber"> |
| | | <el-input v-model="ruleForm.jobNumber" 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="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="gender"> |
| | | <el-radio-group v-model="ruleForm.gender"> |
| | | <el-radio :label="false">男</el-radio> |
| | | <el-radio :label="true">女</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="手机号码" prop="phone"> |
| | | <el-input v-model="ruleForm.phone" 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="position"> |
| | | <el-input v-model="ruleForm.position" placeholder="请填写职位"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <!-- <el-button size="default" type="primary" @click="addForm(ruleFormRef)">继续添加</el-button>--> |
| | | <el-button size="default" @click="resetForm(ruleFormRef)">关闭</el-button> |
| | | <el-button size="default" type="primary" v-if="disabled == true ? false : true" @click="submitForm(titles, ruleFormRef)" >确定</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | <DailogSearchUserManger ref="userRef" @SearchUser="onUser"/> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { |
| | | ref, |
| | | reactive, |
| | | defineComponent |
| | | } from 'vue'; |
| | | |
| | | import type { |
| | | FormRules, |
| | | 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 {contingencyApi} from "/@/api/contingencyManagement/contingency"; |
| | | |
| | | export default defineComponent({ |
| | | name: 'addTeamLeader', |
| | | components: { |
| | | // Search, |
| | | DailogSearchUserManger |
| | | }, |
| | | setup(props, { emit }) { |
| | | const isShowDialog = ref(false) |
| | | const ruleFormRef = ref<FormInstance>() |
| | | const ruleForm = ref ({ |
| | | teamId: '', |
| | | userUid: '', |
| | | gender: '', |
| | | jobNumber: '', // 人员工号 |
| | | name: '', // 人员名称 |
| | | phone: '', // 手机号码 |
| | | position: '', // 职位 |
| | | }); |
| | | const rules = reactive<FormRules>({ |
| | | jobNumber: [ |
| | | { |
| | | required: true, |
| | | message: '人员工号不能为空', |
| | | trigger: 'change', |
| | | }, |
| | | ], |
| | | personnelName: [ |
| | | { |
| | | required: true, |
| | | message: '人员名称不能为空', |
| | | trigger: 'change', |
| | | }, |
| | | ], |
| | | personnelGender: [ |
| | | { |
| | | required: true, |
| | | message: '人员性别不能为空', |
| | | trigger: 'change', |
| | | }, |
| | | ], |
| | | phone: [ |
| | | { |
| | | required: true, |
| | | message: '手机号码不能为空', |
| | | trigger: 'change', |
| | | }, |
| | | ], |
| | | position: [ |
| | | { |
| | | required: true, |
| | | message: '职位不能为空', |
| | | trigger: 'change', |
| | | }, |
| | | ], |
| | | }) |
| | | const titles = ref(); |
| | | const disabled = ref(); |
| | | const submitForm = async (title: string, formEl: FormInstance | undefined) => { |
| | | if (title == '新建应急队伍人员') { |
| | | if (!formEl) return; |
| | | await formEl.validate((valid, fields) => { |
| | | if (valid) { |
| | | isShowDialog.value = false; |
| | | // console.log('-------',ruleForm.value) |
| | | // emit('myAdd', ruleForm.value); |
| | | contingencyApi() |
| | | .addEmergencyTeamPersonnel(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; |
| | | contingencyApi() |
| | | .editEmergencyTeamPersonnel(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 = { |
| | | teamId: '', |
| | | userUid: '', |
| | | gender: '', |
| | | jobNumber: '', // 人员工号 |
| | | name: '', // 人员名称 |
| | | phone: '', // 手机号码 |
| | | position: '', // 职位 |
| | | }; |
| | | } |
| | | } |
| | | const resetForm = (formEl: FormInstance | undefined) => { |
| | | isShowDialog.value = false; |
| | | if (!formEl) return; |
| | | formEl.resetFields(); |
| | | }; |
| | | |
| | | // 打开弹窗 |
| | | const openDialog = (title: string, id: number,teamId:number, type: boolean) => { |
| | | isShowDialog.value = true; |
| | | titles.value = title; |
| | | disabled.value = type; |
| | | ruleForm.value.teamId = teamId |
| | | |
| | | if (title == '查看应急队伍人员' || title == '修改应急队伍人员') { |
| | | contingencyApi() |
| | | .seeEmergencyTeamPersonnel(id) |
| | | .then((res) => { |
| | | if (res.data.code == 200) { |
| | | ruleForm.value = res.data.data; |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | // 打开用户选择弹窗 |
| | | const userRef = ref(); |
| | | const openUser = () => { |
| | | userRef.value.openDailog(); |
| | | }; |
| | | const onUser = (e:any) => { |
| | | ruleForm.value.userUid=e[0].uid |
| | | ruleForm.value.gender=e[0].sex |
| | | ruleForm.value.name=e[0].realName |
| | | ruleForm.value.jobNumber=e[0].jobNumber |
| | | ruleForm.value.phone=e[0].phone |
| | | ruleForm.value.position=e[0].position |
| | | }; |
| | | //全屏 |
| | | const full = ref(false); |
| | | const toggleFullscreen = () => { |
| | | if (full.value == false) { |
| | | full.value = true; |
| | | } else { |
| | | full.value = false; |
| | | } |
| | | }; |
| | | return { |
| | | openDialog, |
| | | // closeDialog, |
| | | isShowDialog, |
| | | ruleFormRef, |
| | | // submitForm, |
| | | // onCancel, |
| | | ruleForm, |
| | | rules, |
| | | Search, |
| | | toggleFullscreen, |
| | | FullScreen, |
| | | full, |
| | | resetForm, |
| | | titles, |
| | | disabled, |
| | | emit, |
| | | openUser, |
| | | userRef, |
| | | onUser, |
| | | submitForm, |
| | | }; |
| | | }, |
| | | }); |
| | | </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; |
| | | } |
| | | </style> |