mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 11:26:43 +08:00
调整
This commit is contained in:
@@ -2,21 +2,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tag-container">
|
<div class="tag-container">
|
||||||
<el-select style="width: 100%;"
|
<el-select style="width: 100%;"
|
||||||
v-model="selectedTags"
|
v-model="selectedTags"
|
||||||
multiple
|
multiple
|
||||||
filterable
|
filterable
|
||||||
value-key="id"
|
value-key="id"
|
||||||
remote
|
default-first-option
|
||||||
reserve-keyword
|
remote
|
||||||
:remote-method="debouncedSearch"
|
reserve-keyword
|
||||||
:loading="loading"
|
:remote-method="debouncedSearch"
|
||||||
:placeholder="'回车创建新标签'"
|
:loading="loading"
|
||||||
@remove-tag="handleTagRemove"
|
:placeholder="'回车创建新标签'"
|
||||||
@change="handleSelectionChange"
|
@remove-tag="handleTagRemove"
|
||||||
@keyup.enter.native="handleEnterKey"
|
@change="handleSelectionChange"
|
||||||
@keyup.delete.native="handleDeleteKey"
|
|
||||||
@focus="handleFocus"
|
|
||||||
ref="tagSelect"
|
@focus="handleFocus"
|
||||||
|
ref="tagSelect"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in searchResults"
|
v-for="item in searchResults"
|
||||||
@@ -168,26 +169,26 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
//按回车键,创建新标签
|
//按回车键,创建新标签
|
||||||
handleEnterKey(event) {
|
// handleEnterKey(event) {
|
||||||
const inputVal = event.target.value?.trim()
|
// const inputVal = event.target.value?.trim()
|
||||||
if (!inputVal) return;
|
// if (!inputVal) return;
|
||||||
// 检查是否与已选择的标签重复
|
// // 检查是否与已选择的标签重复
|
||||||
const isDuplicate = this.selectedTags.some(tag => tag.tagName === inputVal);
|
// const isDuplicate = this.selectedTags.some(tag => tag.tagName === inputVal);
|
||||||
if (isDuplicate) {
|
// if (isDuplicate) {
|
||||||
this.$message.warning('该标签已存在,无需重复创建');
|
// this.$message.warning('该标签已存在,无需重复创建');
|
||||||
event.target.value = '';
|
// event.target.value = '';
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) {
|
// if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) {
|
||||||
this.createNewTag(event.target.value.trim())
|
// 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个标签')
|
||||||
this.clearInput();
|
// this.clearInput();
|
||||||
} else {
|
// } else {
|
||||||
this.clearInput();
|
// this.clearInput();
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
|
|
||||||
// 新增:处理选择变化事件
|
// 新增:处理选择变化事件
|
||||||
handleSelectionChange(newValues) {
|
handleSelectionChange(newValues) {
|
||||||
@@ -273,10 +274,10 @@ export default {
|
|||||||
console.log("---- doSearch ------ query = " + query )
|
console.log("---- doSearch ------ query = " + query )
|
||||||
this.loading = true
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
// 获取 typeId:取 sysTypeList 最后一个有效的值
|
// 获取 typeId:取 sysTypeList 最后一个有效的值
|
||||||
const typeId = this.sysTypeList.length > 2 ? this.sysTypeList[2] :
|
const typeId = this.sysTypeList.length > 2 ? this.sysTypeList[2] :
|
||||||
this.sysTypeList.length > 1 ? this.sysTypeList[1] :
|
this.sysTypeList.length > 1 ? this.sysTypeList[1] :
|
||||||
this.sysTypeList.length > 0 ? this.sysTypeList[0] : null;
|
this.sysTypeList.length > 0 ? this.sysTypeList[0] : null;
|
||||||
console.log("---- doSearch searchTags ------ query = " + query + " , typeId = " + typeId )
|
console.log("---- doSearch searchTags ------ query = " + query + " , typeId = " + typeId )
|
||||||
const {result:tags} = await apiCourseTag.searchTags({tagName:query,typeId:typeId})
|
const {result:tags} = await apiCourseTag.searchTags({tagName:query,typeId:typeId})
|
||||||
console.log("-- searchTags 查询结果 tags = " + tags )
|
console.log("-- searchTags 查询结果 tags = " + tags )
|
||||||
|
|||||||
Reference in New Issue
Block a user