Parcourir la source

修复更改教材字段功能,字段值为空的情况下值不更新

dsy il y a 1 jour
Parent
commit
8f1c4042e7

+ 1 - 1
.env

@@ -11,4 +11,4 @@ VUE_APP_BookWebSI = '/GCLSBookWebSI/ServiceInterface'
 VUE_APP_EepServer = '/EEPServer/SI'
 
 #version
-VUE_APP_VERSION = '2026.11.27'
+VUE_APP_VERSION = '2026.12.01'

+ 4 - 0
packages/BookEep.vue

@@ -154,6 +154,7 @@ export default {
       type: String,
       default: '',
     },
+    // 权限控制对象
     permissControl: {
       type: Object,
       default: () => ({}),
@@ -163,14 +164,17 @@ export default {
       type: String,
       default: '',
     },
+    // 是否显示分组内容
     isShowGroup: {
       type: Boolean,
       default: false,
     },
+    // 行选中状态,JSON 格式字符串
     rowChecked: {
       type: String,
       default: '{}',
     },
+    // 切换章节回调函数
     changeChapter: {
       type: Function,
       default: () => {},

+ 9 - 4
src/views/book/courseware/create/components/PreviewEdit.vue

@@ -462,15 +462,20 @@ export default {
         return;
       }
       const loading = this.$loading('加载组件数据中...');
-      await GetCoursewareComponentBackground(this.curComponentData).then(({ background }) => {
+      try {
+        const { background } = await GetCoursewareComponentBackground(this.curComponentData);
         if (background) {
           this.componentBackground = JSON.parse(background);
         } else {
           this.revertComponentBackground();
         }
-      });
-      loading.close();
-      this.visibleComponentBackground = true;
+        this.visibleComponentBackground = true;
+      } catch (error) {
+        console.error('加载组件背景失败:', error);
+        this.$message.error('加载组件背景失败,请稍后重试');
+      } finally {
+        loading.close();
+      }
     },
     /**
      * 设置组件背景

+ 9 - 1
src/views/personal_workbench/courseware_detail/index.vue

@@ -54,7 +54,10 @@
               </span>
             </div>
           </div>
-          <div class="book-intro">简介:{{ project.content_intro || '-' }}</div>
+          <div class="book-intro">
+            <span class="book-intro__label">简介:</span>
+            <span class="book-intro__text">{{ project.content_intro || '-' }}</span>
+          </div>
           <div v-if="['manage', 'launch'].includes(normalizedType)" class="operator-wrap">
             <div class="preview-button" @click="managePreview">
               <SvgIcon icon-class="courseware-eye" size="14" /><span>预览</span>
@@ -602,6 +605,11 @@ export default {
       font-size: 13px;
       line-height: 1.75;
       color: #64748b;
+      word-break: break-word;
+
+      .book-intro__text {
+        white-space: pre-wrap;
+      }
     }
   }
 

+ 9 - 4
src/views/personal_workbench/edit_task/preview/index.vue

@@ -187,15 +187,20 @@ export default {
         return;
       }
       const loading = this.$loading('加载组件数据中...');
-      await GetCoursewareComponentBackground(this.curComponentData).then(({ background }) => {
+      try {
+        const { background } = await GetCoursewareComponentBackground(this.curComponentData);
         if (background) {
           this.componentBackground = JSON.parse(background);
         } else {
           this.revertComponentBackground();
         }
-      });
-      loading.close();
-      this.visibleComponentBackground = true;
+        this.visibleComponentBackground = true;
+      } catch (error) {
+        console.error('加载组件背景失败:', error);
+        this.$message.error('加载组件背景失败,请稍后重试');
+      } finally {
+        loading.close();
+      }
     },
     /**
      * 设置组件背景

+ 24 - 4
src/views/personal_workbench/project/components/UpdateProjectField.vue

@@ -130,19 +130,34 @@ export default {
     },
   },
   watch: {
+    // 每次打开弹窗都按当前字段值重新初始化,避免上次取消后残留的编辑内容
+    visible(visible) {
+      if (visible) {
+        this.initValue();
+      }
+    },
     value(newVal) {
-      this.stringValue = newVal;
+      this.stringValue = this.normalizeValue(newVal);
 
       if (this.field === 'label_list' && Array.isArray(newVal)) {
         this.arrayValue = [...newVal];
       }
+    },
+  },
+  methods: {
+    initValue() {
+      this.labelInput = '';
+      this.imageId = '';
+      this.stringValue = this.normalizeValue(this.value);
+      this.arrayValue = Array.isArray(this.value) ? [...this.value] : [];
+    },
+    normalizeValue(value) {
       if (this.field === 'plan_publish_date') {
         const date = new Date();
-        this.stringValue = newVal === '0-00-00' ? `${date.getFullYear()}-${date.getMonth()}-${date.getDay()}` : newVal;
+        return value === '0-00-00' ? `${date.getFullYear()}-${date.getMonth()}-${date.getDay()}` : value;
       }
+      return value;
     },
-  },
-  methods: {
     // 处理标签输入
     labelChange() {
       if (this.labelInput.trim() !== '') {
@@ -195,6 +210,11 @@ export default {
         this.$emit('updateProjectFieldValue', this.field, this.stringValue);
       }
       if (this.field === 'cover_image_file_url') {
+        // 未重新上传时不能提交,否则会把已有封面清空
+        if (!this.imageId) {
+          this.$message.warning('请先上传封面图片');
+          return;
+        }
         this.$emit('updateProjectFieldValue', 'cover_image_file_id', this.imageId);
       }
       if (this.field === 'label_list') {