DimensionSubDims.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. import { BrandColors } from '../../../utils/brand-colors.js'
  42. export default {
  43. name: 'DimensionSubDims',
  44. props: {
  45. title: { type: String, default: '维度评分' },
  46. subtitle: { type: String, default: '' },
  47. accentColor: { type: String, default: BrandColors.wisdom },
  48. dims: { type: Array, default: () => [] }
  49. },
  50. methods: {
  51. getScoreLevelText(score) {
  52. if (score >= 80) return '优秀'
  53. if (score >= 60) return '良好'
  54. if (score > 0) return '待提升'
  55. return '-'
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped lang="scss">
  61. .dim-subdims {
  62. margin: 20rpx 30rpx;
  63. background: rgba(255, 255, 255, 0.95);
  64. border-radius: 24rpx;
  65. padding: 28rpx 24rpx;
  66. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  67. border: 1rpx solid rgba(255, 255, 255, 0.8);
  68. }
  69. .dim-header {
  70. margin-bottom: 24rpx;
  71. }
  72. .dim-title {
  73. font-size: 32rpx;
  74. font-weight: 700;
  75. color: $app-ink-night;
  76. display: block;
  77. }
  78. .dim-subtitle {
  79. font-size: 24rpx;
  80. color: $app-text-subtle;
  81. margin-top: 6rpx;
  82. display: block;
  83. }
  84. .dim-list {
  85. display: flex;
  86. flex-direction: column;
  87. gap: 0;
  88. }
  89. .dim-item {
  90. padding: 20rpx 0;
  91. border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
  92. }
  93. .dim-item:last-child {
  94. border-bottom: none;
  95. padding-bottom: 0;
  96. }
  97. .dim-item:first-child {
  98. padding-top: 0;
  99. }
  100. .dim-item-top {
  101. display: flex;
  102. justify-content: space-between;
  103. align-items: flex-start;
  104. margin-bottom: 12rpx;
  105. }
  106. .dim-item-info {
  107. flex: 1;
  108. min-width: 0;
  109. }
  110. .dim-item-label {
  111. font-size: 28rpx;
  112. font-weight: 600;
  113. color: $uni-text-color;
  114. display: block;
  115. line-height: 1.4;
  116. }
  117. .dim-item-desc {
  118. font-size: 22rpx;
  119. color: $app-text-subtle;
  120. margin-top: 4rpx;
  121. display: block;
  122. line-height: 1.4;
  123. }
  124. .dim-item-score-wrap {
  125. text-align: right;
  126. flex-shrink: 0;
  127. margin-left: 16rpx;
  128. }
  129. .dim-item-score {
  130. font-size: 36rpx;
  131. font-weight: 700;
  132. line-height: 1;
  133. }
  134. .score-good { color: $status-success-strong-2; }
  135. .score-ok { color: $status-warning-deep; }
  136. .score-low { color: $status-danger-deep; }
  137. .dim-item-level {
  138. font-size: 20rpx;
  139. font-weight: 500;
  140. display: block;
  141. margin-top: 4rpx;
  142. padding: 2rpx 12rpx;
  143. border-radius: 8rpx;
  144. width: fit-content;
  145. margin-left: auto;
  146. }
  147. .level-good {
  148. color: $status-success-strong-2;
  149. background: $status-success-tint-2;
  150. }
  151. .level-ok {
  152. color: $status-warning-deep;
  153. background: $status-warning-tint;
  154. }
  155. .level-low {
  156. color: $status-danger-deep;
  157. background: $status-danger-tint-2;
  158. }
  159. .dim-bar-track {
  160. height: 8rpx;
  161. background: rgba(0, 0, 0, 0.06);
  162. border-radius: 4rpx;
  163. overflow: hidden;
  164. }
  165. .dim-bar-fill {
  166. height: 100%;
  167. border-radius: 4rpx;
  168. transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  169. }
  170. </style>