<template>
  <a-modal :visible="isShowPage" width="80%" style="top: 20px" title="详情" :ok-button-props="{ style: { display: 'none' } }" cancelText="关闭" @cancel="() => (isShowPage = false)">
    <!--引用表格-->
    <BasicTable @register="registerTable" :rowSelection="rowSelection">
       <!--操作栏-->
       <template #action="{ record }">
        <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
      </template>
    </BasicTable>
  </a-modal>
</template>

<script lang="ts" name="jiaoshi-kcJiaoshirongliang" setup>
  import {ref, computed, unref, Ref } from 'vue';
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
  import { useModal } from '/@/components/Modal';
  import { useListPage } from '/@/hooks/system/useListPage'
  import { columns, searchFormSchema } from './KcZhihuijiaoshiStateLog.data';
  import { list } from './KcZhihuijiaoshiStateLog.api';

  const queryParam:any = ref({});

  const checkedKeys = ref<Array<string | number>>([]);
  //注册model
  const [registerModal, { openModal }] = useModal();
  //注册table数据
  const { tableContext } = useListPage({
    tableProps:{
      title: '教室容量',
      api: list,
      columns,
      canResize:false,
      showActionColumn: false,
      immediate: false,
      formConfig: {
        //labelWidth: 120,
        schemas: searchFormSchema,
        autoSubmitOnEnter:true,
        showAdvancedButton:true,
        fieldMapToNumber: [
        ],
        fieldMapToTime: [
        ],
      },
      beforeFetch: (params) => {
        params.column = '',params.order = '';//新生成的默认不带排序
        return Object.assign(params, queryParam.value);
      },
      actionColumn: {
        width: 120,
        fixed:'right'
      },
    },
  })

  const [registerTable, { reload },{ rowSelection, selectedRowKeys }] = tableContext

  const isShowPage:Ref<boolean> = ref(false);

   /**
    * 详情
   */
   function handleDetail(record: Recordable) {
     openModal(true, {
       record,
       isUpdate: true,
       showFooter: false,
     });
   }
   /**
    * 操作栏
    */
    function getTableAction(record){
       return [
         {
           label: '详情',
           onClick: handleDetail.bind(null, record),
         }
       ]
   }

   function getDropDownAction(record){
    return []
   }

   function open(param){
    // changeQueryParam(param);
    queryParam.value = Object.assign({ }, param);
    reload();
    isShowPage.value = true;
  }

  function close(){
    isShowPage.value = false;
  }

   /**
    * 成功回调
    */
  function handleSuccess() {
      (selectedRowKeys.value = []) && reload();
   }

   defineExpose({
    open,
    close,
   });


</script>

<style scoped>

</style>