light-matrix.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="light-matrix-small">
  3. <div class="card" v-for="(item, i) of list" :key="i" :class="item.color">
  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. },
  50. },
  51. // 生命周期钩子
  52. beforeCreate() {
  53. // 创建前
  54. },
  55. created() {
  56. // 创建后
  57. },
  58. beforeMount() {
  59. // 渲染前
  60. },
  61. mounted() {
  62. // 渲染后
  63. this.$nextTick(() => {
  64. this.calculateWidth();
  65. });
  66. },
  67. beforeUpdate() {
  68. // 数据更新前
  69. },
  70. updated() {
  71. // 数据更新后
  72. this.$nextTick(() => {
  73. this.calculateWidth();
  74. });
  75. },
  76. };
  77. </script>
  78. <style lang="less">
  79. @panelHeight: 6.481vh;
  80. @titleHeight: 3.704vh;
  81. .light-matrix-small {
  82. height: 100%;
  83. padding: 8px;
  84. background: fade(@gray, 20);
  85. display: flex;
  86. flex-direction: row;
  87. flex-wrap: wrap;
  88. align-content: flex-start;
  89. .blank {
  90. margin-right: 4px;
  91. flex: 1 0 4.4444vh;
  92. }
  93. .card {
  94. margin-right: 4px;
  95. margin-top: 4px;
  96. flex: 1 0 4.4444vh;
  97. }
  98. .card {
  99. border-radius: 0.37vh;
  100. padding: 0.185vh 0.3704vh;
  101. text-align: center;
  102. border: 0.093vh solid;
  103. font-size: 14px;
  104. &.write {
  105. color: @black;
  106. border-color: @write;
  107. background-color: @write;
  108. }
  109. &.green {
  110. color: @green;
  111. border-color: @green;
  112. }
  113. &.purple {
  114. color: @purple;
  115. border-color: @purple;
  116. }
  117. &.pink {
  118. color: @pink;
  119. border-color: @pink;
  120. }
  121. &.red {
  122. color: @write;
  123. border-color: @red;
  124. background-color: @red;
  125. }
  126. &.orange {
  127. color: @orange;
  128. border-color: @orange;
  129. }
  130. &.gray {
  131. color: @darkgray;
  132. border-color: @darkgray;
  133. background-color: transparent;
  134. }
  135. }
  136. }
  137. </style>