fix: 添加分段时无法关联问题 #53 (#66)

This commit is contained in:
shaohuzhang1 2024-04-15 13:23:37 +08:00 committed by GitHub
parent f19e78b692
commit 3afdab8acf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -437,6 +437,9 @@ class ParagraphSerializers(ApiMixin, serializers.Serializer):
ParagraphSerializers.Create.or_get(exists_problem_list, problem.get('content'), dataset_id) for ParagraphSerializers.Create.or_get(exists_problem_list, problem.get('content'), dataset_id) for
problem in ( problem in (
instance.get('problem_list') if 'problem_list' in instance else [])] instance.get('problem_list') if 'problem_list' in instance else [])]
# 问题去重
problem_model_list = [x for i, x in enumerate(problem_model_list) if
len([item for item in problem_model_list[:i] if item.content == x.content]) <= 0]
problem_paragraph_mapping_list = [ problem_paragraph_mapping_list = [
ProblemParagraphMapping(id=uuid.uuid1(), document_id=document_id, problem_id=problem_model.id, ProblemParagraphMapping(id=uuid.uuid1(), document_id=document_id, problem_id=problem_model.id,

View File

@ -149,6 +149,15 @@ function addProblemHandle(val: string) {
problemValue.value = '' problemValue.value = ''
isAddProblem.value = false isAddProblem.value = false
}) })
} else {
const problem = problemOptions.value.find((option) => option.id === val)
const content = problem ? problem.content : val
if (!problemList.value.some((item) => item.content === content)) {
problemList.value.push({ content: content })
}
problemValue.value = ''
isAddProblem.value = false
} }
} }