<template>
  <div class="div-box">
    <BasicTable @register="registerTable" :searchInfo="searchInfo"> </BasicTable>
  </div>
</template>
<script lang="ts" setup>
  import { reactive, defineProps ,watch} from 'vue';
  import { getTableList } from '@/api/sys/flowPenal'

  import { BasicTable, useTable, TableAction } from '@/components/Table';

  defineOptions({ name: 'RoleManagement' });
  const props = defineProps({
    dbCode: String
  })
  const searchInfo = reactive < Recordable > ({
    code: props.dbCode
  });
  watch(
    () => props.dbCode,
    (newVal, oldVal) => {
      searchInfo.code = newVal
      reload()
    }
  )

  const [registerTable, { reload, getSelectRows, clearSelectedRowKeys }] = useTable({
    // 表格名称
    title: '数据表列表',
    // 获取数据的接口
    api: getTableList,
    // 表单列信息 BasicColumn[]
    columns: [
      {
        title: '表名',
        dataIndex: 'name',
        width: 200,
      },
      {
        title: '备注',
        dataIndex: 'description',
        width: 180,
      },
    ],
    rowKey: 'name',
    // 使用搜索表单
    useSearchForm: false,
    // 显示表格设置工具
    showTableSetting: false,
    // 是否显示表格边框
    bordered: true,
    // 序号列
    showIndexColumn: false,
    // 勾选列
    rowSelection: {//多选框
      type: 'radio',
    },
    tableSetting: { fullScreen: true },
    isCanResizeParent: true,
    // 搜索
    handleSearchInfoFn(info) {
      return info;
    },
  });

  function getRow() {
    let rows = getSelectRows();
    return rows
  }
  defineExpose({
    getRow
  })

</script>
<style scoped>
  .div-box{
    display: flex;
    height: 100%;
  }
</style>