Skip to content

Commit

Permalink
Merge pull request #4060 from mikhailprivalov/view-uploaded-files
Browse files Browse the repository at this point in the history
View uploaded files
  • Loading branch information
urchinpro authored Jul 4, 2024
2 parents 256b315 + 1adae56 commit 37dcf17
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/laboratory/forms100.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion api/laboratory/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion l2-frontend/src/modals/FileAddModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class="modal-body"
>
<div
v-if="rows.length < 5"
v-if="rows.length < maxCountFiles"
class="uploading-block"
>
<a
Expand Down Expand Up @@ -110,6 +110,11 @@ export default {
type: Number,
required: true,
},
maxCountFiles: {
type: Number,
required: false,
default: 5,
},
},
data() {
return {
Expand Down
15 changes: 8 additions & 7 deletions l2-frontend/src/pages/LaboratoryResults/ResultsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@
<thead>
<tr>
<td colspan="5">
<UploadFileModal
<FileAdd
v-if="research.enabled_add_files"
title="Прикрепить результат"
:types-file="['PDF']"
:forms-file="['api.laboratory.forms100.form_01']"
:entity-id="pk"
:iss_pk="pk"
:count_files="countFiles"
:max-count-files="1"
/>
<strong>
{{ research.title }}
Expand Down Expand Up @@ -327,12 +326,12 @@ import Ref from '@/pages/LaboratoryResults/Ref.vue';
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: {
UploadFileModal,
FileAdd,
RefSettings,
TextInputField,
BloodTypeField,
Expand All @@ -345,6 +344,7 @@ export default {
confirmed: false,
saved: false,
allow_reset_confirm: false,
countFiles: 0,
showRefSettings: false,
pk: null,
research: {},
Expand Down Expand Up @@ -441,6 +441,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;
Expand Down
8 changes: 7 additions & 1 deletion l2-frontend/src/ui-cards/FileAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@click="show_modal"
>
Файлы
<span class="badge badge-secondary">{{ count_files }}</span>
<span class="badge badge-secondary">{{ countFiles }}</span>
</button>
<MountingPortal
mount-to="#portal-place-modal"
Expand All @@ -17,6 +17,7 @@
<FileAddModal
v-if="showModal"
:iss_pk="iss_pk"
:max-count-files="maxCountFiles"
@add-file="countFilesAdd += 1"
/>
</MountingPortal>
Expand All @@ -38,6 +39,11 @@ export default {
type: Number,
required: false,
},
maxCountFiles: {
type: Number,
required: false,
default: 5,
},
},
data() {
return {
Expand Down

0 comments on commit 37dcf17

Please sign in to comment.