<template>
  <a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
    <a-table
      :dataSource="dataSource"
      size="default"
      rowKey="id"
      :columns="columns"
      :pagination="false"
    >
    </a-table>
  </a-modal>
</template>
<script lang="ts" setup>
import { ref, defineExpose } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { dateUtil, formatToDate } from '/@/utils/dateUtil';

  const columns = ref([
    // {
    //   title: '',
    //   dataIndex: '',
    //   key: 'rowIndex',
    //   width: 50,
    //   fixed: 'left',
    //   align: 'center',
    //   slots: { customRender: 'dayWarnning' },
    // },
    {
      title: '课程名称',
      align: 'center',
      dataIndex: 'kcmc',
      width: 80,
    },
    {
      title: '上课教师',
      align: 'center',
      dataIndex: 'skjs',
      width: 80,
    },
    {
      title: '节次',
      align: 'center',
      dataIndex: 'hh',
      width: 80,
    },
    {
      title: '上课地点',
      align: 'center',
      dataIndex: 'skdd',
      width: 80,
    },
  ]);
  const dataSource: any = ref([]);

  const title = ref<string>('');
  const width = ref<number>(700);
  const visible = ref<boolean>(false);
  const disableSubmit = ref<boolean>(false);
  // const registerForm = ref();
  const emit = defineEmits(['register', 'success']);

  function open(){
    console.log("打开了！");
    //打开窗口
    title.value = '今日课堂';
    visible.value = true;
    disableSubmit.value = true;
    loadData();
  }

  function loadData(){
    let skrq = formatToDate(new Date());
    defHttp.get({ url: '/ktgl/kcKetangbiao/skzList', params: { skrq } }).then(res => {
      dataSource.value = res;
    })
  }

  /**
   * 确定按钮点击事件
   */
  function handleOk() {
    //registerForm.value.submitForm();
  }

  /**
   * form保存回调事件
   */
  function submitCallback() {
    handleCancel();
    emit('success');
  }

  /**
   * 取消按钮回调事件
   */
  function handleCancel() {
    visible.value = false;
  }

  defineExpose({
    open
  })
</script>
<style lang="less" scoped>
  /**隐藏样式-modal确定按钮 */
  .jee-hidden {
    display: none !important;
  }
</style>