Browse Source

修改问题

dsy 1 day ago
parent
commit
c63eb223c7

+ 1 - 1
src/components/CommonPreview.vue

@@ -331,7 +331,7 @@ export default {
         }
 
         if (component_list) this.component_list = component_list;
-        this.content_group_row_list = JSON.parse(content_group_row_list) || [];
+        if (content_group_row_list) this.content_group_row_list = JSON.parse(content_group_row_list) || [];
       });
     },
     /**

+ 18 - 4
src/views/book/courseware/create/components/CreateCanvas.vue

@@ -228,13 +228,27 @@ export default {
           let isHas = this.content_group_row_list.some((group) => group.row_id === row_id);
           if (!isHas) {
             this.content_group_row_list.splice(i, 0, { row_id, is_pre_same_group: false });
+
+            [i - 1, i + 1].forEach((start) => {
+              let step = start < i ? -1 : 1;
+              for (let j = start; j >= 0 && j < this.content_group_row_list.length; j += step) {
+                if (this.content_group_row_list[j].is_pre_same_group) {
+                  this.content_group_row_list[j].is_pre_same_group = false;
+                } else {
+                  break;
+                }
+              }
+            });
           }
         });
 
-        // 过滤掉已经不存在的行
-        this.content_group_row_list = this.content_group_row_list.filter((group) => {
-          return val.find((row) => row.row_id === group.row_id);
-        });
+        // 过滤掉已经不存在的行,并将第一行的 is_pre_same_group 设置为 false
+        this.content_group_row_list = this.content_group_row_list.filter((group) =>
+          val.find((row) => row.row_id === group.row_id),
+        );
+        if (this.content_group_row_list[0]) {
+          this.content_group_row_list[0].is_pre_same_group = false;
+        }
       },
       immediate: true,
     },