mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-09 10:56:44 +08:00
Merge branch 'master-20251023-tag' into test1024
# Conflicts: # src/components/Course/courseTag.vue
This commit is contained in:
@@ -117,7 +117,7 @@ export default {
|
||||
handler() {
|
||||
// 只有在已选择分类且有焦点时才重新加载
|
||||
if (this.sysTypeList.length > 0 && this.$refs.tagSelect && this.$refs.tagSelect.visible) {
|
||||
this.doSearch(null);
|
||||
this.doSearch('');
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
@@ -139,7 +139,7 @@ export default {
|
||||
this.previousTags = [...this.selectedTags];
|
||||
// 当输入框获得焦点时,加载默认的搜索结果
|
||||
if (this.sysTypeList.length > 0) {
|
||||
await this.doSearch(null);
|
||||
await this.doSearch('');
|
||||
}
|
||||
},
|
||||
// 新增:重置标签状态的方法
|
||||
@@ -176,15 +176,21 @@ export default {
|
||||
//按回车键,创建新标签
|
||||
handleEnterKey(event) {
|
||||
const inputVal = event.target.value?.trim()
|
||||
if (!inputVal) return;
|
||||
// 检查是否与已选择的标签重复
|
||||
const isDuplicate = this.selectedTags.some(tag => tag.tagName === inputVal);
|
||||
if (isDuplicate) {
|
||||
this.$message.warning('该标签已存在,无需重复创建');
|
||||
event.target.value = '';
|
||||
return;
|
||||
}
|
||||
if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) {
|
||||
console.log(' 标签输入框 : ' + event.target.value.trim() )
|
||||
this.createNewTag(event.target.value.trim())
|
||||
event.target.value = ''
|
||||
console.log(' createNewTag后 标签输入框 : ' + event.target.value.trim() )
|
||||
} else if (this.selectedTags.length >= this.maxTags) {
|
||||
this.$message.warning('最多只能添加5个标签')
|
||||
event.target.value = ''
|
||||
}else {
|
||||
} else {
|
||||
event.target.value = ''
|
||||
}
|
||||
},
|
||||
@@ -218,6 +224,18 @@ export default {
|
||||
this.$message.error('标签不能超过8个字')
|
||||
return;
|
||||
}
|
||||
// 首先检查是否与已选择的标签重复
|
||||
const isDuplicate = this.selectedTags.some(tag => tag.tagName === tagName);
|
||||
if (isDuplicate) {
|
||||
this.$message.warning('该标签已存在,无需重复创建');
|
||||
return;
|
||||
}
|
||||
// 标签格式验证:仅支持中文、英文、数字、下划线、中横线
|
||||
const tagPattern = /^[\u4e00-\u9fa5a-zA-Z0-9_-]+$/;
|
||||
if (!tagPattern.test(tagName)) {
|
||||
this.$message.error('标签名称仅支持中文、英文、数字、下划线(_)和中横线(-),不支持空格、点和特殊字符');
|
||||
return;
|
||||
}
|
||||
// 添加标签数量限制检查
|
||||
if (this.selectedTags.length >= this.maxTags) {
|
||||
this.$message.warning('最多只能添加5个标签')
|
||||
|
||||
Reference in New Issue
Block a user