From 2b6b97babefd1b9cf09faae7afb9df591a53a84d Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Wed, 9 Oct 2024 12:24:02 +0800 Subject: [PATCH] cancel receive tube --- api/laboratory/urls.py | 1 + api/laboratory/views.py | 18 ++++++++++++++- l2-frontend/src/pages/ReceiveOneByOne.vue | 27 ++++++++++++++++++++--- slog/models.py | 1 + 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/api/laboratory/urls.py b/api/laboratory/urls.py index 56518717ac..39d37fc5a2 100644 --- a/api/laboratory/urls.py +++ b/api/laboratory/urls.py @@ -19,4 +19,5 @@ path('receive-one-by-one', views.receive_one_by_one), path('receive-history', views.receive_history), path('save-defect-tube', views.save_defect_tube), + path('cancel-receive', views.cancel_receive), ] diff --git a/api/laboratory/views.py b/api/laboratory/views.py index b40b46de3f..4c3f2fcb8f 100644 --- a/api/laboratory/views.py +++ b/api/laboratory/views.py @@ -957,9 +957,25 @@ def receive_history(request): def save_defect_tube(request): request_data = json.loads(request.body) data_row = request_data.get('row') - t = TubesRegistration.objects.filter(pk=int(data_row['pk'])).first() + t = TubesRegistration.objects.filter(number=int(data_row['pk'])).first() t.is_defect = data_row['is_defect'] t.defect_text = data_row['defect_text'] t.save() message = {"ok": "ok"} return JsonResponse(message) + + +@login_required +@group_required("Получатель биоматериала") +def cancel_receive(request): + request_data = json.loads(request.body) + data_row = request_data.get('row') + t = TubesRegistration.objects.filter(number=int(data_row['pk'])).first() + t.time_recive = None + t.doc_recive = None + t.is_defect = False + t.defect_text = "" + t.save() + Log.log(t.number, 4001, request.user.doctorprofile, {"tubeNumber": t.number, "id": t.pk, "docId": request.user.doctorprofile.pk, "docFio": request.user.doctorprofile.get_fio()}) + message = {"ok": "ok"} + return JsonResponse(message) diff --git a/l2-frontend/src/pages/ReceiveOneByOne.vue b/l2-frontend/src/pages/ReceiveOneByOne.vue index 08fb9061fa..b937efb7fd 100644 --- a/l2-frontend/src/pages/ReceiveOneByOne.vue +++ b/l2-frontend/src/pages/ReceiveOneByOne.vue @@ -96,13 +96,13 @@ - - + + - + @@ -190,6 +190,18 @@ +
+ +
@@ -359,6 +371,15 @@ export default class ReceiveOneByOne extends Vue { this.focus(); } + async cancelReceive(row) { + await this.$store.dispatch(actions.INC_LOADING); + await this.$api('/laboratory/cancel-receive', { row }); + await this.loadNextN(); + this.loadHistory(); + await this.$store.dispatch(actions.DEC_LOADING); + this.focus(); + } + // eslint-disable-next-line class-methods-use-this changeRow(row) { if (!row.is_defect) { diff --git a/slog/models.py b/slog/models.py index bce1166be7..6461cd796f 100644 --- a/slog/models.py +++ b/slog/models.py @@ -26,6 +26,7 @@ class Log(models.Model): (11, 'Приём материала: материал принят'), (12, 'Приём материала: материал не принят'), (4000, 'Приём материала: замечание приёма было очищено'), + (4001, 'Приём материала: отмена приема'), (25, 'Приём материала: печать журнала приема'), (13, 'Ввод результатов: результат сохранен'), (14, 'Ввод результатов: результат подтвержден'),