Ver código fonte

推荐管理 修改精选频道删除按钮调用接口

DESKTOP-O04BTUJ\muzen 2 anos atrás
pai
commit
bb4997bf89
1 arquivos alterados com 30 adições e 10 exclusões
  1. 30 10
      src/views/operation/recommend/index.vue

+ 30 - 10
src/views/operation/recommend/index.vue

@@ -72,7 +72,7 @@
           <el-form label-width="auto" v-for="(item, index) in list" :key="item.id">
           <el-form label-width="auto" v-for="(item, index) in list" :key="item.id">
             <el-form-item label-width="0" :label="(index + 1).toString()">
             <el-form-item label-width="0" :label="(index + 1).toString()">
               <el-link v-if="tabIndex === 2 && active === 1" icon="el-icon-close" :underline="false"
               <el-link v-if="tabIndex === 2 && active === 1" icon="el-icon-close" :underline="false"
-                style="float:right" @click="getChangeTime(item.id, 2, index)" />
+                style="float:right" @click="getRemoveList(item, index)" />
             </el-form-item>
             </el-form-item>
 
 
             <el-form-item label="时间:" v-if="time()">
             <el-form-item label="时间:" v-if="time()">
@@ -229,7 +229,8 @@ import {
   timeList,
   timeList,
   submitTime,
   submitTime,
   changeTime,
   changeTime,
-  expandSave
+  expandSave,
+  removeList
 } from '@/api/operation/recommend'
 } from '@/api/operation/recommend'
 import Upload from '@/components/Upload/index'
 import Upload from '@/components/Upload/index'
 import { isFreeMixin, audioMixin, platformMixin, onOrOffMixin } from '@/mixin/index'
 import { isFreeMixin, audioMixin, platformMixin, onOrOffMixin } from '@/mixin/index'
@@ -539,7 +540,7 @@ export default {
         this.form.platformId = 9
         this.form.platformId = 9
         this.form.audioType = this.audioOptions[0].value
         this.form.audioType = this.audioOptions[0].value
       } else {
       } else {
-        this.form.audioType = this.list[index].forwardType !== null ? this.typeOptions.find(i => i.value === this.list[index].forwardType).type : 2
+        this.form.audioType = this.list[index].forwardType ? this.typeOptions.find(i => i.value === this.list[index].forwardType).type : 2
         this.disabled = this.tabIndex == 2 && this.active === 1 || this.list[index].forwardType !== null ? true : false
         this.disabled = this.tabIndex == 2 && this.active === 1 || this.list[index].forwardType !== null ? true : false
       }
       }
       this.getContentList()
       this.getContentList()
@@ -558,7 +559,7 @@ export default {
         if (res.code === 0) {
         if (res.code === 0) {
           this.tableData = res.data.records
           this.tableData = res.data.records
           this.total = res.data.total
           this.total = res.data.total
-          if (this.tableData.length > 0) {
+          if (this.list[this.index].childList && this.list[this.index].childList.length > 0) {
             this.list[this.index].childList.map(i => {
             this.list[this.index].childList.map(i => {
               let row = res.data.records.find(j => j.audioId === i.contentId)
               let row = res.data.records.find(j => j.audioId === i.contentId)
               if (row) {
               if (row) {
@@ -627,12 +628,10 @@ export default {
       })
       })
     },
     },
 
 
-    // 上下架
+    // 上下架内容模块
     handleChange(item, status) {
     handleChange(item, status) {
       let tips = status === 0 ? '上架' : '下架'
       let tips = status === 0 ? '上架' : '下架'
       this.$confirm(`是否要${tips}?`, '提醒', {
       this.$confirm(`是否要${tips}?`, '提醒', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
         type: 'warning'
         type: 'warning'
       }).then(() => {
       }).then(() => {
         upOrDown(item.id, status).then(res => {
         upOrDown(item.id, status).then(res => {
@@ -644,6 +643,24 @@ export default {
       }).catch(() => { })
       }).catch(() => { })
     },
     },
 
 
+    // 删除内容模块
+    getRemoveList(item, index) {
+      if (item.id) {
+        this.$confirm(`是否要删除${item.title}?`, '提醒', {
+          type: 'warning'
+        }).then(() => {
+          removeList(item.id, 2).then(res => {
+            if (res.code === 0) {
+              this.$message.success(`删除成功!`)
+              this.getContentDetail(item.moduleId)
+            }
+          })
+        }).catch(() => { })
+      } else {
+        this.list.splice(index, 1)
+      }
+    },
+
     // 提交场景电台时间段
     // 提交场景电台时间段
     getSubmitTime(item) {
     getSubmitTime(item) {
       item.startTime = item.date[0]
       item.startTime = item.date[0]
@@ -665,13 +682,16 @@ export default {
     // 新增时间段
     // 新增时间段
     getAdd() {
     getAdd() {
       if (this.tabIndex === 2 && this.active === 1) {
       if (this.tabIndex === 2 && this.active === 1) {
-        this.list.push({})
+        this.list.push({
+          moduleId: this.module[this.active].id,
+          childList: []
+        })
       } else {
       } else {
         this.timeList.push({})
         this.timeList.push({})
       }
       }
     },
     },
 
 
-    // 上下架 / 删除 时间段
+    // 上下架 / 删除时间段
     getChangeTime(id, status, index) {
     getChangeTime(id, status, index) {
       if (id) {
       if (id) {
         let title = status === 0 ? '下架' : status === 1 ? '上架' : '删除'
         let title = status === 0 ? '下架' : status === 1 ? '上架' : '删除'
@@ -686,7 +706,7 @@ export default {
           })
           })
         })
         })
       } else {
       } else {
-        this.tabIndex === 1 && this.active === 0 ? this.timeList.splice(index, 1) : this.list.splice(index, 1)
+        this.timeList.splice(index, 1)
       }
       }
     },
     },