diff --git a/api/construct/urls.py b/api/construct/urls.py index cc8c4b0911..e10c83a369 100644 --- a/api/construct/urls.py +++ b/api/construct/urls.py @@ -3,11 +3,12 @@ from . import views urlpatterns = [ - path('laboratory/get-departments', views.get_departments), + path('laboratory/get-departments', views.get_lab_departments), path('laboratory/get-tubes', views.get_tubes), path('laboratory/update-order-research', views.update_order_research), path('laboratory/update-order-fraction', views.update_order_fraction), path('laboratory/change-visibility-research', views.change_visibility_research), - path('laboratory/get-research', views.get_research), - path('laboratory/update-research', views.update_research), + path('laboratory/get-research', views.get_lab_research), + path('laboratory/update-research', views.update_lab_research), + path('laboratory/get-ref-books', views.get_lab_ref_books), ] diff --git a/api/construct/views.py b/api/construct/views.py index e4ed477bad..edf2365d0f 100644 --- a/api/construct/views.py +++ b/api/construct/views.py @@ -1,7 +1,7 @@ from django.contrib.auth.decorators import login_required from django.http import JsonResponse import simplejson as json -from directory.models import Researches, Fractions +from directory.models import Researches, Fractions, Unit, LaboratoryMaterial, SubGroup from laboratory.decorators import group_required from podrazdeleniya.models import Podrazdeleniya from utils.response import status_response @@ -9,7 +9,7 @@ @login_required @group_required("Конструктор: Лабораторные исследования") -def get_departments(request): +def get_lab_departments(request): result = Podrazdeleniya.get_podrazdeleniya(Podrazdeleniya.LABORATORY) return JsonResponse({"result": result}) @@ -48,7 +48,7 @@ def change_visibility_research(request): @login_required @group_required("Конструктор: Лабораторные исследования") -def get_research(request): +def get_lab_research(request): request_data = json.loads(request.body) result = Researches.get_research(request_data["researchPk"]) return JsonResponse({"result": result}) @@ -56,7 +56,17 @@ def get_research(request): @login_required @group_required("Конструктор: Лабораторные исследования") -def update_research(request): +def update_lab_research(request): request_data = json.loads(request.body) result = Researches.update_lab_research(request_data["research"]) return status_response(result) + + +@login_required +@group_required("Конструктор: Лабораторные исследования") +def get_lab_ref_books(request): + units = Unit.get_units() + materials = LaboratoryMaterial.get_materials() + subgroups = SubGroup.get_groups() + result = {"units": units, "materials": materials, "subgroups": subgroups} + return JsonResponse({"result": result}) diff --git a/directory/models.py b/directory/models.py index 1c7a12936e..1ed6b8a7c8 100644 --- a/directory/models.py +++ b/directory/models.py @@ -140,6 +140,11 @@ class LaboratoryMaterial(models.Model): def __str__(self): return "%s" % self.title + @staticmethod + def get_materials(): + result = [{"id": material.pk, "label": material.title} for material in LaboratoryMaterial.objects.all()] + return result + class Meta: verbose_name = 'Биоматериал' verbose_name_plural = 'Биоматериалы' @@ -151,6 +156,11 @@ class SubGroup(models.Model): def __str__(self): return "%s" % self.title + @staticmethod + def get_groups(): + result = [{"id": group.pk, "label": group.title} for group in SubGroup.objects.all()] + return result + class Meta: verbose_name = 'Погруппа услуги' verbose_name_plural = 'Подгруппы услуг' @@ -526,7 +536,7 @@ def as_json(research): @staticmethod def get_tube_data(research_pk: int, need_fractions: bool = False) -> dict: - fractions = Fractions.objects.filter(research_id=research_pk).select_related('relation__tube').order_by('sort_weight') + fractions = Fractions.objects.filter(research_id=research_pk).select_related('relation__tube', 'unit', 'variants').order_by('sort_weight') research_tubes = {} for fraction in fractions: if research_tubes.get(fraction.relation_id) and need_fractions: @@ -603,8 +613,12 @@ def get_research(research_pk: int): "shortTitle": research.short_title, "code": research.code, "internalCode": research.internal_code, - "ecpCode": research.ecp_id, + "ecpId": research.ecp_id, "preparation": research.preparation, + "departmentId": research.podrazdeleniye_id, + "laboratoryMaterialId": research.laboratory_material_id, + "subGroupId": research.sub_group_id, + "laboratoryDuration": research.laboratory_duration, "tubes": [value for _, value in research_tubes.items()], } return result @@ -616,16 +630,21 @@ def update_lab_research(research_data): for tube in research_data["tubes"]: for fraction in tube["fractions"]: current_fractions = fractions.get(pk=fraction["pk"]) - current_fractions.title = fraction["title"] - current_fractions.ecp_id = fraction["ecpCode"] + current_fractions.title = fraction["title"].strip() + current_fractions.ecp_id = fraction["ecpId"].strip() current_fractions.fsli = fraction["fsli"] + current_fractions.unit_id = fraction["unitId"] current_fractions.save() - research.title = research_data["title"] - research.short_title = research_data["shortTitle"] - research.code = research_data["code"] - research.ecp_id = research_data["ecpCode"] - research.internal_code = research_data["internalCode"] + research.title = research_data["title"].strip() + research.short_title = research_data["shortTitle"].strip() + research.code = research_data["code"].strip() + research.ecp_id = research_data["ecpId"].strip() + research.internal_code = research_data["internalCode"].strip() research.preparation = research_data["preparation"] + research.podrazdeleniye_id = research_data["departmentId"] + research.laboratory_material_id = research_data["laboratoryMaterialId"] + research.sub_group_id = research_data["subGroupId"] + research.laboratory_duration = research_data["laboratoryDuration"] research.save() return True @@ -998,6 +1017,17 @@ class Unit(models.Model): hide = models.BooleanField(default=False, blank=True, verbose_name='Скрытие') ucum = models.CharField(max_length=55, default='', blank=True, verbose_name='UCUM') + @staticmethod + def get_units(): + result = [ + { + "id": unit.pk, + "label": unit.title, + } + for unit in Unit.objects.filter(hide=False) + ] + return result + def __str__(self) -> str: return f"{self.code} — {self.short_title} – {self.title}" @@ -1062,11 +1092,10 @@ def as_json(fraction) -> dict: result = { "pk": fraction.pk, "title": fraction.title, - "unit": fraction.unit.title if fraction.unit else "", - "variants": fraction.variants.get_variants() if fraction.variants else "", - "order": fraction.sort_weight, - "ecpCode": fraction.ecp_id, + "unitId": fraction.unit_id, + "ecpId": fraction.ecp_id, "fsli": fraction.fsli, + "order": fraction.sort_weight, } return result diff --git a/l2-frontend/src/construct/ConstructLaboratory.vue b/l2-frontend/src/construct/ConstructLaboratory.vue index 282018db1a..664d0da3f7 100644 --- a/l2-frontend/src/construct/ConstructLaboratory.vue +++ b/l2-frontend/src/construct/ConstructLaboratory.vue @@ -16,7 +16,7 @@
@@ -55,27 +59,24 @@ import { import Treeselect from '@riophae/vue-treeselect'; import '@riophae/vue-treeselect/dist/vue-treeselect.css'; -import TubeGroup from '@/construct/TubeGroup.vue'; + import { useStore } from '@/store'; import * as actions from '@/store/action-types'; import api from '@/api'; import ResearchDetail from '@/construct/ResearchDetail.vue'; +import ResearchesGroup from '@/construct/ResearchesGroup.vue'; const store = useStore(); const root = getCurrentInstance().proxy.$root; const department = ref(null); -const departments = ref([ - { id: 1, label: 'отделение1' }, -]); +const departments = ref([]); const getDepartments = async () => { await store.dispatch(actions.INC_LOADING); const { result } = await api('construct/laboratory/get-departments'); await store.dispatch(actions.DEC_LOADING); - result.push({ - id: -1, label: 'Все', - }); + result.unshift({ id: -1, label: 'Все' }); departments.value = result; }; @@ -92,7 +93,7 @@ const getTubes = async () => { const currentResearchPk = ref(null); -const edit = async ({ researchPk }) => { +const edit = ({ researchPk }) => { currentResearchPk.value = researchPk; }; @@ -141,8 +142,22 @@ const changeVisibility = async ({ researchPk }) => { } }; +const units = ref([]); +const materials = ref([]); +const subGroups = ref([]); + +const getRefbooks = async () => { + await store.dispatch(actions.INC_LOADING); + const { result } = await api('construct/laboratory/get-ref-books'); + await store.dispatch(actions.DEC_LOADING); + units.value = result.units; + materials.value = result.materials; + subGroups.value = result.subGroups; +}; + onMounted(() => { getDepartments(); + getRefbooks(); }); @@ -150,7 +165,7 @@ onMounted(() => { diff --git a/l2-frontend/src/construct/FractionsTable.vue b/l2-frontend/src/construct/FractionsGroup.vue similarity index 52% rename from l2-frontend/src/construct/FractionsTable.vue rename to l2-frontend/src/construct/FractionsGroup.vue index 4c483e7bdd..aa6cdcceef 100644 --- a/l2-frontend/src/construct/FractionsTable.vue +++ b/l2-frontend/src/construct/FractionsGroup.vue @@ -1,32 +1,32 @@ -Фракция | По умолчанию | -Варианты | Ед. изм | Код ЕЦП | ФСЛИ | -Референсы м. | -Референсы ж. | +||
---|---|---|---|---|---|---|---|---|---|
@@ -60,43 +60,57 @@ placeholder="Введите значение" > | -- - | -- + |
+ |
- + | - |
-
+ |
-
-
+
+ {{ node.raw.id || fraction.fsli }}
+
+
|
- - + | + |