Forráskód Böngészése

feat: 多频多台编辑交换位置本地处理

332777428@qq.com 1 hónapja
szülő
commit
497b2950ff

+ 1 - 1
src/api/operation/channels.js

@@ -83,7 +83,7 @@ export function channelDetail(data) {
   })
 }
 
-// 编辑频道
+// 编辑外层频道数据 最外层
 export function channeledit(data) {
   return request({
     url: `/admin/config/channel/edit`,

+ 0 - 1
src/views/music/blog/detail.vue

@@ -572,7 +572,6 @@ export default {
       detail(this.form.id).then((res) => {
         if (res.code === 0) {
           this.form = res.data;
-          console.log("gadsfqwerqwerqr====" + this.form.platformId);
           ///qq音乐和喜马拉雅
           if (this.form.platformId == 6 || this.form.platformId == 12) {
             this.canOrder = false;

+ 39 - 19
src/views/operation/channels/index.vue

@@ -30,7 +30,9 @@
         <template slot-scope="scope">
           <div v-if="editData.currentEditIndex !== scope.$index">
             <span style="margin-right: 8px">
-              {{ scope.row.sort || "" }}
+              {{ scope.row.indexNum }}
+              <!-- {{ scope.$index + 1 }} -->
+              <!-- {{ scope.row.sort || "" }} -->
             </span>
             <svg-icon
               icon-class="edit"
@@ -39,7 +41,7 @@
           </div>
           <el-input
             v-else
-            v-model="scope.row.sort"
+            v-model="scope.row.indexNum"
             size="mini"
             style="width: 60px"
             type="number"
@@ -309,17 +311,17 @@
 
 <script>
 import {
-change,
-channels,
-classEdit,
-classRemove,
-classSubmit,
-detail,
-dev,
-edit,
-list,
-remove,
-submit,
+  change,
+  channels,
+  classEdit,
+  classRemove,
+  classSubmit,
+  detail,
+  dev,
+  edit,
+  list,
+  remove,
+  submit,
 } from "@/api/operation/channels";
 
 import { dialogCallBack } from "@/utils/DialogUtil";
@@ -400,7 +402,11 @@ export default {
       this.loading = true;
       list().then((res) => {
         if (res.code === 0) {
-          this.tableData = res.data;
+          var data = res.data;
+          for (var i = 0; i < data.length; i++) {
+            data[i].indexNum = i + 1;
+          }
+          this.tableData = data;
           this.loading = false;
         }
       });
@@ -424,7 +430,7 @@ export default {
     // 点击编辑图标显示输入框
     handleEditClick(row, index) {
       this.editData.currentEditIndex = index;
-      this.editData.currentEditSort = row.sort;
+      this.editData.currentEditSort = row.indexNum;
       this.$nextTick(() => {
         this.$refs.numberInput.focus();
       });
@@ -432,16 +438,16 @@ export default {
 
     // 输入框失去焦点时隐藏
     onNumberBlur(row, index) {
-      var newSort = row.sort;
+      var newSort = row.indexNum;
 
       if (newSort === "") {
-        row.sort = this.editData.currentEditSort;
+        row.indexNum = this.editData.currentEditSort;
         this.$message.warning("序号不能为空");
         return;
       }
 
       if (newSort <= 0) {
-        row.sort = this.editData.currentEditSort;
+        row.indexNum = this.editData.currentEditSort;
         this.$message.warning("序号必须大于0");
         return;
       }
@@ -451,9 +457,23 @@ export default {
         return;
       }
 
-      
+      ///删除第index个元素
+
+      this.tableData.splice(index, 1);
+      this.tableData.splice(newSort - 1, 0, row);
+
+      for (var i = 0; i < this.tableData.length; i++) {
+        this.tableData[i].indexNum = i + 1;
+      }
       this.editData.currentEditIndex = -1;
 
+      // channeledit(this.dialogForm).then((res) => {
+      //   if (res.code === 0) {
+      //     this.$message.success("编辑成功!");
+      //     this.getList();
+      //   }
+      // });
+
       // 检查序号是否重复
       // const isDuplicate = this.tableData.some(
       //   (item, i) => i !== index && item.sortIndex === newSort