<template>
    <a-modal
        v-model="visible"
        :title="`设置排序:${row.assembleObjectName}`"
        @ok="handleOk"
        destroyOnClose
        :zIndex="1010"
    >
        <a-form-model layout="vertical" :model="form" :rules="rules" ref="form">
            <a-form-model-item label="排序" prop="order">
                <a-input-number :style="{ width: '100%' }" v-model="form.order" :min="1" :max="9999" />
            </a-form-model-item>
        </a-form-model>
    </a-modal>
</template>
<script>
export default {
    data() {
        return {
            visible: false,
            form: {},
            rules: {
                order: [{ required: true }, { pattern: /^(0|[1-9][0-9]*)$/, message: '请输入正确的排序' }],
            },
            row: {
                assembleObjectName: '',
            },
        };
    },
    props: {
        afterSubmit: Function,
    },

    methods: {
        showModal() {
            this.form = {};
            this.visible = true;
        },
        async handleOk(e) {
            await this.$refs.form.validate();
            const { assembleId, routeId } = this.row;
            const param = {
                assembleId,
                routeId,
                assembleOrder: this.form.order,
            };
            this.afterSubmit && this.afterSubmit(param);
            this.closeModal();
        },
        closeModal() {
            this.visible = false;
        },
        setRow(row) {
            this.row = row;
        },
    },
};
</script>
