Browse Source

推荐管理 新增酷狗模块 修改精选电台自由配置

DESKTOP-O04BTUJ\muzen 2 years ago
parent
commit
804bd9c7d4
1 changed files with 78 additions and 38 deletions
  1. 78 38
      src/views/operation/recommend/index.vue

+ 78 - 38
src/views/operation/recommend/index.vue

@@ -70,7 +70,10 @@
         <!-- 内容列表模块 -->
         <div v-else :style="{'display': tabIndex === 1 && active === 0 ? 'inline-block' : 'block'}">
           <el-form label-width="auto" v-for="(item, index) in list" :key="item.id">
-            <el-form-item label-width="0" :label="item.sort.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"
+                style="float:right" @click="getChangeTime(item.id, 2, index)" />
+            </el-form-item>
 
             <el-form-item label="时间:" v-if="time()">
               <el-date-picker v-model="item.date" type="datetimerange" start-placeholder="开始日期"
@@ -119,6 +122,10 @@
               <Upload listType="picture-card" :url="item.pic" @upload="getUpload($event, index)" />
             </el-form-item>
 
+            <el-form-item label="排序:" v-if="tabIndex === 2 && active === 1">
+              <el-input-number v-model="item.sort" />
+            </el-form-item>
+
             <el-form-item label="列表:" v-if="isList()">
               <el-button type="primary" @click="getDialog(index)" v-hasPermi="['operation:recommend:add']">
                 添加内容
@@ -147,6 +154,8 @@
                 v-hasPermi="['operation:recommend:down']">下架</el-button>
             </el-form-item>
           </el-form>
+          <el-button v-if="tabIndex === 2 && active === 1" type="primary" style="margin-left: 30px"
+            @click="getAdd" v-hasPermi="['operation:recommend:add']">新增</el-button>
         </div>
       </div>
     </div>
@@ -219,7 +228,8 @@ import {
   upOrDown,
   timeList,
   submitTime,
-  changeTime
+  changeTime,
+  expandSave
 } from '@/api/operation/recommend'
 import Upload from '@/components/Upload/index'
 import { isFreeMixin, audioMixin, platformMixin, onOrOffMixin } from '@/mixin/index'
@@ -270,7 +280,8 @@ export default {
           { top: 2460, height: 295 },
           { top: 2760, height: 600 },
           { top: 3370, height: 260 },
-          { top: 3635, height: 600 }
+          { top: 3635, height: 600 },
+          { top: 4245, height: 215 }
         ],
         '2': [
           { top: 135, height: 165 },
@@ -378,12 +389,14 @@ export default {
   },
   watch: {
     async 'form.audioType'(val) {
-      await this.getPlatform({
-        audioType: val
-      })
-      this.form.platformId = this.platformOptions[0].value
-      this.getContentList()
-    },
+      if (this.tabIndex !== 1 && this.active !== 12) {
+        await this.getPlatform({
+          audioType: val
+        })
+        this.platformId = this.platformOptions[0].value
+        this.getContentList()
+      }
+    }
   },
   mounted() {
     this.getTab()
@@ -492,23 +505,43 @@ export default {
 
     // 内容列表提交
     getSubmit(item) {
-      item.startTime = item.date[0]
-      item.endTime = item.date[1]
-      delete item.date
-      submit(item).then(res => {
-        if (res.code === 0) {
-          this.$message.success('提交成功!')
-          this.getContentDetail(item.moduleId)
-        }
-      })
+      if (this.tabIndex === 2 && this.active === 1) {
+        expandSave(item).then(res => {
+          if (res.code === 0) {
+            this.$message.success('提交成功!')
+            this.getContentDetail(item.moduleId)
+          }
+        })
+      } else {
+        item.startTime = item.date[0]
+        item.endTime = item.date[1]
+        delete item.date
+        submit(item).then(res => {
+          if (res.code === 0) {
+            this.$message.success('提交成功!')
+            this.getContentDetail(item.moduleId)
+          }
+        })
+      }
     },
 
     // 弹窗
-    getDialog(index) {
+    async getDialog(index) {
       this.dialogVisible = true
       this.index = index
-      this.form.audioType = this.list[index].forwardType !== null ? 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
+      if (this.tabIndex === 1 && this.active === 12) {
+        await this.getAudioType(9)
+        this.audioOptions = this.audioTypeOptions
+        this.platformOptions = [{
+          value: 9,
+          label: '酷狗音乐'
+        }]
+        this.form.platformId = 9
+        this.form.audioType = this.audioOptions[0].value
+      } else {
+        this.form.audioType = this.list[index].forwardType !== null ? 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.getContentList()
     },
 
@@ -525,7 +558,6 @@ export default {
         if (res.code === 0) {
           this.tableData = res.data.records
           this.total = res.data.total
-          this.$refs.tableData.clearSelection()
           if (this.tableData.length > 0) {
             this.list[this.index].childList.map(i => {
               let row = res.data.records.find(j => j.audioId === i.contentId)
@@ -632,22 +664,30 @@ export default {
 
     // 新增时间段
     getAdd() {
-      this.timeList.push({})
+      if (this.tabIndex === 2 && this.active === 1) {
+        this.list.push({})
+      } else {
+        this.timeList.push({})
+      }
     },
 
     // 上下架 / 删除 时间段
-    getChangeTime(id, status) {
-      let title = status === 0 ? '下架' : status === 1 ? '上架' : '删除'
-      this.$confirm(`是否${title}?`, '提醒', {
-        type: 'warning'
-      }).then(() => {
-        changeTime(id, status).then(res => {
-          if (res.code === 0) {
-            this.$message.success(`${title}成功!`)
-            this.getTimeList()
-          }
+    getChangeTime(id, status, index) {
+      if (id) {
+        let title = status === 0 ? '下架' : status === 1 ? '上架' : '删除'
+        this.$confirm(`是否${title}?`, '提醒', {
+          type: 'warning'
+        }).then(() => {
+          changeTime(id, status).then(res => {
+            if (res.code === 0) {
+              this.$message.success(`${title}成功!`)
+              this.getTimeList()
+            }
+          })
         })
-      })
+      } else {
+        this.tabIndex === 1 && this.active === 0 ? this.timeList.splice(index, 1) : this.list.splice(index, 1)
+      }
     },
 
     // 字典翻译
@@ -665,7 +705,7 @@ export default {
     // 标题模块
     content() {
       let rules = {
-        '1': [3, 4, 5, 6, 7, 8].includes(this.active),
+        '1': [3, 4, 5, 6, 7, 8, 12].includes(this.active),
         '2': [1, 3].includes(this.active),
         '3': [2, 4, 6, 7, 8, 9].includes(this.active),
         '4': [2, 4, 6, 8, 9, 10, 11].includes(this.active),
@@ -690,7 +730,7 @@ export default {
     // 时间
     time() {
       let rules = {
-        '1': this.active !== 3 && this.active !== 8,
+        '1': ![3, 8].includes(this.active),
         '2': [0, 3].includes(this.active),
         '3': this.active !== 1,
         '4': this.active !== 1 || this.active !== 5,
@@ -741,7 +781,7 @@ export default {
     // 内容
     contentName(item) {
       let rules = {
-        '1': [0, 6, 8, 10].includes(this.active),
+        '1': [0, 6, 8, 10, 12].includes(this.active),
         '3': [2, 3, 5, 6, 9].includes(this.active),
         '4': [7].includes(this.active),
         '5': [5].includes(this.active),
@@ -777,7 +817,7 @@ export default {
     // 图片
     pic(item) {
       let rules = {
-        '1': [1, 2, 6, 8, 10].includes(this.active),
+        '1': [1, 2, 6, 8, 10, 12].includes(this.active),
         '2': [0, 1].includes(this.active),
         '3': [0, 2, 3, 5, 6, 9].includes(this.active),
         '4': [0, 3, 7].includes(this.active),