# 多选开启分页功能(支持翻页选中)


isShowPagination 开启分页功能
reserveSelection 开启翻页选中功能,默认开启
@page-change页码改变事件;传出当前选中的页码
table 数据源及表头信息
keywords 选项中的 value(选项的值),label(选项的标签)
@selectionChange="selectionChange"事件返回选中的数据及 id

<template>
  <t-select-table
    :table="table"
    :columns="table.columns"
    :max-height="400"
    :keywords="{label:'materialCode',value:'id'}"
    multiple
    @selectionChange="selectionChange"
    @page-change="pageChange"
    isShowPagination
  ></t-select-table>
</template>

<script>
import data from './data.json'
import data1 from './data1.json'
export default {
  data() {
    return {
      table: {
        total: 0,
        currentPage: 1,
        pageSize: 10,
        data: [],
        columns: [
          { prop: 'factoryModelIdLabel', label: '工厂', minWidth: '100' },
          { prop: 'materialTypeLabel', label: '物料分类', minWidth: '80' },
          { prop: 'materialCode', label: '物料编码', minWidth: '100' },
          { prop: 'materialName', label: '物料名称', minWidth: '160' },
          { prop: 'materialSpecs', label: '规格', minWidth: '80' },
          { prop: 'power', label: '功率', minWidth: '80' },
          { prop: 'materialPropertyLabel', label: '物料属性', minWidth: '80' },
          { prop: 'baseUnit', label: '基本单位', minWidth: '80' },
          { prop: 'singleWeight', label: '单重', minWidth: '80' },
          { prop: 'shortRuleMore', label: '改余', minWidth: '80' },
          { prop: 'shortRuleLess', label: '改损', minWidth: '80' },
          { prop: 'materialSourceLabel', label: '数据来源', minWidth: '100' },
          { prop: 'updateTime', label: '最后更新日期', minWidth: '100' },
          { prop: 'updateBy', label: '最后更新人', minWidth: '100' }
        ],
      }
    }
  },
  created() {
    this.getList(1)
  },
  methods: {
    // 复选框
    selectionChange(val, ids) {
      console.log('复选框', val)
      console.log('复选框--id', ids)
    },
    // 获取当前的页码
    pageChange(val) {
      console.log('获取当前的页码', val)
      this.table.currentPage = val
      this.getList(this.table.currentPage)
    },
    async getList(pageNum) {
      let res
      if (pageNum === 1) {
        res = await data
      } else {
        res = await data1
      }
      if (res.success) {
        // console.log('获取品名下拉数据', res.data)
        this.table.data = res.data.records
        this.table.total = res.data.total
      }
    }
  }
}
</script>

<style>
</style>
显示代码