<template>
|
<div class="system-add-gas-container">
|
<el-dialog
|
:title="state.title"
|
v-model="state.isShowUserDialog"
|
width="550px"
|
>
|
<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"
|
filterable
|
class="w100"
|
style="max-width: 180px"
|
size="default"
|
@change="changePeople"
|
:disabled="state.disabled"
|
>
|
<el-option v-for="item in state.peopleList" :key="item.id" :label="item.name" :value="item.id">
|
<div class="valueTable">
|
<div><div>姓名:</div><span>{{item.name}}</span></div>
|
<div><div>手机号:</div><span>{{item.phone}}</span></div>
|
</div>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="手机号:" prop="points">
|
<el-input v-model.trim="state.peopleForm.phone" disabled ></el-input>
|
</el-form-item>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="handleClose" size="default" v-if="!state.disabled">取 消</el-button>
|
<el-button type="primary" @click="onSubmit" size="default">确 定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import {reactive, ref} from "vue";
|
import {PeopleState} from "/@/types/warning";
|
|
const gasRef = ref();
|
const emit = defineEmits(["getPeopleData"]);
|
const state = reactive<PeopleState>({
|
title: '',
|
isShowUserDialog: false,
|
disabled: false,
|
peopleForm: {
|
name: '',
|
phone: ''
|
},
|
setFormRules:{
|
name: [{ required: true, message: '请选择预警人员', trigger: 'blur' }],
|
phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
|
},
|
peopleList: [
|
// {
|
// id: '1',
|
// name: '张三',
|
// phone: '112554566666'
|
// },
|
// {
|
// id: '2',
|
// name: '李四',
|
// phone: '11254212321'
|
// }
|
]
|
});
|
const openDialog = (type: string, value: any) => {
|
state.isShowUserDialog = true;
|
if (type === '查看') {
|
state.disabled = true;
|
state.title = '查看预警人员';
|
state.peopleForm = JSON.parse(JSON.stringify(value));
|
} else if (type === '修改'){
|
state.disabled = false;
|
state.title = '修改预警人员';
|
state.peopleForm = JSON.parse(JSON.stringify(value));
|
}else {
|
state.disabled = false;
|
state.title = '新增预警人员';
|
state.peopleForm = {
|
name: '',
|
phone: ''
|
}
|
}
|
};
|
|
const changePeople = (val:any) => {
|
const obj = state.peopleList.find(item => item.id === val);
|
if(obj){
|
state.peopleForm.phone = obj.phone;
|
}
|
}
|
const onSubmit = () => {
|
gasRef.value.clearValidate();
|
state.isShowUserDialog = false;
|
emit('getPeopleData');
|
};
|
|
const handleClose = () => {
|
gasRef.value.clearValidate();
|
state.isShowUserDialog = false;
|
emit('getPeopleData');
|
}
|
defineExpose({
|
openDialog
|
});
|
</script>
|
<style scoped lang="scss">
|
.valueTable{
|
line-height: 18px;
|
&>div{
|
line-height: 1;
|
margin-bottom: 6px;
|
display: flex;
|
align-items: center;
|
|
div{
|
color: #999;
|
}
|
|
span{
|
font-weight: bolder;
|
}
|
|
&:last-of-type{
|
margin-bottom: 0;
|
margin-top: 10px;
|
}
|
}
|
}
|
.el-select-dropdown__item {
|
height: 50px;
|
line-height: 50px;
|
margin-top: 6px;
|
}
|
</style>
|