<template>
  <div class="renKeJiaoChengBase">
    <a-modal :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" :getContainer="getPDom" cancelText="关闭">
      <template #title>
        <div style="text-align: center;">订阅课程提醒</div>
      </template>
      <KcKetangbiaoForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"/>
    </a-modal>
  </div>
</template>

<script lang="ts" setup>
  import { ref, nextTick, defineExpose } from 'vue';
  import KcKetangbiaoForm from './baseForm.vue'

  const width = ref<number>(600);
  const visible = ref<boolean>(false);
  const disableSubmit = ref<boolean>(false);
  const registerForm = ref();

  function getPDom() {
    return document.querySelector('.renKeJiaoChengBase')
  }

  /**
   * 新增
   */
  function add() {
    visible.value = true;
    nextTick(() => {
      registerForm.value.add();
    });
  }

  /**
   * 编辑
   * @param record
   */
  function edit(record) {
    visible.value = true;
    nextTick(() => {
      registerForm.value.edit(record);
    });
  }

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

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

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

  defineExpose({
    add,
    edit,
    disableSubmit,
  });
</script>

<style lang="less" scoped>
  /**隐藏样式-modal确定按钮 */

  // .renKeJiaoChengBaseModal :deep(.ant-modal-content) {
    // text-align: center;
    // background: red;
  // }
.renKeJiaoChengBase {
  .jee-hidden {
    display: none !important;
  }
  // background: orange;

  :deep(.ant-modal-content) {
    // background: green;
    .ant-modal-footer {
      text-align: center;
      // background: red;
    }
  }

}
</style>
