diff --git a/src/api/audition.js b/src/api/audition.js index 9cc8b17..7df4cd2 100644 --- a/src/api/audition.js +++ b/src/api/audition.js @@ -24,6 +24,31 @@ async function getAuditionDetail(id) { return Vue.axios.get("/admin/audition/" + id); } -export { - getAuditionList, createAudition, updateAudition, getAuditionDetail +async function createAuditionRole(formData) { + return Vue.axios.post("/admin/audition/role", formData, { + headers: { + "Content-Type": "multipart/form-data", + }, + }); +} + +async function updateAuditionRole(formData) { + return Vue.axios.put("/admin/audition/role", formData, { + headers: { + "Content-Type": "multipart/form-data", + }, + }); +} + +async function getAuditionRoleDetail(id) { + return Vue.axios.get("/admin/audition/role/" + id); +} + +async function getAuditionApplicantList(id, page) { + return Vue.axios.get("/admin/audition/role/" + id + "/applicant?page=" + (page - 1) + "&size=20"); +} + +export { + getAuditionList, createAudition, updateAudition, getAuditionDetail, + createAuditionRole, updateAuditionRole, getAuditionRoleDetail, getAuditionApplicantList } diff --git a/src/views/Audition/AuditionDetailView.vue b/src/views/Audition/AuditionDetailView.vue index 2243ab2..43f65a2 100644 --- a/src/views/Audition/AuditionDetailView.vue +++ b/src/views/Audition/AuditionDetailView.vue @@ -50,6 +50,7 @@ color="#3bb9f1" dark depressed + @click="showWriteDialog" > 배역 등록 @@ -60,7 +61,7 @@ @@ -68,6 +69,7 @@ @@ -81,11 +83,13 @@ 수정 삭제 @@ -101,6 +105,152 @@ + + + + + 오디션 배역 등록 + + +
+ + +
+ + + + + 배역 이름* + + + + + + + + + + 오디션 대본 URL + + + + + + + + + + 모집상태 + + + + + + + + + + + + + + + + + + + 취소 + + + 수정 + + + 등록 + + +
+
+ + + + + + 삭제하시겠습니까? + + + + + 취소 + + + 확인 + + + + @@ -122,7 +272,11 @@ export default { audition_detail: {}, audition_role_list: [], + show_write_dialog: false, + show_delete_confirm_dialog: false, + audition_role: {}, + selected_role: null, } }, @@ -190,11 +344,206 @@ export default { this.is_loading = false } }, + + imageAdd(payload) { + const file = payload; + if (file) { + this.audition_role.image_url = URL.createObjectURL(file) + URL.revokeObjectURL(file) + } else { + this.audition_role.image_url = null + } + }, + + showWriteDialog() { + this.show_write_dialog = true + }, + + showModifyDialog(auditionRole) { + this.audition_role = { + name: auditionRole.name, + image_url: auditionRole.imageUrl, + audition_script_url: auditionRole.auditionScriptUrl, + status: auditionRole.status + } + + this.selected_role = auditionRole + this.show_write_dialog = true + }, + + cancel() { + this.audition_role = {} + this.selected_role = null + this.show_write_dialog = false + this.show_delete_confirm_dialog = false + }, + + deleteConfirm(auditionRole) { + this.selected_role = auditionRole + this.show_delete_confirm_dialog = true + }, + + validate() { + if (this.audition_role.image === undefined || this.audition_role.image === null) { + this.notifyError('배역 이미지를 선택하세요') + return + } + + if (this.audition_role.name.trim().length <= 0) { + this.notifyError('배역 이름을 입력하세요') + return + } + + if ( + this.audition_role.audition_script_url === undefined || + this.audition_role.audition_script_url === null || + this.audition_role.audition_script_url.trim().length <= 10 + ) { + this.notifyError('오디션 대본 URL을 입력하세요') + return + } + + this.submit() + }, + + async submit() { + if (this.is_loading) return; + this.is_loading = true + + try { + const request = { + auditionId: this.audition_id, + name: this.audition_role.name, + auditionScriptUrl: this.audition_role.audition_script_url + } + + const formData = new FormData() + formData.append("image", this.audition_role.image); + formData.append("request", JSON.stringify(request)) + + const res = await api.createAuditionRole(formData); + if (res.status === 200 && res.data.success === true) { + this.cancel(); + this.notifySuccess(res.data.message || '등록되었습니다.') + this.is_loading = false + + await this.getAuditionDetail() + } else { + this.is_loading = false + this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } + } catch (e) { + this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } finally { + this.is_loading = false + } + }, + + async modify() { + if (this.is_loading) return; + this.is_loading = true + + try { + const request = {id: this.selected_role.id} + if (this.audition_role.name !== this.selected_role.name) { + request.name = this.audition_role.name + } + + if (this.audition_role.audition_script_url !== this.selected_role.audition_script_url) { + request.auditionScriptUrl = this.audition_role.audition_script_url + } + + if (this.audition_role.status !== this.selected_role.status) { + request.status = this.audition_role.status + } + + const formData = new FormData() + formData.append("request", JSON.stringify(request)) + + if (this.audition_role.image !== undefined && this.audition_role.image !== null) { + formData.append("image", this.audition_role.image) + } + + const res = await api.updateAuditionRole(formData); + if (res.status === 200 && res.data.success === true) { + this.cancel(); + this.notifySuccess(res.data.message || '등록되었습니다.') + this.is_loading = false + + await this.getAuditionDetail() + } else { + this.is_loading = false + this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } + } catch (e) { + this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } finally { + this.is_loading = false + } + }, + + async deleteAuditionRole() { + if (this.is_loading) return; + this.is_loading = true + + try { + const request = {id: this.selected_role.id, isActive: false} + const formData = new FormData() + formData.append("request", JSON.stringify(request)) + + const res = await api.updateAuditionRole(formData) + if (res.status === 200 && res.data.success === true) { + this.cancel(); + this.notifySuccess('오디션 배역이 삭제되었습니다.') + this.is_loading = false + + await this.getAuditionDetail() + } else { + this.is_loading = false + this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + this.is_loading = false + } + } catch (e) { + this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') + } finally { + this.is_loading = false + } + }, + + selectAuditionRole(auditionRole) { + }, }, }