diff --git a/src/api/modules/courseFile.js b/src/api/modules/courseFile.js index ee84dd57..ac14a174 100644 --- a/src/api/modules/courseFile.js +++ b/src/api/modules/courseFile.js @@ -22,7 +22,7 @@ const pageList = function(data) { /** * 选择课件的查询,这里也是分页查询,只是返回的内容,字段会很少,用于课件制作那选择已有课件内容。 - * + * * @param {Object} data * 查询参数如上面pageList方法 */ @@ -47,7 +47,9 @@ const findList = function(data) { } */ const saveUpload = function(data) { - return ajax.post('/xboe/m/course/file/upload/save', data); + return ajax.post('/xboe/m/course/file/upload/save', data, { + timeout: 60000 + }); } /** @@ -88,4 +90,4 @@ export default { batchUpdate, detail, delFile -} \ No newline at end of file +} diff --git a/src/components/Course/chooseCourseFile.vue b/src/components/Course/chooseCourseFile.vue index 74e3301b..c8bbc9be 100644 --- a/src/components/Course/chooseCourseFile.vue +++ b/src/components/Course/chooseCourseFile.vue @@ -50,7 +50,7 @@ - +
将文件拖到此处,或点击上传
文件大小限制:{{curComType.maxSizeName}},支持的文件类型:{{curComType.fileTypes.join(',')}}
@@ -199,6 +199,7 @@ }); }else{ this.$message({message:"上传失败:"+res.message,type:'error',offset:100}); + this.$refs.uploadRef.clearFiles(); } //this.$emit("success", res); diff --git a/src/components/Course/courseTag.vue b/src/components/Course/courseTag.vue index 58da0f56..6a96b6f0 100644 --- a/src/components/Course/courseTag.vue +++ b/src/components/Course/courseTag.vue @@ -69,8 +69,7 @@ export default { params: {}, tag: {}, // 添加临时存储用于回滚 - previousTags: [], - allTags: [] + previousTags: [] } }, computed: { @@ -117,14 +116,8 @@ export default { sysTypeList: { handler() { // 只有在已选择分类且有焦点时才重新加载 - // if (this.sysTypeList.length > 0 && this.$refs.tagSelect && this.$refs.tagSelect.visible) { - // this.doSearch(''); - // } - if (this.sysTypeList.length > 0) { - this.shouldReloadAllTags = true; // 设置重新加载标志 - if (this.$refs.tagSelect && this.$refs.tagSelect.visible) { - this.doSearch(''); // 触发重新加载 - } + if (this.sysTypeList.length > 0 && this.$refs.tagSelect && this.$refs.tagSelect.visible) { + this.doSearch(''); } }, deep: true @@ -175,7 +168,7 @@ export default { }, //按回车键,创建新标签 - async handleEnterKey(event) { + handleEnterKey(event) { const inputVal = event.target.value?.trim() if (!inputVal) return; // 检查是否与已选择的标签重复 @@ -185,8 +178,8 @@ export default { event.target.value = ''; return; } - if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) { - await this.createNewTag(inputVal) + if (!isDuplicate && inputVal && this.selectedTags.length < this.maxTags) { + this.createNewTag(event.target.value.trim()) this.clearInput(); } else if (this.selectedTags.length >= this.maxTags) { this.$message.warning('最多只能添加5个标签') @@ -198,7 +191,14 @@ export default { // 新增:处理选择变化事件 handleSelectionChange(newValues) { - console.log("----------handleSelectionChange---------->",newValues) + + // 检查每个标签对象是否完整 + newValues.forEach((tag, index) => { + if (!tag.tagName) { + console.error(`第${index}个标签缺少tagName:`, tag); + } + }); + // 检查数量限制 if (newValues.length > this.maxTags) { this.$message.warning(`最多只能选择${this.maxTags}个标签`); @@ -218,8 +218,7 @@ export default { if (this.$refs.tagSelect) { const input = this.$refs.tagSelect.$refs.input; if (input) { - console.log("----------调用了注释的清除文字方法 clearInput---------->",input.value) - // input.value = ''; + input.value = ''; } } }, @@ -262,59 +261,56 @@ export default { if (this.sysTypeList.length > 2) { this.params.sysType3 = this.sysTypeList[2]; //三级的id } - - const {result:newTag} = await apiCourseTag.createTag(this.params) this.$message.success('标签创建成功',newTag); - this.selectedTags.push(newTag); - this.searchResults.push(newTag) + this.selectedTags = [...this.selectedTags, newTag]; + // 更新搜索结果的逻辑保持不变 + this.searchResults = [newTag, ...this.searchResults]; this.tagMap.set(newTag.id, newTag) - console.info(' 标签创建成功 id = ' + newTag.id) - console.info(' 标签创建成功 tagName = ' + newTag.tagName) - console.info(' 标签创建成功 selectedTags = ' + this.selectedTags) - console.info(' 标签创建成功 searchResults = ' + this.searchResults) - console.info(' 标签创建成功 tagMap = ' + this.tagMap) this.$emit('change', this.displayTags) - this.doSearch(''); + + this.$nextTick(() => { + // 强制重新设置selectedTags来触发更新 + const tempTags = [...this.selectedTags]; + this.selectedTags = []; + this.$nextTick(() => { + this.selectedTags = tempTags; + }); + this.$refs.tagSelect.visible = false; + }); } finally { this.loading = false } }, // 修改doSearch方法,添加搜索结果为空时的提示 async doSearch(query) { - // 如果是初始化(query为空且allTags为空)或者分类变更后 - if ((!query && this.allTags.length === 0) || this.shouldReloadAllTags) { - this.loading = true; - try { - const typeId = this.sysTypeList.length > 2 ? this.sysTypeList[2] : - this.sysTypeList.length > 1 ? this.sysTypeList[1] : - this.sysTypeList.length > 0 ? this.sysTypeList[0] : null; + // 不再在空查询时清空搜索结果 + // if (!query.trim()) { + // this.searchResults = [] + // return + // } + console.log("---- doSearch ------ query = " + query ) + this.loading = true + try { + // 获取 typeId:取 sysTypeList 最后一个有效的值 + const typeId = this.sysTypeList.length > 2 ? this.sysTypeList[2] : + this.sysTypeList.length > 1 ? this.sysTypeList[1] : + this.sysTypeList.length > 0 ? this.sysTypeList[0] : null; + console.log("---- doSearch searchTags ------ query = " + query + " , typeId = " + typeId ) + const {result:tags} = await apiCourseTag.searchTags({tagName:query,typeId:typeId}) + console.log("-- searchTags 查询结果 tags = " + tags ) - const { result: tags } = await apiCourseTag.searchTags({ tagName: '', typeId: typeId }); - - tags.forEach(item => { - this.tagMap.set(item.id, item); - }); - - this.allTags = tags; // 保存所有标签 - this.searchResults = tags; // 初始显示所有标签 - - this.shouldReloadAllTags = false; // 重置标志位 - } finally { - this.loading = false; - } - } else { - // 本地过滤 - const filteredTags = this.allTags.filter(tag => - tag.tagName.toLowerCase().includes(query.toLowerCase()) - ); - this.searchResults = filteredTags; - - // 当本地过滤结果为空时提示创建 - if (filteredTags.length === 0 && query) { - this.$message.info('无此标签,按回车键创建'); + tags.forEach(item => { + this.tagMap.set(item.id, item) + }) + this.searchResults = tags + // 当搜索结果为空时,提示用户可以按回车键创建标签 + if (tags.length === 0) { + this.$message.info('无此标签,按回车键创建') } + } finally { + this.loading = false } } }