IndicatorIncompleteBanner.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view v-if="visible" class="incomplete-banner" :class="toneClass">
  3. <text class="banner-icon">ⓘ</text>
  4. <text class="banner-text">{{ bannerText }}</text>
  5. </view>
  6. </template>
  7. <script>
  8. /**
  9. * IndicatorIncompleteBanner —— 残缺横幅(P0 红线,不可裁剪)
  10. *
  11. * 文案契约(design §1.2.2 / PRD §5.3 ②·5,四条件):
  12. * 0 < pointsCount < totalReportCount → 「共 N 份报告,本指标目前 M 期数据(历史数据整理中)」(橙)
  13. * pointsCount == 0 && total > 0 → 「共 N 份报告,本指标暂无可显示的历史数据」(橙)
  14. * pointsCount == 0 && total == 0 → 「该成员暂无报告数据」(灰)
  15. * pointsCount == totalReportCount → 横幅隐藏(数据完整,无需解释)
  16. *
  17. * 硬性禁止:任何路径下均不得出现孤立的「暂无趋势数据」。
  18. * 三处复用:indicator-timeline.vue / indicator-curve.vue / report-detail.vue
  19. */
  20. export default {
  21. name: 'IndicatorIncompleteBanner',
  22. props: {
  23. /** 本指标已具备的期数 */
  24. pointsCount: { type: Number, required: true },
  25. /** 该成员(该报告类型)的报告总份数 */
  26. totalReportCount: { type: Number, required: true }
  27. },
  28. computed: {
  29. visible: function() {
  30. var pc = this.pointsCount || 0
  31. var tc = this.totalReportCount || 0
  32. // 数据完整 → 隐藏
  33. if (pc === tc) return false
  34. // 有报告但无期次 → 显示「暂无可显示的历史数据」
  35. if (pc === 0 && tc > 0) return true
  36. // 有期次但少于报告数 → 显示「历史数据整理中」
  37. if (pc > 0 && pc < tc) return true
  38. // pc > tc(脏数据兜底)→ 隐藏,避免误导
  39. return false
  40. },
  41. toneClass: function() {
  42. var pc = this.pointsCount || 0
  43. var tc = this.totalReportCount || 0
  44. // 无任何报告 → 灰;其余残缺态 → 橙
  45. return (pc === 0 && tc === 0) ? 'banner-gray' : 'banner-orange'
  46. },
  47. bannerText: function() {
  48. var pc = this.pointsCount || 0
  49. var tc = this.totalReportCount || 0
  50. if (pc === 0 && tc === 0) return '该成员暂无报告数据'
  51. if (pc === 0) return '共 ' + tc + ' 份报告,本指标暂无可显示的历史数据'
  52. return '共 ' + tc + ' 份报告,本指标目前 ' + pc + ' 期数据(历史数据整理中)'
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped lang="scss">
  58. .incomplete-banner {
  59. display: flex;
  60. flex-direction: row;
  61. align-items: flex-start;
  62. padding: 10rpx 16rpx;
  63. margin: 16rpx 0;
  64. border-radius: 8rpx;
  65. }
  66. .banner-icon {
  67. font-size: 22rpx;
  68. margin-right: 8rpx;
  69. line-height: 30rpx;
  70. }
  71. .banner-text {
  72. flex: 1;
  73. font-size: 20rpx;
  74. line-height: 30rpx;
  75. }
  76. .banner-orange {
  77. background: #FFF7ED;
  78. }
  79. .banner-orange .banner-icon {
  80. color: #EA580C;
  81. }
  82. .banner-orange .banner-text {
  83. color: #C2410C;
  84. }
  85. .banner-gray {
  86. background: #F8FAFC;
  87. }
  88. .banner-gray .banner-icon {
  89. color: #94A3B8;
  90. }
  91. .banner-gray .banner-text {
  92. color: #64748B;
  93. }
  94. </style>