审查视图

src/views/bus/UserMessageBinding.vue 47.2 KB
1
<template>
王勇 authored
2 3 4 5 6 7
    <el-container>
        <el-main>
            <el-card style="background-color: #F5F7FA">
                <!-- 搜素区域 -->
                <div>
                    <el-row>
8 9
                        <el-col :span="5">
                            <el-input v-model="umb_queryInfo.username"
10
                                      size="medium"
11 12 13
                                      placeholder="用户名称" clearable>
                                <template  slot="prepend" ><i class="el-icon-user"></i>用户名称</template>
                            </el-input>
14
                        </el-col>
15 16
                        <el-col :span="6">
                            <el-input v-model="umb_queryInfo.serverName"
王勇 authored
17
                                      size="medium"
18 19 20
                                      placeholder="服务器名称" clearable>
                                <template  slot="prepend"><i class="el-icon-s-platform"></i>服务器名称</template>
                            </el-input>
王勇 authored
21
                        </el-col>
22 23
                        <el-col :span="6">
                            <el-input v-model="umb_queryInfo.virtualHostName"
王勇 authored
24
                                      size="medium"
25 26 27
                                      placeholder="虚拟主机名称" clearable>
                                <template  slot="prepend"><i class="el-icon-s-operation"></i>虚拟主机名称</template>
                            </el-input>
王勇 authored
28
                        </el-col>
29 30
                        <el-col :span="6">
                            <el-input v-model="umb_queryInfo.exchangeName"
王勇 authored
31
                                      size="medium"
32 33 34
                                      placeholder="交换机名称" clearable>
                                <template  slot="prepend"><i class="el-icon-sort"></i>交换机名称</template>
                            </el-input>
王勇 authored
35
                        </el-col>
36 37
                    </el-row>
                    <el-row>
38 39
                        <el-col :span="5">
                            <el-input v-model="umb_queryInfo.queueName"
王勇 authored
40
                                      size="medium"
41 42 43
                                      placeholder="队列名称" clearable>
                                <template  slot="prepend"><i class="el-icon-notebook-2"></i>队列名称</template>
                            </el-input>
王勇 authored
44
                        </el-col>
45 46
                        <el-col :span="6">
                            <el-input v-model="umb_queryInfo.routingKeyName"
王勇 authored
47
                                      size="medium"
48 49 50
                                      placeholder="路由键名称" clearable>
                                <template  slot="prepend" ><i class="el-icon-user"></i>路由键名称</template>
                            </el-input>
王勇 authored
51 52
                        </el-col>
                        <el-col :span="8">
53
                            <el-button type="warning" style="width:150px" size="medium" icon="el-icon-search" @click="umb_getList">
王勇 authored
54 55
                                查询配置信息
                            </el-button>
56
                            <el-button type="primary" style="width:150px" size="medium" icon="el-icon-plus" @click="umb_toAddDialog">
王勇 authored
57 58 59 60 61 62 63 64
                                添加配置信息
                            </el-button>
                        </el-col>
                    </el-row>
                </div>
                <!-- 列表区域 -->
                <div style="margin-top: 20px;">
                    <el-table :data="umb_page.umbList" border v-loading="umb_loading.listLoading"
65 66 67 68
                              @selection-change="umb_selectChange" size="small"
                              element-loading-text="获取配置信息列表,拼命加载中"
                              :header-cell-style="{background:'#6F8294',color:'#FFFFFF'}"
                              style="border-radius: 10px 10px 0px 0px;line-height: 25px;">
王勇 authored
69 70 71
                        <el-table-column type="selection" width="55" align="center"></el-table-column>
                        <el-table-column type="index" align="center"></el-table-column>
                        <el-table-column label="用户名称" prop="username" align="center" width="220"></el-table-column>
72
                        <!--  <el-table-column label="订阅者名称" prop="subscriber" align="center" width="220"></el-table-column>-->
王勇 authored
73 74 75 76 77
                        <el-table-column label="服务器名称" prop="serverName" align="center"
                                         width="220"></el-table-column>
                        <el-table-column label="虚拟主机名称" prop="virtualHostName" align="center"
                                         width="220"></el-table-column>
                        <el-table-column label="交换机名称" prop="exchangeName" align="center" width="220"></el-table-column>
王勇 authored
78
                        <el-table-column label="队列名称" prop="queueName" align="center" width="400"></el-table-column>
王勇 authored
79 80
                        <el-table-column label="路由键名称" prop="routingKeyName" align="center"
                                         width="220"></el-table-column>
王勇 authored
81 82
                        <el-table-column label="相关描述" prop="description" align="center"
                                         width="220"></el-table-column>
王勇 authored
83 84 85 86
                        <el-table-column label="操作" width="245px" align="center" fixed="right">
                            <template slot-scope="scope">
                                <!-- 编辑按钮-->
                                <el-tooltip effect="dark" content="编辑" placement="top-start" :enterable="false">
王勇 authored
87 88
                                    <el-button type="primary" icon="el-icon-view" size="mini"
                                               @click="umb_toEditDialog(scope.$index,scope.row)">查看
王勇 authored
89 90 91 92 93 94
                                    </el-button>
                                </el-tooltip>

                                <!-- 删除按钮-->
                                <el-tooltip effect="dark" content="删除" placement="top-start" :enterable="false">
                                    <el-button type="danger" icon="el-icon-delete" size="mini"
95
                                               :loading="umb_loading.listLoading"
王勇 authored
96 97 98 99 100 101 102 103 104 105 106 107
                                               @click="umb_remove(scope.$index,scope.row)">删除
                                    </el-button>
                                </el-tooltip>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
                <!--分页区域-->
                <div style="margin-top: 10px">
                    <el-row :gutter="24">
                        <el-col :span="5">
                            <el-button type="danger" icon="el-icon-delete"
王勇 authored
108
                                       :loading="umb_loading.listLoading"
王勇 authored
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
                                       :disabled="this.umb_page.selectList.length===0"
                                       @click="umb_batchRemove">批量删除
                            </el-button>
                        </el-col>
                        <el-col :span="10" style="margin-top: 5px">
                            <el-pagination
                                    @size-change="umb_handleSizeChange"
                                    @current-change="umb_handleCurrentChange"
                                    :current-page="umb_queryInfo.pageNum"
                                    :page-sizes="[10,20,30,50]"
                                    :page-size="umb_queryInfo.pageSize"
                                    layout="total, sizes, prev, pager, next, jumper"
                                    :total="umb_page.total">
                            </el-pagination>
                        </el-col>
                    </el-row>
                </div>
            </el-card>
            <!-- 增加,对话框区域 -->
            <div>
                <el-dialog title="添加配置信息"
                           :visible.sync="umb_dialog.addDialog"
131 132
                           v-loading="umb_loading.addLoading" element-loading-text="拼命添加配置中"
                           style="margin-top: -50px" text-align="center" width="60%"
王勇 authored
133 134
                           @close="umb_addDialogClosed">
135
                    <el-form :inline="true" label-width="120px" status-icon style="margin-top: -30px" align="center"
王勇 authored
136
                             :model="umb_addForm" :rules="umb_addFormRules" ref="umb_addFormRef">
137
138
                        <el-form-item label="" prop="usernames">
139
                            <el-select v-model="umb_addForm.usernames" prefix-icon="el-icon-search" clearable
140
                                       @change="umb_userInfo_addChange"
141
                                       style="width:300px" size="medium" filterable multiple
142 143
                                       placeholder="请选择用户">
                                <el-option
144
                                        v-for="item in (user_cloud.cloudUserList)"
145 146
                                        :key="item.id"
                                        :label="item.username"
147 148 149
                                        :value="item.username">
                                    <span style="float: left">{{ item.username }}</span>
                                    <span style="float: right; color: #0984e3; ">{{ item.realname }}</span>
150 151
                                </el-option>
                            </el-select>
王勇 authored
152
                        </el-form-item>
153
                        <el-form-item label="" prop="serverId">
王勇 authored
154
                            <el-select v-model="umb_addForm.serverId" prefix-icon="el-icon-search" clearable
155
                                       style="width:300px" size="medium" filterable
156
                                       :disabled="umb_addForm.usernames.length===0"
王勇 authored
157
                                       @change="umb_server_addChange"
158
                                       placeholder="请选择服务器">
王勇 authored
159 160 161 162 163 164 165
                                <el-option
                                        v-for="item in (umb_config.serverList)"
                                        :key="item.id"
                                        :label="item.serverName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
166
                        </el-form-item>
王勇 authored
167
168
                        <el-form-item label="" prop="virtualHostId">
王勇 authored
169
                            <el-select v-model="umb_addForm.virtualHostId" prefix-icon="el-icon-search" clearable
170
                                       style="width:300px" size="medium" filterable
王勇 authored
171
                                       @change="umb_virtualHost_addChange"
172
                                       :disabled="umb_addForm.serverId==='' || umb_addForm.usernames.length===0"
173
                                       placeholder="请选择虚拟主机">
王勇 authored
174 175 176 177 178 179 180
                                <el-option
                                        v-for="item in (umb_config.virtualHostList)"
                                        :key="item.id"
                                        :label="item.virtualHostName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
181 182
                        </el-form-item>
183
                        <el-form-item label="" prop="exchangeIds">
184
                            <el-select v-model="umb_addForm.exchangeIds" prefix-icon="el-icon-search" clearable
185
                                       style="width:300px" size="medium" filterable multiple
王勇 authored
186 187
                                       @change="umb_exchange_addChange"
                                       :disabled="umb_addForm.virtualHostId===''"
188
                                       placeholder="请选择交换机">
王勇 authored
189 190 191 192 193 194 195
                                <el-option
                                        v-for="item in (umb_config.exchangeList)"
                                        :key="item.id"
                                        :label="item.exchangeName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
196
                        </el-form-item>
王勇 authored
197
198
                        <el-form-item label="" prop="routingKeyIds">
199
                            <el-select v-model="umb_addForm.routingKeyIds" prefix-icon="el-icon-search" clearable
200
                                       style="width:300px" size="medium" filterable multiple
王勇 authored
201
                                       :disabled="umb_addForm.exchangeIds===''"
202
                                       placeholder="请选择路由键">
王勇 authored
203
                                <el-option
204
                                        v-for="item in (umb_config.routingKeyList)"
王勇 authored
205
                                        :key="item.id"
206
                                        :label="item.routingKeyName"
王勇 authored
207 208 209
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
210
                        </el-form-item>
王勇 authored
211
212
                        <el-form-item label="" prop="queueIds">
213
                            <el-select v-model="umb_addForm.queueIds" prefix-icon="el-icon-search" clearable
214
                                       style="width:300px" size="medium" filterable multiple
215
                                       :disabled="umb_addForm.virtualHostId==='' || umb_addForm.usernames.length===0"
216
                                       placeholder="请选择订阅者队列">
王勇 authored
217
                                <el-option
218
                                        v-for="item in (umb_config.queueList)"
王勇 authored
219
                                        :key="item.id"
220
                                        :label="item.queueName"
王勇 authored
221 222 223
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
224
                        </el-form-item>
225
226 227
                        <el-form-item label="" prop="description">
                            <el-input v-model="umb_addForm.description" style="width:300px" size="medium" clearable
228
                                      type="textarea" autosize :rows="1"
王勇 authored
229 230 231
                                      placeholder="请输入相关描述">
                            </el-input>
                        </el-form-item>
王勇 authored
232
                    </el-form>
王勇 authored
233
                    <div slot="footer" class="dialog-footer" style="text-align: center;margin-top: 0px">
王勇 authored
234
                        <el-button type="info" @click="umb_dialog.addDialog = false" size="medium"
235
                                   style="width: 100px;background-color: #6F8294;color: #ffffff">取消
王勇 authored
236 237 238 239 240 241 242 243 244
                        </el-button>
                        <el-button type="primary" @click="umb_add" :loading="umb_loading.addLoading"
                                   size="medium" style="width: 100px">添加
                        </el-button>
                    </div>
                </el-dialog>
            </div>
            <!-- 编辑,对话框区域 -->
            <div>
王勇 authored
245
                <el-dialog title="查看配置信息"
王勇 authored
246
                           :visible.sync="umb_dialog.editDialog"
247
                           style="margin-top: -50px" text-align="center" width="50%"
王勇 authored
248
                           @close="umb_editDialogClosed">
249
                    <el-form :inline="true" label-width="120px" status-icon style="margin-left: 30px" align="center"
王勇 authored
250
                             :model="umb_editForm" :rules="umb_editFormRules" ref="umb_editFormRef">
251
                        <el-form-item label="" prop="username">
252
                            <el-input v-model="umb_editForm.username" style="width:300px" size="small" clearable disabled
王勇 authored
253
                                      placeholder="请输入用户名称">
254
                                <template  slot="prepend" >用户名称</template>
王勇 authored
255 256
                            </el-input>
                        </el-form-item>
257 258 259 260 261
                        <!--                        <el-form-item label="订阅者名称:" prop="subscriber">-->
                        <!--                            <el-input v-model="umb_editForm.subscriber" style="width:240px" size="small" clearable-->
                        <!--                                      placeholder="请输入订阅者名称">-->
                        <!--                            </el-input>-->
                        <!--                        </el-form-item>-->
王勇 authored
262
263
                        <!-- @change="umb_server_editChange" -->
264
                        <el-form-item label="" prop="serverId">
265
                            <el-select v-model="umb_editForm.serverId" prefix-icon="el-icon-search" clearable
266
                                       style="width:300px" size="small" filterable disabled
王勇 authored
267 268 269 270 271 272 273 274
                                       placeholder="请选择所属服务器">
                                <el-option
                                        v-for="item in (umb_config.serverList)"
                                        :key="item.id"
                                        :label="item.serverName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
275
                        </el-form-item>
王勇 authored
276
277
                        <!-- :disabled="umb_editForm.serverId===''"-->
278
                        <el-form-item label="" prop="virtualHostId">
王勇 authored
279
                            <el-select v-model="umb_editForm.virtualHostId" prefix-icon="el-icon-search" clearable
280
                                       style="width:300px" size="small" filterable disabled
王勇 authored
281 282 283 284 285 286 287 288 289
                                       @change="umb_virtualHost_editChange"
                                       placeholder="请选择虚拟主机名称">
                                <el-option
                                        v-for="item in (umb_config.virtualHostList)"
                                        :key="item.id"
                                        :label="item.virtualHostName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
290 291
                        </el-form-item>
292
                        <!-- :disabled="umb_editForm.virtualHostId===''" -->
293
                        <el-form-item label="" prop="exchangeId">
王勇 authored
294
                            <el-select v-model="umb_editForm.exchangeId" prefix-icon="el-icon-search" clearable
295
                                       style="width:300px" size="small" filterable disabled
王勇 authored
296 297 298 299 300 301 302 303 304
                                       @change="umb_exchange_editChange"
                                       placeholder="请选择交换机名称">
                                <el-option
                                        v-for="item in (umb_config.exchangeList)"
                                        :key="item.id"
                                        :label="item.exchangeName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
305
                        </el-form-item>
王勇 authored
306
307
                        <!-- :disabled="umb_editForm.exchangeId===''" -->
308
                        <el-form-item label="" prop="routingKeyId">
309 310 311
                            <el-select v-model="umb_editForm.routingKeyId" prefix-icon="el-icon-search" clearable
                                       style="width:300px" size="small" filterable disabled
                                       placeholder="请选择路由键名称">
王勇 authored
312
                                <el-option
313
                                        v-for="item in (umb_config.routingKeyList)"
王勇 authored
314
                                        :key="item.id"
315
                                        :label="item.routingKeyName"
王勇 authored
316 317 318
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
319
                        </el-form-item>
王勇 authored
320
321
                        <!-- :disabled="umb_editForm.virtualHostId===''" -->
322
                        <el-form-item label="" prop="queueIds">
323 324 325
                            <el-select v-model="umb_editForm.queueIds" prefix-icon="el-icon-search" clearable
                                       style="width:300px" size="small" filterable multiple disabled
                                       placeholder="请选择订阅者队列">
王勇 authored
326
                                <el-option
327
                                        v-for="item in (umb_config.queueList)"
王勇 authored
328
                                        :key="item.id"
329
                                        :label="item.queueName"
王勇 authored
330 331 332
                                        :value="item.id">
                                </el-option>
                            </el-select>
王勇 authored
333
                        </el-form-item>
334
335
                        <el-form-item label="" prop="description">
336 337
                            <el-input v-model="umb_editForm.description" style="width:300px" size="small" clearable
                                      type="textarea" autosize :rows="1" disabled
王勇 authored
338 339 340
                                      placeholder="请输入相关描述">
                            </el-input>
                        </el-form-item>
王勇 authored
341 342 343
                    </el-form>
                    <div slot="footer" class="dialog-footer" style="text-align: center">
                        <el-button type="info" @click="umb_dialog.editDialog = false" size="medium"
344
                                   style="width: 100px;background-color: #6F8294;color: #ffffff">取消
王勇 authored
345
                        </el-button>
王勇 authored
346 347
                        <el-button type="primary" @click="umb_dialog.editDialog = false" :loading="umb_loading.addLoading" disabled
                                   size="medium" style="width: 100px">关闭
王勇 authored
348 349 350 351 352 353
                        </el-button>
                    </div>
                </el-dialog>
            </div>
        </el-main>
    </el-container>
354 355 356
</template>

<script>
王勇 authored
357 358 359 360 361 362
    import {
        selectUserMessageBindingList,
        insertUserMessageBinding,
        updateUserMessageBinding,
        deleteUserMessageBinding,
        batchRemoveUserMessageBinding,
363 364
        getServerList, getHostList, getExchangeList, getQueueList, getRoutingKeyList,
        getUserInfoList
王勇 authored
365
    } from "../../api/message_bus";
366
    import {getUserList} from '../../api/user';
王勇 authored
367
368
    export default {
王勇 authored
369 370 371 372
        /**
         * UserMessageBinding:  账户信息绑定配置
         * 简称:umb
         */
373 374 375 376
        name: "UserMessageBinding",

        data() {
            return {
王勇 authored
377
                /**
378 379 380 381 382 383 384 385 386 387 388
                 * 用户中心,相关
                 */
                user_cloud: {
                    cloudUserList: [],
                    queryInfo: {
                        pageNum: 1,
                        pageSize: 10000,
                    }
                },

                /**
王勇 authored
389 390
                 * umb,配置与参数
                 */
王勇 authored
391 392 393 394 395 396 397 398 399 400 401
                umb_config: {
                    // 服务器列表
                    serverList: [],
                    // 虚拟主机列表
                    virtualHostList: [],
                    // 交换机列表
                    exchangeList: [],
                    // 队列-列表
                    queueList: [],
                    // 路由键列表
                    routingKeyList: [],
402 403
                    // 用户信息列表
                    userInfoList: [],
王勇 authored
404
                },
405
王勇 authored
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
                /**
                 *  umb,搜索参数
                 */
                umb_queryInfo: {
                    // 用户名称
                    username: '',
                    // 订阅者名称
                    subscriber: '',
                    // 服务器名称
                    serverName: '',
                    // 虚拟主机名称
                    virtualHostName: '',
                    // 交换机名称
                    exchangeName: '',
                    // 队列名称
                    queueName: '',
                    // 路由键名称
                    routingKeyName: '',
                    // 当前页数
                    pageNum: 1,
                    // 每页条数
                    pageSize: 10
                },
                /**
                 * umb,分页
                 */
                umb_page: {
                    // 配置,列表
                    umbList: [],
                    // 总条数
                    total: 0,
                    // 批量删除,选中列表
                    selectList: [],
                },
                /**
                 * umb,新增表单
                 */
                umb_addForm: {
444 445
                    // 用户id
                    userId: '',
王勇 authored
446 447
                    // 用户名称
                    username: '',
王勇 authored
448 449 450 451 452 453 454 455 456 457
                    // 服务器id
                    serverId: '',
                    // 虚拟主机id
                    virtualHostId: '',
                    // 交换机id
                    exchangeId: '',
                    // 队列id
                    queueId: '',
                    // 路由键id
                    routingKeyId: '',
458 459 460 461 462 463
                    // 临时字段,队列id集合
                    queueIds: [],
                    // 临时字段,交换机id集合
                    exchangeIds: [],
                    // 临时字段,用户id集合
                    userIds: [],
464 465
                    // 临时字段,用户名称集合
                    usernames: [],
466 467
                    // 临时字段,路由键id集合
                    routingKeyIds: [],
王勇 authored
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
                },
                /**
                 * umb,编辑表单
                 */
                umb_editForm: {},
                /**
                 * umb,加载
                 */
                umb_loading: {
                    // 列表加载
                    listLoading: false,
                    // 添加加载
                    addLoading: false,
                    // 编辑加载
                    editLoading: false,
                    // 删除加载
                    delLoading: false,
                    // 批量删除加载
                    batchDelLoading: false,
                },
                /**
                 *  umb,对话框管理
                 */
                umb_dialog: {
                    // 添加对话框
                    addDialog: false,
                    // 编辑对话框
                    editDialog: false,
                },
                /**
                 * umb,添加表单,验证规则
                 */
                umb_addFormRules: {
                    // 用户名称
502
                    userIds: [
王勇 authored
503 504
                        {required: true, message: '请输入用户名称', trigger: ['blur', 'change']},
                    ],
505 506 507 508
                    // 用户名称
                    usernames: [
                        {required: true, message: '请输入用户名称', trigger: ['blur', 'change']},
                    ],
王勇 authored
509
                    // 订阅者名称
510 511 512
                    // subscriber: [
                    //     {required: true, message: '请输入订阅者名称', trigger: ['blur', 'change']},
                    // ],
王勇 authored
513 514 515
                    // 服务器ID
                    serverId: [
                        {required: true, message: '请选择服务器名称', trigger: ['blur', 'change']},
王勇 authored
516
                    ],
王勇 authored
517 518 519
                    // 虚拟主机ID
                    virtualHostId: [
                        {required: true, message: '请选择虚拟主机名称', trigger: ['blur', 'change']},
王勇 authored
520
                    ],
王勇 authored
521
                    // 交换机ID
522
                    exchangeIds: [
王勇 authored
523
                        {required: true, message: '请选择交换机名称', trigger: ['blur', 'change']},
王勇 authored
524
                    ],
王勇 authored
525
                    // 队列ID
526
                    queueIds: [
王勇 authored
527
                        {required: true, message: '请选择队列名称', trigger: ['blur', 'change']},
王勇 authored
528
                    ],
王勇 authored
529
                    // 路由键ID
530
                    routingKeyIds: [
王勇 authored
531
                        {required: true, message: '请选择路由键名称', trigger: ['blur', 'change']},
王勇 authored
532 533 534 535 536 537 538 539 540 541 542 543 544 545
                    ],
                },
                /**
                 * umb,编辑表单,验证规则
                 */
                umb_editFormRules: {
                    // 用户名称
                    username: [
                        {required: true, message: '请输入用户名称', trigger: ['blur', 'change']},
                    ],
                    // 订阅者名称
                    subscriber: [
                        {required: true, message: '请输入订阅者名称', trigger: ['blur', 'change']},
                    ],
王勇 authored
546 547 548
                    // 服务器ID
                    serverId: [
                        {required: true, message: '请选择服务器名称', trigger: ['blur', 'change']},
王勇 authored
549
                    ],
王勇 authored
550 551 552
                    // 虚拟主机ID
                    virtualHostId: [
                        {required: true, message: '请选择虚拟主机名称', trigger: ['blur', 'change']},
王勇 authored
553
                    ],
王勇 authored
554 555 556
                    // 交换机ID
                    exchangeId: [
                        {required: true, message: '请选择交换机名称', trigger: ['blur', 'change']},
王勇 authored
557
                    ],
王勇 authored
558
                    // 队列ID
559
                    queueIds: [
王勇 authored
560
                        {required: true, message: '请选择队列名称', trigger: ['blur', 'change']},
王勇 authored
561
                    ],
王勇 authored
562 563 564
                    // 路由键ID
                    routingKeyId: [
                        {required: true, message: '请选择路由键名称', trigger: ['blur', 'change']},
王勇 authored
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
                    ],
                },
                /**
                 * Boolean属性,选择列表
                 */
                booleanList: [
                    {
                        value: true,
                        label: '是'
                    },
                    {
                        value: false,
                        label: '否'
                    },
                ],
580 581 582
            }
        },
        methods: {
王勇 authored
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
            /**
             * 分页查询,监听 pageSize 改变的事件
             */
            umb_handleSizeChange(newSize) {
                this.umb_queryInfo.pageSize = newSize;
                //刷新列表
                this.umb_getList();
            },
            /**
             * 分页查询,监听 pageNum 改变的事件
             */
            umb_handleCurrentChange(newPage) {
                this.umb_queryInfo.pageNum = newPage;
                //刷新列表
                this.umb_getList();
            },
            /**
             * umb,分页查询
             */
            umb_getList() {
                // 开启加载
                this.umb_loading.listLoading = true;
                selectUserMessageBindingList(this.umb_queryInfo).then((response) => {
                    let res = response.data;
                    if (res.code !== '200') {
                        // 关闭加载
                        this.umb_loading.listLoading = false;
610
                        return this.$message.error(res.msg);
王勇 authored
611 612 613 614 615 616 617
                    }
                    // 获取列表数据
                    this.umb_page.umbList = res.data.list;
                    // 获取列表的总记录数
                    this.umb_page.total = res.data.total;
                    // 关闭加载
                    this.umb_loading.listLoading = false;
618
                    this.$message.success(res.msg);
王勇 authored
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
                }).catch(error => {
                    // 关闭加载
                    this.umb_loading.listLoading = false;
                    this.$message.error(error.toString());
                });
            },
            /**
             * umb,添加对话框,打开事件
             */
            umb_toAddDialog() {
                this.umb_dialog.addDialog = true;
            },
            /**
             * umb,添加对话框,关闭事件
             */
            umb_addDialogClosed() {
                // 重置对话框
                this.$refs.umb_addFormRef.resetFields();
            },
            /**
             * umb,添加功能
             */
            umb_add() {
642
                this.umb_addForm.queueId = this.umb_addForm.queueIds.join();
643
                this.umb_addForm.username = this.umb_addForm.usernames.join();
644 645
                this.umb_addForm.exchangeId = this.umb_addForm.exchangeIds.join();
                this.umb_addForm.routingKeyId = this.umb_addForm.routingKeyIds.join();
王勇 authored
646 647 648 649 650 651 652 653 654 655 656 657
                // 进行表单的预验证
                this.$refs.umb_addFormRef.validate(valid => {
                    // 未通过,表单预校验
                    if (!valid) return;
                    // 通过,表单预检验,开启加载
                    this.umb_loading.addLoading = true;
                    insertUserMessageBinding(this.umb_addForm).then((response) => {
                        let res = response.data;
                        // 添加失败
                        if (res.code !== '200') {
                            // 关闭加载
                            this.umb_loading.addLoading = false;
658
                            return this.$message.error(res.msg);
王勇 authored
659 660
                        }
                        // 添加,成功
661
                        this.$message.success(res.msg);
王勇 authored
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
                        // 关闭加载
                        this.umb_loading.addLoading = false;
                        // 隐藏对话框
                        this.umb_dialog.addDialog = false;
                        // 刷新列表
                        this.umb_getList();
                    }).catch(error => {
                        // 关闭加载
                        this.umb_loading.addLoading = false;
                        this.$message.error(error.toString());
                    });
                })
            },

            /**
             * umb,编辑对话框,打开事件
             */
            umb_toEditDialog(index, row) {
王勇 authored
680 681 682 683 684
                this.selectServerList()
                this.selectHostList(row.serverId)
                this.selectQueueList(row.virtualHostId)
                this.selectExchangeList(row.virtualHostId)
                this.selectRoutingKeyList(row.exchangeId)
王勇 authored
685
                this.umb_editForm = Object.assign({}, row);
686 687 688 689 690 691 692 693

                this.umb_editForm.queueIds = [];
                if (this.umb_editForm.queueId.indexOf(",") === -1) {
                    // 队列id中不包含","
                    this.umb_editForm.queueIds[0] = this.umb_editForm.queueId;
                } else {
                    this.umb_editForm.queueIds = this.umb_editForm.queueId.split(",")
                }
王勇 authored
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
                this.umb_dialog.editDialog = true;
            },
            /**
             * umb,编辑对话框,关闭事件
             */
            umb_editDialogClosed() {
                //重置对话框
                this.$refs.umb_editFormRef.resetFields();
            },
            /**
             * umb,编辑功能
             */
            umb_edit() {
                //进行表单的预验证
                this.$refs.umb_editFormRef.validate(valid => {
                    // 未通过,表单预校验
                    if (!valid) return;
                    // 通过,表单预检验,开启加载
                    this.umb_loading.editLoading = true;
                    updateUserMessageBinding(this.umb_editForm).then((response) => {
                        let res = response.data;
                        if (res.code !== '200') {
                            if (res.code === '999') {
                                // 关闭加载
                                this.umb_loading.editLoading = false;
                                return this.$message.error('未知异常,编辑配置信息,失败');
                            }
                            //关闭加载
                            this.umb_loading.editLoading = false;
                            return this.$message.error('编辑配置信息,失败');
                        }
                        // 关闭加载
                        this.umb_loading.editLoading = false;
                        this.$message.success('编辑配置信息,成功!');
                        // 隐藏对话框
                        this.umb_dialog.editDialog = false;
                        // 刷新列表
                        this.umb_getList();
                    }).catch(error => {
                        // 关闭加载
                        this.umb_loading.editLoading = false;
                        this.$message.error(error.toString());
                    });
                })
            },
            /**
             * umb,删除功能
             */
            umb_remove(index, row) {
                // 弹框询问是否删除?
                this.$confirm('此操作永久删除该配置信息, 是否继续?', '警告', {
                        confirmButtonText: '确定删除',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }
                ).then(() => {
                    // 开启加载
751
                    this.umb_loading.listLoading = true;
王勇 authored
752 753 754 755
                    deleteUserMessageBinding(row).then((response) => {
                        let res = response.data;
                        if (res.code !== '200') {
                            // 关闭加载
756
                            this.umb_loading.listLoading = false;
王勇 authored
757 758 759
                            return this.$message.error('删除-配置-信息,失败');
                        }
                        // 关闭加载
760
                        this.umb_loading.listLoading = false;
王勇 authored
761 762 763 764 765
                        this.$message.success('删除-配置-信息,成功!');
                        // 刷新列表
                        this.umb_getList();
                    }).catch(error => {
                        // 关闭加载
766
                        this.umb_loading.listLoading = false;
王勇 authored
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790
                        this.$message.error(error.toString());
                    });
                }).catch(() => {
                });
            },

            /**
             * umb,批量删除---选中
             */
            umb_selectChange: function (selectList) {
                this.umb_page.selectList = selectList;
            },
            /**
             * umb,批量删除功能
             */
            umb_batchRemove() {
                const ids = this.umb_page.selectList.map(item => item.id).toString();
                this.$confirm('此操作将永久删除选中的配置信息, 是否继续?', '警告', {
                        confirmButtonText: '确定删除',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }
                ).then(() => {
                    // 开启加载
王勇 authored
791
                    this.umb_loading.listLoading = true;
王勇 authored
792 793 794 795 796
                    let params = {ids: ids};
                    batchRemoveUserMessageBinding(params).then(response => {
                        let res = response.data;
                        if (res.code !== '200') {
                            // 关闭加载
王勇 authored
797
                            this.umb_loading.listLoading = false;
王勇 authored
798 799 800 801
                            return this.$message.error('批量删除-配置-信息,失败');
                        }
                        this.$message.success('批量删除-配置-信息,成功!');
                        // 关闭加载
王勇 authored
802
                        this.umb_loading.listLoading = false;
王勇 authored
803 804 805 806
                        // 刷新列表
                        this.umb_getList();
                    }).catch(error => {
                        // 关闭加载
王勇 authored
807
                        this.umb_loading.listLoading = false;
王勇 authored
808 809 810 811 812
                        this.$message.error(error.toString());
                    });
                }).catch(() => {
                });
            },
813
王勇 authored
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865
            /**
             * 获取服务器列表
             */
            selectServerList() {
                getServerList().then((response) => {
                    let res = response.data;
                    if (res.code !== '200') {
                        return this.$message.error('获取服务器列表,失败!');
                    }
                    // 获取服务器列表数据
                    this.umb_config.serverList = res.data;
                }).catch(error => {
                    this.$message.error(error.toString());
                });
            },

            /**
             * 获取虚拟主机列表
             */
            selectHostList(id) {
                let params = {serverId: id};
                getHostList(params).then((response) => {
                    let res = response.data;
                    if (res.code !== '200') {
                        return this.$message.error('获取虚拟主机列表,失败!');
                    }
                    // 获取虚拟主机列表数据
                    this.umb_config.virtualHostList = res.data;
                }).catch(error => {
                    this.$message.error(error.toString());
                });
            },

            /**
             * 获取交换机列表
             */
            selectExchangeList(id) {
                let params = {virtualHostId: id};
                getExchangeList(params).then((response) => {
                    let res = response.data;
                    if (res.code !== '200') {
                        return this.$message.error('获取交换机列表,失败!');
                    }
                    // 获取交换机列表数据
                    this.umb_config.exchangeList = res.data;
                }).catch(error => {
                    this.$message.error(error.toString());
                });
            },
            /**
             * 获取队列-列表
             */
866
            selectQueueList(virtualHostId) {
867
                let params = {
868
                    virtualHostId: virtualHostId,
869
                };
王勇 authored
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
                getQueueList(params).then((response) => {
                    let res = response.data;
                    if (res.code !== '200') {
                        return this.$message.error('获取队列-列表,失败!');
                    }
                    // 获取队列-列表数据
                    this.umb_config.queueList = res.data;
                }).catch(error => {
                    this.$message.error(error.toString());
                });
            },
            /**
             * 获取路由键-列表
             */
            selectRoutingKeyList(id) {
                let params = {exchangeId: id};
                getRoutingKeyList(params).then((response) => {
                    let res = response.data;
                    if (res.code !== '200') {
                        return this.$message.error('获取路由键列表,失败!');
                    }
                    // 获取路由键列表数据
                    this.umb_config.routingKeyList = res.data;
                }).catch(error => {
                    this.$message.error(error.toString());
                });
            },

            /**
             * 添加方法,服务器ID值,改变
             */
            umb_server_addChange(value) {
                // 现将对应的虚拟主机的ID清空
                this.umb_addForm.virtualHostId = undefined;
                // 根据服务器ID,获取出对应的虚拟主机的列表
                this.selectHostList(value);
            },
907 908

            umb_userInfo_addChange(value) {
909
910 911
            },
王勇 authored
912 913 914 915
            /**
             * 添加方法,虚拟主机ID值,改变
             */
            umb_virtualHost_addChange(value) {
王勇 authored
916 917 918
                this.umb_addForm.exchangeIds = undefined;
                this.umb_addForm.queueIds = undefined;
                this.umb_addForm.routingKeyIds = undefined;
王勇 authored
919
                this.selectExchangeList(value);
920
                this.selectQueueList(value);
王勇 authored
921
            },
922
王勇 authored
923 924 925 926 927
            /**
             * 添加方法,交换机ID值,改变
             */
            umb_exchange_addChange(value) {
                // 先将对应的路由键的ID清空
王勇 authored
928
                this.umb_addForm.routingKeyIds = undefined;
王勇 authored
929
                // 根据交换机ID,获取出对应的路由键的列表
930
                this.selectRoutingKeyList(value.join());
王勇 authored
931
            },
932 933 934 935 936 937 938
            // /**
            //  * 添加方法,队列ID值,改变
            //  */
            // umb_queue_addChange(value) {
            //     // 将多选的queueID,用逗号相连接
            //     this.umb_addForm.queueId = value.join();
            // },
王勇 authored
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
            /**
             * 编辑方法,服务器ID值,改变
             */
            umb_server_editChange(value) {
                // 现将对应的虚拟主机的ID清空
                this.umb_editForm.virtualHostId = undefined;
                // 根据服务器ID,获取出对应的虚拟主机的列表
                this.selectHostList(value);
            },
            /**
             * 编辑方法,虚拟主机ID值,改变
             */
            umb_virtualHost_editChange(value) {
                // 先将对应的交换机和队列的ID清空
                this.umb_editForm.exchangeId = undefined;
                this.umb_editForm.queueId = undefined;

                // 根据虚拟主机ID,获取出对应的交换机和队列的列表
                this.selectExchangeList(value);
                this.selectQueueList(value);
            },
            /**
             * 编辑方法,交换机ID值,改变
             */
            umb_exchange_editChange(value) {
                // 先将对应的路由键的ID清空
                this.umb_editForm.routingKeyId = undefined;
                // 根据交换机ID,获取出对应的路由键的列表
                this.selectRoutingKeyList(value);
            },
969 970 971 972 973 974 975
            /**
             * 获取所有用户的信息
             */
            umb_getUserInfoList() {
                getUserInfoList().then((response) => {
                    let res = response.data;
                    if (res.code !== '200') {
976
                        return this.$message.error('获取用户信息列表,失败!');
977 978 979 980 981 982 983
                    }
                    // 获取列表数据
                    this.umb_config.userInfoList = res.data;
                }).catch(error => {
                    this.$message.error(error.toString());
                });
            },
984 985 986 987 988 989 990 991 992 993 994

            /**
             * 查询用户中心的用户
             */
            getCloudUser() {
                getUserList(this.user_cloud.queryInfo).then((response) => {
                    this.user_cloud.cloudUserList = response.data.data.list;
                }).catch((error) => {
                    this.$message.error(error.toString());
                });
            },
995 996
        },
        created() {
王勇 authored
997
            // 刷新列表
998
            // this.umb_getList();
999 1000
        },
        mounted() {
王勇 authored
1001 1002
            // 获取服务器列表
            this.selectServerList();
1003 1004
            // 获取用户中心的用户列表
            this.getCloudUser();
1005
        },
王勇 authored
1006
        computed: {},
1007 1008 1009 1010 1011 1012
    }
</script>

<style scoped>

</style>