Skip to content

Commit 3afdab8

Browse files
authored
fix: 添加分段时无法关联问题 #53 (#66)
1 parent f19e78b commit 3afdab8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

apps/dataset/serializers/paragraph_serializers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ def get_paragraph_problem_model(dataset_id: str, document_id: str, instance: Dic
437437
ParagraphSerializers.Create.or_get(exists_problem_list, problem.get('content'), dataset_id) for
438438
problem in (
439439
instance.get('problem_list') if 'problem_list' in instance else [])]
440+
# 问题去重
441+
problem_model_list = [x for i, x in enumerate(problem_model_list) if
442+
len([item for item in problem_model_list[:i] if item.content == x.content]) <= 0]
440443

441444
problem_paragraph_mapping_list = [
442445
ProblemParagraphMapping(id=uuid.uuid1(), document_id=document_id, problem_id=problem_model.id,

ui/src/views/paragraph/component/ProblemComponent.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ function addProblemHandle(val: string) {
149149
problemValue.value = ''
150150
isAddProblem.value = false
151151
})
152+
} else {
153+
const problem = problemOptions.value.find((option) => option.id === val)
154+
const content = problem ? problem.content : val
155+
if (!problemList.value.some((item) => item.content === content)) {
156+
problemList.value.push({ content: content })
157+
}
158+
159+
problemValue.value = ''
160+
isAddProblem.value = false
152161
}
153162
}
154163

0 commit comments

Comments
 (0)