<template>
    <BasicModal :maskClosable="false" :width="440" @register="registerModal" v-bind="$attrs" title="数据恢复" centered
        @ok="handleSubmit">
        <BasicForm @register="registerForm" />
    </BasicModal>
</template>
<script>
import { defineComponent, reactive, ref, onMounted, watch, computed } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { message } from 'ant-design-vue';
import { formSchema } from './dataRestore.data';
import { dataRestore } from '/@/api/sys/dataBackUp';
import { session } from '/@/utils/Memory';

export default defineComponent({
    name: 'scheduledTaskManageModal',
    components: { BasicModal, BasicForm },
    setup(_, { emit }) {
        const [registerModal, { closeModal }] = useModalInner(async (data) => {
            console.log(data)
            resetFields();
            setFieldsValue({
                bfFid: data.bfFid
            });
        });
        const [registerForm, { setFieldsValue, updateSchema, resetFields, validate, getFieldsValue }] = useForm({
            schemas: formSchema,
            labelCol: { span: 6 },
            wrapperCol: { span: 16 },
            showActionButtonGroup: false
        });
        // 提交信息
        const handleSubmit = () => {
            validate().then(async (res) => {
                if (res) {
                    // const { bfFid, bfsm } = getFieldsValue();
                    // const userid = session.getItem('userId')
                    // await dataRestore({bfFid, bfsm, userid})
                    console.log('res', res);
                    // 关闭弹窗
                    closeModal();
                    // 触发父组件事件
                    emit('success', res);
                }
            });
        };
        return {
            registerModal,
            registerForm,
            handleSubmit,
        };
    },
});
</script>