chore: install prettier
This commit is contained in:
@@ -1,25 +1,24 @@
|
||||
<script setup>
|
||||
import FileUpload from '@/components/media/FileUpload.vue';
|
||||
import FileUpload from "@/components/media/FileUpload.vue";
|
||||
|
||||
const { dealer } = useStore();
|
||||
const { $buildFileUrl, $formatFileSize, $getdata, $insertapi, $patchapi, $snackbar } = useNuxtApp();
|
||||
|
||||
const project = await $getdata('project', undefined, undefined, true);
|
||||
const project = await $getdata("project", undefined, undefined, true);
|
||||
const projectDocuments = ref([]);
|
||||
|
||||
async function loadProjectDocuments() {
|
||||
projectDocuments.value = await $getdata("projectfile", undefined, {
|
||||
filter: { project: project.id, file__type: 1 } ,
|
||||
values: "id,project,file,file__id,file__code,file__type,file__name,file__file,file__size,file__caption,file__user,file__user__fullname,create_time",
|
||||
})
|
||||
filter: { project: project.id, file__type: 1 },
|
||||
values:
|
||||
"id,project,file,file__id,file__code,file__type,file__name,file__file,file__size,file__caption,file__user,file__user__fullname,create_time",
|
||||
});
|
||||
}
|
||||
|
||||
loadProjectDocuments();
|
||||
|
||||
async function attachFilesToProject(files) {
|
||||
const payload = files
|
||||
.filter((file) => file && file.id)
|
||||
.map((file) => ({ project: project.id, file: file.id }));
|
||||
const payload = files.filter((file) => file && file.id).map((file) => ({ project: project.id, file: file.id }));
|
||||
if (payload.length === 0) return 0;
|
||||
const result = await $insertapi("projectfile", payload, undefined, false);
|
||||
if (result === "error") {
|
||||
@@ -36,18 +35,12 @@ async function onUploadedProjectDocs(payload) {
|
||||
if (linked > 0) {
|
||||
await loadProjectDocuments();
|
||||
const message =
|
||||
linked === 1
|
||||
? "Đã thêm tài liệu dự án thành công"
|
||||
: `Đã thêm ${linked} tài liệu dự án thành công`;
|
||||
linked === 1 ? "Đã thêm tài liệu dự án thành công" : `Đã thêm ${linked} tài liệu dự án thành công`;
|
||||
$snackbar(message, "Thành công", "Success");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error attaching project documents:", error);
|
||||
$snackbar(
|
||||
"Không thể thêm tài liệu dự án, vui lòng thử lại",
|
||||
"Lỗi",
|
||||
"Error"
|
||||
);
|
||||
$snackbar("Không thể thêm tài liệu dự án, vui lòng thử lại", "Lỗi", "Error");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -67,9 +60,7 @@ async function onUploadedProjectDocs(payload) {
|
||||
});
|
||||
});
|
||||
const message =
|
||||
totalFiles === 1
|
||||
? "Đã thêm tài liệu dự án thành công"
|
||||
: `Đã thêm ${totalFiles} tài liệu dự án thành công`;
|
||||
totalFiles === 1 ? "Đã thêm tài liệu dự án thành công" : `Đã thêm ${totalFiles} tài liệu dự án thành công`;
|
||||
$snackbar(message, "Thành công", "Success");
|
||||
event.target.value = "";
|
||||
}
|
||||
@@ -87,9 +78,7 @@ function editDocument(doc) {
|
||||
|
||||
async function saveEditDocument() {
|
||||
if (!editingDocument.value) return;
|
||||
const index = projectDocuments.value.findIndex(
|
||||
(doc) => doc.id === editingDocument.value.id
|
||||
);
|
||||
const index = projectDocuments.value.findIndex((doc) => doc.id === editingDocument.value.id);
|
||||
if (index !== -1) {
|
||||
projectDocuments.value[index] = {
|
||||
...projectDocuments.value[index],
|
||||
@@ -107,7 +96,7 @@ async function saveEditDocument() {
|
||||
caption: editingDocumentCaption.value?.trim() || null,
|
||||
},
|
||||
{},
|
||||
false
|
||||
false,
|
||||
);
|
||||
$snackbar("Đã cập nhật tài liệu thành công", "Thành công", "Success");
|
||||
} catch (error) {
|
||||
@@ -145,7 +134,10 @@ function cancelEditDocument() {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-for="doc in projectDocuments" :key="doc.id">
|
||||
<template
|
||||
v-for="doc in projectDocuments"
|
||||
:key="doc.id"
|
||||
>
|
||||
<tr v-if="editingDocument?.id === doc.id">
|
||||
<td colspan="4">
|
||||
<div class="columns is-multiline">
|
||||
@@ -201,7 +193,7 @@ function cancelEditDocument() {
|
||||
<td>
|
||||
<div class="is-flex is-align-items-center">
|
||||
<div>
|
||||
<a
|
||||
<a
|
||||
:href="$buildFileUrl(doc.file__file)"
|
||||
target="_blank"
|
||||
class="has-text-weight-semibold"
|
||||
@@ -215,9 +207,7 @@ function cancelEditDocument() {
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="is-size-7">{{
|
||||
doc.file__caption || "-"
|
||||
}}</span>
|
||||
<span class="is-size-7">{{ doc.file__caption || "-" }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
@@ -225,13 +215,7 @@ function cancelEditDocument() {
|
||||
{{ doc.file__user__fullname }}
|
||||
</p>
|
||||
<p class="is-size-7 has-text-grey">
|
||||
{{
|
||||
doc.create_time
|
||||
? new Date(doc.create_time).toLocaleString(
|
||||
"vi-VN"
|
||||
)
|
||||
: "-"
|
||||
}}
|
||||
{{ doc.create_time ? new Date(doc.create_time).toLocaleString("vi-VN") : "-" }}
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
@@ -252,7 +236,7 @@ function cancelEditDocument() {
|
||||
></SvgIcon
|
||||
></span>
|
||||
</a>
|
||||
<a
|
||||
<a
|
||||
:href="$buildFileUrl(doc.file__file)"
|
||||
target="_blank"
|
||||
title="Tải xuống"
|
||||
@@ -267,9 +251,9 @@ function cancelEditDocument() {
|
||||
></SvgIcon
|
||||
></span>
|
||||
</a>
|
||||
<a
|
||||
<a
|
||||
v-if="!dealer && $getEditRights()"
|
||||
@click="deleteDocument(doc)"
|
||||
@click="deleteDocument(doc)"
|
||||
title="Xóa"
|
||||
>
|
||||
<span class="icon"
|
||||
@@ -287,13 +271,14 @@ function cancelEditDocument() {
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-if="projectDocuments.length === 0">
|
||||
<td colspan="4" class="has-text-centered py-4">
|
||||
<p class="has-text-grey">
|
||||
Chưa có tài liệu nào được đính kèm.
|
||||
</p>
|
||||
<td
|
||||
colspan="4"
|
||||
class="has-text-centered py-4"
|
||||
>
|
||||
<p class="has-text-grey">Chưa có tài liệu nào được đính kèm.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user