zhouwenxuan
2023-08-11 1c328d7233aaa6ea48fbdfb73b415eb9837956a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<template>
    <div class="system-add-gas-container">
        <el-dialog
            :title="state.title"
            v-model="state.isShowUserDialog"
            width="550px"
        >
            <el-form :model="state.infoForm" size="default" ref="gasRef" :rules="state.setFormRules" label-width="150px">
                <el-form-item label="处理人:" prop="name">
                    <el-select
                        v-model="state.infoForm.name"
                        filterable
                        class="w100"
                        style="max-width: 180px"
                        size="default"
                        :disabled="state.disabled"
                    >
                        <el-option v-for="item in state.peopleList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="处理方式:" prop="points">
                    <el-input type="textarea" v-model.trim="state.infoForm.method" :disabled="state.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 {InfoState} from "/@/types/warning";
 
const gasRef = ref();
const emit = defineEmits(["getInfoData"]);
const state = reactive<InfoState>({
    title: '',
    isShowUserDialog: false,
    disabled: false,
    infoForm: {
        name: '',
        method: ''
    },
    setFormRules:{
        name: [{ required: true, message: '请选择预警人员', trigger: 'blur' }],
    },
    peopleList: [
        // {
        //     id: '1',
        //     name: '张三',
        // },
        // {
        //     id: '2',
        //     name: '李四',
        // }
    ]
});
const openDialog = (type: string, value: any) => {
    state.isShowUserDialog = true;
    if (type === '查看') {
        state.disabled = true;
        state.infoForm = JSON.parse(JSON.stringify(value));
        state.infoForm.name = state.infoForm.managePeople;
        console.log("info",state.infoForm)
    } else if (type === '处理'){
        state.disabled = false;
        state.infoForm = {
            name: '',
            method: ''
        }
    }
    state.title = type;
};
 
const onSubmit = () => {
    gasRef.value.clearValidate();
    state.isShowUserDialog = false;
    emit('getInfoData');
};
 
const handleClose = () => {
    gasRef.value.clearValidate();
    state.isShowUserDialog = false;
    emit('getInfoData');
}
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>