From 86d73417b727a63c1fb0d188996fa85db2cf1240 Mon Sep 17 00:00:00 2001 From: maxmon <541182180@qq.com> Date: Thu, 7 Apr 2022 22:14:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ner):=20=E5=8F=B3=E4=BE=A7=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=A0=87=E7=AD=BE=E9=BC=A0=E6=A0=87=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fe/src/components/NER/index.vue | 47 ++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/fe/src/components/NER/index.vue b/fe/src/components/NER/index.vue index ba5c3d0..92e1324 100644 --- a/fe/src/components/NER/index.vue +++ b/fe/src/components/NER/index.vue @@ -118,7 +118,9 @@ backgroundColor: types[ner.type] ? types[ner.type].color : `#fff`, }" > - {{ ner.name }} + {{ ner.name }} + + @@ -253,6 +255,9 @@ export default { } }, methods: { + log (...args) { + console.log(args) + }, // 获取文件列表 getFiles () { const that = this @@ -484,6 +489,19 @@ export default { } this.$set(this, 'wordsOutType', this.wordsOutType) }, + delIdx: function (idx) { + const ners = this.ners + for (let i = ners.length - 1; i >= 0; i -= 1) { + const ner = ners[i] + if (idx >= ner.start && idx < ner.end) { + ners.splice(i, 1) + this.$set(this, 'ners', ners) + this.flushWordsType() + this.save() // 删除时实时保存 + return true + } + } + }, startSelect: function (idx, event) { if (this.projectType !== '命名实体识别') return let isNeedDel = false @@ -501,17 +519,7 @@ export default { if (isNeedDel) { event.preventDefault() // 右键删除对应的图标 - const ners = this.ners - for (let i = ners.length - 1; i >= 0; i -= 1) { - const ner = ners[i] - if (idx >= ner.start && idx < ner.end) { - ners.splice(i, 1) - this.$set(this, 'ners', ners) - this.flushWordsType() - this.save() // 删除时实时保存 - return true - } - } + this.delIdx(idx) return true } this.setMode('select') @@ -948,6 +956,7 @@ export default { width: 120px; } .result { + position: relative; overflow: hidden; padding: 0 4px; height: 22px; @@ -973,6 +982,20 @@ export default { .result-name { width: calc(100% - 8px); } +.result-name-del { + display: none; + vertical-align: text-bottom; + position: absolute; + right: 0px; + top: 2px; +} +.result-name-del:hover { + cursor: pointer; + opacity: .6; +} +.result-name:hover .result-name-del { + display: inline-block; +} .word-rect-area { position: absolute;