Переглянути джерело

Merge remote-tracking branch 'origin/master'

yuhongqi 5 днів тому
батько
коміт
0515ac4f63
1 змінених файлів з 92 додано та 136 видалено
  1. 92 136
      src/views/qw/sopTemp/updateSopTemp.vue

+ 92 - 136
src/views/qw/sopTemp/updateSopTemp.vue

@@ -496,26 +496,26 @@
                                             </el-card>
                                           </div>
                                         </el-form-item>
-<!--                                        <el-form-item label="添加短链"-->
-<!--                                                      v-if="content.type == 2 && setList.contentType == 1  ">-->
-<!--                                          <el-tooltip content="请先根据课程选定课程小节之后再添加" effect="dark"-->
-<!--                                                      :disabled="!content.videoId">-->
-<!--                                            <el-switch-->
-<!--                                              @change="updateHtml"-->
-<!--                                              v-model="setList.isBindUrl"-->
-<!--                                              :disabled="!content.videoId && formType == 3 && !roles.includes('edit_sop_temp_content')"-->
-<!--                                              active-color="#13ce66"-->
-<!--                                              inactive-color="#DCDFE6"-->
-<!--                                              active-value="1"-->
-<!--                                              inactive-value="2">-->
-<!--                                            </el-switch>-->
-<!--                                          </el-tooltip>-->
-
-<!--                                          <span v-if="setList.isBindUrl == '1'"-->
-<!--                                                style="margin-left: 10px; color: #13ce66">添加URL</span>-->
-<!--                                          <span v-if="setList.isBindUrl == '2'"-->
-<!--                                                style="margin-left: 10px; color: #b1b4ba">不加URL</span>-->
-<!--                                        </el-form-item>-->
+                                        <!--                                        <el-form-item label="添加短链"-->
+                                        <!--                                                      v-if="content.type == 2 && setList.contentType == 1  ">-->
+                                        <!--                                          <el-tooltip content="请先根据课程选定课程小节之后再添加" effect="dark"-->
+                                        <!--                                                      :disabled="!content.videoId">-->
+                                        <!--                                            <el-switch-->
+                                        <!--                                              @change="updateHtml"-->
+                                        <!--                                              v-model="setList.isBindUrl"-->
+                                        <!--                                              :disabled="!content.videoId && formType == 3 && !roles.includes('edit_sop_temp_content')"-->
+                                        <!--                                              active-color="#13ce66"-->
+                                        <!--                                              inactive-color="#DCDFE6"-->
+                                        <!--                                              active-value="1"-->
+                                        <!--                                              inactive-value="2">-->
+                                        <!--                                            </el-switch>-->
+                                        <!--                                          </el-tooltip>-->
+
+                                        <!--                                          <span v-if="setList.isBindUrl == '1'"-->
+                                        <!--                                                style="margin-left: 10px; color: #13ce66">添加URL</span>-->
+                                        <!--                                          <span v-if="setList.isBindUrl == '2'"-->
+                                        <!--                                                style="margin-left: 10px; color: #b1b4ba">不加URL</span>-->
+                                        <!--                                        </el-form-item>-->
                                         <el-form-item label="课节过期时间"
                                                       v-if="content.type == 2 && (setList.isBindUrl == '1' || setList.contentType==4) && setList.contentType != 2  && setList.contentType != 5  && setList.contentType != 6 && setList.contentType != 8 && setList.contentType != 9 && setList.contentType != 10  ">
                                           <el-row>
@@ -543,25 +543,25 @@
                                           </el-input-number>
                                           <span class="tip">单位:分钟,最大1440分钟(24小时)</span>
                                         </el-form-item>
-<!--                                        <el-form-item label="内容" style="margin: 2%">-->
-<!--                                          <el-input-->
-<!--                                            v-model="setList.value"-->
-<!--                                            type="textarea"-->
-<!--                                            :rows="3"-->
-<!--                                            placeholder="内容"-->
-<!--                                            style="width: 90%;margin-top: 10px;"/>-->
-<!--                                        </el-form-item>-->
-<!--                                        <el-form-item label="交流状态" style="margin: 2%">-->
-<!--                                          <el-select v-model="setList.talkType" placeholder="更改交流状态" size="mini"-->
-<!--                                                     style=" margin-right: 10px;" clearable>-->
-<!--                                            <el-option label="非首次交流" value="非首次交流"></el-option>-->
-<!--                                            <el-option label="首次交流1" value="首次交流1"></el-option>-->
-<!--                                            <el-option label="首次交流2" value="首次交流2"></el-option>-->
-<!--                                            <el-option label="交流状态1" value="交流状态1"></el-option>-->
-<!--                                            <el-option label="交流状态2" value="交流状态2"></el-option>-->
-<!--                                            <el-option label="交流状态3" value="交流状态3"></el-option>-->
-<!--                                          </el-select>-->
-<!--                                        </el-form-item>-->
+                                        <!--                                        <el-form-item label="内容" style="margin: 2%">-->
+                                        <!--                                          <el-input-->
+                                        <!--                                            v-model="setList.value"-->
+                                        <!--                                            type="textarea"-->
+                                        <!--                                            :rows="3"-->
+                                        <!--                                            placeholder="内容"-->
+                                        <!--                                            style="width: 90%;margin-top: 10px;"/>-->
+                                        <!--                                        </el-form-item>-->
+                                        <!--                                        <el-form-item label="交流状态" style="margin: 2%">-->
+                                        <!--                                          <el-select v-model="setList.talkType" placeholder="更改交流状态" size="mini"-->
+                                        <!--                                                     style=" margin-right: 10px;" clearable>-->
+                                        <!--                                            <el-option label="非首次交流" value="非首次交流"></el-option>-->
+                                        <!--                                            <el-option label="首次交流1" value="首次交流1"></el-option>-->
+                                        <!--                                            <el-option label="首次交流2" value="首次交流2"></el-option>-->
+                                        <!--                                            <el-option label="交流状态1" value="交流状态1"></el-option>-->
+                                        <!--                                            <el-option label="交流状态2" value="交流状态2"></el-option>-->
+                                        <!--                                            <el-option label="交流状态3" value="交流状态3"></el-option>-->
+                                        <!--                                          </el-select>-->
+                                        <!--                                        </el-form-item>-->
                                       </el-form>
                                     </el-col>
                                     <el-col :span="1" :offset="1">
@@ -663,7 +663,7 @@
   cursor: pointer;
 }
 
-.custom-input /deep/ .el-badge__content.is-fixed {
+/deep/ .el-badge__content.is-fixed {
   top: 10px !important;
   right: 0 !important;
   width: 8px;
@@ -708,8 +708,6 @@ export default {
   components: {ImageUpload, userVideo, draggable},
   data() {
     return {
-      tabDataCache: {}, // tab数据缓存
-      tabLoadingStates: {}, // tab加载状态跟踪
       projectFrom:process.env.VUE_APP_PROJECT_FROM,
       addTag: [{
         addTag: [],
@@ -980,95 +978,46 @@ export default {
     leave(index, oldIndex) {
       const newData = this.setting[index]
       if (newData.dayNum && newData.id) {
-        // 检查是否有缓存数据
-        if (this.tabDataCache[newData.id]) {
-          // 使用缓存数据
-          this.applyCachedData(index, newData, this.tabDataCache[newData.id]);
-          // 预加载下一个tab数据
-          this.preloadNextTab(index);
-          return true;
-        }
-
-        // 防止重复请求同一tab数据
-        if (this.tabLoadingStates[newData.id]) {
-          return false;
-        }
-
-        this.tabLoadingStates[newData.id] = true;
         this.loading = true;
-
         selectRulesInfo(newData.id).then(res => {
-          // 缓存当前tab数据
-          this.tabDataCache[newData.id] = res.data;
-          this.applyCachedData(index, newData, res.data);
-          this.loading = false;
-          this.tabLoadingStates[newData.id] = false;
-
-          // 预加载下一个tab数据
-          this.preloadNextTab(index);
-        }).catch(() => {
-          this.loading = false;
-          this.tabLoadingStates[newData.id] = false;
-        });
-      }
-      return false;
-    },
+          this.$nextTick(() => {
+            this.loading = false;
+            this.videoList = [];
+            this.addTag = [];
+            this.$set(this.setting, index, {
+              ...newData,
+              voice: res.data.voice,
+              content: res.data.list || [{type: this.defaultContentType, contentType: '1', setting: [{contentType: '1', value: ""}]}]
+            });
 
-    // 应用缓存数据到tab
-    applyCachedData(index, newData, cachedData) {
-      this.$nextTick(() => {
-        this.videoList = [];
-        this.addTag = [];
-        this.$set(this.setting, index, {
-          ...newData,
-          voice: cachedData.voice,
-          content: cachedData.list || [{type: this.defaultContentType, contentType: '1', setting: [{contentType: '1', value: ""}]}]
-        });
+            for (let j = 0; j < this.setting[index].content.length; j++) {
 
-        for (let j = 0; j < this.setting[index].content.length; j++) {
-          if (this.setting[index].content[j].addTag != null) {
-            this.setting[index].content[j].addTag = JSON.parse(this.setting[index].content[j].addTag)
-          }
-          if (this.setting[index].content[j].delTag != null) {
-            this.setting[index].content[j].delTag = JSON.parse(this.setting[index].content[j].delTag)
-          }
-          this.videoList.push([])
-          this.addTag.push({
-            addTag: [],
-            inputVisible: false,
-            inputValue: '',
-            delTag: [],
-            delTagVisible: false,
-            delTagValue: ''
-          })
-          if (this.setting[index].content[j].type == 2) {
-            if (this.setting[index].content[j].hasOwnProperty('courseId')) {
-              this.courseChange(this.setting[index].content[j], index, j);
+              if (this.setting[index].content[j].addTag != null) {
+                this.setting[index].content[j].addTag = JSON.parse(this.setting[index].content[j].addTag)
+              }
+              if (this.setting[index].content[j].delTag != null) {
+                this.setting[index].content[j].delTag = JSON.parse(this.setting[index].content[j].delTag)
+              }
+              this.videoList.push([])
+              this.addTag.push({
+                addTag: [],
+                inputVisible: false,
+                inputValue: '',
+                delTag: [],
+                delTagVisible: false,
+                delTagValue: ''
+              })
+              if (this.setting[index].content[j].type == 2) {
+                if (this.setting[index].content[j].hasOwnProperty('courseId')) {
+                  this.courseChange(this.setting[index].content[j], index, j);
+                }
+              }
             }
-          }
-        }
-      })
-    },
-
-    // 预加载下一个tab数据
-    preloadNextTab(currentIndex) {
-      const nextIndex = (parseInt(currentIndex) + 1) % this.setting.length;
-      if (nextIndex !== parseInt(currentIndex) && this.setting[nextIndex] && this.setting[nextIndex].id) {
-        const nextTabId = this.setting[nextIndex].id;
-
-        // 如果下一个tab数据还没有缓存且未在加载中,则预加载
-        if (!this.tabDataCache[nextTabId] && !this.tabLoadingStates[nextTabId]) {
-          this.tabLoadingStates[nextTabId] = true;
-          selectRulesInfo(nextTabId).then(res => {
-            this.tabDataCache[nextTabId] = res.data;
-            this.tabLoadingStates[nextTabId] = false;
-          }).catch(() => {
-            this.tabLoadingStates[nextTabId] = false;
-          });
-        }
+          })
+        });
       }
-    },
 
+    },
     save() {
       let data = this.setting[this.tabIndex];
       let check = this.checkData(data);
@@ -1134,7 +1083,6 @@ export default {
         this.loading = false;
       });
     },
-
     checkData(data) {
       if (this.form.sendType != 4) {
 
@@ -1339,10 +1287,12 @@ export default {
           content[contentIndex].setting.push(newSetting);
         }
       }
-    },
 
+
+    },
     delSetList(index, contentIndex, setIndex) {
       this.setting[index].content[contentIndex].setting.splice(setIndex, 1)
+
     },
 
     addContent(index) {
@@ -1391,6 +1341,7 @@ export default {
         dayNum: (this.form.gap * this.setting.length) + 1,
         content
       })
+
     },
     delSetting(index) {
       const newData = this.setting[index]
@@ -1407,6 +1358,7 @@ export default {
       } else {
         this.del(index);
       }
+
     },
     del(index) {
       if (index == 0) {
@@ -1459,13 +1411,18 @@ export default {
 
     //修改
     courseChangeUpdate(content, index, countIndex) {
+
       this.$set(content, 'videoId', null);
       // 查找选中的课程对应的 label
       const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === content.courseId);
       for (let i = 0; i < content.setting.length; i++) {
+
+
         this.$set(content.setting[i], 'linkTitle', null);
         this.$set(content.setting[i], 'linkDescribe', null);
         this.$set(content.setting[i], 'linkImageUrl', null);
+
+
         //如果是链接的才上
         if (selectedCourse && content.type == 2 && content.courseId != null) {
           //响应式直接给链接的标题/封面上值
@@ -1477,22 +1434,31 @@ export default {
           if (content.setting[i].contentType == 4 || content.setting[i].contentType == 10) {
             this.$set(content.setting[i], 'miniprogramPicUrl', selectedCourse.dictImgUrl);
           }
+
+
         }
       }
+
+
       this.courseUpdate(content, index, countIndex);
     },
     handleInputVideoText(value, content) {
       // 允许的字符:中文、英文(大小写)、数字和指定标点符号(,。!?)
       const regex = /^[\u4e00-\u9fa5,。!?,!?]+$/;
+
       // 删除不符合条件的字符
       const filteredValue = value.split('').filter(char => regex.test(char)).join('');
+
       this.$set(content, 'value', filteredValue);
+
     },
     courseUpdate(content, index, countIndex) {
       videoList(content.courseId).then(response => {
         // this.$set(this.videoList, countIndex, response.list); // 响应式设置videoList
         this.videoList.splice(countIndex, 1, response.list);
+
       });
+
     },
     toggleSalesCall(itemIndex, contentIndex, setIndex) {
       // 获取目标对象
@@ -1840,9 +1806,6 @@ export default {
     /** 修改按钮操作 */
     handleUpdate(id) {
       getSopTemp(id).then(response => {
-        this.tabDataCache = {}; // 清空缓存
-        this.tabLoadingStates = {}; // 清空加载状态
-
         this.videoList = []
         this.form = response.data;
         this.setting = this.form.list || [];
@@ -1883,13 +1846,6 @@ export default {
             });
           }
         });
-        // 默认加载第一个 tab 的数据
-        if (this.setting && this.setting.length > 0) {
-          this.tabIndex = "0";
-          this.$nextTick(() => {
-            this.leave(0);
-          });
-        }
         // this.addTag.push({
         //   addTag: [],
         //   inputVisible: false,