<template>
<div>
  <m-page
    :tableHead="tableHead"
    :tableData="tableData"
    :params="params"
    :objFn="objFn"
    :tableConfig="tableConfig"
  >
</m-page>
</div>
</template>

<script>
import mPage from '../../components/module/mPage.vue'

export default {
  name: '',
  components: { mPage },
  data () {
    return {
      tableConfig: { border: '', size: '', selection: { has: false, sels: [], width: '50px', fix: 'left', align: '' } },
      tableHead: [
        { prop: 'page_name', label: '页面名称', minWidth: '80', fix: 'left' },
        { prop: 'title', label: '标题', minWidth: '70', fix: false },
        { prop: 'keyword', label: '关键词', minWidth: '90', fix: false },
        { prop: 'detail', label: '描述', minWidth: '170', fix: false },
        { prop: 'operate', label: '操作', width: '60px', fix: false, commandArr: [ { command: 'pagelist-edit', name: '编辑' } ] }
      ],
      tableData: [],
      params: { keywords: '', curPage: 1, pageSize: 10, total: '' },
      objFn: {
        paramsFn: (_this) => {
          return {
            'keywords': _this.params.keywords,
            'page_num': _this.params.curPage,
            'page_size': _this.params.pageSize,
            'quota_type': 'org_bigscience_stat'
          }
        },
        nameAPI: 'getArticleList',
        // nameExcel: 'getStatSummaryExcel',
        nameExcel: 'getExportExcel3_4_14',
        callback: (_this, data) => {
          _this.params.total = 1
          /* 伪造数据 */
          var fakeData = [
            { page_name: '首页', title: '校园类', keyword: '平安,医保,科技...', detail: '平安医保科技公司是...' },
            { page_name: '关于我们', title: '校园类', keyword: '平安,医保,科技...', detail: '平安医保科技公司是...' },
            { page_name: '解决方案', title: '校园类', keyword: '平安,医保,科技...', detail: '平安医保科技公司是...' },
            { page_name: '核心优势', title: '科技类', keyword: '平安,医保,科技...', detail: '平安医保科技公司是...' },
            { page_name: '城市案例', title: '科技类', keyword: '平安,医保,科技...', detail: '平安医保科技公司是...' }
          ]
          fakeData.forEach((elem, i) => {
            elem.index = i + 1 + (_this.params.curPage - 1) * _this.params.pageSize
            _this.tableData.push(elem)
          })
        }
      }
    }
  },
  mounted () {
    this.VueEvent.$on('command-tablelist', (_obj) => {
      if (_obj.command === 'newslist-edit') {
      }
      if (_obj.command === 'newslist-del') {
      }
    })
  },
  methods: {
    searchList (val) {
      this.params.keywords = val
    },
    /* 删除选中 */
    batchRemove () {
      console.log(this.tableConfig.selection.sels)
    }
  }
}
</script>

<style lang="scss" scoped>
.self-selects {
  margin: 10px auto 30px auto;
  overflow: hidden;
  .btns {
    float: left;
  }
  .search-input {
    float: right;
    width: 40%;
  }
}
</style>
