<template>
  <div>
    <YMTableSearch :loading="loading" :search-form="searchForm" @onValueChange="onValueChange" @submit="onSubmit" />
    <YMTable
      ref="table"
      :table-key="1"
      :index="true"
      :selection="false"
      :table-options="tableOptions"
      :edit-form="editForm"
      :edit-config="editConfig"
      :columns="columns"
      :rows-actions="rowsActions"
      :show-summary="false"
      :apis="apis"
      :custom-style="{ height: 'calc(100vh - 310px)' }"
    />

  </div>
</template>
<script>

export default {
  data() {
    return {
      loading: false,
      visibleBasicDrawer: false,
      renderContent: '',
      searchForm: [
        // {
        //   label: '汇总类型',
        //   type: 'select',
        //   prop: 'xxxx',
        //   clearable: false,
        //   options: [
        //     {
        //       value: 0,
        //       label: '否'
        //     },
        //     {
        //       value: 1,
        //       label: '是'
        //     }
        //   ]
        // },
        {
          label: '时间',
          type: 'datetimerange',
          prop: 'xxxx',
          clearable: false
        }
        // {
        //   text: '按钮',
        //   type: 'button',
        //   method: () => {
        //     console.log('按钮')
        //   }
        // },
        // {
        //   label: '模板模板',
        //   type: 'input',
        //   prop: 'xxxx',
        //   clearable: false
        // }
      ],
      columns: [
        {
          label: '登陆网址',
          prop: 'xxxx'
        },
        {
          label: '登陆人数',
          prop: 'xxxx'
        }
      ],
      rowsActions: [],
      apis: {
        list: {
          url: 'agent/host',
          dataParam: 'data.list',
          resultParam: 'data',
          init: false
        },
        add: {
          url: '',
          cover: true,
          coverMethod: (row, node) => {
            return row.year + '、' + node[0].label
          }
        },
        edit: {
          url: '',
          cover: true,
          coverMethod: (row, node) => {
            return row.year + '、' + node[0].label
          }
        },
        preview: {
          url: '',
          dataParam: 'datas',
          keyParam: 'cache_key'
        },
        import: {
          url: '',
          params: 'cache_key'
        },
        batchDelete: {
          url: '',
          params: 'ids'
        },
        delete: {
          url: '',
          params: 'ids'
        }
      },
      tableOptions: {
        add: {
          show: false,
          initData: () => {
            return { test: 'test' }
          }
        },
        import: {
          show: false,
          tip: '注：备注',
          columns: [
            {
              label: '严控',
              prop: 0,
              required: true
            }
          ]
        },
        export: {
          show: false,
          dataName: 'xxx.xlsx',
          baseApi: process.env.VUE_APP_BASE_IMG + '/',
          theadMap: [
            {
              xxxx: {}
            }
          ],
          theadProps: {
            xxxx: {}
          }
        },
        download: {
          show: false,
          url: '/static/template.xlsx'
        },
        batchDelete: {
          show: false
        }
      },
      editForm: [
        {
          body: [
            {
              label: '年度',
              type: 'year',
              prop: 'year',
              clearable: false,
              rules: [
                {
                  required: true,
                  message: '请选择年度',
                  trigger: 'change'
                }
              ]
            }
          ]
        }
      ],
      editConfig: {
        addTip: '注：备注',
        editTip: '注：备注'
      },
      countData: {}
    }
  },
  created() {
  },
  mounted() {
    this.onSubmit()
  },
  methods: {
    handleClickDrawer(row) {

    },
    onValueChange(val) {

    },
    onSubmit(params) {
      this.$refs.table.getList(params)
    }
  }
}
</script>
