longyvfengyun
2022-03-02 3262c2b455860102d40d4ece95b32d95ce676c4d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
    <el-tooltip :class="stateName" effect="dark" :content="content" placement="bottom">
        <div class="statusWarp" @click="handleClick">
      <el-badge :value="value" :max="99" class="item" v-if="showBadge">
        <i class="iconfont" :class="icon"></i>
      </el-badge>
      <i class="iconfont" :class="icon" v-else></i>
        </div>
    </el-tooltip>
</template>
 
<script>
    export default {
        props: {
            state: {
                type: Number,
                default: 0
            },
            icon: {
                type: String,
                default: '',
            },
            content: {
                type: String,
                default: '未知'
            },
      showBadge: {
        type: Boolean,
        default: false
      },
      value: {
        type: [String, Number],
        default: 0
      },
        },
    methods: {
        handleClick() {
            this.$emit('handleClick')
        }
    },
        computed: {
            stateName() {
                let result = '';
                switch (this.state) {
                    case 0:
                        result = 'error-state';
                        break;
                    case 1:
                        result = "";
                        break;
                    case 2:
                        result = "stop-state";
                        break;
                }
                return result;
            },
        }
    }
</script>
 
<style scoped>
    
    .statusWarp{
        margin-right: 14px;
        vertical-align: top;
        cursor: pointer;
        width: 22px;
        height: 22px;
        display: inline-flex;
        justify-content: center;
        align-items: center;
        border-radius: 50%;
    }
    .iconfont {
        font-size: 12px;
        color: #041f6c;
    }
</style>