<template>
   <a-modal :mask-closable="false" title="驳回意见" :visible="isOpen" :width="500" centered class="geg" @cancel="handleCancel">
     <a-form ref="formRef" :model="formState" :rules="rules" :label-col="{ span: 5 }">
      <div class="dialog-wrap">
        <a-form-item label="批复意见" name="reply">
          <a-textarea  v-model:value="formState.reply"  placeholder="请输入" :auto-size="{ minRows: 2, maxRows: 5 }"/>
        </a-form-item>
      </div>  
     </a-form>
     <template #footer>
      <a-button :disabled="loading" @click="handleCancel">取消</a-button>
      <a-button :loading="loading" type="primary" @click="handleSubmit">确定</a-button>
    </template>
   </a-modal>
</template>

<script setup lang="ts">
import {  ref, onMounted, computed, unref,reactive,watch } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { Form, message } from 'ant-design-vue';
import { useI18n } from '/@/hooks/web/useI18n';
import type { Rule } from 'ant-design-vue/es/form';
import { useMessage } from '/@/hooks/web/useMessage';
import type { FormInstance } from 'ant-design-vue';
const { t } = useI18n(); 
const isUpdate = ref(true);
const formRef = ref()
const { notification } = useMessage();
const loading = ref(false)
const emit = defineEmits(['success','register']);
let formState = reactive({
});
const isOpen = ref(false)
const rules = {
  reply: [{ required: true, message: "该项为必填项", trigger: 'change' }],
};
const props = defineProps({
  type: String,
  visible: Boolean
})


  onMounted(() => {

  });
  watch(
      () => props.visible,
      (val) => {
        isOpen.value = val
        formRef.value && formRef.value.resetFields();
      },
      {
        immediate: true,
        deep: true,
      }
    );
  const handleCancel = () => {
    formRef.value.resetFields();
    isOpen.value = false
    emit('cancel');
  }
  const handleSubmit = async () => {
    try {
      await formRef.value.validate();
      emit('success', formState);
      // formRef.value.resetFields();
    } catch (error) {
      console.log('验证失败:', error);
    }
  };
  </script>
  <style lang="less" scoped>
    .dialog-wrap {
        padding: 10px 15px 0 0;
    }
  </style>