<template>
  <div>
    <BasicTable :clickToRowSelect="false" @register="registerTable">

      <template #action="{ record }">
        <!-- v-if="dataCenter.editableData[record.ordern]" -->
        <!-- <div>{{dataCenter.editableData[record.ordern]}}</div> -->
        <TableAction
          :actions="[
            {
              label: '编辑',
              // auth: 'api:sw:hhgl:eidt',
              icon: 'clarity:note-edit-line',
              onClick: handleViewEidt.bind(null, record),
            },
          ]"
        />
      </template>
      <template #toolbar>
        <Authority>
          <a-button type="primary" @click="exportDataFn">导出</a-button>
        </Authority>
      </template>
    </BasicTable>
    <AccountModalLibrar @register="registerModal" @success="handleSuccess" />
  </div>
</template>
<script lang="ts" setup>
import { computed, defineComponent, createVNode, ref, watch, onMounted, reactive } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { getBaseConfigShow } from '/@/api/swHome/index';
import AccountModalLibrar from './components/AccountModalLibrar.vue';
import { useModal } from '/@/components/Modal';
const [registerModal, { openModal }] = useModal();
import { exportData } from '/@/utils/fnUtils.ts';
import { getBasicColumns } from './columns';
let dataCenter = reactive({
  
});
// 表格控件
const [
  registerTable,
  { reload, getForm, setColumns, getSelectRowKeys, getRowSelection, setTableData, getColumns, getDataSource },
] = useTable({
  title: '库表结构',
  api: getBaseConfigShow,
  columns: getBasicColumns(),
  showIndexColumn: true,
  clickToRowSelect: false,
  inset: true,
  // rowSelection: { type: 'checkbox' },
  tableSetting: {
    redo: false,
    setting: false,
  },
  useSearchForm: false,
  showTableSetting: true,
  bordered: true,
  fetchSetting: {
    listField: 'data',
  },
  actionColumn: {
    width: 200,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    fixed: 'right',
  },
});
// 编辑
const handleViewEidt = (key, item) => {
  console.log(key)
  openModal(true, {
    isUpdate: true,
    data:key
  });
};
const exportDataFn = () => {
  exportData(getColumns(),getDataSource(),'库表结构.xlsx')
}
// 成功
const handleSuccess = () => {
  // console.log('成功啦')
  reload()
}
</script>