Compare commits
1 Commits
e50c53e50a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| afc5229f5b |
@ -102,7 +102,7 @@
|
||||
<div class="form-group">
|
||||
<label for="description">Nový komentár:</label>
|
||||
<textarea
|
||||
ref="attachmentNewContent"
|
||||
v-model="attachmentNewContent"
|
||||
rows="5"
|
||||
class="form-control"
|
||||
placeholder="Nove zistenia alebo riesenia"
|
||||
@ -175,9 +175,10 @@ const attachments = ref([
|
||||
created_dt: "--",
|
||||
},
|
||||
]);
|
||||
const attachmentNewContent = ref(null);
|
||||
const attachmentNewFiles = ref(null);
|
||||
let selectedFiles = [];
|
||||
let selectedFilesContent = [];
|
||||
const selectedFiles = ref([]);
|
||||
const selectedFilesContent = ref([]);
|
||||
|
||||
onMounted(() => {
|
||||
// console.log(report_id);
|
||||
@ -208,7 +209,7 @@ function onDescriptionChange(event) {
|
||||
|
||||
function reportDelete() {
|
||||
if (!confirm("Naozaj chcete report zmazať?")) return;
|
||||
loading = true;
|
||||
loading.value = true;
|
||||
backend.delete(report_id).then(() => {
|
||||
router.push("/");
|
||||
});
|
||||
@ -228,9 +229,9 @@ function reportDone() {
|
||||
}
|
||||
|
||||
function attachmentAdd() {
|
||||
let comment = $refs.attachmentNewContent.value;
|
||||
let comment = attachmentNewContent.value;
|
||||
if (comment.trim().length > 0) {
|
||||
loading = true;
|
||||
loading.value = true;
|
||||
backend
|
||||
.attachmentAdd(
|
||||
report_id,
|
||||
@ -238,28 +239,28 @@ function attachmentAdd() {
|
||||
attachmentNewContent.value
|
||||
)
|
||||
.then(() => {
|
||||
$refs.attachmentNewContent.value = "";
|
||||
attachmentNewContent.value = "";
|
||||
loadReportData();
|
||||
loading = false;
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
if (selectedFiles.length > 0) {
|
||||
let for_upload = selectedFiles.length;
|
||||
loading = true;
|
||||
for (let i = 0; i < selectedFiles.length; i++) {
|
||||
if (selectedFiles.value.length > 0) {
|
||||
let for_upload = selectedFiles.value.length;
|
||||
loading.value = true;
|
||||
for (let i = 0; i < selectedFiles.value.length; i++) {
|
||||
backend
|
||||
.attachmentAdd(report_id, "file", {
|
||||
'filename': selectedFiles[i].name,
|
||||
'base64': selectedFilesContent[i]
|
||||
'filename': selectedFiles.value[i].name,
|
||||
'base64': selectedFilesContent.value[i]
|
||||
})
|
||||
.then(() => {
|
||||
for_upload--;
|
||||
if (for_upload == 0) {
|
||||
selectedFiles = [];
|
||||
selectedFilesContent = [];
|
||||
selectedFiles.value = [];
|
||||
selectedFilesContent.value = [];
|
||||
attachmentNewFiles.value = null;
|
||||
loadReportData();
|
||||
loading = false;
|
||||
loading.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -268,20 +269,20 @@ function attachmentAdd() {
|
||||
|
||||
function attachmentDelete(attachment) {
|
||||
if (!confirm("Naozaj chcete zmazať prilohu?")) return;
|
||||
loading = true;
|
||||
loading.value = true;
|
||||
backend.attachmentDelete(attachment.attachment_id).then(() => {
|
||||
loadReportData();
|
||||
loading = false;
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
function updateAttachmentContent(event, attachment) {
|
||||
loading = true;
|
||||
loading.value = true;
|
||||
backend
|
||||
.attachmentUpdate(attachment.attachment_id, event.target.innerText)
|
||||
.then(() => {
|
||||
loadReportData();
|
||||
loading = false;
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
@ -289,10 +290,10 @@ function handleFileUpload(event) {
|
||||
const files = event.target.files;
|
||||
if (files) {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
selectedFiles.push(files[i]);
|
||||
selectedFiles.value.push(files[i]);
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
selectedFilesContent[i] = reader.result;
|
||||
selectedFilesContent.value[i] = reader.result;
|
||||
};
|
||||
reader.readAsDataURL(files[i]);
|
||||
}
|
||||
@ -300,8 +301,8 @@ function handleFileUpload(event) {
|
||||
}
|
||||
|
||||
function removeFile(index) {
|
||||
selectedFiles.splice(index, 1);
|
||||
selectedFilesContent.splice(index, 1);
|
||||
selectedFiles.value.splice(index, 1);
|
||||
selectedFilesContent.value.splice(index, 1);
|
||||
}
|
||||
|
||||
function formatFileSize(size) {
|
||||
|
||||
Reference in New Issue
Block a user