From 344f4087867b13164741e2f82eb79a45592ede7e Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Mon, 2 Dec 2024 12:25:58 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=8B=20-=20back?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/researches/urls.py | 2 ++ api/researches/views.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/api/researches/urls.py b/api/researches/urls.py index 5cb6ed90f5..ce37f501b3 100644 --- a/api/researches/urls.py +++ b/api/researches/urls.py @@ -39,4 +39,6 @@ path('get-research-performer', views.get_research_performer), path('get-research-permissions', views.get_research_permissions), path('save-research-permissions', views.save_research_permissions), + path('change-group-field', views.change_group_field), + ] diff --git a/api/researches/views.py b/api/researches/views.py index ca1056c8a4..b98cf80ac1 100644 --- a/api/researches/views.py +++ b/api/researches/views.py @@ -719,6 +719,19 @@ def researches_update(request): f.save() if department_template_field: department_template_field.save() + if field.get("newGroupId"): + new_group_id = field.get("newGroupId") + new_group = ParaclinicInputGroups.objects.filter(pk=new_group_id).first() + if new_group.research != res: + request_data["changeGroup"] = "Попытка указать id из другой услуги" + else: + old_group_id = f.group_id + fields_new_group = ParaclinicInputField.objects.filter(group_id=field.get("newGroupId")).order_by('order').last() + new_order_number = fields_new_group.order + 1 + f.group_id = new_group_id + f.order = new_order_number + f.save() + request_data["changeGroup"] = f"Изменена группа с {old_group_id} на {new_group_id}" if f.default_value == '': continue @@ -1260,3 +1273,25 @@ def save_research_permissions(request): user_ids = request_data.get('userIds') result = ConstructorEditAccessResearch.save_permissions(research_id, department_id, user_ids) return JsonResponse(result) + + +@login_required +@group_required("Оператор", "Конструктор: Параклинические (описательные) исследования") +def change_group_field(request): + request_data = json.loads(request.body) + field_id = request_data.get('fieldId') + new_group_id = request_data.get('groupId') + research_id = request_data.get('researchId') + current_field = ParaclinicInputField.objects.filter(id=field_id).first() + current_research_id = current_field.group.research_id + if current_research_id != research_id: + result = {"ok": False, "message": "ошибка услуги"} + else: + fields_new_group = ParaclinicInputField.objects.filter(group_id=new_group_id).order_by('order').last() + new_order_number = fields_new_group.order + 1 + current_field.group_id = new_group_id + current_field.order = new_order_number + current_field.save() + result = {"ok": True, "message": "Группа изменена"} + + return JsonResponse(result) From 090a9b41bf67dc5684a5d4f7d0be8ba191441910 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Mon, 2 Dec 2024 12:44:55 +0800 Subject: [PATCH 2/3] chnge group for field --- l2-frontend/src/construct/ParaclinicResearchEditor.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/l2-frontend/src/construct/ParaclinicResearchEditor.vue b/l2-frontend/src/construct/ParaclinicResearchEditor.vue index ff723c6ce4..cbcb8f70c0 100644 --- a/l2-frontend/src/construct/ParaclinicResearchEditor.vue +++ b/l2-frontend/src/construct/ParaclinicResearchEditor.vue @@ -1400,7 +1400,7 @@ export default { await this.loadDepartmentsForPermissions(); await this.load_deparments(); await this.loadDynamicDirectories(); - this.findPossibleGroupForField(); + await this.findPossibleGroupForField(); }, mounted() { window.$(window).on('beforeunload', () => { @@ -1799,7 +1799,7 @@ export default { closePermissionsModal() { this.showPermissionsModal = false; }, - findPossibleGroupForField() { + async findPossibleGroupForField() { this.possibleGroupForField = this.groups.map(group => ({ id: group.pk, label: group.pk })); }, }, From 6e2b6c18c7d7f8a1a5367684bbb3ea8aba7ef762 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Mon, 2 Dec 2024 12:57:34 +0800 Subject: [PATCH 3/3] fix --- l2-frontend/src/construct/ParaclinicResearchEditor.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/l2-frontend/src/construct/ParaclinicResearchEditor.vue b/l2-frontend/src/construct/ParaclinicResearchEditor.vue index cbcb8f70c0..931cb9d4be 100644 --- a/l2-frontend/src/construct/ParaclinicResearchEditor.vue +++ b/l2-frontend/src/construct/ParaclinicResearchEditor.vue @@ -1400,7 +1400,6 @@ export default { await this.loadDepartmentsForPermissions(); await this.load_deparments(); await this.loadDynamicDirectories(); - await this.findPossibleGroupForField(); }, mounted() { window.$(window).on('beforeunload', () => { @@ -1706,6 +1705,7 @@ export default { if (this.ex_deps.length > 0 && this.site_type === null) { this.site_type = this.ex_deps[0].pk; } + this.findPossibleGroupForField(); }, cancel() { // eslint-disable-next-line no-restricted-globals,no-alert @@ -1799,8 +1799,9 @@ export default { closePermissionsModal() { this.showPermissionsModal = false; }, - async findPossibleGroupForField() { + findPossibleGroupForField() { this.possibleGroupForField = this.groups.map(group => ({ id: group.pk, label: group.pk })); + console.log(this.possibleGroupForField); }, }, };