record.vue 5.1 KB
<template>
  <div class="record-layout">
    <div class="timeline" v-if="recordList.length">
      <div v-for="(item, index) in recordList" :key="index" class="timeline-item">
        <!-- 内容 -->

        <div class="step">
          {{ getStepText(item.status, 'text') }}
          <div class="status" :style="{ color: examineStatusClass[item.status] }">
            {{ getStepText(item.status, 'status') }}
          </div>
          <span v-if="item.rejectedStatus">
            <span style="display: inline-block; margin: 0 8px;">至</span>
            <span>{{ getRejectText(item.rejectedStatus, 'rejectedStatus') }}</span>
          </span>
        </div>

        <div class="details">
          <div class="detail-row" v-if="item.rejectCause">
            <span>驳回原因:</span>
            <span class="word-break">{{
                                            formatOpinionText(
                                                item.rejectCause,
                                            ) || "-"
                                        }}</span>
          </div>
          <div class="detail-row">
            <span>审核人:</span>
            <span>{{ item.reviewedBy }}</span>
          </div>
          <div class="detail-row">
            <span>审核时间:</span>
            <span>{{ item.reviewedDate }}</span>
          </div>
          <div v-if="item.remark" class="detail-row">
            <span>备注:</span>
            <span class="remark word-break">{{
                                            formatOpinionText(
                                                item.remark,
                                            ) || "-"
                                        }}</span>
          </div>
        </div>
        <!-- 圆点 -->
        <div class="dot" v-if="index != 0"></div>
        <img class="highlight" v-else src="https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/equity/highlight.png" />
        <!-- 线 -->
        <div class="line" v-if="index < recordList.length - 1"></div>
      </div>
    </div>
    <div v-else class="no-data">
      <img src="@/assets/images/no-data.png" />
      <span class="no-data-text">暂无数据</span>
    </div>
  </div>
</template>

<script>
import { parseTime } from '@/utils/tools.js'
export default {
  name: 'record',
  props: {
    recordList: {
      type: Array,
      default: () => ([])
    }
  },
  data() {
    return {
      statusForShow: {
        2: { text: '运营审核', status: '通过' },
        4: { text: '运营审核', status: '驳回' },
        5: { text: '商务审核', status: '通过' },
        6: { text: '商务审核', status: '驳回' },
        7: { text: '调拨驳回', status: '驳回' }
      },
      examineStatusClass: {
        2: '#35C376',
        4: '#F24724',
        5: '#35C376',
        6: '#F24724',
        7: '#F24724',
        8: '#35C376',
        9: '#F24724'
      },
      rejectedForShow: {
        1: { rejectedStatus: '调拨商户' },
        2: { rejectedStatus: '运营审核' },
        3: { rejectedStatus: '商务审核' }
      }
    }
  },
  methods: {
    formatOpinionText(opinion) {
			const s = String(opinion == null ? "-" : opinion);
			return s.replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n");
		},
    getStepText(status, key) {
      const mapping = this.statusForShow[status]
      return mapping ? mapping[key] : ''
    },
    getRejectText(status, key) {
      const mapping = this.rejectedForShow[status]
      return mapping ? mapping[key] : ''
    },

    formatReviewTime(timestamp) {
      if (!timestamp) return '-'
      return parseTime(timestamp, '{y}-{m}-{d} {h}:{i}:{s}')
    },
    // 可添加接口请求逻辑
    fetchRecordData() {
      // 示例:axios.get('/api/audit/record')
      //   .then(res => {
      //     this.recordList = res.data;
      //   });
    }
  },
  mounted() {
    // this.fetchRecordData();
  }
}
</script>

<style scoped lang="scss">
.record-layout {
  //   padding: 0 20px 20px;
  .no-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-items: center;
    img {
      width: 72px;
      height: 72px;
    }
    .no-data-text {
      color: #999ea8;
      font-size: 12px;
    }
  }
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8eb2fb;
  position: absolute;
  left: 3px;
  top: 9px;
  z-index: 99;
}
.highlight {
  width: 16px;
  height: 16px;
  position: absolute;
  left: 0px;
  top: 4px;
  z-index: 99;
}
.line {
  position: absolute;
  top: 16px;
  left: 7.5px;
  width: 1.5px;
  height: 94%;
  background-color: #d6e4ff;
}

.timeline-item {
  padding: 4px 0 12px 30px;
  font-size: 14px;
  position: relative;
}

.step {
  font-weight: bold;
  color: #333333;
  margin-bottom: 8px;
}

.status {
  margin-left: 6px;
  display: inline-block;
}

.detail-row {
  display: flex;
  margin-bottom: 8px;
  font-size: 14px;
  color: #666;
}

.detail-row :nth-child(1) {
  display: inline-block;
  width: 84px;
  color: #999999;
  margin-right: 9px;
}
.detail-row :nth-child(2) {
  color: #333333;
  width: calc(100% - 84px);
}
.word-break {
  white-space: pre-wrap;
	word-break: break-word;
}
</style>