mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-07 01:46:42 +08:00
修复管理端创建标签时字数限制为8个字
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
:disabled="sysTypeList.length===0"
|
||||
placeholder="按回车键Enter创建标签"
|
||||
@remove-tag="handleTagRemove"
|
||||
@change="handleSelectionChange"
|
||||
@keyup.enter.native="handleEnterKey"
|
||||
>
|
||||
<el-option
|
||||
@@ -22,18 +23,6 @@
|
||||
:value="item"
|
||||
/>
|
||||
</el-select>
|
||||
<!-- 预览 ---
|
||||
<div class="tag-preview">
|
||||
<el-tag
|
||||
v-for="tag in displayTags"
|
||||
:key="tag.id"
|
||||
closable
|
||||
@close="removeTag(tag.id)"
|
||||
>
|
||||
{{ tag.tagName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -116,8 +105,17 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// 新增:处理选择变化事件
|
||||
handleSelectionChange() {
|
||||
this.$emit('change', this.displayTags)
|
||||
},
|
||||
//创建新标签
|
||||
async createNewTag(tagName) {
|
||||
// 标签不能超过八个字
|
||||
if (tagName.length > 8) {
|
||||
this.$message.error('标签不能超过8个字')
|
||||
return;
|
||||
}
|
||||
this.loading = true
|
||||
try {
|
||||
this.params.courseId = this.courseId;
|
||||
@@ -134,8 +132,10 @@ export default {
|
||||
}
|
||||
const {result:newTag} = await apiCourseTag.createTag(this.params)
|
||||
this.tagMap.set(newTag.id, newTag)
|
||||
this.selectedTags.push(newTag.tagName)
|
||||
this.$emit('change', this.selectedTags.map(tag => tag.id))
|
||||
// 修复:存储完整的标签对象,而不是名称
|
||||
this.selectedTags.push(newTag)
|
||||
// 修复:正确传递标签对象数组
|
||||
this.$emit('change', this.displayTags)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user