light-matrix.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div class="light-matrix-small">
  3. <div class="card" v-for="(item, i) of list" :key="i" :class="item.color" @click="jumpUrl(item.wpId, item.wtId)">
  4. {{ item.tag }}
  5. </div>
  6. <!-- 站位用 保证卡片布局最后一行不会有问题 -->
  7. <i class="blank" v-for="i in list.length" :key="i"></i>
  8. </div>
  9. </template>
  10. <script>
  11. import util from "@/helper/util.js";
  12. export default {
  13. // 名称
  14. name: "LightMatrix1",
  15. // 使用组件
  16. components: {},
  17. // 数据
  18. props: {
  19. list: {
  20. type: Array,
  21. default: () => [
  22. // {
  23. // tag: "A01",
  24. // color: "gray",
  25. // },
  26. ],
  27. },
  28. },
  29. // 函数
  30. methods: {
  31. calculateWidth() {
  32. if (this.list.length > 60 && this.list.length <= 72) {
  33. this.$el.style.width = "440px";
  34. } else if (this.list.length > 72 && this.list.length <= 88) {
  35. this.$el.style.width = "540px";
  36. } else if (this.list.length > 88 && this.list.length <= 96) {
  37. this.$el.style.width = "600px";
  38. } else if (this.list.length > 97 && this.list.length <= 112) {
  39. this.$el.style.width = "680px";
  40. } else if (this.list.length > 113 && this.list.length <= 128) {
  41. this.$el.style.width = "780px";
  42. } else if (this.list.length > 129 && this.list.length <= 144) {
  43. this.$el.style.width = "880px";
  44. } else if (this.list.length > 144 && this.list.length <= 168) {
  45. this.$el.style.width = "1000px";
  46. } else if (this.list.length > 168) {
  47. this.$el.style.width = "1168px";
  48. }
  49. let myevent = new Event("resize");
  50. window.dispatchEvent(myevent);
  51. },
  52. // 页面跳转
  53. jumpUrl(wpId, wtId){
  54. if (wpId.indexOf("FDC") !== -1) {
  55. this.$router.push({
  56. path: `/monitor/windsite/info/${wpId}/${wtId}`
  57. });
  58. } else {
  59. this.$router.push({
  60. path: `../../windsite/inverter-info/${wpId}/${wtId}`
  61. });
  62. }
  63. }
  64. },
  65. // 生命周期钩子
  66. beforeCreate() {
  67. // 创建前
  68. },
  69. created() {
  70. // 创建后
  71. },
  72. beforeMount() {
  73. // 渲染前
  74. },
  75. mounted() {
  76. // 渲染后
  77. this.$nextTick(() => {
  78. this.calculateWidth();
  79. });
  80. },
  81. beforeUpdate() {
  82. // 数据更新前
  83. },
  84. updated() {
  85. // 数据更新后
  86. this.$nextTick(() => {
  87. this.calculateWidth();
  88. });
  89. },
  90. };
  91. </script>
  92. <style lang="less">
  93. @panelHeight: 6.481vh;
  94. @titleHeight: 3.704vh;
  95. .light-matrix-small {
  96. height: 100%;
  97. padding: 8px;
  98. background: fade(@gray, 20);
  99. display: flex;
  100. flex-direction: row;
  101. flex-wrap: wrap;
  102. align-content: flex-start;
  103. .blank {
  104. margin-right: 4px;
  105. flex: 1 0 4.4444vh;
  106. }
  107. .card {
  108. margin-right: 4px;
  109. margin-top: 4px;
  110. flex: 1 0 4.4444vh;
  111. }
  112. .card {
  113. border-radius: 0.37vh;
  114. padding: 0.185vh 0.3704vh;
  115. text-align: center;
  116. border: 0.093vh solid;
  117. font-size: 14px;
  118. cursor: pointer;
  119. &.write {
  120. color: @black;
  121. border-color: @write;
  122. background-color: @write;
  123. }
  124. &.green {
  125. color: @green;
  126. border-color: @green;
  127. }
  128. &.purple {
  129. color: @purple;
  130. border-color: @purple;
  131. }
  132. &.pink {
  133. color: @pink;
  134. border-color: @pink;
  135. }
  136. &.red {
  137. color: @write;
  138. border-color: @red;
  139. background-color: @red;
  140. }
  141. &.orange {
  142. color: @orange;
  143. border-color: @orange;
  144. }
  145. &.gray {
  146. color: @darkgray;
  147. border-color: @darkgray;
  148. background-color: transparent;
  149. }
  150. }
  151. }
  152. </style>