From 4449b2b380ded1eeebddf2b5e15121f217207969 Mon Sep 17 00:00:00 2001 From: laoluo <375119293@qq.com> Date: Tue, 21 Sep 2021 16:39:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A0=87=E7=AD=BE=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=88=9D=E5=A7=8B=E5=8C=96=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/core/toolOperation/tagOperation.ts | 14 +++++++++++--- .../lb-components/src/store/annotation/reducer.ts | 11 +++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/lb-annotation/src/core/toolOperation/tagOperation.ts b/packages/lb-annotation/src/core/toolOperation/tagOperation.ts index f99cdc1c4..85b382b22 100644 --- a/packages/lb-annotation/src/core/toolOperation/tagOperation.ts +++ b/packages/lb-annotation/src/core/toolOperation/tagOperation.ts @@ -28,7 +28,7 @@ class TagOperation extends BasicToolOperation { } public setResult(tagResult: any[], isInitData = false) { - if (isInitData === true) { + if (isInitData === true && tagResult.length === 0) { // 注意,该获取方式是需要拉取所有的 basicResultList tagResult = TagUtils.getDefaultTagResult(this.config.inputList, []); } @@ -37,11 +37,14 @@ class TagOperation extends BasicToolOperation { this.render(); } + /** + * 当前页面的标注结果 + */ public get currentTagResult() { return this.tagResult.filter((v) => { const basicSourceID = `${v.sourceID}`; return basicSourceID === this.sourceID; - })[0]; + })[0] || {}; } public onKeyDown(e: KeyboardEvent) { @@ -96,6 +99,11 @@ class TagOperation extends BasicToolOperation { return; } + if (!this.basicResult && this.dependToolName) { + // 有依赖情况下无依赖结果则不允许进行标注 + return; + } + const labelInfoSet = this.config.inputList; if (!labelInfoSet[i]) { @@ -218,7 +226,7 @@ class TagOperation extends BasicToolOperation { } const dom = document.createElement('div'); - const tagInfoList = TagUtils.getTagNameList(this.currentTagResult.result, this.config.inputList); + const tagInfoList = TagUtils.getTagNameList(this.currentTagResult.result || {}, this.config.inputList); dom.innerHTML = tagInfoList.reduce((acc: string, cur: { keyName: string; value: string[] }) => { diff --git a/packages/lb-components/src/store/annotation/reducer.ts b/packages/lb-components/src/store/annotation/reducer.ts index 53978d6da..18bf3174b 100644 --- a/packages/lb-components/src/store/annotation/reducer.ts +++ b/packages/lb-components/src/store/annotation/reducer.ts @@ -47,7 +47,6 @@ const calcStepProgress = (fileList: any[], step: number) => return pre; }, 0) / fileList.length; - const updateToolInstance = (annotation: AnnotationState, imgNode: HTMLImageElement) => { const { step, stepList } = annotation; const stepConfig = StepUtils.getCurrentStepInfo(step, stepList); @@ -206,6 +205,10 @@ export const annotationReducer = ( const dependStepConfig = getStepConfig(stepList, dataSourceStep); let stepBasicResultList = []; + // 当前步骤结果 + const stepResult = fileResult[`step_${step}`]; + const isInitData = !stepResult; // 是否为初始化数据 + if (dataSourceStep && tool) { stepBasicResultList = fileResult[`step_${dataSourceStep}`]?.result; @@ -219,8 +222,7 @@ export const annotationReducer = ( } } - toolInstance.setResult(result); - + toolInstance.setResult(result, isInitData); toolInstance.history.initRecord(result, true); return { @@ -366,9 +368,10 @@ export const annotationReducer = ( // 更新当前的结果 const fileResult = jsonParser(newResult); const stepResult = fileResult[`step_${step}`]; + const isInitData = !stepResult; const result = stepResult?.result || []; - toolInstance.setResult(result); + toolInstance.setResult(result, isInitData); toolInstance.history.pushHistory(result); return {