From 335716f860dffe92bc185f1635c70be00109ed5f Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Thu, 4 Jan 2024 00:02:07 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=98=EC=A0=95=20=EA=B8=B0=EB=8A=A5=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/api/can.js | 5 ++ src/views/Can/CanCoupon.vue | 158 +++++++++++++++++++++++++++++++++++- 2 files changed, 159 insertions(+), 4 deletions(-) diff --git a/src/api/can.js b/src/api/can.js index f3d2f32..cd18d1a 100644 --- a/src/api/can.js +++ b/src/api/can.js @@ -35,11 +35,16 @@ async function downloadCouponNumberList(couponId) { return Vue.axios.get('/can/coupon/number-list/download?couponId=' + couponId, { responseType: 'blob' }); } +async function modifyCoupon(request) { + return Vue.axios.put('/can/coupon', request); +} + export { getCans, insertCan, deleteCan, paymentCan, + modifyCoupon, getCouponList, generateCoupon, getCouponNumberList, diff --git a/src/views/Can/CanCoupon.vue b/src/views/Can/CanCoupon.vue index 72fbee1..924908d 100644 --- a/src/views/Can/CanCoupon.vue +++ b/src/views/Can/CanCoupon.vue @@ -83,6 +83,14 @@ 다운로드 + @@ -154,7 +162,96 @@ - + + + + 취소 + + + 쿠폰 발행하기 + + + + + + + + + + 쿠폰 수정 + + + + 쿠폰명 + + + {{ selected_coupon.couponName }} + + + + + + + 쿠폰금액 + + + {{ selected_coupon.can }} + + + + + + + 발행수량 + + + {{ selected_coupon.couponCount }} + + + + + + + 유효기간 + + + + + + + + + + 인증 계정당 중복 사용 가능여부 + + + + + + + 활성화 @@ -179,9 +276,9 @@ - 쿠폰 발행하기 + 수정하기 @@ -265,6 +362,7 @@ export default { is_loading: false, is_modify: false, show_write_dialog: false, + show_modify_dialog: false, show_coupon_number_list_dialog: false, coupon_number_list: [], @@ -357,6 +455,12 @@ export default { align: 'center', sortable: false, value: 'download', + }, + { + text: '관리', + align: 'center', + sortable: false, + value: 'management', } ], @@ -426,7 +530,7 @@ export default { }, cancel() { - this.is_modify = false + this.show_modify_dialog = false this.show_write_dialog = false this.show_coupon_number_list_dialog = false @@ -440,6 +544,14 @@ export default { this.coupon_number_count = null }, + showModifyDialog(value) { + this.selected_coupon = value + this.validity = value.validity + this.is_multiple_use = value.isMultipleUse + this.is_active = value.isActive + this.show_modify_dialog = true + }, + formatWithHyphens(value) { const chunks = []; for (let i = 0; i < value.length; i += 4) { @@ -556,6 +668,44 @@ export default { this.notifyError('다운로드를 하지 못했습니다.\n다시 시도해 주세요.') this.is_loading = false } + }, + + async modify() { + if (this.is_loading) return; + + this.is_loading = true + + try { + const request = {couponId: this.selected_coupon.id} + + if (this.validity !== this.selected_coupon.validity) { + request.validity = this.validity + ' 23:59:59'; + } + + if (this.is_active !== this.selected_coupon.isActive) { + request.isActive = this.is_active; + } + + if (this.is_multiple_use !== this.selected_coupon.isMultipleUse) { + request.isMultipleUse = this.is_multiple_use; + } + + const res = await api.modifyCoupon(request); + + if (res.status === 200 && res.data.success === true) { + this.cancel() + this.notifySuccess(res.data.message || '수정되었습니다.') + + this.coupon_list = []; + await this.getCouponList() + } else { + this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } + } catch (e) { + this.notifyError("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.") + } + + this.is_loading = false } } }