Skip to content

Commit

Permalink
Merge pull request #4565 from mikhailprivalov/consturctor-laboratory-…
Browse files Browse the repository at this point in the history
…search

Конструктор лаборатории - улучшения и исправления v2
  • Loading branch information
urchinpro authored Dec 16, 2024
2 parents f1c5368 + 465e427 commit 5956579
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/construct/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_lab_ref_books(request):
materials = LaboratoryMaterial.get_materials()
subgroups = SubGroupPadrazdeleniye.get_subgroup_podrazdeleniye(request_data["departmentId"])
variants = ResultVariants.get_all()
tubes = Tubes.get_all()
tubes = Tubes.get_all(True)
relations_tubes = ReleationsFT.get_all_relation()
result = {"units": units, "materials": materials, "subGroups": subgroups, "variants": variants, "tubes": tubes, "relations": relations_tubes}
return JsonResponse({"result": result})
Expand Down
12 changes: 6 additions & 6 deletions directory/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def get_or_create_relation(relation_data):

@staticmethod
def get_all_relation():
relations = ReleationsFT.objects.all()
data = [{"id": i.pk, "label": f"{i.tube.title}-({i.pk})"} for i in relations]
relations = ReleationsFT.objects.all().select_related('tube').order_by('tube__title')
data = [{"id": i.pk, "label": f"{i.tube.title} ({i.pk})", "color": i.tube.color} for i in relations]
return data


Expand Down Expand Up @@ -584,10 +584,10 @@ def get_site_type_id(self):
return self.site_type_id

@staticmethod
def as_json(research):
def as_json(research, pk_in_title=False):
result = {
"pk": research.pk,
"title": research.title,
"title": research.title if not pk_in_title else f"{research.title} ({research.pk})",
"internalCode": research.internal_code,
"code": research.code,
"hide": research.hide,
Expand Down Expand Up @@ -658,10 +658,10 @@ def get_tubes(podrazdelenie_id: int):
tubes_info = [value for _, value in research_tubes.items()]
tubes_keys = tuple(research_tubes.keys())
if tubes.get(tubes_keys):
tubes[tubes_keys]["researches"].append(research.as_json(research))
tubes[tubes_keys]["researches"].append(research.as_json(research, True))
else:
tubes[tubes_keys] = {
"researches": [research.as_json(research)],
"researches": [research.as_json(research, True)],
"tubes": tubes_info,
}

Expand Down
22 changes: 21 additions & 1 deletion l2-frontend/src/construct/FractionsGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,27 @@
:options="props.tubesData"
:multiple="false"
class="treeselect-wide treeselect-26px"
/>
placeholder="Выберите пробирку"
>
<div
slot="value-label"
slot-scope="{ node }"
>
<ColorTitled
:title="node.label"
:color="node.raw.color"
/>
</div>
<div
slot="option-label"
slot-scope="{ node }"
>
<ColorTitled
:title="node.label"
:color="node.raw.color"
/>
</div>
</Treeselect>
</div>
<table class="table">
<colgroup>
Expand Down
6 changes: 3 additions & 3 deletions researches/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ def get_short_title(self):
return pr

@staticmethod
def get_all():
def get_all(pk_in_title=False):
result = [
{
"id": tube.pk,
"label": f"{tube.title} - tube.pk",
"label": tube.title if not pk_in_title else f"{tube.title} ({tube.pk})",
"color": tube.color,
}
for tube in Tubes.objects.all()
for tube in Tubes.objects.all().order_by("title")
]
return result

Expand Down

0 comments on commit 5956579

Please sign in to comment.