From 6903cd29bd889445540ff5d20df25f9441a2afc6 Mon Sep 17 00:00:00 2001 From: Well Date: Thu, 4 Jul 2024 16:53:02 +0800 Subject: [PATCH 1/5] count files --- api/laboratory/views.py | 4 +++- l2-frontend/src/modals/FileAddModal.vue | 7 ++++++- .../src/pages/LaboratoryResults/ResultsForm.vue | 12 +++++++++++- l2-frontend/src/ui-cards/FileAdd.vue | 6 ++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/api/laboratory/views.py b/api/laboratory/views.py index 4d5bcd66fa..b40b46de3f 100644 --- a/api/laboratory/views.py +++ b/api/laboratory/views.py @@ -14,7 +14,7 @@ from appconf.manager import SettingManager from barcodes.views import tubes -from directions.models import TubesRegistration, Issledovaniya, Napravleniya, Result +from directions.models import TubesRegistration, Issledovaniya, Napravleniya, Result, IssledovaniyaFiles from directions.sql_func import get_tube_registration from directory.models import Fractions, Researches, Unit from ftp_orders.main import push_result @@ -362,6 +362,7 @@ def form(request): request_data = json.loads(request.body) pk = request_data["pk"] iss: Issledovaniya = Issledovaniya.objects.prefetch_related('result_set').get(pk=pk) + count_files = IssledovaniyaFiles.objects.filter(issledovaniye_id=iss.pk).count() research: Researches = Researches.objects.prefetch_related( Prefetch('fractions_set', queryset=Fractions.objects.all().order_by("sort_weight", "pk").prefetch_related('references_set')) ).get(pk=iss.research_id) @@ -376,6 +377,7 @@ def form(request): "docConfirmation": iss.doc_confirmation.get_fio() if iss.doc_confirmation else None, "app": iss.api_app.name if iss.api_app else None, }, + "count_files": count_files, "allow_reset_confirm": iss.allow_reset_confirm(request.user), "research": { "title": research.title, diff --git a/l2-frontend/src/modals/FileAddModal.vue b/l2-frontend/src/modals/FileAddModal.vue index ca8eb7036f..8a2de19a04 100644 --- a/l2-frontend/src/modals/FileAddModal.vue +++ b/l2-frontend/src/modals/FileAddModal.vue @@ -17,7 +17,7 @@ class="modal-body" >
+ {{ research.title }} @@ -328,10 +334,12 @@ import TextInputField from '@/pages/LaboratoryResults/TextInputField.vue'; import BloodTypeField from '@/pages/LaboratoryResults/BloodTypeField.vue'; import RefSettings from '@/pages/LaboratoryResults/RefSettings.vue'; import UploadFileModal from '@/modals/UploadFileModal.vue'; +import FileAdd from '@/ui-cards/FileAdd.vue'; export default { name: 'ResultsForm', components: { + FileAdd, UploadFileModal, RefSettings, TextInputField, @@ -345,6 +353,7 @@ export default { confirmed: false, saved: false, allow_reset_confirm: false, + countFiles: 0, showRefSettings: false, pk: null, research: {}, @@ -441,6 +450,7 @@ export default { this.result = data.result; this.confirmed = data.confirmed; this.saved = data.saved; + this.countFiles = data.count_files; this.laborants = data.laborants; this.co_executor = data.co_executor; this.co_executor2 = data.co_executor2; diff --git a/l2-frontend/src/ui-cards/FileAdd.vue b/l2-frontend/src/ui-cards/FileAdd.vue index a6a8322504..5adaeee1de 100644 --- a/l2-frontend/src/ui-cards/FileAdd.vue +++ b/l2-frontend/src/ui-cards/FileAdd.vue @@ -17,6 +17,7 @@ @@ -38,6 +39,11 @@ export default { type: Number, required: false, }, + maxCountFiles: { + type: Number, + required: false, + default: 5, + }, }, data() { return { From dd342d43fd30cf9063a2c2fd72b04ff8a34034e9 Mon Sep 17 00:00:00 2001 From: Well Date: Thu, 4 Jul 2024 16:53:51 +0800 Subject: [PATCH 2/5] count files --- api/laboratory/forms100.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/laboratory/forms100.py b/api/laboratory/forms100.py index 3ed533eafd..7aa1fd05ae 100644 --- a/api/laboratory/forms100.py +++ b/api/laboratory/forms100.py @@ -8,7 +8,7 @@ def form_01(request_data): issledovanie: Issledovaniya = Issledovaniya.objects.filter(pk=issledovanie_id).select_related('research').first() if issledovanie: iss_files = IssledovaniyaFiles.objects.filter(issledovaniye_id=issledovanie.pk) - if file and iss_files.count() >= 5: + if file and iss_files.count() >= 1: return {"ok": False, "result": [], "message": "Вы добавили слишком много файлов в одну заявку"} if file and file.size > 5242880: From 4ac395938bbb74338e73447da51754e146e871b7 Mon Sep 17 00:00:00 2001 From: Well Date: Thu, 4 Jul 2024 17:12:19 +0800 Subject: [PATCH 3/5] count files v2 --- l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue b/l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue index 65cc209aed..baa571014e 100644 --- a/l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue +++ b/l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue @@ -78,6 +78,7 @@ :types-file="['PDF']" :forms-file="['api.laboratory.forms100.form_01']" :entity-id="pk" + @uploadSuccess="loadForm(pk)" /> Date: Thu, 4 Jul 2024 17:21:48 +0800 Subject: [PATCH 4/5] count files v3 --- .../src/pages/LaboratoryResults/ResultsForm.vue | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue b/l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue index baa571014e..266cb66398 100644 --- a/l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue +++ b/l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue @@ -72,16 +72,8 @@ - Date: Thu, 4 Jul 2024 17:24:18 +0800 Subject: [PATCH 5/5] count files v4 --- l2-frontend/src/ui-cards/FileAdd.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l2-frontend/src/ui-cards/FileAdd.vue b/l2-frontend/src/ui-cards/FileAdd.vue index 5adaeee1de..fab21e9e0e 100644 --- a/l2-frontend/src/ui-cards/FileAdd.vue +++ b/l2-frontend/src/ui-cards/FileAdd.vue @@ -7,7 +7,7 @@ @click="show_modal" > Файлы - {{ count_files }} + {{ countFiles }}