审查视图

src/views/bus/UserMessageBinding.vue 47.6 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
                                添加配置信息
                            </el-button>
                        </el-col>
                    </el-row>
                </div>
                <!-- 列表区域 -->
                <div style="margin-top: 20px;">
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
                    <el-row>
                        <el-col :span="24">
                            <el-table :data="umb_page.umbList" border v-loading="umb_loading.listLoading"
                                      @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;">
                                <el-table-column type="selection" width="55" align="center"></el-table-column>
                                <el-table-column type="index" align="center" width="55" ></el-table-column>
                                <el-table-column label="用户名称" prop="username" align="center" width="120"></el-table-column>
                                <!--  <el-table-column label="订阅者名称" prop="subscriber" align="center" width="220"></el-table-column>-->
                                <el-table-column label="服务器名称" prop="serverName" align="center"
                                                 width="120"></el-table-column>
                                <el-table-column label="虚拟主机名称" prop="virtualHostName" align="center"
                                                 width="120"></el-table-column>
                                <el-table-column label="交换机名称" prop="exchangeName" align="center" width="120"></el-table-column>
                                <el-table-column label="队列名称" prop="queueName" align="center" width="220"></el-table-column>
                                <el-table-column label="路由键名称" prop="routingKeyName" align="center"
                                                 width="120"></el-table-column>
                                <el-table-column label="相关描述" prop="description" align="center"
                                                 width="220"></el-table-column>
                                <el-table-column label="操作" width="200px" align="center" fixed="right">
                                    <template slot-scope="scope">
                                        <!-- 编辑按钮-->
                                        <el-tooltip effect="dark" content="编辑" placement="top-start" :enterable="false">
                                            <el-button type="primary" icon="el-icon-view" size="mini" style="margin-bottom: 2px"
                                                       @click="umb_toEditDialog(scope.$index,scope.row)">查看
                                            </el-button>
                                        </el-tooltip>

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

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

        data() {
            return {
王勇 authored
382
                /**
383 384 385 386 387 388 389 390 391 392 393
                 * 用户中心,相关
                 */
                user_cloud: {
                    cloudUserList: [],
                    queryInfo: {
                        pageNum: 1,
                        pageSize: 10000,
                    }
                },

                /**
王勇 authored
394 395
                 * umb,配置与参数
                 */
王勇 authored
396 397 398 399 400 401 402 403 404 405 406
                umb_config: {
                    // 服务器列表
                    serverList: [],
                    // 虚拟主机列表
                    virtualHostList: [],
                    // 交换机列表
                    exchangeList: [],
                    // 队列-列表
                    queueList: [],
                    // 路由键列表
                    routingKeyList: [],
407 408
                    // 用户信息列表
                    userInfoList: [],
王勇 authored
409
                },
410
王勇 authored
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 444 445 446 447 448
                /**
                 *  umb,搜索参数
                 */
                umb_queryInfo: {
                    // 用户名称
                    username: '',
                    // 订阅者名称
                    subscriber: '',
                    // 服务器名称
                    serverName: '',
                    // 虚拟主机名称
                    virtualHostName: '',
                    // 交换机名称
                    exchangeName: '',
                    // 队列名称
                    queueName: '',
                    // 路由键名称
                    routingKeyName: '',
                    // 当前页数
                    pageNum: 1,
                    // 每页条数
                    pageSize: 10
                },
                /**
                 * umb,分页
                 */
                umb_page: {
                    // 配置,列表
                    umbList: [],
                    // 总条数
                    total: 0,
                    // 批量删除,选中列表
                    selectList: [],
                },
                /**
                 * umb,新增表单
                 */
                umb_addForm: {
449 450
                    // 用户id
                    userId: '',
王勇 authored
451 452
                    // 用户名称
                    username: '',
王勇 authored
453 454 455 456 457 458 459 460 461 462
                    // 服务器id
                    serverId: '',
                    // 虚拟主机id
                    virtualHostId: '',
                    // 交换机id
                    exchangeId: '',
                    // 队列id
                    queueId: '',
                    // 路由键id
                    routingKeyId: '',
463 464 465 466 467 468
                    // 临时字段,队列id集合
                    queueIds: [],
                    // 临时字段,交换机id集合
                    exchangeIds: [],
                    // 临时字段,用户id集合
                    userIds: [],
469 470
                    // 临时字段,用户名称集合
                    usernames: [],
471 472
                    // 临时字段,路由键id集合
                    routingKeyIds: [],
王勇 authored
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 502 503 504 505 506
                },
                /**
                 * 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: {
                    // 用户名称
507
                    userIds: [
王勇 authored
508 509
                        {required: true, message: '请输入用户名称', trigger: ['blur', 'change']},
                    ],
510 511 512 513
                    // 用户名称
                    usernames: [
                        {required: true, message: '请输入用户名称', trigger: ['blur', 'change']},
                    ],
王勇 authored
514
                    // 订阅者名称
515 516 517
                    // subscriber: [
                    //     {required: true, message: '请输入订阅者名称', trigger: ['blur', 'change']},
                    // ],
王勇 authored
518 519 520
                    // 服务器ID
                    serverId: [
                        {required: true, message: '请选择服务器名称', trigger: ['blur', 'change']},
王勇 authored
521
                    ],
王勇 authored
522 523 524
                    // 虚拟主机ID
                    virtualHostId: [
                        {required: true, message: '请选择虚拟主机名称', trigger: ['blur', 'change']},
王勇 authored
525
                    ],
王勇 authored
526
                    // 交换机ID
527
                    exchangeIds: [
王勇 authored
528
                        {required: true, message: '请选择交换机名称', trigger: ['blur', 'change']},
王勇 authored
529
                    ],
王勇 authored
530
                    // 队列ID
531
                    queueIds: [
王勇 authored
532
                        {required: true, message: '请选择队列名称', trigger: ['blur', 'change']},
王勇 authored
533
                    ],
王勇 authored
534
                    // 路由键ID
535
                    routingKeyIds: [
王勇 authored
536
                        {required: true, message: '请选择路由键名称', trigger: ['blur', 'change']},
王勇 authored
537 538 539 540 541 542 543 544 545 546 547 548 549 550
                    ],
                },
                /**
                 * umb,编辑表单,验证规则
                 */
                umb_editFormRules: {
                    // 用户名称
                    username: [
                        {required: true, message: '请输入用户名称', trigger: ['blur', 'change']},
                    ],
                    // 订阅者名称
                    subscriber: [
                        {required: true, message: '请输入订阅者名称', trigger: ['blur', 'change']},
                    ],
王勇 authored
551 552 553
                    // 服务器ID
                    serverId: [
                        {required: true, message: '请选择服务器名称', trigger: ['blur', 'change']},
王勇 authored
554
                    ],
王勇 authored
555 556 557
                    // 虚拟主机ID
                    virtualHostId: [
                        {required: true, message: '请选择虚拟主机名称', trigger: ['blur', 'change']},
王勇 authored
558
                    ],
王勇 authored
559 560 561
                    // 交换机ID
                    exchangeId: [
                        {required: true, message: '请选择交换机名称', trigger: ['blur', 'change']},
王勇 authored
562
                    ],
王勇 authored
563
                    // 队列ID
564
                    queueIds: [
王勇 authored
565
                        {required: true, message: '请选择队列名称', trigger: ['blur', 'change']},
王勇 authored
566
                    ],
王勇 authored
567 568 569
                    // 路由键ID
                    routingKeyId: [
                        {required: true, message: '请选择路由键名称', trigger: ['blur', 'change']},
王勇 authored
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
                    ],
                },
                /**
                 * Boolean属性,选择列表
                 */
                booleanList: [
                    {
                        value: true,
                        label: '是'
                    },
                    {
                        value: false,
                        label: '否'
                    },
                ],
585 586 587
            }
        },
        methods: {
王勇 authored
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
            /**
             * 分页查询,监听 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;
615
                        return this.$message.error(res.msg);
王勇 authored
616 617 618 619 620 621 622
                    }
                    // 获取列表数据
                    this.umb_page.umbList = res.data.list;
                    // 获取列表的总记录数
                    this.umb_page.total = res.data.total;
                    // 关闭加载
                    this.umb_loading.listLoading = false;
623
                    this.$message.success(res.msg);
王勇 authored
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646
                }).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() {
647
                this.umb_addForm.queueId = this.umb_addForm.queueIds.join();
648
                this.umb_addForm.username = this.umb_addForm.usernames.join();
649 650
                this.umb_addForm.exchangeId = this.umb_addForm.exchangeIds.join();
                this.umb_addForm.routingKeyId = this.umb_addForm.routingKeyIds.join();
王勇 authored
651 652 653 654 655 656 657 658 659 660 661 662
                // 进行表单的预验证
                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;
663
                            return this.$message.error(res.msg);
王勇 authored
664 665
                        }
                        // 添加,成功
666
                        this.$message.success(res.msg);
王勇 authored
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
                        // 关闭加载
                        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
685 686 687 688 689
                this.selectServerList()
                this.selectHostList(row.serverId)
                this.selectQueueList(row.virtualHostId)
                this.selectExchangeList(row.virtualHostId)
                this.selectRoutingKeyList(row.exchangeId)
王勇 authored
690
                this.umb_editForm = Object.assign({}, row);
691 692 693 694 695 696 697 698

                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
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 751 752 753 754 755
                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(() => {
                    // 开启加载
756
                    this.umb_loading.listLoading = true;
王勇 authored
757 758 759 760
                    deleteUserMessageBinding(row).then((response) => {
                        let res = response.data;
                        if (res.code !== '200') {
                            // 关闭加载
761
                            this.umb_loading.listLoading = false;
王勇 authored
762 763 764
                            return this.$message.error('删除-配置-信息,失败');
                        }
                        // 关闭加载
765
                        this.umb_loading.listLoading = false;
王勇 authored
766 767 768 769 770
                        this.$message.success('删除-配置-信息,成功!');
                        // 刷新列表
                        this.umb_getList();
                    }).catch(error => {
                        // 关闭加载
771
                        this.umb_loading.listLoading = false;
王勇 authored
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795
                        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
796
                    this.umb_loading.listLoading = true;
王勇 authored
797 798 799 800 801
                    let params = {ids: ids};
                    batchRemoveUserMessageBinding(params).then(response => {
                        let res = response.data;
                        if (res.code !== '200') {
                            // 关闭加载
王勇 authored
802
                            this.umb_loading.listLoading = false;
王勇 authored
803 804 805 806
                            return this.$message.error('批量删除-配置-信息,失败');
                        }
                        this.$message.success('批量删除-配置-信息,成功!');
                        // 关闭加载
王勇 authored
807
                        this.umb_loading.listLoading = false;
王勇 authored
808 809 810 811
                        // 刷新列表
                        this.umb_getList();
                    }).catch(error => {
                        // 关闭加载
王勇 authored
812
                        this.umb_loading.listLoading = false;
王勇 authored
813 814 815 816 817
                        this.$message.error(error.toString());
                    });
                }).catch(() => {
                });
            },
818
王勇 authored
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 866 867 868 869 870
            /**
             * 获取服务器列表
             */
            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());
                });
            },
            /**
             * 获取队列-列表
             */
871
            selectQueueList(virtualHostId) {
872
                let params = {
873
                    virtualHostId: virtualHostId,
874
                };
王勇 authored
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 907 908 909 910 911
                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);
            },
912 913

            umb_userInfo_addChange(value) {
914
915 916
            },
王勇 authored
917 918 919 920
            /**
             * 添加方法,虚拟主机ID值,改变
             */
            umb_virtualHost_addChange(value) {
王勇 authored
921 922 923
                this.umb_addForm.exchangeIds = undefined;
                this.umb_addForm.queueIds = undefined;
                this.umb_addForm.routingKeyIds = undefined;
王勇 authored
924
                this.selectExchangeList(value);
925
                this.selectQueueList(value);
王勇 authored
926
            },
927
王勇 authored
928 929 930 931 932
            /**
             * 添加方法,交换机ID值,改变
             */
            umb_exchange_addChange(value) {
                // 先将对应的路由键的ID清空
王勇 authored
933
                this.umb_addForm.routingKeyIds = undefined;
王勇 authored
934
                // 根据交换机ID,获取出对应的路由键的列表
935
                this.selectRoutingKeyList(value.join());
王勇 authored
936
            },
937 938 939 940 941 942 943
            // /**
            //  * 添加方法,队列ID值,改变
            //  */
            // umb_queue_addChange(value) {
            //     // 将多选的queueID,用逗号相连接
            //     this.umb_addForm.queueId = value.join();
            // },
王勇 authored
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 969 970 971 972 973
            /**
             * 编辑方法,服务器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);
            },
974 975 976 977 978 979 980
            /**
             * 获取所有用户的信息
             */
            umb_getUserInfoList() {
                getUserInfoList().then((response) => {
                    let res = response.data;
                    if (res.code !== '200') {
981
                        return this.$message.error('获取用户信息列表,失败!');
982 983 984 985 986 987 988
                    }
                    // 获取列表数据
                    this.umb_config.userInfoList = res.data;
                }).catch(error => {
                    this.$message.error(error.toString());
                });
            },
989 990 991 992 993 994 995 996 997 998 999

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

<style scoped>

</style>