he wei
2024-04-15 c94f1afa786f297be86b01b49a641b2c0ad98b6e
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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
  <div :class="['alarm-card', {pointer: childrenCount > 0}]">
    <div class="name">{{ name }}</div>
    <div
      :class="[
        'state',
        {
          level1: 1 == level,
          level2: 2 == level,
          level3: 3 == level,
          alarm: isAlarm,
        },
      ]"
    ></div>
  </div>
</template>
 
<script>
export default {
  name: "AlarmCard",
  props: {
    name: {
      type: String,
      required: true,
    },
    level: {
      type: Number,
      default: 0,
      validator(value) {
        return [0, 1, 2, 3].some((v) => v == value);
      },
    },
    childrenCount: {
      type: Number,
      default: 0,
    },
    // childrenVisible: {
    //   type: Boolean,
    //   default: false,
    // },
    flag: {
      type: [Number, Array],
      default: 0,
    },
  },
  computed: {
    // cols() {
    //   return Math.ceil(Math.sqrt(this.childrenCount));
    // },
    // rows() {
    //   if (!this.cols) {
    //     return 0;
    //   }
    //   return Math.ceil(this.childrenCount / this.cols);
    // },
    isAlarm() {
      const flag = this.flag;
      if (Array.isArray(flag)) {
        return flag.some((v) => v > 0);
      } else {
        return !!flag;
      }
    },
  },
  data() {
    return {};
  },
  components: {},
  methods: {
    close() {
      console.log("close?");
      this.$emit("close");
    },
  },
 
  mounted() {},
};
</script>
 
<style scoped lang="less">
.alarm-card {
  background: #0c4d77;
  border: 1px solid #78eef8;
  border-radius: 4px;
  // width: 320px;
  width: 100%;
  height: 38px;
  display: flex;
  padding: 6px;
  justify-content: space-between;
  align-items: center;
  &.pointer {
    cursor: pointer;
  }
  .state {
    width: 60px;
    background: #78eef8;
    border-radius: 4px;
    align-self: stretch;
    &.level1.alarm {
      background: #4871e3;
    }
    &.level2.alarm {
      background: #f69f40;
    }
    &.level3.alarm {
      background: #ff3801;
    }
  }
  // .card-children-container {
  //   z-index: 100;
  //   position: fixed;
  //   top: 50%;
  //   left: 50%;
  //   width: 1600px;
 
  //   // height: 600px;
  //   transform: translate(-50%, -50%);
  //   background: gray;
  //   padding: 20px;
  //   display: flex;
  //   flex-direction: column;
  //   &.small {
  //     width: 800px;
  //   }
  //   .sub-title {
  //     text-align: center;
  //     font-size: 20px;
  //     padding-bottom: 10px;
  //   }
  //   .row {
  //     display: flex;
  //     & ~ .row {
  //       margin-top: 8px;
  //     }
  //     .col {
  //       flex: 1;
  //       & ~ .col {
  //         margin-left: 8px;
  //       }
  //     }
  //   }
  // }
  // .mask {
  //   position: fixed;
  //   top: 0;
  //   left: 0;
  //   right: 0;
  //   bottom: 0;
  //   background: rgba(0, 0, 0, 0.4);
  //   z-index: 99;
  // }
}
</style>