IndicatorIncompleteBanner.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. // ★ 必须先于 pc === tc 判定:否则 0 === 0 先命中「数据完整隐藏」,第三条件永不可达
  34. if (pc === 0 && tc === 0) return true
  35. // 数据完整 → 隐藏
  36. if (pc === tc) return false
  37. // 有报告但无期次 → 显示「暂无可显示的历史数据」
  38. if (pc === 0 && tc > 0) return true
  39. // 有期次但少于报告数 → 显示「历史数据整理中」
  40. if (pc > 0 && pc < tc) return true
  41. // pc > tc(脏数据兜底)→ 隐藏,避免误导
  42. return false
  43. },
  44. toneClass: function() {
  45. var pc = this.pointsCount || 0
  46. var tc = this.totalReportCount || 0
  47. // 无任何报告 → 灰;其余残缺态 → 橙
  48. return (pc === 0 && tc === 0) ? 'banner-gray' : 'banner-orange'
  49. },
  50. bannerText: function() {
  51. var pc = this.pointsCount || 0
  52. var tc = this.totalReportCount || 0
  53. if (pc === 0 && tc === 0) return '该成员暂无报告数据'
  54. if (pc === 0) return '共 ' + tc + ' 份报告,本指标暂无可显示的历史数据'
  55. return '共 ' + tc + ' 份报告,本指标目前 ' + pc + ' 期数据(历史数据整理中)'
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped lang="scss">
  61. .incomplete-banner {
  62. display: flex;
  63. flex-direction: row;
  64. align-items: flex-start;
  65. padding: 10rpx 16rpx;
  66. margin: 16rpx 0;
  67. border-radius: 8rpx;
  68. }
  69. .banner-icon {
  70. font-size: 22rpx;
  71. margin-right: 8rpx;
  72. line-height: 30rpx;
  73. }
  74. .banner-text {
  75. flex: 1;
  76. font-size: 20rpx;
  77. line-height: 30rpx;
  78. }
  79. .banner-orange {
  80. background: #FFF7ED;
  81. }
  82. .banner-orange .banner-icon {
  83. color: #EA580C;
  84. }
  85. .banner-orange .banner-text {
  86. color: #C2410C;
  87. }
  88. .banner-gray {
  89. background: #F8FAFC;
  90. }
  91. .banner-gray .banner-icon {
  92. color: #94A3B8;
  93. }
  94. .banner-gray .banner-text {
  95. color: #64748B;
  96. }
  97. </style>