export default { data() { return { type: 0, form: {}, title: '', }; }, 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; if (type === 0) { this.title = '新增'; } else if (type === 1) { this.title = '编辑'; } else if (type === 2) { this.title = '查看'; } else { this.title = ''; } }, }, };