เพื่มการ อัปโหลดไฟล์เอกสารหลักฐานการประชุม
This commit is contained in:
parent
8fce35bf13
commit
d9a99332d7
4 changed files with 41 additions and 5 deletions
|
|
@ -3,6 +3,7 @@ import { ref, reactive, watch, onMounted } from "vue";
|
|||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRoute } from "vue-router";
|
||||
import axios from "axios";
|
||||
import type {
|
||||
FormData,
|
||||
FormRef,
|
||||
|
|
@ -163,7 +164,7 @@ const fetchDataFileDownload = async (pathName: string) => {
|
|||
* addFiles
|
||||
*/
|
||||
function uploadFile() {
|
||||
fetchDataFile();
|
||||
// fetchDataFile();
|
||||
if (file) {
|
||||
const fileList = [
|
||||
{
|
||||
|
|
@ -180,18 +181,42 @@ function uploadFile() {
|
|||
showLoader();
|
||||
http
|
||||
.post(config.API.meetingFilebyId("การประชุม", id.value), requestBody)
|
||||
.then((res) => {})
|
||||
.then((res) => {
|
||||
const foundKey: string | undefined = Object.keys(res.data).find(
|
||||
(key) =>
|
||||
res.data[key]?.fileName !== undefined &&
|
||||
res.data[key]?.fileName !== ""
|
||||
);
|
||||
foundKey && uploadfileURL(res.data[foundKey]?.uploadUrl, file.value);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
file.value = null;
|
||||
setTimeout(() => fetchDataFile(), 500);
|
||||
// hideLoader();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadfileURL(uploadUrl: string, file: any) {
|
||||
await axios
|
||||
.put(uploadUrl, file, {
|
||||
headers: {
|
||||
"Content-Type": file.type,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
success($q, "อัปโหลไฟล์สำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(async () => {
|
||||
await setTimeout(() => fetchDataFile(), 500);
|
||||
});
|
||||
}
|
||||
|
||||
function deleteFile(id: string) {
|
||||
dialogRemove($q, () => confirmDelete(id));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue