Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Загрузка результата - PDF #4051

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/laboratory/forms100.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def form_01(request_data):
return {"ok": True, "result": [], "message": ""}
5 changes: 3 additions & 2 deletions l2-frontend/src/components/UploadFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<script setup lang="ts">
// todo - slot на вывод результата, для удобного вывода каждому)
// todo - дефолтный вывод результата - таблица, строчка
// todo - уведомление о успешной загрузке файла
import {
getCurrentInstance, onMounted, PropType, ref, watch,
} from 'vue';
Expand Down Expand Up @@ -141,9 +140,11 @@ const selectedForm = ref(null);

const changeType = () => {
fileFilter.value = `.${selectedType.value}`;
currentFileForms.value = getForms(String(selectedType.value), props.formsFile);
currentFileForms.value = getForms(String(selectedType.value), props.formsFile, props.uploadResult);
if (currentFileForms.value.length > 0) {
selectedForm.value = currentFileForms.value[0].id;
} else {
selectedForm.value = null;
}
};

Expand Down
23 changes: 19 additions & 4 deletions l2-frontend/src/components/types-and-forms-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface formsFile {
export default function typesAndForms() {
const fileTypes = ref({
XLSX: { id: 'XLSX', label: 'XLSX' },
PDF: { id: 'PDF', label: 'PDF' },
});
// todo - сделать соотношение - расширение файла - и все виды accept фильтров {xlsx: '.xlx, .xlsx, ws-excel'}
const getTypes = (types: string[]): typesFile[] => {
Expand All @@ -27,22 +28,36 @@ export default function typesAndForms() {
return result;
};

const isResultFunc = ref([
'api.laboratory.forms100.form_01',
]);

/* (101.01) - 101 номер файла, 01 - номер функции в файле для обработки загруженного файла (см. parseFile) */
const fileForms = ref({
XLSX: {
'api.contracts.forms100.form_01': { id: 'api.contracts.forms100.form_01', label: 'Загрузка цен по прайсу' },
},
PDF: {
'api.laboratory.forms100.form_01': { id: 'api.laboratory.forms100.form_01', label: 'Загрузка PDF результата из QMS' },
},
});
// todo - режим UploadResult - получать по расширению файла - только функции связанные с сохранением результата (анализаторы)
// todo - UploadResult + forms - получать только выбранные isResult функции
const getForms = (type: string, forms: string[] = []): formsFile[] => {
// todo - UploadResult + forms - получать только выбранные isResult функции (протестировать)
const getForms = (type: string, forms: string[] = null, onlyResult = false): formsFile[] => {
let result: formsFile[] = [];
if (forms && forms.length > 0) {
for (const form of forms) {
if (fileForms.value[type][form]) {
if (!onlyResult && fileForms.value[type][form]) {
result.push(fileForms.value[type][form]);
} else if (onlyResult && isResultFunc.value.includes(form)) {
result.push(fileForms.value[type][form]);
}
}
} else if (!forms && onlyResult) {
for (const func of isResultFunc.value) {
if (fileForms.value[type][func]) {
result.push(fileForms.value[type][func]);
}
}
} else {
result = Object.values(fileForms.value[type]);
}
Expand Down
11 changes: 9 additions & 2 deletions l2-frontend/src/modals/UploadFileModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<div>
<component
:is="tag"
>
<slot>
<a
class="pointer"
Expand Down Expand Up @@ -44,7 +46,7 @@
</div>
</div>
</Modal>
</div>
</component>
</template>

<script setup lang="ts">
Expand All @@ -60,6 +62,11 @@ const props = defineProps({
type: String,
required: false,
},
tag: {
type: String,
default: 'div',
required: false,
},
typesFile: {
type: Array as PropType<string[]>,
required: false,
Expand Down
16 changes: 16 additions & 0 deletions l2-frontend/src/ui-cards/LaboratoryHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
<ul class="nav navbar-nav">
<LoadFile />
</ul>
<ul class="nav navbar-nav">
<UploadFileModal
tag="li"
title="Прикрепить результат"
:types-file="['PDF']"
:forms-file="['api.laboratory.forms100.form_01']"
:upload-result="true"
/>
</ul>
</div>
</template>

Expand All @@ -45,10 +54,12 @@ import LaboratorySelector from '@/ui-cards/LaboratorySelector.vue';
import ExecutionList from '@/ui-cards/ExecutionList.vue';
import LaboratoryJournal from '@/ui-cards/LaboratoryJournal.vue';
import LaboratoryPrintResults from '@/ui-cards/LaboratoryPrintResults.vue';
import UploadFileModal from '@/modals/UploadFileModal.vue';

export default {
name: 'LaboratoryHeader',
components: {
UploadFileModal,
LoadFile,
LaboratorySelector,
ExecutionList,
Expand Down Expand Up @@ -80,4 +91,9 @@ export default {
background: #049372 !important;
border: none !important;
}

.nav-upload-file {
padding: 8px 15px;
}

</style>
Loading