<!--
 * @FilePath: \code\Goats-Cloud-ui\src\views\big\device\components\Wtable.vue
 * @Author: 王路平
 * @文件版本: V1.0.0
 * @Date: 2023-06-28 10:45:06
 * @Description: 
 * 
 * 版权信息         : 2023 by ${再登软件}, All Rights Reserved.
-->
<template>
  <div style="width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: space-between;">
    <el-table :data="tableData" style="width: 100%" :height="config.height">
      <el-table-column
        :prop="configItem.prop"
        :label="configItem.label"
        :width="configItem.width"
        v-for="configItem in config.column"
        :key="configItem.prop"
      />
    </el-table>
    <!-- /没用的div 占位 -->
    <div style="width: 100%; height: 10px;"></div>
    <el-pagination
      v-model:current-page="currentPage.page"
      v-model:page-size="currentPage.pageSize"
      :page-sizes="[5, 10, 20, 50]"
      :small="small"
      :disabled="disabled"
      :background="background"
      layout=" prev, pager, next, sizes"
      :total="currentPage.total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script setup lang="ts">
import { computed, ref } from "vue";
const prop = defineProps({
  config: {
    type: Object,
    default: {
      height:800,
      column: [
        {
          //输入框
          prop: "name",
          label: "",
          width: "180",
        },
      ],
    },
  },
  tableData: {
    type: Array,
    default: [
      {
        name: "",
      },
    ],
  },
  page:{
    type: Object,
    default: {
        page:1,
        pageSize:5,
        total:1
      },
  }
});
//实现父子组件数据双向绑定
const currentPage = computed({
  get: () => prop.page,
  set: val => {
    emit('update:page', val)
  },
})
// //当前页
// const currentPage=ref(1)
// //每页数据量
// const pageSize=ref(10)
//小图标显示
const small = ref(true)
//是否禁用分页
const disabled = ref(false)
//页码显示背景色
const background = ref(false)
//改变每页数据量方法
const handleSizeChange = (val: number) => {
  emit('gettabellist')
}
//改变当前页方法
const handleCurrentChange = (val: number) => {
  emit('gettabellist')
}
const emit = defineEmits([ 'gettabellist','update:page'])
</script>

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