<template>
  <BasicModal v-bind="$attrs" destroyOnClose @register="registerModal" showFooter :title="getTitle" width="40%" @ok="handleSubmit" @cancel="handleCancel">
    <a-form ref="formRef" :model="formState" :rules="rules" v-bind="{labelCol: { span: 8 },wrapperCol: { span: 16 },}">
      <a-row>
        <a-col :span="24">
          <a-form-item label="批复意见" name="reply" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
            <a-textarea  v-model:value="formState.reply"  placeholder="请输入" :auto-size="{ minRows: 2, maxRows: 5 }"/>
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
  </BasicModal>
</template>

<script setup lang="ts">
import {  ref, onMounted, computed, unref,reactive } 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 emit = defineEmits(['success','register']);
const getTitle = computed(() => t('驳回意见') )
let formState = reactive({
});
const rules = {
  reply: [{ required: true, message: "该项为必填项", trigger: 'change' }],
};
const props = defineProps({
  type: String
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  setModalProps({ confirmLoading: false });
  isUpdate.value = !!data?.isUpdate;

  });

  onMounted(() => {

  });
  const handleCancel = () => {
    formRef.value.resetFields();
  }
  const handleSubmit = async () => {
    try {
      await formRef.value.validate();
      emit('success', formState);
      formRef.value.resetFields();
      closeModal();
    } catch (error) {
      console.log('验证失败:', error);
    }
  };
  </script>