QueueView.vue 7.2 KB
<template>
    <el-container>
        <el-main>
            <el-card style="background-color: #F5F7FA">
                <!-- 搜素区域 -->
                <div>
                    <el-row>
                        <el-col :span="4">
                            <el-input v-model="queueView_queryInfo.serverName" prefix-icon="el-icon-search" size="medium"
                                      placeholder="服务器名称" clearable></el-input>
                        </el-col>
                        <el-col :span="4">
                            <el-input v-model="queueView_queryInfo.virtualHostName" prefix-icon="el-icon-search" size="medium"
                                      placeholder="虚拟主机名称" clearable></el-input>
                        </el-col>
                        <el-col :span="8">
                            <el-button type="success" style="width:150px" size="medium" @click="getQueueViewList">
                                队列监控
                            </el-button>
                        </el-col>
                    </el-row>
                </div>
                <!-- 列表区域 -->
                <div style="margin-top: 20px;">
                    <el-table :data="queueView_page.queueViewList" border size="small"
                              v-loading="queueView_loading.listLoading" element-loading-text="获取队列监控信息,拼命加载中">
                        <el-table-column type="index" align="center"></el-table-column>
                        <el-table-column label="服务器名称" prop="serverName" align="center" width="150"></el-table-column>
                        <el-table-column label="虚拟主机名称" prop="queueInfo.vhost" align="center" width="150"></el-table-column>
                        <el-table-column label="队列名称" prop="queueInfo.name" align="center" width="230">
                        </el-table-column>
                        <el-table-column label="积压消息" prop="queueInfo.messages_ready" align="center" width="120">
                            <template slot-scope="scope">
                                <span v-if="scope.row.queueInfo.messages_ready !== null" style="color: #eb2f06">
                                    {{scope.row.queueInfo.messages_ready}}
                                </span>
                            </template>
                        </el-table-column>
                        <el-table-column label="消息总数" prop="queueInfo.messages" align="center" width="120"></el-table-column>
                        <el-table-column label="持久化" prop="queueInfo.durable" align="center" width="120">
                            <template slot-scope="scope">
                                <span v-if="scope.row.queueInfo.durable ===false">否</span>
                                <span v-if="scope.row.queueInfo.durable ===true">是</span>
                            </template>
                        </el-table-column>
                        <el-table-column label="自动删除" prop="queueInfo.auto_delete" align="center" width="120">
                            <template slot-scope="scope">
                                <span v-if="scope.row.queueInfo.auto_delete ===false">否</span>
                                <span v-if="scope.row.queueInfo.auto_delete ===true">是</span>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
                <!-- 分页区域 -->
                <div style="margin-top: 10px">
                    <el-row :gutter="24">
                        <el-col :span="6" style="margin-top: 5px"></el-col>
                        <el-col :span="10" style="margin-top: 5px">
                            <el-pagination
                                    @size-change="queueView_handleSizeChange"
                                    @current-change="queueView_handleCurrentChange"
                                    :current-page="queueView_queryInfo.pageNum"
                                    :page-sizes="[10,50,100,500]"
                                    :page-size="queueView_queryInfo.pageSize"
                                    layout="total, sizes, prev, pager, next, jumper"
                                    :total="queueView_page.total">
                            </el-pagination>
                        </el-col>
                    </el-row>
                </div>
            </el-card>
        </el-main>
    </el-container>
</template>

<script>
    import {selectQueueViewList} from "../../../api/message_bus";

    export default {
        name: "QueueView",
        data() {
            return {
                queueView_queryInfo: {
                    serverName: '',
                    virtualHostName: '',
                    pageNum: 1,
                    pageSize: 10
                },
                queueView_page: {
                    queueViewList: [],
                    total: 0,
                },
                queueView_loading: {
                    listLoading: false,
                },
                /**
                 * Boolean属性,选择列表
                 */
                booleanList: [
                    {
                        value: true,
                        label: '是'
                    },
                    {
                        value: false,
                        label: '否'
                    },
                ],
            }
        },
        methods: {
            /**
             * 分页查询,监听 pageSize 改变的事件
             */
            queueView_handleSizeChange(newSize) {
                this.queueView_queryInfo.pageSize = newSize;
                this.getQueueViewList();
            },

            /**
             * 分页查询,监听 pageNum 改变的事件
             */
            queueView_handleCurrentChange(newPage) {
                this.queueView_queryInfo.pageNum = newPage;
                this.getQueueViewList();
            },

            getQueueViewList() {
                this.queueView_loading.listLoading = true;
                selectQueueViewList(this.queueView_queryInfo).then((response) => {
                    let res = response.data;
                    if (res.code !== '200') {
                        this.queueView_loading.listLoading = false;
                        return this.$message.error(res.msg);
                    }
                    this.queueView_page.queueViewList = res.data;
                    this.queueView_page.total = res.total;
                    this.queueView_loading.listLoading = false;
                }).catch(error => {
                    this.queueView_loading.listLoading = false;
                    this.$message.error(error.toString());
                });
            }
        },
        created() {
        },
        mounted() {
            this.timer = setInterval(this.getQueueViewList, 5000);
        },
        beforeDestroy() {
            clearInterval(this.timer);
        },
        computed: {},
    }
</script>

<style scoped>
    .demo-table-expand {
        font-size: 0;
    }

    .demo-table-expand label {
        width: 90px;
        color: #99a9bf;
    }

    .demo-table-expand .el-form-item {
        margin-right: 0;
        margin-bottom: 0;
        width: 50%;
    }
</style>