DimensionSubDims.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="dim-subdims" :style="{ '--accent': accentColor }">
  3. <view class="dim-header">
  4. <text class="dim-title">{{ title }}</text>
  5. <text class="dim-subtitle">{{ subtitle }}</text>
  6. </view>
  7. <view class="dim-list">
  8. <view
  9. class="dim-item"
  10. v-for="(d, i) in dims"
  11. :key="d.label"
  12. :style="{ '--dim-color': d.color || accentColor }"
  13. >
  14. <view class="dim-item-top">
  15. <view class="dim-item-info">
  16. <text class="dim-item-label">{{ d.label }}</text>
  17. <text class="dim-item-desc">{{ d.desc }}</text>
  18. </view>
  19. <view class="dim-item-score-wrap">
  20. <text
  21. class="dim-item-score"
  22. :class="getScoreClass(d.score)"
  23. >{{ d.score }}</text>
  24. <text
  25. class="dim-item-level"
  26. :class="'level-' + getScoreLevel(d.score)"
  27. >{{ getScoreLevelText(d.score) }}</text>
  28. </view>
  29. </view>
  30. <view class="dim-bar-track">
  31. <view
  32. class="dim-bar-fill"
  33. :style="{ width: d.score + '%', background: d.color || accentColor }"
  34. ></view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. name: 'DimensionSubDims',
  43. props: {
  44. title: { type: String, default: '维度评分' },
  45. subtitle: { type: String, default: '' },
  46. accentColor: { type: String, default: '#6366F1' },
  47. dims: { type: Array, default: () => [] }
  48. },
  49. methods: {
  50. getScoreLevel(score) {
  51. if (score >= 80) return 'good'
  52. if (score >= 60) return 'ok'
  53. return 'low'
  54. },
  55. getScoreLevelText(score) {
  56. if (score >= 80) return '优秀'
  57. if (score >= 60) return '良好'
  58. if (score > 0) return '待提升'
  59. return '-'
  60. },
  61. getScoreClass(score) {
  62. if (score >= 80) return 'score-good'
  63. if (score >= 60) return 'score-ok'
  64. return 'score-low'
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. .dim-subdims {
  71. margin: 20rpx 30rpx;
  72. background: rgba(255, 255, 255, 0.95);
  73. border-radius: 24rpx;
  74. padding: 28rpx 24rpx;
  75. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  76. border: 1rpx solid rgba(255, 255, 255, 0.8);
  77. }
  78. .dim-header {
  79. margin-bottom: 24rpx;
  80. }
  81. .dim-title {
  82. font-size: 32rpx;
  83. font-weight: 700;
  84. color: #1a1a2e;
  85. display: block;
  86. }
  87. .dim-subtitle {
  88. font-size: 24rpx;
  89. color: #94a3b8;
  90. margin-top: 6rpx;
  91. display: block;
  92. }
  93. .dim-list {
  94. display: flex;
  95. flex-direction: column;
  96. gap: 0;
  97. }
  98. .dim-item {
  99. padding: 20rpx 0;
  100. border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
  101. }
  102. .dim-item:last-child {
  103. border-bottom: none;
  104. padding-bottom: 0;
  105. }
  106. .dim-item:first-child {
  107. padding-top: 0;
  108. }
  109. .dim-item-top {
  110. display: flex;
  111. justify-content: space-between;
  112. align-items: flex-start;
  113. margin-bottom: 12rpx;
  114. }
  115. .dim-item-info {
  116. flex: 1;
  117. min-width: 0;
  118. }
  119. .dim-item-label {
  120. font-size: 28rpx;
  121. font-weight: 600;
  122. color: #1e293b;
  123. display: block;
  124. line-height: 1.4;
  125. }
  126. .dim-item-desc {
  127. font-size: 22rpx;
  128. color: #94a3b8;
  129. margin-top: 4rpx;
  130. display: block;
  131. line-height: 1.4;
  132. }
  133. .dim-item-score-wrap {
  134. text-align: right;
  135. flex-shrink: 0;
  136. margin-left: 16rpx;
  137. }
  138. .dim-item-score {
  139. font-size: 36rpx;
  140. font-weight: 700;
  141. line-height: 1;
  142. }
  143. .score-good { color: #16a34a; }
  144. .score-ok { color: #d97706; }
  145. .score-low { color: #dc2626; }
  146. .dim-item-level {
  147. font-size: 20rpx;
  148. font-weight: 500;
  149. display: block;
  150. margin-top: 4rpx;
  151. padding: 2rpx 12rpx;
  152. border-radius: 8rpx;
  153. width: fit-content;
  154. margin-left: auto;
  155. }
  156. .level-good {
  157. color: #16a34a;
  158. background: #f0fdf4;
  159. }
  160. .level-ok {
  161. color: #d97706;
  162. background: #fffbeb;
  163. }
  164. .level-low {
  165. color: #dc2626;
  166. background: #fef2f2;
  167. }
  168. .dim-bar-track {
  169. height: 8rpx;
  170. background: rgba(0, 0, 0, 0.06);
  171. border-radius: 4rpx;
  172. overflow: hidden;
  173. }
  174. .dim-bar-fill {
  175. height: 100%;
  176. border-radius: 4rpx;
  177. transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  178. }
  179. </style>