index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="centreLeft1">
  3. <!-- <div class="bg-color-black">
  4. <div class="d-flex pt-2 pl-2">
  5. <span>
  6. <i class="iconfont icon-tongji4" />
  7. </span>
  8. <div class="d-flex">
  9. <span class="fs-xl text mx-2">任务通过率</span>
  10. <dv-decoration-3 class="dv-dec-3" />
  11. </div>
  12. </div>
  13. <div class="d-flex jc-center">
  14. <chart />
  15. </div>
  16. <div class="bottom-data">
  17. <div
  18. class="item-box mt-2"
  19. v-for="(item, index) in numberData"
  20. :key="index"
  21. >
  22. <div class="d-flex jc-end">
  23. <i class="iconfont" :class="[iconFont[index]]" />
  24. <dv-digital-flop class="dv-digital-flop" :config="item.config" />
  25. </div>
  26. <p>
  27. <span> {{ item.text }} </span>
  28. <span class="colorYellow">(件)</span>
  29. </p>
  30. </div>
  31. </div>
  32. </div> -->
  33. </div>
  34. </template>
  35. <script lang="ts">
  36. import { defineComponent, onMounted, onUnmounted, reactive } from 'vue'
  37. import Chart from './chart/index'
  38. export default defineComponent({
  39. components: {
  40. Chart
  41. },
  42. setup() {
  43. // 下层数据
  44. const dataArr = [
  45. {
  46. number: 150,
  47. text: '今日构建总量'
  48. },
  49. {
  50. number: 144,
  51. text: '总共完成数量'
  52. },
  53. {
  54. number: 361,
  55. text: '正在编译数量'
  56. },
  57. {
  58. number: 571,
  59. text: '未通过数量'
  60. }
  61. ]
  62. // 对应图标
  63. const iconFont = [
  64. 'icon-diagnose',
  65. 'icon-monitoring',
  66. 'icon-cloudupload',
  67. 'icon-clouddownload'
  68. ]
  69. const numberData = reactive([])
  70. let intervalInstance = null
  71. onMounted(() => {
  72. setData()
  73. changeTiming()
  74. })
  75. const setData = () => {
  76. dataArr.forEach(e => {
  77. numberData.push({
  78. config: {
  79. number: [e.number],
  80. toFixed: 1,
  81. content: '{nt}',
  82. style: {
  83. fontSize: 24
  84. }
  85. },
  86. text: e.text
  87. })
  88. })
  89. }
  90. const changeTiming = () => {
  91. intervalInstance = setInterval(() => {
  92. changeNumber()
  93. }, 2000)
  94. }
  95. const changeNumber = () => {
  96. numberData.forEach((item, index) => {
  97. item.config.number[0] += ++index
  98. item.config = { ...item.config }
  99. })
  100. }
  101. onUnmounted(() => {
  102. clearInterval(intervalInstance)
  103. })
  104. return { numberData, iconFont}
  105. }
  106. })
  107. </script>
  108. <style lang="scss" scoped>
  109. $box-width: 300px;
  110. $box-height: 410px;
  111. .centreLeft1 {
  112. padding: 16px;
  113. height: $box-height;
  114. width: $box-width;
  115. border-radius: 10px;
  116. .bg-color-black {
  117. height: $box-height - 30px;
  118. border-radius: 10px;
  119. }
  120. .text {
  121. color: #c3cbde;
  122. }
  123. .dv-dec-3 {
  124. position: relative;
  125. width: 100px;
  126. height: 20px;
  127. top: -3px;
  128. }
  129. .bottom-data {
  130. .item-box {
  131. & > div {
  132. padding-right: 5px;
  133. }
  134. font-size: 14px;
  135. float: right;
  136. position: relative;
  137. width: 50%;
  138. color: #d3d6dd;
  139. .dv-digital-flop {
  140. width: 120px;
  141. height: 30px;
  142. }
  143. i {
  144. font-size: 20px;
  145. line-height: 30px;
  146. margin-left: 20px;
  147. }
  148. .colorYellow {
  149. color: yellowgreen;
  150. }
  151. p {
  152. text-align: center;
  153. }
  154. }
  155. }
  156. }
  157. </style>