DimensionSubDims.vue 4.2 KB

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