<template>
  <div>
    <basic-container>
      <avue-crud
        :option="option"
        :data="dataList"
        ref="crud"
        v-model="form"
        :page.sync="page"
        :search.sync="search"
        @search-change="searchChange"
        @current-change="currentChange"
        @size-change="sizeChange"
        @refresh-change="refreshChange"
        @on-load="onLoad"
        :table-loading="loading"
        @saveColumn="saveColumn"
      ></avue-crud>
    </basic-container>
  </div>
</template>

<script>
import option from './config/mainList.json';

export default {
  name: "index",
  data() {
    return {
      option: {},
      dataList: [],
      form: {},
      page: {
        pageSize: 10,
        pagerCount: 5,
        total: 0,
      },
      search: {},
      loading: false,
    }
  },
  created() {
    this.option = option
    let i = 0;
    this.option.column.forEach(item => {
      if (item.search) i++
    })
    if (i % 3 !== 0){
      const num = 3 - Number(i % 3)
      this.option.searchMenuSpan = num * 8;
      this.option.searchMenuPosition = "right";
    }
  },
  methods: {
    searchChange(params, done) {
      done();
    },
    currentChange(val) {
      this.page.currentPage = val;
    },
    sizeChange(val) {
      this.page.currentPage = 1;
      this.page.pageSize = val;
    },
    refreshChange() {
      this.onLoad(this.page, this.search);
    },
    onLoad(page, params) {},
    async saveColumn() {},
  },
}
</script>

<style scoped>

</style>
