Pārlūkot izejas kodu

feat: 多频多台频道内能调整配置内容顺序

Damon 11 mēneši atpakaļ
vecāks
revīzija
09e43f04ca
2 mainītis faili ar 31 papildinājumiem un 33 dzēšanām
  1. 8 17
      src/api/operation/channels.js
  2. 23 16
      src/views/operation/channels/detail.vue

+ 8 - 17
src/api/operation/channels.js

@@ -9,7 +9,7 @@ export function list() {
 }
 
 // 设备
-export function dev(type){
+export function dev(type) {
   return request({
     url: `/admin/config/channel/getIsExistclientTypeList/${type}`,
     method: 'post'
@@ -33,7 +33,7 @@ export function channels(id) {
 }
 
 // 新增
-export function submit(data){
+export function submit(data) {
   return request({
     url: `/admin/config/channel/addPage`,
     method: 'post',
@@ -42,7 +42,7 @@ export function submit(data){
 }
 
 // 编辑
-export function edit(data){
+export function edit(data) {
   return request({
     url: `/admin/config/channel/channelEdit`,
     method: 'post',
@@ -51,7 +51,7 @@ export function edit(data){
 }
 
 // 新增分类
-export function classSubmit(name, type, id){
+export function classSubmit(name, type, id) {
   return request({
     url: `/admin/config/channel/addchannelClassification/${name}/${type}/${id}`,
     method: 'get'
@@ -74,19 +74,10 @@ export function classRemove(id) {
   })
 }
 
-// 频道详情 排序
-// export function changeDetail(data) {
-//   return request({
-//     url: `/admin/config/channel/view`,
-//     method: 'post',
-//     data
-//   })
-// }
-
-// 频道详情 
-export function changeDetail(data) {
+// 频道详情 修改频道内数据顺序
+export function channelDetail(data) {
   return request({
-    url: `/admin/config/channel/channel/sortEdit`,
+    url: `/admin/config/channel/view`,
     method: 'post',
     data
   })
@@ -116,4 +107,4 @@ export function remove(id) {
     url: `/admin/config/channel/deleteTemplate/${id}`,
     method: 'delete'
   })
-}
+}

+ 23 - 16
src/views/operation/channels/detail.vue

@@ -1,4 +1,4 @@
-<!-- 多频多台 -->
+<!-- 多频多台 详情 -->
 <template>
   <div class="app-container">
     <!-- 表单 -->
@@ -112,14 +112,15 @@
               <el-button
                 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
                 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>
@@ -142,11 +143,7 @@
 </template>
 
 <script>
-import {
-  changeDetail,
-  channelDetail,
-  channeledit,
-} from "@/api/operation/channels";
+import { channelDetail, channeledit } from "@/api/operation/channels";
 
 import Dialog from "@/components/Dialog/index.vue";
 import { disabledMixin, isFreeMixin, platformMixin } from "@/mixin/index";
@@ -178,11 +175,20 @@ export default {
   },
   methods: {
     // 排序
-    getChangeDetail(row, sort) {
-      changeDetail({
-        id: row.id,
-        sort: sort,
-      }).then((res) => {
+    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,
+        });
+      });
+      channeledit(this.form).then((res) => {
         if (res.code === 0) {
           this.$message.success("修改成功!");
           this.getDetail();
@@ -192,8 +198,9 @@ export default {
 
     // 频道详情
     getDetail() {
+      const channelId = this.$route.query.channelId;
       channelDetail({
-        channelId: this.$route.query.channelId,
+        channelId: channelId,
       }).then((res) => {
         if (res.code === 0) {
           this.form = res.data;