From cdcf340a7586d3a3a5bae2a049252bd24e53ae10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chuailei000=E2=80=9D?= <2280131253@qq.com> Date: Thu, 23 Mar 2023 11:25:58 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E4=BC=98=E5=8C=96RelationCard=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=88=A0=E9=99=A4=E4=B9=8B=E5=90=8E=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/RelationCard/index.vue | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/RelationCard/index.vue b/src/components/RelationCard/index.vue index 121163166..8231f0710 100644 --- a/src/components/RelationCard/index.vue +++ b/src/components/RelationCard/index.vue @@ -117,6 +117,22 @@ export default { that.$message.success(that.$t('common.RemoveSuccessMsg')) } }, + onDeleteFail: { + type: Function, + default(error, that) { + let msg = '' + const data = error.response.data + for (const item of Object.keys(data)) { + const value = data[item] + if (value instanceof Array) { + msg = value.join(',') + } else { + msg = value + } + } + that.$message.error(msg) + } + }, performAdd: { type: Function, default: (objects, that) => {} @@ -248,7 +264,9 @@ export default { removeObject(obj) { this.performDelete(obj, this).then( () => this.onDeleteSuccess(obj, this) - ) + ).catch(error => { + this.onDeleteFail(error, this) + }) }, addObjects() { const objects = this.$refs.select2.$refs.select.selected.map(item => ({ label: item.label, value: item.value }))