<!-- 表格记录 -->
<script lang="ts" setup>
import type { PropType } from 'vue'
import type { TableColumn } from '@/components/NormalTable/table_interface'

const props = defineProps({
  loading: {
    type: Boolean,
    default: false,
  },
  columns: {
    type: Array as PropType<TableColumn[]>,
    required: true,
  },
  list: {
    type: Array,
    required: true,
  },
  total: {
    type: Number,
    default: 0,
  },
})
const emits = defineEmits(['changePage'])
const searchQuery = ref({
  limit: 10,
  offset: 1,
})
console.log(props.list, '6666')
// 页数发生变化后的操作，可能是页码变化，可能是每页容量变化，此函数必写
const changePage = (val: { size?: number; page?: number }) => {
  if (val && val.size) {
    searchQuery.value.limit = val.size
  }
  if (val && val.page) {
    searchQuery.value.offset = val.page
  }
  emits('changePage', searchQuery)
}
</script>

<template>
  <div>
    <normal-table
      :data="list" :total="total" :columns="columns"
      :query="{ limit: searchQuery.limit, offset: searchQuery.offset }"
      :list-loading="loading"
      @change="changePage"
    />
  </div>
</template>

