<template>
  <div class="apply-audit-history">
    <div v-if="auditHistory.length">
      <p class="audit-result" v-if="latestHistory">
        <span>审核结果：</span>
        <span
          :class="
            latestHistory.approvePass === 'REJECT'
              ? 'color-danger'
              : 'color-dark'
          "
          >{{ latestHistory.reviewStatus }}</span
        >
      </p>
      <el-table border :data="auditHistory">
        <el-table-column prop="operateTime" label="审核日期">
          <span slot-scope="scope"
            >{{ scope.row.operateTime | timestampFilter }}
          </span>
        </el-table-column>
        <el-table-column prop="reviewStatus" label="审核结果">
        </el-table-column>
        <el-table-column prop="reason" label="审核意见"></el-table-column>
        <el-table-column prop="operateName" label="审核人"></el-table-column>
      </el-table>
    </div>
    <div class="history-none" v-else>
      <p class="tips-info text-center">暂无数据</p>
    </div>
  </div>
</template>

<script>
import { taskApplyAuditHistory } from "../api";

export default {
  name: "apply-audit-history",
  props: {
    flowId: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      auditHistory: [],
      latestHistory: null
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    async getData() {
      if (!this.flowId) return;
      this.auditHistory = await taskApplyAuditHistory(this.flowId);
      this.latestHistory = this.auditHistory[0];
    }
  }
};
</script>
