<template>
  <div id="index">
    <el-row>
      <el-col :span="24">
        <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search"></data-table>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import dataTable from '@common/src/components/frame/filter-page-table.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: inviteCode } = createNamespacedHelpers('inviteCode');
import _ from 'lodash';
export default {
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  name: 'index',
  props: {},
  components: {
    dataTable,
  },
  data: function() {
    return {
      opera: [],
      fields: [
        { label: '机构代码或邀请码', prop: 'code', filter: 'input' },
        { label: '所属人', prop: 'user_name', filter: 'input' },
      ],
      list: [],
      total: 0,
    };
  },
  async created() {
    await this.search();
  },
  methods: {
    ...inviteCode(['query']),
    async search({ skip = 0, limit = 10, ...info } = {}) {
      let res = await this.query({ skip, limit, ...info });
      if (this.$checkRes(res)) {
        this.$set(this, `list`, res.data);
        this.$set(this, `total`, res.total);
      }
    },
  },
  computed: {
    ...mapState(['user']),
  },
  watch: {},
};
</script>

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