시리즈 관리 - 드래그 앤 드롭으로 순서변경 기능 추가

This commit is contained in:
Yu Sung 2024-08-14 16:40:00 +09:00
parent d459d42a60
commit 3a0ee08ab0
2 changed files with 64 additions and 38 deletions

View File

@ -55,6 +55,13 @@ async function removeContentInTheSeries(seriesId, contentId) {
) )
} }
async function updateSeriesOrders(ids) {
return Vue.axios.put(
"/creator-admin/audio-content/series/orders",
{ids: ids}
)
}
export { export {
getGenreList, getGenreList,
getSeriesList, getSeriesList,
@ -62,6 +69,7 @@ export {
modifySeries, modifySeries,
getSeriesDetail, getSeriesDetail,
getSeriesContent, getSeriesContent,
updateSeriesOrders,
addingContentToTheSeries, addingContentToTheSeries,
removeContentInTheSeries, removeContentInTheSeries,
searchContentNotInSeries searchContentNotInSeries

View File

@ -22,10 +22,15 @@
</v-btn> </v-btn>
</v-col> </v-col>
</v-row> </v-row>
<v-row <div
ref="scroll_container" ref="scroll_container"
class="scroll_container" class="scroll_container"
@scroll="onScroll" @scroll="onScroll"
>
<draggable
v-model="series_list"
class="row"
@end="onDropCallback(series_list)"
> >
<v-col <v-col
v-for="(item, i) in series_list" v-for="(item, i) in series_list"
@ -63,7 +68,8 @@
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-col> </v-col>
</v-row> </draggable>
</div>
</v-container> </v-container>
<v-dialog <v-dialog
@ -349,10 +355,11 @@
<script> <script>
import * as api from '@/api/audio_content_series'; import * as api from '@/api/audio_content_series';
import Draggable from "vuedraggable";
export default { export default {
name: "ContentSeriesList", name: "ContentSeriesList",
components: {Draggable},
data() { data() {
return { return {
is_loading: false, is_loading: false,
@ -497,6 +504,17 @@ export default {
this.$router.push({name: 'ContentSeriesDetail', params: {seriesId: series.seriesId}}) this.$router.push({name: 'ContentSeriesDetail', params: {seriesId: series.seriesId}})
}, },
async onDropCallback(items) {
const ids = items.map((item) => {
return item.seriesId
})
const res = await api.updateSeriesOrders(ids)
if (res.status === 200 && res.data.success === true) {
this.notifySuccess(res.data.message)
}
},
async getSeriesGenreList() { async getSeriesGenreList() {
try { try {
const res = await api.getGenreList() const res = await api.getGenreList()