index.js 711 Bytes
Newer Older
陈浩玮's avatar
修改  
陈浩玮 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
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) {
陈浩玮's avatar
角色  
陈浩玮 committed
30
            this.form = { ...data };
陈浩玮's avatar
修改  
陈浩玮 committed
31 32 33 34
            this.type = type;
        },
    },
};