zhouwx
2024-12-04 80c8993820fc3f958397bebe9dbd72be6a449c55
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<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.realName" :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";
import {userApi} from "/@/api/systemManage/user";
import {ElMessage} from "element-plus";
import {warningInfoApi} from "/@/api/warningManage/warningInfo";
 
const gasRef = ref();
const emit = defineEmits(["getInfoData"]);
const state = reactive<InfoState>({
    title: '',
    isShowUserDialog: false,
    disabled: false,
    infoForm: {
        id: '',
        name: '',
        method: ''
    },
    setFormRules:{
        name: [{ required: true, message: '请选择预警人员', trigger: 'blur' }],
    },
    peopleList: []
});
const openDialog = (type: string, value: any) => {
    getUserList();
    state.isShowUserDialog = true;
    if (type === '查看') {
        state.disabled = true;
        let data = JSON.parse(JSON.stringify(value));
        state.infoForm.id = data.id;
        state.infoForm.name = data.handlerId;
        state.infoForm.method = data.handlerDesc;
    } else if (type === '处理'){
        state.disabled = false;
        state.infoForm = JSON.parse(JSON.stringify(value));
    }
    state.title = type;
};
 
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 onSubmit = async () => {
    if(state.title == '处理') {
        const param = {
            id: state.infoForm.id,
            userId: state.infoForm.name,
            handlerDesc: state.infoForm.method
        }
        let res = await warningInfoApi().handleWarnLog(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('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>