<template>
  <div id="list">
    <cbtn :list="btnList" @btnBarOpera="btnOpera"></cbtn>
    <ctable
      :fields="fields"
      :opera="opera"
      :data="list"
      :total="total"
      :limit="limit"
      :usePage="usePage"
      :vOpera="vOpera"
      @query="search"
      @rowClick="rowClick"
      @opera="toOpera"
    ></ctable>
  </div>
</template>

<script>
const _ = require('lodash');
import cbtn from '@/components/usual/c-btnbar.vue';
import ctable from '@/components/usual/c-table.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'list',
  props: {},
  components: { ctable, cbtn },
  data: function () {
    return {
      fields: [],
      opera: [],
      btnList: [],
      list: [],
      total: 0,
      limit: 10,
      usePage: true,
      vOpera: false,
    };
  },
  computed: {
    ...mapState(['user']),
  },
  created() {},
  methods: {
    async search() {},
    async rowClick(row) {},
    toOpera({ method, ...others }) {
      method = _.capitalize(method);
      if (this[`to${method}`]) this[`to${method}`](others);
      else console.warn('没有响应的函数,无法执行');
    },
    btnOpera(method) {
      method = _.capitalize(method);
      if (this[`to${method}`]) this[`to${method}`](others);
      else console.warn('没有响应的函数,无法执行');
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

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