mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 19:36:43 +08:00
Merge remote-tracking branch '121/test1024' into test1024
This commit is contained in:
@@ -22,7 +22,7 @@ const pageList = function(data) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择课件的查询,这里也是分页查询,只是返回的内容,字段会很少,用于课件制作那选择已有课件内容。
|
* 选择课件的查询,这里也是分页查询,只是返回的内容,字段会很少,用于课件制作那选择已有课件内容。
|
||||||
*
|
*
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
* 查询参数如上面pageList方法
|
* 查询参数如上面pageList方法
|
||||||
*/
|
*/
|
||||||
@@ -47,7 +47,9 @@ const findList = function(data) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const saveUpload = 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,
|
batchUpdate,
|
||||||
detail,
|
detail,
|
||||||
delFile
|
delFile
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
<el-input-number v-model="duration" size="mini" :min="1" :max="100"></el-input-number>
|
<el-input-number v-model="duration" size="mini" :min="1" :max="100"></el-input-number>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<el-upload class="upload-demo" :headers="headers" :data="data" drag :action="uploadFileUrl" :on-success="handleUploadSuccess" :before-upload="handleBeforeUpload">
|
<el-upload ref="uploadRef" class="upload-demo" :headers="headers" :data="data" drag :action="uploadFileUrl" :on-success="handleUploadSuccess" :before-upload="handleBeforeUpload">
|
||||||
<i class="el-icon-upload"></i>
|
<i class="el-icon-upload"></i>
|
||||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
<div class="el-upload__tip" slot="tip">文件大小限制:{{curComType.maxSizeName}},支持的文件类型:{{curComType.fileTypes.join(',')}}</div>
|
<div class="el-upload__tip" slot="tip">文件大小限制:{{curComType.maxSizeName}},支持的文件类型:{{curComType.fileTypes.join(',')}}</div>
|
||||||
@@ -199,6 +199,7 @@
|
|||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
this.$message({message:"上传失败:"+res.message,type:'error',offset:100});
|
this.$message({message:"上传失败:"+res.message,type:'error',offset:100});
|
||||||
|
this.$refs.uploadRef.clearFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.$emit("success", res);
|
//this.$emit("success", res);
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ export default {
|
|||||||
params: {},
|
params: {},
|
||||||
tag: {},
|
tag: {},
|
||||||
// 添加临时存储用于回滚
|
// 添加临时存储用于回滚
|
||||||
previousTags: [],
|
previousTags: []
|
||||||
allTags: []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -117,14 +116,8 @@ export default {
|
|||||||
sysTypeList: {
|
sysTypeList: {
|
||||||
handler() {
|
handler() {
|
||||||
// 只有在已选择分类且有焦点时才重新加载
|
// 只有在已选择分类且有焦点时才重新加载
|
||||||
// if (this.sysTypeList.length > 0 && this.$refs.tagSelect && this.$refs.tagSelect.visible) {
|
if (this.sysTypeList.length > 0 && this.$refs.tagSelect && this.$refs.tagSelect.visible) {
|
||||||
// this.doSearch('');
|
this.doSearch('');
|
||||||
// }
|
|
||||||
if (this.sysTypeList.length > 0) {
|
|
||||||
this.shouldReloadAllTags = true; // 设置重新加载标志
|
|
||||||
if (this.$refs.tagSelect && this.$refs.tagSelect.visible) {
|
|
||||||
this.doSearch(''); // 触发重新加载
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
@@ -175,7 +168,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
//按回车键,创建新标签
|
//按回车键,创建新标签
|
||||||
async handleEnterKey(event) {
|
handleEnterKey(event) {
|
||||||
const inputVal = event.target.value?.trim()
|
const inputVal = event.target.value?.trim()
|
||||||
if (!inputVal) return;
|
if (!inputVal) return;
|
||||||
// 检查是否与已选择的标签重复
|
// 检查是否与已选择的标签重复
|
||||||
@@ -185,8 +178,8 @@ export default {
|
|||||||
event.target.value = '';
|
event.target.value = '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) {
|
if (!isDuplicate && inputVal && this.selectedTags.length < this.maxTags) {
|
||||||
await this.createNewTag(inputVal)
|
this.createNewTag(event.target.value.trim())
|
||||||
this.clearInput();
|
this.clearInput();
|
||||||
} else if (this.selectedTags.length >= this.maxTags) {
|
} else if (this.selectedTags.length >= this.maxTags) {
|
||||||
this.$message.warning('最多只能添加5个标签')
|
this.$message.warning('最多只能添加5个标签')
|
||||||
@@ -198,7 +191,14 @@ export default {
|
|||||||
|
|
||||||
// 新增:处理选择变化事件
|
// 新增:处理选择变化事件
|
||||||
handleSelectionChange(newValues) {
|
handleSelectionChange(newValues) {
|
||||||
console.log("----------handleSelectionChange---------->",newValues)
|
|
||||||
|
// 检查每个标签对象是否完整
|
||||||
|
newValues.forEach((tag, index) => {
|
||||||
|
if (!tag.tagName) {
|
||||||
|
console.error(`第${index}个标签缺少tagName:`, tag);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 检查数量限制
|
// 检查数量限制
|
||||||
if (newValues.length > this.maxTags) {
|
if (newValues.length > this.maxTags) {
|
||||||
this.$message.warning(`最多只能选择${this.maxTags}个标签`);
|
this.$message.warning(`最多只能选择${this.maxTags}个标签`);
|
||||||
@@ -218,8 +218,7 @@ export default {
|
|||||||
if (this.$refs.tagSelect) {
|
if (this.$refs.tagSelect) {
|
||||||
const input = this.$refs.tagSelect.$refs.input;
|
const input = this.$refs.tagSelect.$refs.input;
|
||||||
if (input) {
|
if (input) {
|
||||||
console.log("----------调用了注释的清除文字方法 clearInput---------->",input.value)
|
input.value = '';
|
||||||
// input.value = '';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -262,59 +261,56 @@ export default {
|
|||||||
if (this.sysTypeList.length > 2) {
|
if (this.sysTypeList.length > 2) {
|
||||||
this.params.sysType3 = this.sysTypeList[2]; //三级的id
|
this.params.sysType3 = this.sysTypeList[2]; //三级的id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const {result:newTag} = await apiCourseTag.createTag(this.params)
|
const {result:newTag} = await apiCourseTag.createTag(this.params)
|
||||||
this.$message.success('标签创建成功',newTag);
|
this.$message.success('标签创建成功',newTag);
|
||||||
|
|
||||||
this.selectedTags.push(newTag);
|
this.selectedTags = [...this.selectedTags, newTag];
|
||||||
this.searchResults.push(newTag)
|
// 更新搜索结果的逻辑保持不变
|
||||||
|
this.searchResults = [newTag, ...this.searchResults];
|
||||||
this.tagMap.set(newTag.id, newTag)
|
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.$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 {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 修改doSearch方法,添加搜索结果为空时的提示
|
// 修改doSearch方法,添加搜索结果为空时的提示
|
||||||
async doSearch(query) {
|
async doSearch(query) {
|
||||||
// 如果是初始化(query为空且allTags为空)或者分类变更后
|
// 不再在空查询时清空搜索结果
|
||||||
if ((!query && this.allTags.length === 0) || this.shouldReloadAllTags) {
|
// if (!query.trim()) {
|
||||||
this.loading = true;
|
// this.searchResults = []
|
||||||
try {
|
// return
|
||||||
const typeId = this.sysTypeList.length > 2 ? this.sysTypeList[2] :
|
// }
|
||||||
this.sysTypeList.length > 1 ? this.sysTypeList[1] :
|
console.log("---- doSearch ------ query = " + query )
|
||||||
this.sysTypeList.length > 0 ? this.sysTypeList[0] : null;
|
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)
|
||||||
tags.forEach(item => {
|
})
|
||||||
this.tagMap.set(item.id, item);
|
this.searchResults = tags
|
||||||
});
|
// 当搜索结果为空时,提示用户可以按回车键创建标签
|
||||||
|
if (tags.length === 0) {
|
||||||
this.allTags = tags; // 保存所有标签
|
this.$message.info('无此标签,按回车键创建')
|
||||||
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('无此标签,按回车键创建');
|
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.loading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user