| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <template>
- <text class="status-tag" :class="tagClass">{{ tagText }}</text>
- </template>
- <script>
- /**
- * 状态徽标(原子组件)
- * 目的:把 status → 文案/颜色的映射收敛到一处,避免各页面各写一份导致口径漂移。
- * 用法:<StatusTag status="published" type="cohort" />
- */
- export default {
- name: 'StatusTag',
- props: {
- // 状态值
- status: {
- type: String,
- default: ''
- },
- // 业务域:cohort / credit / attendance / promo
- type: {
- type: String,
- default: ''
- },
- // 自定义文案(优先于映射)
- text: {
- type: String,
- default: ''
- }
- },
- computed: {
- tagText() {
- if (this.text) return this.text
- var map = this.textMap()
- return map[this.status] || this.status || '未知'
- },
- tagClass() {
- return 'tag-' + this.colorKey()
- },
- colorKey() {
- var map = this.colorMap()
- return map[this.status] || 'grey'
- }
- },
- methods: {
- textMap() {
- var map = {
- // 批次
- draft: '未发布',
- published: '可报名',
- ongoing: '进行中',
- full: '已满',
- closed: '已截止',
- signed: '已报名',
- // 学时
- effective: '生效中',
- pending: '待生效',
- objected: '异议中',
- rejected: '已驳回',
- settled: '已结算',
- // 签到
- success: '签到成功',
- dupe: '已签到',
- invalid: '码无效',
- // 通用
- accepted: '已通过',
- rejected2: '未通过',
- // 晋升
- promoted: '已晋升',
- evaluated: '评定中',
- // 证据包
- done: '已完成',
- processing: '生成中',
- failed: '生成失败'
- }
- if (this.type === 'credit') {
- return map
- }
- return map
- },
- colorMap() {
- var map = {
- draft: 'grey',
- published: 'blue',
- ongoing: 'green',
- full: 'orange',
- closed: 'grey',
- signed: 'blue',
- effective: 'green',
- pending: 'orange',
- objected: 'blue',
- rejected: 'red',
- settled: 'grey',
- success: 'green',
- dupe: 'blue',
- invalid: 'red',
- accepted: 'green',
- promoted: 'green',
- evaluated: 'blue',
- done: 'green',
- processing: 'blue',
- failed: 'red'
- }
- return map
- }
- }
- }
- </script>
- <style scoped>
- .status-tag {
- font-size: 22rpx;
- padding: 4rpx 16rpx;
- border-radius: 8rpx;
- line-height: 1.5;
- }
- .tag-blue { background: #E8F3FC; color: #2E6FA8; }
- .tag-green { background: #E6F6EE; color: #0E8A4F; }
- .tag-orange { background: #FEF3E2; color: #B9770E; }
- .tag-red { background: #FDE8E8; color: #C0392B; }
- .tag-grey { background: #F0F4F9; color: #3B5A78; }
- </style>
|