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