审查视图

src/views/bus/view/QueueView.vue 7.0 KB
1 2 3 4
<template>
    <el-container>
        <el-main>
            <el-card style="background-color: #F5F7FA">
朱兆平 authored
5
<!--                 搜素区域 -->
6 7
                <div>
                    <el-row>
朱兆平 authored
8 9 10 11 12 13 14 15
<!--                        <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>-->
16
                        <el-col :span="8">
朱兆平 authored
17 18
                            <el-button type="success" style="width:150px" size="medium" @click="timerStatus==='start'?timerEnd():timerStart()">
                                {{timergMap[timerStatus]}}
19 20 21 22
                            </el-button>
                        </el-col>
                    </el-row>
                </div>
朱兆平 authored
23
<!--                 列表区域 -->
24 25
                <div style="margin-top: 20px;">
                    <el-table :data="queueView_page.queueViewList" border size="small"
朱兆平 authored
26
                              :default-sort = "{prop: 'lag', order: 'descending'}"
27 28
                              v-loading="queueView_loading.listLoading" element-loading-text="获取队列监控信息,拼命加载中">
                        <el-table-column type="index" align="center"></el-table-column>
朱兆平 authored
29 30 31
                        <el-table-column label="消费组" prop="groupName" align="center" width="150"></el-table-column>
                        <el-table-column label="TOPIC" prop="topic" align="center" width="150"></el-table-column>
                        <el-table-column label="partition" prop="partition" align="center" width="230">
32
                        </el-table-column>
朱兆平 authored
33 34 35 36 37 38
                        <el-table-column label="积压消息" prop="lag" align="center" width="120" sortable>
<!--                            <template slot-scope="scope">-->
<!--                                <span v-if="scope.row.queueInfo.messages_ready !== null" style="color: #eb2f06">-->
<!--                                    {{scope.row.queueInfo.messages_ready}}-->
<!--                                </span>-->
<!--                            </template>-->
39
                        </el-table-column>
朱兆平 authored
40 41 42 43 44 45 46 47 48 49 50 51 52
                        <el-table-column label="消息总数" prop="endoffset" 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>-->
53 54 55 56 57 58 59 60 61 62 63 64 65 66
                    </el-table>
                </div>
            </el-card>
        </el-main>
    </el-container>
</template>

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

    export default {
        name: "QueueView",
        data() {
            return {
朱兆平 authored
67 68 69 70 71 72
                timergMap: {
                    start: '监控中',
                    end: '已停止',
                },
                timerStatus: "start",
                timer:{},
73
                queueView_queryInfo: {
朱兆平 authored
74 75 76 77
                    GroupName: '',
                    topic: '',
                    partition: 1,
                    Lag: 10
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
                },
                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();
            },
朱兆平 authored
109 110 111 112 113 114 115 116 117
            timerStart(){
                this.timerStatus= "start";
                this.getQueueViewList();
                this.timer = setInterval(this.getQueueViewList, 10000);
            },
            timerEnd(){
                this.timerStatus= "end";
                clearInterval(this.timer);
            },
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
            /**
             * 分页查询,监听 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;
朱兆平 authored
135
                    // this.queueView_page.total = res.total;
136 137 138 139 140 141 142 143 144 145
                    this.queueView_loading.listLoading = false;
                }).catch(error => {
                    this.queueView_loading.listLoading = false;
                    this.$message.error(error.toString());
                });
            }
        },
        created() {
        },
        mounted() {
朱兆平 authored
146
            this.timerStart();
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
        },
        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>