mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-17 06:46:43 +08:00
调试
This commit is contained in:
@@ -26,6 +26,12 @@
|
|||||||
:disabled="isTagDisabled(item)"
|
:disabled="isTagDisabled(item)"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<div style="margin-top: 10px; font-size: 12px; color: #666;">
|
||||||
|
<div>调试信息 - selectedTags:</div>
|
||||||
|
<div v-for="(tag, index) in selectedTags" :key="tag.id">
|
||||||
|
{{ index }}: {{ tag.tagName }} ({{ tag.id }})
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- 添加标签计数显示 -->
|
<!-- 添加标签计数显示 -->
|
||||||
<div class="tag-count">
|
<div class="tag-count">
|
||||||
{{ selectedTags.length }}/5
|
{{ selectedTags.length }}/5
|
||||||
@@ -214,7 +220,15 @@ export default {
|
|||||||
|
|
||||||
// 新增:处理选择变化事件
|
// 新增:处理选择变化事件
|
||||||
handleSelectionChange(newValues) {
|
handleSelectionChange(newValues) {
|
||||||
console.log("----------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}个标签`);
|
||||||
@@ -279,35 +293,42 @@ export default {
|
|||||||
this.params.sysType3 = this.sysTypeList[2]; //三级的id
|
this.params.sysType3 = this.sysTypeList[2]; //三级的id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('添加前的selectedTags:', this.selectedTags);
|
||||||
|
console.log('添加前的searchResults:', this.searchResults);
|
||||||
|
|
||||||
const {result:newTag} = await apiCourseTag.createTag(this.params)
|
const {result:newTag} = await apiCourseTag.createTag(this.params)
|
||||||
console.log('API返回的新标签对象:', newTag);
|
console.log('API返回的新标签对象:', newTag);
|
||||||
console.log('标签ID:', newTag?.id);
|
console.log('标签ID:', newTag?.id);
|
||||||
console.log('标签名称:', newTag?.tagName);
|
console.log('标签名称:', newTag?.tagName);
|
||||||
console.log('标签完整结构:', JSON.stringify(newTag));
|
console.log('标签完整结构:', JSON.stringify(newTag));
|
||||||
if (!newTag?.id || !newTag?.tagName) {
|
|
||||||
console.error('API返回的标签数据不完整');
|
|
||||||
this.$message.error('标签创建失败:返回数据不完整');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$message.success('标签创建成功',newTag);
|
this.$message.success('标签创建成功',newTag);
|
||||||
|
|
||||||
const tagObject = {
|
this.selectedTags = [...this.selectedTags, newTag];
|
||||||
id: newTag.id,
|
// 更新搜索结果的逻辑保持不变
|
||||||
tagName: newTag.tagName,
|
this.searchResults = [newTag, ...this.searchResults];
|
||||||
// 如果有其他必要字段也加上
|
this.tagMap.set(newTag.id, newTag);
|
||||||
...newTag
|
|
||||||
};
|
|
||||||
|
|
||||||
this.selectedTags.push(newTag);
|
|
||||||
this.searchResults.push(newTag)
|
|
||||||
this.tagMap.set(newTag.id, newTag)
|
|
||||||
|
|
||||||
console.log('添加后的selectedTags:', this.selectedTags);
|
console.log('添加后的selectedTags:', this.selectedTags);
|
||||||
console.log('添加后的searchResults:', this.searchResults);
|
// 触发change事件
|
||||||
|
this.$emit('change', this.displayTags);
|
||||||
|
|
||||||
|
// 强制更新el-select组件
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.tagSelect) {
|
||||||
|
// 强制重新渲染选择器
|
||||||
|
this.$refs.tagSelect.$forceUpdate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// this.$nextTick(() => {
|
||||||
|
// // 强制重新设置selectedTags来触发更新
|
||||||
|
// const tempTags = [...this.selectedTags];
|
||||||
|
// this.selectedTags = [];
|
||||||
|
// this.$nextTick(() => {
|
||||||
|
// this.selectedTags = tempTags;
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
this.$emit('change', this.displayTags)
|
|
||||||
this.doSearch('');
|
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user