시리즈 등록/수정/삭제 페이지 추가

This commit is contained in:
Yu Sung 2024-04-23 00:18:32 +09:00
parent b16e85a27f
commit 1082c9334f
5 changed files with 769 additions and 0 deletions

19
package-lock.json generated
View File

@ -11,6 +11,7 @@
"core-js": "^3.6.5",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vue-show-more-text": "^2.0.2",
"vue2-datepicker": "^3.11.1",
"vue2-editor": "^2.10.3",
"vue2-timepicker": "^1.1.6",
@ -14488,6 +14489,15 @@
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.3.tgz",
"integrity": "sha512-FUlILrW3DGitS2h+Xaw8aRNvGTwtuaxrRkNSHWTizOfLUie7wuYwezeZ50iflRn8YPV5kxmU2LQuu3nM/b3Zsg=="
},
"node_modules/vue-show-more-text": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/vue-show-more-text/-/vue-show-more-text-2.0.2.tgz",
"integrity": "sha512-x/WuikWAx8Hm4gpZx6KHtJYiXDordGdSoXrd34lTiJeAnlT8Y7Yc0FfGBNdUv6mXncuET3LiRwwNz+X5gI+oiw==",
"dependencies": {
"core-js": "^3.6.5",
"vue": "^2.6.11"
}
},
"node_modules/vue-style-loader": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.3.tgz",
@ -27252,6 +27262,15 @@
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.3.tgz",
"integrity": "sha512-FUlILrW3DGitS2h+Xaw8aRNvGTwtuaxrRkNSHWTizOfLUie7wuYwezeZ50iflRn8YPV5kxmU2LQuu3nM/b3Zsg=="
},
"vue-show-more-text": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/vue-show-more-text/-/vue-show-more-text-2.0.2.tgz",
"integrity": "sha512-x/WuikWAx8Hm4gpZx6KHtJYiXDordGdSoXrd34lTiJeAnlT8Y7Yc0FfGBNdUv6mXncuET3LiRwwNz+X5gI+oiw==",
"requires": {
"core-js": "^3.6.5",
"vue": "^2.6.11"
}
},
"vue-style-loader": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.3.tgz",

View File

@ -13,6 +13,7 @@
"core-js": "^3.6.5",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vue-show-more-text": "^2.0.2",
"vue2-datepicker": "^3.11.1",
"vue2-editor": "^2.10.3",
"vue2-timepicker": "^1.1.6",

View File

@ -0,0 +1,60 @@
import Vue from 'vue';
async function getGenreList() {
return Vue.axios.get("/creator-admin/audio-content/series/genre");
}
async function getSeriesList(page) {
return Vue.axios.get("/creator-admin/audio-content/series?page=" + (page - 1) + "&size=10");
}
async function createSeries(formData) {
return Vue.axios.post("/creator-admin/audio-content/series", formData, {
headers: {
"Content-Type": "multipart/form-data",
},
});
}
async function modifySeries(formData) {
return Vue.axios.put("/creator-admin/audio-content/series", formData, {
headers: {
"Content-Type": "multipart/form-data",
},
});
}
async function getSeriesDetail(seriesId) {
return Vue.axios.get("/creator-admin/audio-content/series/" + seriesId);
}
async function getSeriesContent(seriesId, page) {
return Vue.axios.get(
"/creator-admin/audio-content/series/" + seriesId + "/content?page=" + (page - 1) + "&size=10"
);
}
async function addingContentToTheSeries(seriesId, contentIdList) {
return Vue.axios.post(
"/creator-admin/audio-content/series/add/content",
{seriesId: seriesId, contentIdList: contentIdList}
)
}
async function removeContentInTheSeries(seriesId, contentId) {
return Vue.axios.post(
"/creator-admin/audio-content/series/remove/content",
{seriesId: seriesId, contentId: contentId}
)
}
export {
getGenreList,
getSeriesList,
createSeries,
modifySeries,
getSeriesDetail,
getSeriesContent,
addingContentToTheSeries,
removeContentInTheSeries
}

View File

@ -25,6 +25,11 @@ const routes = [
name: 'ContentCategoryList',
component: () => import(/* webpackChunkName: "content" */ '../views/Content/ContentCategoryList.vue')
},
{
path: '/content/series/list',
name: 'ContentSeriesList',
component: () => import(/* webpackChunkName: "content" */ '../views/Content/ContentSeriesList.vue')
},
{
path: '/calculate/live',
name: 'CalculateLive',

View File

@ -0,0 +1,684 @@
<template>
<div>
<v-toolbar dark>
<v-spacer />
<v-toolbar-title>시리즈 관리</v-toolbar-title>
<v-spacer />
</v-toolbar>
<br>
<v-container>
<v-row>
<v-col cols="10" />
<v-col>
<v-btn
block
color="#3bb9f1"
dark
depressed
@click="showWriteDialog"
>
시리즈 등록
</v-btn>
</v-col>
</v-row>
<v-row>
<v-col
v-for="(item, i) in series_list"
:key="i"
cols="3"
>
<v-card>
<v-card-title>
<v-spacer />
<v-img :src="item.coverImageUrl" />
<v-spacer />
</v-card-title>
<v-card-text class="series-title-container">
{{ item.title }}
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn
text
@click="showModifyDialog(item)"
>
수정
</v-btn>
<v-btn
text
@click="deleteConfirm(item)"
>
삭제
</v-btn>
<v-spacer />
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-container>
<v-dialog
v-model="show_write_dialog"
max-width="1000px"
persistent
>
<v-card>
<v-card-title>
시리즈 등록
</v-card-title>
<div class="image-select">
<label for="image">
커버 이미지 등록
</label>
<v-file-input
id="image"
v-model="series.cover_image"
accept="image/*"
@change="imageAdd"
/>
</div>
<img
v-if="series.cover_image_url"
:src="series.cover_image_url"
alt=""
class="image-preview"
>
<v-card-text>
<v-row align="center">
<v-col cols="4">
제목*
</v-col>
<v-col cols="8">
<v-text-field
v-model="series.title"
label="제목"
required
/>
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row align="center">
<v-col cols="4">
소개*
</v-col>
<v-col cols="8">
<v-textarea
v-model="series.introduction"
label="소개"
required
/>
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row>
<v-col cols="4">
연재요일*
</v-col>
<v-col
cols="8"
align="left"
>
<v-row>
<v-col
v-for="(day, index) in days_of_week"
:key="index"
>
<input
:id="'checkbox_' + day.value"
v-model="series.published_days_of_week"
type="checkbox"
:value="day.value"
@change="handleCheckboxChange(day.value, $event)"
>
<label :for="'checkbox_' + day.value"> {{ day.str }}</label><br>
</v-col>
</v-row>
<input
id="checkbox_random"
v-model="series.published_days_of_week"
type="checkbox"
value="RANDOM"
@change="handleCheckboxChange('RANDOM', $event)"
>
<label for="checkbox_random"> 랜덤</label>
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row align="center">
<v-col cols="4">
크리에이터
</v-col>
<v-col cols="8">
<v-select
v-model="series.genre_id"
:items="series_genre_list"
item-text="name"
item-value="value"
label="장르 선택"
/>
</v-col>
</v-row>
</v-card-text>
<v-card-text v-show="selected_series === undefined || selected_series === null">
<v-row align="center">
<v-col cols="4">
키워드*
</v-col>
<v-col cols="8">
<v-text-field
v-model="series.keyword"
label="키워드 예 : #달달 #장기연애 #첫사랑"
required
/>
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row>
<v-col cols="4">
연령제한
</v-col>
<v-col
cols="8"
align="left"
>
<input
v-model="series.is_adult"
type="checkbox"
>
</v-col>
</v-row>
</v-card-text>
<v-card-text v-show="selected_series !== undefined && selected_series !== null">
<v-row>
<v-col cols="4">
완결여부*
</v-col>
<v-col
cols="8"
align="left"
>
<v-row>
<v-col>
<input
id="radio_proceeding"
v-model="series.state"
type="radio"
value="PROCEEDING"
>
<label for="radio_proceeding"> 연재중</label>
</v-col>
<v-col>
<input
id="radio_suspend"
v-model="series.state"
type="radio"
value="SUSPEND"
>
<label for="radio_suspend"> 휴재중</label>
</v-col>
<v-col>
<input
id="radio_complete"
v-model="series.state"
type="radio"
value="COMPLETE"
>
<label for="radio_complete"> 완결</label>
</v-col>
</v-row>
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row align="center">
<v-col cols="4">
작가
</v-col>
<v-col cols="8">
<v-text-field
v-model="series.writer"
label="작가"
required
/>
</v-col>
</v-row>
</v-card-text>
<v-card-text>
<v-row align="center">
<v-col cols="4">
제작사
</v-col>
<v-col cols="8">
<v-text-field
v-model="series.studio"
label="제작사"
required
/>
</v-col>
</v-row>
</v-card-text>
<v-card-actions v-show="!is_loading">
<v-spacer />
<v-btn
color="blue darken-1"
text
@click="cancel"
>
취소
</v-btn>
<v-btn
v-if="selected_series !== undefined && selected_series !== null"
color="blue darken-1"
text
@click="modify"
>
수정
</v-btn>
<v-btn
v-else
color="blue darken-1"
text
@click="validate"
>
등록
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog
v-model="show_delete_confirm_dialog"
max-width="400px"
persistent
>
<v-card>
<v-card-text />
<v-card-text>
삭제하시겠습니까?
</v-card-text>
<v-card-actions v-show="!is_loading">
<v-spacer />
<v-btn
color="blue darken-1"
text
@click="deleteCancel"
>
취소
</v-btn>
<v-btn
color="blue darken-1"
text
@click="deleteSeries"
>
확인
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>
<script>
import * as api from '@/api/audio_content_series';
export default {
name: "ContentSeriesList",
data() {
return {
is_loading: false,
is_modify: false,
show_write_dialog: false,
show_delete_confirm_dialog: false,
series: {is_adult: false, published_days_of_week: []},
series_list: [],
selected_series: null,
series_genre_list: [],
page: 1,
total_page: 0,
days_of_week: [
{value: 'SUN', str: '일'},
{value: 'MON', str: '월'},
{value: 'TUE', str: '화'},
{value: 'WED', str: '수'},
{value: 'THR', str: '목'},
{value: 'FRI', str: '금'},
{value: 'SAT', str: '토'},
],
}
},
async created() {
await this.getSeriesGenreList();
await this.getSeriesList();
},
methods: {
imageAdd(payload) {
const file = payload;
if (file) {
this.series.cover_image_url = URL.createObjectURL(file)
URL.revokeObjectURL(file)
} else {
this.series.cover_image_url = null
}
},
notifyError(message) {
this.$dialog.notify.error(message)
},
notifySuccess(message) {
this.$dialog.notify.success(message)
},
showWriteDialog() {
this.show_write_dialog = true
},
showModifyDialog(series) {
this.series = {
title: series.title,
introduction: series.introduction,
published_days_of_week: series.publishedDaysOfWeek,
genre_id: series.genreId,
is_adult: series.isAdult,
state: series.state,
cover_image_url: series.coverImageUrl
}
if (series.writer !== undefined && series.writer !== null) {
this.series.writer = series.writer
}
if (series.studio !== undefined && series.studio !== null) {
this.series.studio = series.studio
}
this.selected_series = series
this.show_write_dialog = true
},
cancel() {
this.series = {is_adult: false, published_days_of_week: []}
this.selected_series = null
this.show_write_dialog = false
this.show_delete_confirm_dialog = false
},
deleteConfirm(series) {
this.selected_series = series
this.show_delete_confirm_dialog = true
},
deleteCancel() {
this.cancel();
},
handleCheckboxChange(checked_days_of_week, event) {
if (checked_days_of_week === 'RANDOM' && event.target.checked) {
this.series.published_days_of_week = ['RANDOM'];
} else {
this.series.published_days_of_week = this.series.published_days_of_week.filter(item => item !== 'RANDOM');
}
},
validate() {
if (this.series.cover_image === undefined || this.series.cover_image === null) {
this.notifyError('커버 이미지를 선택하세요')
return
}
if (this.series.title === undefined || this.series.title === null || this.series.title.trim().length <= 0) {
this.notifyError('시리즈 제목을 입력하세요')
return
}
if (this.series.introduction === undefined || this.series.introduction === null || this.series.introduction.trim().length <= 0) {
this.notifyError('시리즈 소개를 입력하세요')
return
}
if (this.series.published_days_of_week === undefined || this.series.published_days_of_week === null || this.series.published_days_of_week.length <= 0) {
this.notifyError('시리즈 연재요일을 선택하세요')
return
}
if (this.series.keyword === undefined || this.series.keyword === null || this.series.keyword.replaceAll('#', '').trim().length <= 0) {
this.notifyError('시리즈를 설명할 수 있는 키워드를 입력하세요')
return
}
if (this.series.genre_id === undefined || this.series.genre_id === null || this.series.genre_id <= 0) {
this.notifyError('올바른 장르를 선택하세요')
return
}
this.submit();
},
async getSeriesGenreList() {
this.is_loading = true
try {
const res = await api.getGenreList()
if (res.status === 200 && res.data.success === true) {
this.series_genre_list = res.data.data.map((item) => {
return {name: item.genre, value: item.id}
})
} else {
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
}
this.is_loading = false
} catch (e) {
this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
this.is_loading = false
}
},
async getSeriesList() {
this.is_loading = true
try {
const res = await api.getSeriesList(this.page)
if (res.status === 200 && res.data.success === true) {
const data = res.data.data
const total_page = Math.ceil(data.totalCount / 20)
this.series_list = data.items
if (total_page <= 0)
this.total_page = 1
else
this.total_page = total_page
} else {
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
}
this.is_loading = false
} catch (e) {
this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
this.is_loading = false
}
},
async submit() {
if (this.is_loading) return;
this.is_loading = true
try {
const request = {
title: this.series.title,
introduction: this.series.introduction,
publishedDaysOfWeek: this.series.published_days_of_week,
keyword: this.series.keyword,
genreId: this.series.genre_id,
isAdult: this.series.is_adult,
writer: this.series.writer || null,
studio: this.series.studio || null
}
const formData = new FormData()
formData.append("image", this.series.cover_image);
formData.append("request", JSON.stringify(request))
const res = await api.createSeries(formData);
if (res.status === 200 && res.data.success === true) {
this.cancel();
this.notifySuccess(res.data.message || '등록되었습니다.')
this.page = 1
await this.getSeriesList()
} else {
this.is_loading = false
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
this.is_loading = false
}
} catch (e) {
this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
} finally {
this.is_loading = false
}
},
async modify() {
if (this.is_loading) return;
this.is_loading = true
try {
const request = {seriesId: this.selected_series.seriesId}
if (this.selected_series.title !== this.series.title) {
request.title = this.series.title
}
if (this.selected_series.introduction !== this.series.introduction) {
request.introduction = this.series.introduction
}
if (this.selected_series.publishedDaysOfWeek !== this.series.published_days_of_week) {
request.publishedDaysOfWeek = this.series.published_days_of_week
}
if (this.selected_series.genreId !== this.series.genre_id) {
request.genreId = this.series.genre_id
}
if (this.selected_series.isAdult !== this.series.is_adult) {
request.isAdult = this.series.is_adult
}
if (this.selected_series.state !== this.series.state) {
request.state = this.series.state
}
if (this.selected_series.state !== this.series.state) {
request.state = this.series.state
}
if (this.selected_series.writer !== this.series.writer) {
request.writer = this.series.writer
}
if (this.selected_series.studio !== this.series.studio) {
request.studio = this.series.studio
}
console.log(request)
const formData = new FormData()
formData.append("request", JSON.stringify(request))
if (this.series.cover_image !== undefined && this.series.cover_image !== null) {
formData.append("image", this.series.cover_image);
}
const res = await api.modifySeries(formData);
if (res.status === 200 && res.data.success === true) {
this.cancel();
this.notifySuccess(res.data.message || '등록되었습니다.')
this.page = 1
await this.getSeriesList()
} else {
this.is_loading = false
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
this.is_loading = false
}
} catch (e) {
this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
} finally {
this.is_loading = false
}
},
async deleteSeries() {
if (this.is_loading) return;
this.is_loading = true
try {
const request = {seriesId: this.selected_series.seriesId, isActive: false}
const formData = new FormData()
formData.append("request", JSON.stringify(request))
const res = await api.modifySeries(formData)
if (res.status === 200 && res.data.success === true) {
this.cancel();
this.notifySuccess('시리즈가 삭제되었습니다.')
this.page = 1
await this.getSeriesList()
} else {
this.is_loading = false
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
this.is_loading = false
}
} catch (e) {
this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
} finally {
this.is_loading = false
}
}
},
}
</script>
<style scoped>
.image-select label {
display: inline-block;
padding: 10px 20px;
background-color: #232d4a;
color: #fff;
vertical-align: middle;
font-size: 15px;
cursor: pointer;
border-radius: 5px;
}
.v-file-input {
position: absolute;
width: 0;
height: 0;
padding: 0;
overflow: hidden;
border: 0;
}
.image-preview {
max-width: 100%;
width: 250px;
object-fit: cover;
margin-top: 10px;
}
.series-title-container {
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
max-height: 2em;
}
</style>