<template>
  <div id="flow">
    <el-card v-for="(i, index) in list" :key="`flow-${index}`" style="margin: 10px">
      <template #header>
        <el-row type="flex" :gutter="10" justify="space-between">
          <el-col :span="8">{{ getStep(i) }}</el-col>
          <el-col :span="5">{{ getTime(i) }}</el-col>
        </el-row>
      </template>
      意见:
      <p>{{ i.desc }}</p>
    </el-card>
  </div>
</template>

<script>
const moment = require('moment');
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: ticket } = createNamespacedHelpers('ticket');
export default {
  name: 'flow',
  props: { id: { type: String, required: true } },
  components: {},
  data: function () {
    return {
      list: [],
      status: [
        { value: '0', label: '申请' },
        { value: '1', label: '资质审核成功' },
        { value: '-1', label: '资质审查失败' },
        { value: '2', label: '企业填写资料完成,信息资料审查中' },
        { value: '3', label: '中介机构审核成功' },
        { value: '-3', label: '信息资料审查失败' },
        { value: '4', label: '创新劵领取成功' },
      ],
    };
  },
  created() {
    this.search();
  },
  methods: {
    ...ticket(['record']),
    async search() {
      const res = await this.record({ ticket_id: this.id });
      if (this.$checkRes(res)) {
        this.$set(this, `list`, res.data);
      }
    },
    getStep(data) {
      const { status } = data;
      const r = this.status.find((f) => f.value === status);
      if (r) return r.label;
      else return '未知步骤';
    },
    getTime(data) {
      return moment(_.get(data, 'meta.createdAt')).format('YYYY-MM-DD HH:mm:ss');
    },
  },
  computed: {
    ...mapState(['user', 'menuParams']),
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

<style lang="less" scoped></style>
