<template>
  <div id="status-2">
    <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit"> </data-table>
  </div>
</template>

<script>
const moment = require('moment');
const { ticketType } = require('@common/dict/index');
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: ticket } = createNamespacedHelpers('ticket');
export default {
  name: 'status-2',
  props: {},
  components: {},
  data: function () {
    return {
      list: [],
      total: 0,
      opera: [
        {
          label: '审核',
          method: 'edit',
        },
      ],
      fields: [
        { label: '企业', prop: 'name', filter: true },
        { label: '申请时间', prop: 'meta.createdAt', format: (i) => moment(i).format('YYYY-MM-DD HH:mm:ss') },
        {
          label: '状态',
          prop: 'status',
          format: (i) => {
            const r = ticketType.find((f) => f.value === i);
            if (r) return r.label;
            else return '';
          },
        },
      ],
    };
  },
  created() {
    this.search();
  },
  methods: {
    ...ticket(['query', 'delete']),
    async search({ skip = 0, limit = 10, ...info } = {}) {
      const res = await this.query({ skip, limit, ...info, status: '2' });
      if (this.$checkRes(res)) {
        this.$set(this, `list`, res.data);
        this.$set(this, `total`, res.total);
      }
    },
    toEdit({ data }) {
      this.$router.push({ path: '/adminCenter/ticket/detail', query: { id: data._id, status: data.status } });
    },
  },
  computed: {
    ...mapState(['user', 'menuParams']),
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

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