浏览代码

修复bug新增模块会带出上一次的数据

DESKTOP-2S67K1S\31396 2 年之前
父节点
当前提交
b5dc5182b7
共有 1 个文件被更改,包括 12 次插入9 次删除
  1. 12 9
      src/views/operation/recommend/detail.vue

+ 12 - 9
src/views/operation/recommend/detail.vue

@@ -150,7 +150,7 @@ export default {
       // 表单
       form: [],
       // 模板
-      module: {},
+      module: [],
       // 弹窗
       dialogVisible: false,
       // 弹窗表单
@@ -238,12 +238,11 @@ export default {
         if (res.code === 0) {
           res.data.elementIds.map(i => {
             if (i === '4') { // 内容 关联 音频数据 存在底层module
-              this.module.contentName = ''
-              this.module.module = {}
+              this.module.push('contentName', 'module')
             } else if (i === '9') {
-              this.module.childList = []
+              this.module.push('childList')
             } else {
-              this.$set(this.module, moduleOptions[i], '')
+              this.module.push(moduleOptions[i])
             }
           })
           if (this.$route.query.threeId) {
@@ -263,13 +262,13 @@ export default {
             let obj = {}
 
             // 是否有简介
-            if ('description' in this.module) {
+            if (this.module.find(i => i === 'description')) {
               obj.description = i.module.description
             }
 
             // 只保留组件模板的参数
             for (const key in i) {
-              if (this.module.hasOwnProperty(key)) {
+              if (this.module.find(j => j === key)) {
                 obj[key] = i[key]
                 // 跳转方式关联 内容 栏目 地址
                 if ([0, 1, 2, 3, 4].includes(i.forwardType)) {
@@ -297,7 +296,11 @@ export default {
 
     // 新增模块
     getPush() {
-      this.form.push(this.module)
+      let obj = {}
+      this.module.map(i => {
+        obj[i] = i === 'childrenList' ? [] : i === 'module' ? {} : ''
+      })
+      this.form.push(obj)
     },
 
     // 爱听专区
@@ -408,7 +411,7 @@ export default {
       // 封面模式自定义封面会丢失内容封面图片 所以缓存以便改回来使用
       this.picList[this.index] = row.audioPic
       // 是否有简介 若有则将音频的简介赋值进去
-      if ('description' in this.module) {
+      if (this.module.find(i => i === 'description')) {
         e.description = row.description
       }
       this.$message.success('选择成功!')