index.js 1021 Bytes
Newer Older
陈浩玮's avatar
修改  
陈浩玮 committed
1 2 3 4 5
export default {
    data() {
        return {
            type: 0,
            form: {},
陈浩玮's avatar
设备  
陈浩玮 committed
6
            title: '',
陈浩玮's avatar
修改  
陈浩玮 committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
        };
    },
    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) {
水落(YangLei)'s avatar
水落(YangLei) committed
24
                return this.add();
陈浩玮's avatar
修改  
陈浩玮 committed
25 26
            }
            if (this.isEdit) {
水落(YangLei)'s avatar
水落(YangLei) committed
27
                return this.edit();
陈浩玮's avatar
修改  
陈浩玮 committed
28 29 30
            }
        },
        setData(data, type) {
陈浩玮's avatar
角色  
陈浩玮 committed
31
            this.form = { ...data };
陈浩玮's avatar
修改  
陈浩玮 committed
32
            this.type = type;
陈浩玮's avatar
设备  
陈浩玮 committed
33 34 35 36 37 38 39 40 41
            if (type === 0) {
                this.title = '新增';
            } else if (type === 1) {
                this.title = '编辑';
            } else if (type === 2) {
                this.title = '查看';
            } else {
                this.title = '';
            }
陈浩玮's avatar
修改  
陈浩玮 committed
42 43 44
        },
    },
};