From 3a0ee08ab00c84a37a23cf2e1f8fbf3540f216a6 Mon Sep 17 00:00:00 2001
From: Yu Sung <hwchon1234@gmail.com>
Date: Wed, 14 Aug 2024 16:40:00 +0900
Subject: [PATCH] =?UTF-8?q?=EC=8B=9C=EB=A6=AC=EC=A6=88=20=EA=B4=80?=
 =?UTF-8?q?=EB=A6=AC=20-=20=EB=93=9C=EB=9E=98=EA=B7=B8=20=EC=95=A4=20?=
 =?UTF-8?q?=EB=93=9C=EB=A1=AD=EC=9C=BC=EB=A1=9C=20=EC=88=9C=EC=84=9C?=
 =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/api/audio_content_series.js         |  8 +++
 src/views/Content/ContentSeriesList.vue | 94 +++++++++++++++----------
 2 files changed, 64 insertions(+), 38 deletions(-)

diff --git a/src/api/audio_content_series.js b/src/api/audio_content_series.js
index b7bfbe6..f77959e 100644
--- a/src/api/audio_content_series.js
+++ b/src/api/audio_content_series.js
@@ -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 {
     getGenreList,
     getSeriesList,
@@ -62,6 +69,7 @@ export {
     modifySeries,
     getSeriesDetail,
     getSeriesContent,
+    updateSeriesOrders,
     addingContentToTheSeries,
     removeContentInTheSeries,
     searchContentNotInSeries
diff --git a/src/views/Content/ContentSeriesList.vue b/src/views/Content/ContentSeriesList.vue
index 11752eb..e994149 100644
--- a/src/views/Content/ContentSeriesList.vue
+++ b/src/views/Content/ContentSeriesList.vue
@@ -22,48 +22,54 @@
           </v-btn>
         </v-col>
       </v-row>
-      <v-row
+      <div
         ref="scroll_container"
         class="scroll_container"
         @scroll="onScroll"
       >
-        <v-col
-          v-for="(item, i) in series_list"
-          :key="i"
-          cols="3"
+        <draggable
+          v-model="series_list"
+          class="row"
+          @end="onDropCallback(series_list)"
         >
-          <v-card>
-            <v-card-title>
-              <v-spacer />
-              <v-img
-                :src="item.coverImageUrl"
-                class="cover-image"
-                @click="selectSeries(item)"
-              />
-              <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-col
+            v-for="(item, i) in series_list"
+            :key="i"
+            cols="3"
+          >
+            <v-card>
+              <v-card-title>
+                <v-spacer />
+                <v-img
+                  :src="item.coverImageUrl"
+                  class="cover-image"
+                  @click="selectSeries(item)"
+                />
+                <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>
+        </draggable>
+      </div>
     </v-container>
 
     <v-dialog
@@ -349,10 +355,11 @@
 
 <script>
 import * as api from '@/api/audio_content_series';
+import Draggable from "vuedraggable";
 
 export default {
   name: "ContentSeriesList",
-
+  components: {Draggable},
   data() {
     return {
       is_loading: false,
@@ -497,6 +504,17 @@ export default {
       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() {
       try {
         const res = await api.getGenreList()