Browse Source

feat: 定制频道内能调整配置内容顺序

Damon 11 months atrás
parent
commit
ae6abce9db
2 changed files with 31 additions and 7 deletions
  1. 30 7
      src/views/operation/channel/detail.vue
  2. 1 0
      src/views/operation/channels/detail.vue

+ 30 - 7
src/views/operation/channel/detail.vue

@@ -1,3 +1,4 @@
+<!-- 定制频道 -->
 <template>
   <div class="app-container">
     <!-- 表单 -->
@@ -107,22 +108,21 @@
           <el-table-column label="操作" align="center">
             <template slot-scope="scope">
               <el-button type="delete" @click="getDelete(scope.row)"
-                >删除{{ form.list.length }}</el-button
+                >删除</el-button
               >
 
               <el-button
-                v-if="form.list.length > 1"
                 type="text"
                 icon="el-icon-caret-top"
-                @click="getChangeDetail(scope.row, scope.row.sort - 1)"
-                :disabled="disabled"
+                @click="getChangeSort(scope.$index, scope.$index - 1)"
+                :disabled="scope.$index <= 0"
               />
+
               <el-button
-                v-if="form.list.length > 1"
                 type="text"
                 icon="el-icon-caret-bottom"
-                @click="getChangeDetail(scope.row, scope.row.sort + 1)"
-                :disabled="disabled"
+                @click="getChangeSort(scope.$index, scope.$index + 1)"
+                :disabled="scope.$index > form.list.length - 2"
               />
             </template>
           </el-table-column>
@@ -178,7 +178,30 @@ export default {
     this.getDetail();
     this.getPlatform({});
   },
+
   methods: {
+    // 排序
+    getChangeSort(row, sort) {
+      const rowBean = this.form.list[row];
+      const sortBean = this.form.list[sort];
+      this.form.list[row] = sortBean;
+      this.form.list[sort] = rowBean;
+
+      this.form.audioList = [];
+      this.form.list.map((i) => {
+        this.form.audioList.push({
+          audioId: i.audioId,
+          audioType: i.audioType,
+        });
+      });
+      edit(this.form).then((res) => {
+        if (res.code === 0) {
+          this.$message.success("修改成功!");
+          this.getDetail();
+        }
+      });
+    },
+
     // 频道详情
     getDetail() {
       channelDetail({

+ 1 - 0
src/views/operation/channels/detail.vue

@@ -122,6 +122,7 @@
                 @click="getChangeSort(scope.$index, scope.$index + 1)"
                 :disabled="scope.$index > form.list.length - 2"
               />
+              
             </template>
           </el-table-column>
         </el-table>