From ceee1681c967a60357d4f3e5c60722cefca29d35 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Mon, 13 Apr 2026 13:59:26 +0900 Subject: [PATCH] =?UTF-8?q?feat(agent):=20=EC=97=90=EC=9D=B4=EC=A0=84?= =?UTF-8?q?=ED=8A=B8-=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Agent/AgentDetail.vue | 72 ++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/src/views/Agent/AgentDetail.vue b/src/views/Agent/AgentDetail.vue index fc62204..98a6bd3 100644 --- a/src/views/Agent/AgentDetail.vue +++ b/src/views/Agent/AgentDetail.vue @@ -317,21 +317,42 @@ export default { this.fetchList(1) }, methods: { + notifyError(message) { + // vuetify-dialog 플러그인을 통해 오류 노출 + if (this.$dialog && this.$dialog.notify && this.$dialog.notify.error) { + this.$dialog.notify.error(message) + } + }, + getErrorMessage(e) { + const fallback = '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.' + try { + if (!e) return fallback + // axios 형태의 에러 응답을 우선 사용 + const msg = (e.response && e.response.data && (e.response.data.message || e.response.data.error || e.response.data.msg)) + || e.message + return msg || fallback + } catch (_) { + return fallback + } + }, async fetchList(page = this.page) { if (this.is_loading) return this.is_loading = true try { this.page = page const res = await getAgentAssignedCreatorList(this.agentId, Math.max(1, this.page), this.page_size) - // ApiResponse - let payload = res && res.data ? res.data : null - if (payload && payload.data) payload = payload.data - const data = payload || { totalCount: 0, items: [] } - this.totalCount = data.totalCount || 0 - this.items = Array.isArray(data.items) ? data.items : [] + if (res && res.status === 200 && res.data && res.data.success === true) { + const data = (res.data && res.data.data) || { totalCount: 0, items: [] } + this.totalCount = data.totalCount || 0 + this.items = Array.isArray(data.items) ? data.items : [] + } else { + const msg = res && res.data && (res.data.message || res.data.error || res.data.msg) + this.notifyError(msg || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } } catch (e) { this.totalCount = 0 this.items = [] + this.notifyError(this.getErrorMessage(e)) } finally { this.is_loading = false } @@ -356,12 +377,17 @@ export default { this.assignDialog.searchLoading = true try { const res = await searchAdminAgentAssignableCreators(query) - let payload = res && res.data ? res.data : null - if (payload && payload.data) payload = payload.data - const data = payload || { totalCount: 0, items: [] } - this.assignDialog.searchItems = Array.isArray(data.items) ? data.items : [] + if (res && res.status === 200 && res.data && res.data.success === true) { + const data = (res.data && res.data.data) || { totalCount: 0, items: [] } + this.assignDialog.searchItems = Array.isArray(data.items) ? data.items : [] + } else { + this.assignDialog.searchItems = [] + const msg = res && res.data && (res.data.message || res.data.error || res.data.msg) + this.notifyError(msg || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } } catch (e) { this.assignDialog.searchItems = [] + this.notifyError(this.getErrorMessage(e)) } finally { this.assignDialog.searchLoading = false } @@ -371,15 +397,20 @@ export default { this.assignDialog.loading = true try { const assignedAt = `${this.assignDialog.assignedDate}T00:00:00` - await assignAgentCreator({ + const res = await assignAgentCreator({ agentId: Number(this.agentId), creatorId: Number(this.assignDialog.selectedCreatorId), assignedAt, }) - this.closeAssignDialog() - this.fetchList(1) + if (res && res.status === 200 && res.data && res.data.success === true) { + this.closeAssignDialog() + this.fetchList(1) + } else { + const msg = res && res.data && (res.data.message || res.data.error || res.data.msg) + this.notifyError(msg || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } } catch (e) { - // noop: 에러 토스트 자리는 프로젝트 전역 플러그인 유무에 따라 추가 가능 + this.notifyError(this.getErrorMessage(e)) } finally { this.assignDialog.loading = false } @@ -400,14 +431,19 @@ export default { try { const time = this.unassignDialog.time || '00:00' const unassignedAt = `${this.unassignDialog.date}T${time}:00` - await removeAgentCreator({ + const res = await removeAgentCreator({ creatorId: Number(this.unassignDialog.target.creatorId), unassignedAt, }) - this.closeUnassignDialog() - this.fetchList(this.page) + if (res && res.status === 200 && res.data && res.data.success === true) { + this.closeUnassignDialog() + this.fetchList(this.page) + } else { + const msg = res && res.data && (res.data.message || res.data.error || res.data.msg) + this.notifyError(msg || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } } catch (e) { - // noop + this.notifyError(this.getErrorMessage(e)) } finally { this.unassignDialog.loading = false }