work-card.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="work-card">
  3. <div class="work-card-item" v-for="item in dataList" :key="item.title">
  4. <div class="card-header">
  5. <!-- <i class="iconfont" :class="iconName"></i> -->
  6. <span class="card-title">{{ item.title }}</span>
  7. </div>
  8. <div class="card-content">
  9. <div class="card-subtitle">{{ item.subtitle }}</div>
  10. <div class="card-value">{{ formatNumber(item.value) }}</div>
  11. </div>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. name: "WorkCard",
  18. props: {
  19. iconName: {
  20. type: String,
  21. required: true,
  22. default: "icon-enterprise",
  23. },
  24. title: {
  25. type: String,
  26. required: true,
  27. },
  28. subtitle: {
  29. type: String,
  30. required: true,
  31. },
  32. value: {
  33. type: [Number, String],
  34. required: true,
  35. default: 0,
  36. },
  37. },
  38. data() {
  39. return {
  40. dataList: [
  41. {
  42. title: "数电票业务",
  43. subtitle: "已开发票数",
  44. value: 345345,
  45. },
  46. {
  47. title: "道闸系统",
  48. subtitle: "设备数量",
  49. value: 453,
  50. },
  51. {
  52. title: "智慧二维码",
  53. subtitle: "配置数量",
  54. value: 45,
  55. },
  56. {
  57. title: "短信业务",
  58. subtitle: "销售数量",
  59. value: 3456,
  60. },
  61. {
  62. title: "房屋租售",
  63. subtitle: "发布资产数",
  64. value: 887,
  65. },
  66. {
  67. title: "业委会",
  68. subtitle: "开通数量",
  69. value: 34,
  70. },
  71. ],
  72. }
  73. },
  74. methods: {
  75. // 格式化数字显示
  76. formatNumber(num) {
  77. if (typeof num === "string") {
  78. return num
  79. }
  80. // 如果数字是整数,直接返回字符串形式
  81. return num.toString()
  82. },
  83. },
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. @import "@/assets/css/theme.scss";
  88. .work-card {
  89. display: grid;
  90. grid-template-columns: repeat(3, 1fr);
  91. grid-template-rows: repeat(2, 1fr);
  92. gap: 10px;
  93. }
  94. .work-card-item {
  95. background: var(--content-bg);
  96. border-radius: 4px;
  97. height: 100%;
  98. display: flex;
  99. flex-direction: column;
  100. justify-content: space-between;
  101. }
  102. .card-header {
  103. display: flex;
  104. align-items: center;
  105. margin-bottom: 16px;
  106. padding: 20px;
  107. background: var(--title-bg);
  108. .iconfont {
  109. font-size: 24px;
  110. margin-right: 10px;
  111. // 根据不同图标使用不同颜色
  112. color: var(--primary-color, #409eff);
  113. }
  114. .card-title {
  115. font-size: 16px;
  116. font-weight: 500;
  117. color: var(--title-primary);
  118. }
  119. }
  120. .card-content {
  121. display: flex;
  122. align-items: flex-end;
  123. padding: 20px;
  124. .card-subtitle {
  125. font-size: 14px;
  126. color: #82d1f6;
  127. }
  128. .card-value {
  129. margin-left: 12px;
  130. font-size: 18px;
  131. font-weight: 600;
  132. color: #fff;
  133. letter-spacing: 1px;
  134. }
  135. }
  136. </style>