export default {
    data() {
        return {
            type: 0,
            form: {},
        };
    },
    computed: {
        isAdd() {
            return this.type === 0;
        },
        isEdit() {
            return this.type === 1;
        },
        isView() {
            return this.type === 2;
        },
    },
    methods: {
        async submit() {
            await this.$refs.DrawerForm.validate();
            if (this.isAdd) {
                return this?.add();
            }
            if (this.isEdit) {
                return this?.edit();
            }
        },
        setData(data, type) {
            this.form = data;
            this.type = type;
        },
    },
};
