From d1babbc00b53e2ae91c90e4601ce6a5ce77a0c24 Mon Sep 17 00:00:00 2001 From: maslow Date: Thu, 14 Oct 2021 17:13:30 +0800 Subject: [PATCH] fix(sys-client): dbm - update doc error catch --- .../src/views/database/collections.vue | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/packages/system-client/src/views/database/collections.vue b/packages/system-client/src/views/database/collections.vue index 0fd5e46406..9654ec887d 100644 --- a/packages/system-client/src/views/database/collections.vue +++ b/packages/system-client/src/views/database/collections.vue @@ -10,7 +10,7 @@ 添加记录 - +
选择集合 @@ -341,19 +341,21 @@ export default { async updateDocument() { await this.$confirm('确认要更新数据?', '确认') const record = typeof this.record === 'string' ? JSON.parse(this.record) : this.record - const { _id, ...params } = record if (!_id) return - const ret = await db + const r = await db .collection(this.collectionName) .doc(_id) .set({ ...params }) - if (ret) { - this.$message('更新成功') - this.getList() + if (r.error) { + const message = typeof r.error !== 'string' ? JSON.stringify(r.error) : r.error + return showError('更新失败: ' + message) } + + showSuccess('更新成功') + this.getList() }, handleCreateRecord() { this.formMode = 'create' @@ -364,28 +366,18 @@ export default { try { const params = JSON.parse(this.record) const r = await db.collection(this.collectionName) - .add({ - ...params - }) + .add({ ...params }) if (r.error) { - console.log(r.code) const message = typeof r.error !== 'string' ? JSON.stringify(r.error) : r.error - return showError('创建失败: ' + message) + return showError('添加失败: ' + message) } - this.$notify({ - type: 'success', - message: '创建成功!' - }) - + showSuccess('添加成功') this.getList() this.showDocEditorForm = false } catch (error) { - this.$notify({ - type: 'error', - message: '创建失败!' + error - }) + showError('创建失败!' + error) } }, /**