mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-06 17:36:42 +08:00
调试
This commit is contained in:
@@ -607,6 +607,8 @@ export default {
|
||||
// 限制最多5个标签
|
||||
if (tags.length > 5) {
|
||||
this.$message.warning('最多只能选择5个标签')
|
||||
// 强制限制为5个
|
||||
tags = tags.slice(0, 5);
|
||||
return
|
||||
}
|
||||
let ids = "";
|
||||
@@ -615,9 +617,7 @@ export default {
|
||||
ids += tag.id + ',';
|
||||
})
|
||||
this.courseInfo.tags = ids;
|
||||
console.log("父组件ids : ",this.courseInfo.tags)
|
||||
// 同时更新showTags,确保显示与实际数据一致
|
||||
this.showTags = tags.map(tag => tag.tagName);
|
||||
this.$emit('change', tags.slice(0, 5)); // 确保传出数据也不超过5个
|
||||
},
|
||||
showChooseOrg(){
|
||||
this.$refs.refChooseOrg.dlgShow = true;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
:key="item.id"
|
||||
:label="item.tagName"
|
||||
:value="item"
|
||||
:disabled="isTagDisabled(item)"
|
||||
/>
|
||||
</el-select>
|
||||
<!-- 添加标签计数显示 -->
|
||||
@@ -66,7 +67,9 @@ export default {
|
||||
tagMap: new Map(),
|
||||
inputBuffer: '',
|
||||
params: {},
|
||||
tag: {}
|
||||
tag: {},
|
||||
// 添加临时存储用于回滚
|
||||
previousTags: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -121,9 +124,19 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 新增:检查标签是否应该被禁用
|
||||
isTagDisabled(tag) {
|
||||
// 如果标签已经被选中,不应该禁用(允许取消选择)
|
||||
const isSelected = this.selectedTags.some(selectedTag => selectedTag.id === tag.id);
|
||||
if (isSelected) {
|
||||
return false;
|
||||
}
|
||||
// 如果标签未被选中且已达到最大数量,则禁用
|
||||
return this.selectedTags.length >= this.maxTags;
|
||||
},
|
||||
// 新增:处理输入框获得焦点事件
|
||||
async handleFocus() {
|
||||
console.log("-- handleFocus --- " + this.sysTypeList.length)
|
||||
this.previousTags = [...this.selectedTags];
|
||||
// 当输入框获得焦点时,加载默认的搜索结果
|
||||
if (this.sysTypeList.length > 0) {
|
||||
await this.doSearch('');
|
||||
@@ -172,16 +185,27 @@ export default {
|
||||
},
|
||||
|
||||
// 新增:处理选择变化事件
|
||||
handleSelectionChange() {
|
||||
this.$emit('change', this.displayTags)
|
||||
// 选择标签后清空输入框
|
||||
handleSelectionChange(newValues) {
|
||||
// 检查数量限制
|
||||
if (newValues.length > this.maxTags) {
|
||||
this.$message.warning(`最多只能选择${this.maxTags}个标签`);
|
||||
// 回滚到之前的状态
|
||||
this.selectedTags = [...this.previousTags];
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新前保存当前状态
|
||||
this.previousTags = [...newValues];
|
||||
this.$emit('change', this.displayTags);
|
||||
|
||||
if (this.$refs.tagSelect) {
|
||||
const input = this.$refs.tagSelect.$refs.input
|
||||
const input = this.$refs.tagSelect.$refs.input;
|
||||
if (input) {
|
||||
input.value = ''
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//创建新标签
|
||||
async createNewTag(tagName) {
|
||||
// 标签不能超过八个字
|
||||
|
||||
@@ -2694,7 +2694,7 @@ a.custom2 {
|
||||
gap: 15px;
|
||||
align-items: center;
|
||||
padding-top: 2px;
|
||||
margin-left: 90px; /* 为"热点标签:"文本留出空间 */
|
||||
//margin-left: 90px; /* 为"热点标签:"文本留出空间 */
|
||||
}
|
||||
|
||||
/* 调整option-item样式以适应换行布局 */
|
||||
|
||||
Reference in New Issue
Block a user