<template>
  <div>
    <a-table
      :columns="columns"
      :data-source="tableData"
      :pagination="pagination"
      :scroll="{ x: 1400 }"
      @change="handleTableChange"
      :row-selection="{
        selectedRowKeys: selectedRowKeys,
        onChange: selectionChoosed,
      }"
      :row-key="
        (record, index) => {
          return record.id;
        }
      "
    >
    </a-table>
  </div>
</template>

<script>
import { columns,pagination } from "./depend/config.js";
import { shopPushList } from "@/api/shop/goods";
export default {
	data() {
		return {
			columns,pagination,
			tableData: [],
			selectedRowKeys: [],
		};
	},
	mounted() {
		this.getData();
	},
	methods: {
		getData() {
			shopPushList({
				pageNum: this.pagination.current,
				size: this.pagination.pageSize,
			}).then((res) => {
				this.tableData = res.data.rows;
				this.pagination.total = res.data.total;
			});
		},
		selectionChoosed(data) {
			console.log(data);
			this.selectedRowKeys = data;
		},
		handleTableChange(pagination) {
			console.log(pagination);
			const pager = { ...this.pagination };
			pager.current = pagination.current;
			pager.pageSize = pagination.pageSize;
			this.pagination = pager;
			this.getData();
		},
	},
};
</script>

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