<template>
    <div>
        <a-modal :visible="visible" @ok="handOK" :confirmLoading="confirmLoading" @cancel="handCancle" width="900px"
            :maskClosable="false" :destroyOnClose="true">
            <template slot="title">
                生成试卷
            </template>
            <div class="modal-box" style="padding:0">
                <a-form :form="form" @submit="handOK" layout="horizontal">
                    <a-form-item label="纸张大小：" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
                        <a-radio-group v-decorator="['paperSize',{rules: [{ required: true, message: '请选择纸张大小!' }]
                }]">
                            <a-radio :value="0">A4竖向</a-radio>
                            <a-radio :value="1">A3横向</a-radio>
                        </a-radio-group>
                    </a-form-item>
                </a-form>
            </div>
        </a-modal>
    </div>
</template>
<script>
    import { PaperProduce } from '@/api/api'
    export default {
        data() {
            return {
                confirmLoading: false,
                visible: false,
                form: this.$form.createForm(this),
                examId: ''
            };
        },
        mounted() {

        },
        methods: {
            showModal(examId) {
                this.examId = examId;
                this.visible = true;
            },
            //表单确认
            handOK(e) {
                e.preventDefault();
                this.form.validateFields((err, values) => {
                    if (!err) {
                        this.confirmLoading = true;
                        console.log(values, 'values')
                        let params = {
                            paperId: this.examId
                        }
                        PaperProduce(values, params).then(res => {
                            this.$message.success('操作成功，可在试卷管理列表中查看！')
                            this.confirmLoading = false;
                            this.handCancle();
                        }).catch(err => {
                            this.confirmLoading = false;
                        })
                    }
                })
            },
            handCancle() {
                this.visible = false;
            }
        },
    };
</script>
<style scoped>

</style>