| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <template>
- <view class="degrade-wrap" :class="wrapClass">
- <view class="degrade-icon">{{ icon }}</view>
- <view class="degrade-text">{{ text }}</view>
- <view class="degrade-action" v-if="retry && scene === 'error'">
- <text class="retry-btn" @tap="onRetry">重试</text>
- </view>
- </view>
- </template>
- <script>
- /**
- * IndicatorDegrade —— 降级态合集(P0-5,跨页面复用)
- * 文案契约:PRD §5.5 九个场景 + 新增 `incomplete` 场景(合规,文案硬编码在此组件内)
- *
- * Props:
- * scene {String} 必填:n0 / n1 / missing / invalid / upload-date / skip / unit-mismatch / other-type / error / incomplete
- * dates {Array} 缺失日期列表(skip 场景用)
- * date {String} 跳比参考日期(skip 场景用)
- * count {Number} 其他类型期数(other-type 场景用)
- * retry {Function} error 场景的重试回调
- */
- export default {
- name: 'IndicatorDegrade',
- props: {
- scene: { type: String, required: true },
- dates: { type: Array, default: function() { return [] } },
- date: { type: String, default: '' },
- count: { type: Number, default: 0 },
- /** scene='incomplete' 专用:报告总份数 */
- totalReportCount: { type: Number, default: 0 },
- /** scene='incomplete' 专用:本指标已具备期数 */
- pointsCount: { type: Number, default: 0 },
- retry: { type: Function, default: null }
- },
- computed: {
- wrapClass: function() {
- return this.scene === 'error' ? 'degrade-wrap-error' : 'degrade-wrap'
- },
- icon: function() {
- var s = this.scene
- if (s === 'n0' || s === 'missing' || s === 'invalid') return '—'
- if (s === 'n1') return '●'
- if (s === 'upload-date') return '*'
- if (s === 'skip') return 'ⓘ'
- if (s === 'unit-mismatch') return '*'
- if (s === 'other-type') return '—'
- if (s === 'error') return '⚠'
- if (s === 'incomplete') return 'ⓘ'
- return '—'
- },
- text: function() {
- var s = this.scene
- if (s === 'n0') return '暂无该指标数据'
- if (s === 'n1') return '首次记录 · 暂无对比'
- if (s === 'missing') return '该期未检测'
- if (s === 'invalid') return '该期无有效数值'
- if (s === 'upload-date') return '未识别到采样日期,按上传日期记录'
- if (s === 'skip') {
- var ds = this.dates && this.dates.length > 0 ? this.dates.join('、') : ''
- return ds ? ('ⓘ ' + ds + ' 两期未检测该项,对比的是 ' + (this.date || '')) : ('ⓘ 中间 N 期未检测该项,对比的是 ' + (this.date || ''))
- }
- if (s === 'unit-mismatch') return '该期单位与其他期不同,未做换算'
- if (s === 'other-type') return '其他报告类型有 ' + this.count + ' 期数据,暂不支持跨类型对比'
- if (s === 'error') return '趋势数据加载失败,请下拉重试'
- if (s === 'incomplete') {
- var pc = this.pointsCount || 0
- var tc = this.totalReportCount || 0
- if (pc === 0 && tc === 0) return '该成员暂无报告数据'
- if (pc === 0) return '共 ' + tc + ' 份报告,本指标暂无可显示的历史数据'
- return '共 ' + tc + ' 份报告,本指标目前 ' + pc + ' 期数据(历史数据整理中)'
- }
- return ''
- }
- },
- methods: {
- onRetry: function() {
- if (this.retry) this.retry()
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .degrade-wrap {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- margin: 40rpx 0;
- padding: 16rpx;
- }
- .degrade-wrap-error {
- background: #FEF2F2;
- border: 1rpx dashed #FCA5A5;
- border-radius: 8rpx;
- }
- .degrade-icon {
- font-size: 24rpx;
- margin-right: 10rpx;
- width: 34rpx;
- text-align: center;
- }
- .degrade-text {
- font-size: 22rpx;
- line-height: 32rpx;
- color: #94A3B8;
- }
- .degrade-wrap-error .degrade-text {
- color: #EF4444;
- }
- .retry-btn {
- font-size: 20rpx;
- color: #EF4444;
- background: #FEE2E2;
- border-radius: 8rpx;
- padding: 6rpx 14rpx;
- margin-left: 12rpx;
- }
- </style>
|