수정 기능 추가

This commit is contained in:
Yu Sung 2024-01-04 00:02:07 +09:00
parent aa3c3211aa
commit 335716f860
2 changed files with 159 additions and 4 deletions

View File

@ -35,11 +35,16 @@ async function downloadCouponNumberList(couponId) {
return Vue.axios.get('/can/coupon/number-list/download?couponId=' + couponId, { responseType: 'blob' }); 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 { export {
getCans, getCans,
insertCan, insertCan,
deleteCan, deleteCan,
paymentCan, paymentCan,
modifyCoupon,
getCouponList, getCouponList,
generateCoupon, generateCoupon,
getCouponNumberList, getCouponNumberList,

View File

@ -83,6 +83,14 @@
다운로드 다운로드
</v-btn> </v-btn>
</template> </template>
<template v-slot:item.management="{ item }">
<v-btn
:disabled="is_loading"
@click="showModifyDialog(item)"
>
수정
</v-btn>
</template>
</v-data-table> </v-data-table>
</v-col> </v-col>
</v-row> </v-row>
@ -154,7 +162,96 @@
</v-col> </v-col>
</v-row> </v-row>
</v-card-text> </v-card-text>
<v-card-text v-show="selected_coupon !== null"> <v-card-actions v-show="!is_loading">
<v-spacer />
<v-btn
color="blue darken-1"
text
@click="cancel"
>
취소
</v-btn>
<v-btn
color="blue darken-1"
text
@click="validate"
>
쿠폰 발행하기
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-row>
<v-row v-if="selected_coupon !== null">
<v-dialog
v-model="show_modify_dialog"
max-width="1000px"
persistent
>
<v-card>
<v-card-title>쿠폰 수정</v-card-title>
<v-card-text>
<v-row align="center">
<v-col cols="4">
쿠폰명
</v-col>
<v-col cols="8">
{{ selected_coupon.couponName }}
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row align="center">
<v-col cols="4">
쿠폰금액
</v-col>
<v-col cols="8">
{{ selected_coupon.can }}
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row align="center">
<v-col cols="4">
발행수량
</v-col>
<v-col cols="8">
{{ selected_coupon.couponCount }}
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row align="center">
<v-col cols="4">
유효기간
</v-col>
<v-col
cols="8"
class="datepicker-wrapper"
>
<datetime
v-model="validity"
class="datepicker"
format="YYYY-MM-DD"
/>
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row align="center">
<v-col cols="4">
인증 계정당 중복 사용 가능여부
</v-col>
<v-col cols="8">
<input
v-model="is_multiple_use"
type="checkbox"
>
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row align="center"> <v-row align="center">
<v-col cols="4"> <v-col cols="4">
활성화 활성화
@ -179,9 +276,9 @@
<v-btn <v-btn
color="blue darken-1" color="blue darken-1"
text text
@click="validate" @click="modify"
> >
쿠폰 발행하기 수정하기
</v-btn> </v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
@ -265,6 +362,7 @@ export default {
is_loading: false, is_loading: false,
is_modify: false, is_modify: false,
show_write_dialog: false, show_write_dialog: false,
show_modify_dialog: false,
show_coupon_number_list_dialog: false, show_coupon_number_list_dialog: false,
coupon_number_list: [], coupon_number_list: [],
@ -357,6 +455,12 @@ export default {
align: 'center', align: 'center',
sortable: false, sortable: false,
value: 'download', value: 'download',
},
{
text: '관리',
align: 'center',
sortable: false,
value: 'management',
} }
], ],
@ -426,7 +530,7 @@ export default {
}, },
cancel() { cancel() {
this.is_modify = false this.show_modify_dialog = false
this.show_write_dialog = false this.show_write_dialog = false
this.show_coupon_number_list_dialog = false this.show_coupon_number_list_dialog = false
@ -440,6 +544,14 @@ export default {
this.coupon_number_count = null 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) { formatWithHyphens(value) {
const chunks = []; const chunks = [];
for (let i = 0; i < value.length; i += 4) { for (let i = 0; i < value.length; i += 4) {
@ -556,6 +668,44 @@ export default {
this.notifyError('다운로드를 하지 못했습니다.\n다시 시도해 주세요.') this.notifyError('다운로드를 하지 못했습니다.\n다시 시도해 주세요.')
this.is_loading = false 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
} }
} }
} }