<template>
  <div id="approve">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="one" v-if="type">
          <el-col :span="24" class="txt">企业申请资料受理记录</el-col>
          <data-table :fields="fields" :opera="opera" :data="oneList"> </data-table>
        </el-col>
        <el-col :span="24" class="one">
          <el-col :span="24" class="txt">企业申请资料审核记录</el-col>
          <data-table :fields="fields" :opera="opera" :data="twoList"> </data-table>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
const _ = require('lodash');
import { mapGetters, createNamespacedHelpers } from 'vuex';
const { mapActions } = createNamespacedHelpers('company_base');
const { mapActions: accept } = createNamespacedHelpers('company_accept');
const { mapActions: examine } = createNamespacedHelpers('company_examine');

export default {
  name: 'approve',
  props: {},
  components: {},
  data: function () {
    return {
      type: false,
      fields: [
        { label: '审核时间', model: 'examine_prsonal' },
        { label: '审核人', model: 'examine_date' },
        { label: '审核意见', model: 'resaon' },
      ],
      opera: [],
      // 受理
      oneList: [],
      // 审批
      twoList: [],
    };
  },
  created() {},
  mounted() {
    this.init();
  },
  methods: {
    ...mapActions(['fetch']),
    ...accept({ acceptQuery: 'query', acceptCreate: 'create' }),
    ...examine({ examineQuery: 'query', examineCreate: 'create' }),
    async init() {
      if (!_.get(this.tokenInfo, 'id')) return;
      const res = await this.fetch({ id: this.$route.query.id });
      if (this.$checkRes(res)) {
        let data = _.cloneDeep(res.data);
        let type = data.purpose.indexOf('保安服务公司申请设立');
        if (type != -1) this.$set(this, `type`, true);
        this.search({ company_id: data.id });
      }
    },
    async search({ skip = 0, limit = 10, company_id, ...info } = {}) {
      let res = await this.acceptQuery({ skip, limit, company_id, ...info });
      if (this.$checkRes(res)) this.$set(this, `oneList`, res.data);
      res = await this.examineQuery({ skip, limit, company_id, ...info });
      if (this.$checkRes(res)) this.$set(this, `twoList`, res.data);
    },
  },
  computed: {
    ...mapGetters(['tokenInfo']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .one {
    .txt {
      font-size: 18px;
      font-weight: bold;
      margin: 0 0 10px 0;
    }
  }
}
</style>
