<template>
  <j-modal :title="title" width="70%" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
    <SelectNuList ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></SelectNuList>
  </j-modal>
</template>

<script lang="ts" setup>
  import { ref, nextTick, defineExpose } from 'vue';
  import SelectNuList from './SelectNuList.vue'
  import JModal from '/@/components/Modal/src/JModal/JModal.vue';

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

  /**
   * 日志
   * @param record
   */
  function showNuList(record,_type) {
    title.value = '选择区域';
    visible.value = true;
    type.value = _type;
    nextTick(() => {
      registerForm.value.init(record);
    });
  }

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

  /**
   * form保存回调事件
   */
  function submitCallback(params) {
    params.type = type.value;
    visible.value = false;
    emit('success',params);
  }

  /**
   * 取消按钮回调事件
   */
  function handleCancel() {
    let params = {'type':type.value};
    visible.value = false;
    emit('cancel',params);
  }

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

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