| | |
| | | <el-form :model="state.peopleForm" size="default" ref="gasRef" :rules="state.setFormRules" label-width="150px"> |
| | | <el-form-item label="预警人员:" prop="name"> |
| | | <el-select |
| | | v-model="state.peopleForm.name" |
| | | v-model="state.peopleForm.realName" |
| | | filterable |
| | | class="w100" |
| | | style="max-width: 180px" |
| | |
| | | @change="changePeople" |
| | | :disabled="state.disabled" |
| | | > |
| | | <el-option v-for="item in state.peopleList" :key="item.id" :label="item.name" :value="item.id"> |
| | | <el-option v-for="item in state.peopleList" :key="item.id" :label="item.realName" :value="item.id"> |
| | | <div class="valueTable"> |
| | | <div><div>姓名:</div><span>{{item.name}}</span></div> |
| | | <div><div>姓名:</div><span>{{item.realName}}</span></div> |
| | | <div><div>手机号:</div><span>{{item.phone}}</span></div> |
| | | </div> |
| | | </el-option> |
| | |
| | | <script setup lang="ts"> |
| | | import {reactive, ref} from "vue"; |
| | | import {PeopleState} from "/@/types/warning"; |
| | | import { userApi } from "/@/api/systemManage/user"; |
| | | import { warningPeopleApi } from "/@/api/warningManage/warningPeople"; |
| | | import {ElMessage} from "element-plus"; |
| | | |
| | | const gasRef = ref(); |
| | | const emit = defineEmits(["getPeopleData"]); |
| | |
| | | isShowUserDialog: false, |
| | | disabled: false, |
| | | peopleForm: { |
| | | id: '', |
| | | name: '', |
| | | phone: '' |
| | | phone: '', |
| | | realName: '' |
| | | }, |
| | | setFormRules:{ |
| | | name: [{ required: true, message: '请选择预警人员', trigger: 'blur' }], |
| | | phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }], |
| | | }, |
| | | peopleList: [ |
| | | // { |
| | | // id: '1', |
| | | // name: '张三', |
| | | // phone: '112554566666' |
| | | // }, |
| | | // { |
| | | // id: '2', |
| | | // name: '李四', |
| | | // phone: '11254212321' |
| | | // } |
| | | ] |
| | | peopleList: [] |
| | | }); |
| | | |
| | | let chooseObj = reactive<any>({}); |
| | | |
| | | const openDialog = (type: string, value: any) => { |
| | | getUserList(); |
| | | state.isShowUserDialog = true; |
| | | if (type === '查看') { |
| | | state.disabled = true; |
| | |
| | | state.disabled = false; |
| | | state.title = '修改预警人员'; |
| | | state.peopleForm = JSON.parse(JSON.stringify(value)); |
| | | chooseObj = state.peopleForm; |
| | | }else { |
| | | state.disabled = false; |
| | | state.title = '新增预警人员'; |
| | | state.peopleForm = { |
| | | id: '', |
| | | name: '', |
| | | phone: '' |
| | | phone: '', |
| | | realName: '' |
| | | } |
| | | } |
| | | }; |
| | | const getUserList = async () => { |
| | | const param = { |
| | | pageIndex: 1, |
| | | pageSize: 9999, |
| | | searchParams: { |
| | | roleId: null, |
| | | name: "", |
| | | realName: "", |
| | | userIndentityId: null |
| | | } |
| | | } |
| | | let res = await userApi().getUserList(param); |
| | | if(res.data.code == 100) { |
| | | state.peopleList = res.data.data; |
| | | }else { |
| | | ElMessage({ |
| | | type: 'error', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | const changePeople = (val:any) => { |
| | | const obj = state.peopleList.find(item => item.id === val); |
| | | if(obj){ |
| | | state.peopleForm.phone = obj.phone; |
| | | chooseObj = state.peopleList.find(item => item.id === val); |
| | | console.log("obj",chooseObj) |
| | | if(chooseObj){ |
| | | state.peopleForm.phone = chooseObj.phone; |
| | | } |
| | | } |
| | | const onSubmit = () => { |
| | | const onSubmit = async () => { |
| | | if(state.title == '新增预警人员' || state.title == '修改预警人员'){ |
| | | const valid = gasRef.value.validate(); |
| | | if(valid) { |
| | | if(state.title == '新增预警人员'){ |
| | | const param = { |
| | | userId: chooseObj.id, |
| | | name: chooseObj.name, |
| | | realName: chooseObj.realName, |
| | | phone: chooseObj.phone |
| | | } |
| | | let res = await warningPeopleApi().addWarnUser(param); |
| | | if(res.data.code == 100) { |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '新增成功' |
| | | }); |
| | | }else{ |
| | | ElMessage({ |
| | | type: 'error', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | }else if(state.title == '修改预警人员'){ |
| | | const param = { |
| | | id: state.peopleForm.id, |
| | | userId: chooseObj.id, |
| | | name: chooseObj.name, |
| | | realName: chooseObj.realName, |
| | | phone: chooseObj.phone |
| | | } |
| | | console.log("res",param) |
| | | let res = await warningPeopleApi().handelWarnUser(param); |
| | | if(res.data.code == 100) { |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '修改成功' |
| | | }); |
| | | }else{ |
| | | ElMessage({ |
| | | type: 'error', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | gasRef.value.clearValidate(); |
| | | state.isShowUserDialog = false; |
| | | emit('getPeopleData'); |
| | | }else { |
| | | state.isShowUserDialog = false; |
| | | emit('getPeopleData'); |
| | | } |
| | | }; |
| | | |
| | | const handleClose = () => { |