From 06a68a14c5073b6f4f896422101c4bed385af14f Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Fri, 5 Dec 2025 15:36:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E6=B3=A8=E6=97=B6=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../image-captioning-library/index.vue | 1 + .../components/HistoryView.vue | 1 + .../components/ImageResults.vue | 92 ++++++++ .../components/TagSelector.vue | 203 ++++++++++++------ .../components/TagSelectorOld.vue | 95 ++++++++ .../image-captioning/index.vue | 23 +- 6 files changed, 345 insertions(+), 70 deletions(-) create mode 100644 src/views/imageCaptioning/image-captioning/components/TagSelectorOld.vue diff --git a/src/views/imageCaptioning/image-captioning-library/index.vue b/src/views/imageCaptioning/image-captioning-library/index.vue index beb8a72..20548cc 100644 --- a/src/views/imageCaptioning/image-captioning-library/index.vue +++ b/src/views/imageCaptioning/image-captioning-library/index.vue @@ -21,6 +21,7 @@ placeholder="请选择" clearable filterable + allow-create style="width: 240px" > diff --git a/src/views/imageCaptioning/image-captioning/components/ImageResults.vue b/src/views/imageCaptioning/image-captioning/components/ImageResults.vue index 7a6d91b..02e1967 100644 --- a/src/views/imageCaptioning/image-captioning/components/ImageResults.vue +++ b/src/views/imageCaptioning/image-captioning/components/ImageResults.vue @@ -289,6 +289,35 @@ {{ option.label }} + + +
+ + {{ tag }} + + + + + 其他 +
@@ -446,6 +475,9 @@ export default { imgSrc: '', isSure: null, + newTagsList: [], + inputVisible: false, + inputValue: '', } }, created() { @@ -962,6 +994,49 @@ export default { })) }) }, + + handleClose(tag) { + this.newTagsList.splice(this.newTagsList.indexOf(tag), 1) + // 根据value删除annotationTypeOptions中的数据 + this.annotationTypeOptions = this.annotationTypeOptions.filter( + (item) => item.value !== tag, + ) + }, + + showInput() { + this.inputVisible = true + this.$nextTick((_) => { + this.$refs.saveTagInput.$refs.input.focus() + }) + }, + + handleInputConfirm() { + let inputValue = this.inputValue + + // 根据inputValue在annotationTypeOptions中查找是否存在 + const index = this.annotationTypeOptions.findIndex( + (item) => item.value === inputValue, + ) + if (index === -1) { + this.newTagsList.push(inputValue) + this.annotationTypeOptions.push({ + label: inputValue, + value: inputValue, + }) + } else { + this.$message.warning('标签已存在') + return + } + // if (inputValue) { + // this.newTagsList.push(inputValue) + // this.annotationTypeOptions.push({ + // label: inputValue, + // value: inputValue, + // }) + // } + this.inputVisible = false + this.inp + }, }, } @@ -1067,6 +1142,7 @@ export default { display: flex; align-items: center; gap: 12px; + flex-wrap: wrap; } .annotation-type .label { @@ -1262,4 +1338,20 @@ el-image { font-size: 30px; } } + +.input-new-tag { + width: 90px; + margin-left: 10px; + vertical-align: bottom; +} +.el-tag + .el-tag { + margin-left: 10px; +} +.button-new-tag { + margin-left: 10px; + height: 32px; + line-height: 30px; + padding-top: 0; + padding-bottom: 0; +} diff --git a/src/views/imageCaptioning/image-captioning/components/TagSelector.vue b/src/views/imageCaptioning/image-captioning/components/TagSelector.vue index 909f082..2738a40 100644 --- a/src/views/imageCaptioning/image-captioning/components/TagSelector.vue +++ b/src/views/imageCaptioning/image-captioning/components/TagSelector.vue @@ -1,95 +1,164 @@ diff --git a/src/views/imageCaptioning/image-captioning/components/TagSelectorOld.vue b/src/views/imageCaptioning/image-captioning/components/TagSelectorOld.vue new file mode 100644 index 0000000..909f082 --- /dev/null +++ b/src/views/imageCaptioning/image-captioning/components/TagSelectorOld.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/src/views/imageCaptioning/image-captioning/index.vue b/src/views/imageCaptioning/image-captioning/index.vue index ea3804d..01678a0 100644 --- a/src/views/imageCaptioning/image-captioning/index.vue +++ b/src/views/imageCaptioning/image-captioning/index.vue @@ -24,6 +24,7 @@ :visible-tags="visibleTags" :selected-tag="selectedTag" @toggle-tag="toggleTag" + @new-tag-change="newTagChange" @toggle-all-tags="toggleAllTags" /> @@ -61,6 +62,7 @@ @hand-click="handleHandClick" @confirm-results="confirmResults" @toggle-tag="toggleTag" + @new-tag-change="newTagChange" @toggle-all-tags="toggleAllTags" @file-change="handleFileChange" @remove-image="removeImage" @@ -119,6 +121,8 @@ export default { groupedImageResults: [], // 新增分组数据 remarkInfo: '', // 备注信息 + + newTagsList: [], // 新增标签列表 } }, @@ -140,7 +144,9 @@ export default { id: item.id, name: item.name, })) - this.visibleTags = this.tags.slice(0, 3) + // this.visibleTags = this.tags.slice(0, 3) + console.log('this.tags:', this.tags) + this.visibleTags = this.tags } else { console.error('获取标签列表失败:', res) this.tags = [] @@ -190,9 +196,16 @@ export default { const selectedTagIds = this.selectedTag .map((tag) => tag.id) .join(',') - const selectedTagNames = this.selectedTag + let selectedTagNames = this.selectedTag .map((tag) => tag.name) .join(',') + + let newTagsNames = '' + if (this.newTagsList.length > 0) { + newTagsNames = this.newTagsList.join(',') + selectedTagNames = `${selectedTagNames},${newTagsNames}` + } + console.log('选中的标签IDs:', selectedTagIds) console.log('选中的标签名称:', selectedTagNames) if (this.fileList.length === 0) { @@ -344,10 +357,14 @@ export default { } if (!this.showAllTags) { - this.updateVisibleTagsInCollapsedState() + // this.updateVisibleTagsInCollapsedState() } }, + newTagChange(newTagsList) { + this.newTagsList = newTagsList + }, + updateVisibleTagsInCollapsedState() { const selectedTags = this.selectedTag || [] const defaultTags = this.tags.slice(0, 3)