DimensionSubDims.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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="d.score >= 80 ? 'score-good' : (d.score >= 60 ? 'score-ok' : 'score-low')"
  23. >{{ d.score }}</text>
  24. <text
  25. class="dim-item-level"
  26. :class="'level-' + (d.score >= 80 ? 'good' : (d.score >= 60 ? 'ok' : 'low'))"
  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. getScoreLevelText(score) {
  51. if (score >= 80) return '优秀'
  52. if (score >= 60) return '良好'
  53. if (score > 0) return '待提升'
  54. return '-'
  55. }
  56. }
  57. }
  58. </script>
  59. <style scoped>
  60. .dim-subdims {
  61. margin: 20rpx 30rpx;
  62. background: rgba(255, 255, 255, 0.95);
  63. border-radius: 24rpx;
  64. padding: 28rpx 24rpx;
  65. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  66. border: 1rpx solid rgba(255, 255, 255, 0.8);
  67. }
  68. .dim-header {
  69. margin-bottom: 24rpx;
  70. }
  71. .dim-title {
  72. font-size: 32rpx;
  73. font-weight: 700;
  74. color: #1a1a2e;
  75. display: block;
  76. }
  77. .dim-subtitle {
  78. font-size: 24rpx;
  79. color: #94a3b8;
  80. margin-top: 6rpx;
  81. display: block;
  82. }
  83. .dim-list {
  84. display: flex;
  85. flex-direction: column;
  86. gap: 0;
  87. }
  88. .dim-item {
  89. padding: 20rpx 0;
  90. border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
  91. }
  92. .dim-item:last-child {
  93. border-bottom: none;
  94. padding-bottom: 0;
  95. }
  96. .dim-item:first-child {
  97. padding-top: 0;
  98. }
  99. .dim-item-top {
  100. display: flex;
  101. justify-content: space-between;
  102. align-items: flex-start;
  103. margin-bottom: 12rpx;
  104. }
  105. .dim-item-info {
  106. flex: 1;
  107. min-width: 0;
  108. }
  109. .dim-item-label {
  110. font-size: 28rpx;
  111. font-weight: 600;
  112. color: #1e293b;
  113. display: block;
  114. line-height: 1.4;
  115. }
  116. .dim-item-desc {
  117. font-size: 22rpx;
  118. color: #94a3b8;
  119. margin-top: 4rpx;
  120. display: block;
  121. line-height: 1.4;
  122. }
  123. .dim-item-score-wrap {
  124. text-align: right;
  125. flex-shrink: 0;
  126. margin-left: 16rpx;
  127. }
  128. .dim-item-score {
  129. font-size: 36rpx;
  130. font-weight: 700;
  131. line-height: 1;
  132. }
  133. .score-good { color: #16a34a; }
  134. .score-ok { color: #d97706; }
  135. .score-low { color: #dc2626; }
  136. .dim-item-level {
  137. font-size: 20rpx;
  138. font-weight: 500;
  139. display: block;
  140. margin-top: 4rpx;
  141. padding: 2rpx 12rpx;
  142. border-radius: 8rpx;
  143. width: fit-content;
  144. margin-left: auto;
  145. }
  146. .level-good {
  147. color: #16a34a;
  148. background: #f0fdf4;
  149. }
  150. .level-ok {
  151. color: #d97706;
  152. background: #fffbeb;
  153. }
  154. .level-low {
  155. color: #dc2626;
  156. background: #fef2f2;
  157. }
  158. .dim-bar-track {
  159. height: 8rpx;
  160. background: rgba(0, 0, 0, 0.06);
  161. border-radius: 4rpx;
  162. overflow: hidden;
  163. }
  164. .dim-bar-fill {
  165. height: 100%;
  166. border-radius: 4rpx;
  167. transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  168. }
  169. </style>