diff --git a/apps/dataset/serializers/paragraph_serializers.py b/apps/dataset/serializers/paragraph_serializers.py index 0b69e8e3f..c3e1fea1c 100644 --- a/apps/dataset/serializers/paragraph_serializers.py +++ b/apps/dataset/serializers/paragraph_serializers.py @@ -437,6 +437,9 @@ class ParagraphSerializers(ApiMixin, serializers.Serializer): ParagraphSerializers.Create.or_get(exists_problem_list, problem.get('content'), dataset_id) for problem in ( 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 = [ ProblemParagraphMapping(id=uuid.uuid1(), document_id=document_id, problem_id=problem_model.id, diff --git a/ui/src/views/paragraph/component/ProblemComponent.vue b/ui/src/views/paragraph/component/ProblemComponent.vue index aec770ffa..cef42b4e1 100644 --- a/ui/src/views/paragraph/component/ProblemComponent.vue +++ b/ui/src/views/paragraph/component/ProblemComponent.vue @@ -149,6 +149,15 @@ function addProblemHandle(val: string) { problemValue.value = '' 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 } }