coreData.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. itemWidth: 150,
  6. };
  7. },
  8. props: {
  9. dataList: Array,
  10. },
  11. mounted() {
  12. let clientWidth = Math.floor(100/this.dataList.length)-2+'%'
  13. this.itemWidth = clientWidth;
  14. },
  15. };
  16. </script>
  17. <template>
  18. <div class="coreData">
  19. <template v-for="(ele, index) in dataList">
  20. <div
  21. class="coreData-item"
  22. :key="index"
  23. :style="{
  24. width: itemWidth,
  25. backgroundColor: ele.isHighLight ? '#e7f5fc' : '',
  26. }"
  27. >
  28. <div class="coreData-item-title">{{ ele.title }}</div>
  29. <template v-if="ele.type === 1"> </template>
  30. <template v-else>
  31. <div class="coreData-item-num">{{ ele.num }}</div>
  32. <div class="coreData-item-unit" v-html="ele.unit"></div>
  33. <div class="coreData-item-history">
  34. <div class="coreData-item-historyDesc">
  35. <span v-if="ele.historyNum === 0">{{ ele.historyDesc }}持平</span>
  36. <span v-else-if="ele.historyNum > 0"
  37. >{{ ele.historyDesc }}上升</span
  38. >
  39. <span v-else-if="ele.historyNum < 0"
  40. >{{ ele.historyDesc }}下降</span
  41. >
  42. <span v-else></span>
  43. </div>
  44. <div class="coreData-item-historyNum" v-if="!isNaN(ele.historyNum)">
  45. {{ Math.abs(ele.historyNum) }}%
  46. </div>
  47. </div>
  48. </template>
  49. </div>
  50. </template>
  51. </div>
  52. </template>
  53. <style lang="less" scoped>
  54. .coreData {
  55. width: 100%;
  56. height: 140px;
  57. .coreData-item {
  58. display: inline-block;
  59. vertical-align: top;
  60. height: 120px;
  61. margin: 10px;
  62. background-color: #f7fbff;
  63. padding: 8px 8px 8px 1.5%;
  64. border-radius: 5px;
  65. .coreData-item-title {
  66. line-height: 30px;
  67. }
  68. .coreData-item-num {
  69. display: inline-block;
  70. font-size: 30px;
  71. font-weight: bolder;
  72. height: 50%;
  73. }
  74. .coreData-item-unit {
  75. display: inline-block;
  76. margin-left: 3px;
  77. color: #9a9a9a;
  78. }
  79. .coreData-item-historyDesc {
  80. display: inline-block;
  81. }
  82. .coreData-item-historyNum {
  83. margin-left: 5px;
  84. display: inline-block;
  85. color: red;
  86. }
  87. }
  88. }
  89. </style>