uploadFile invoice,receice

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-08-25 10:35:33 +07:00
parent 48cbe7510c
commit 5bfd87c97b
3 changed files with 81 additions and 20 deletions

View file

@ -228,7 +228,7 @@ const fectDataByid = async (id: string) => {
Advertise.value = data.number;
brand.value = data.requestInsigniaId;
receivedate.value = data.dateReceive;
issue.value = "";
issue.value = data.issue;
affiliationRequest.value = data.organizationOrganizationSend;
affiliationReceived.value = data.organizationOrganizationReceive;
announceDate.value = data.date;

View file

@ -16,8 +16,14 @@ import { useQuasar } from "quasar";
// const router = useRouter();
const DataStore = useResultDataStore();
const mixin = useCounterMixin();
const { date2Thai, dialogConfirm, showLoader, hideLoader, messageError } =
mixin;
const {
date2Thai,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
} = mixin;
const $q = useQuasar();
const tab = ref<string>("");
@ -205,18 +211,6 @@ const rows = ref<any>([
// typepay: null,
// address: " 2/3 14 ...",
// },
// {
// no: "2",
// status: " .. 7 ",
// name: " ",
// type: "",
// page: "12",
// number: "11",
// vatnumber: "1122345",
// datepay: null,
// typepay: null,
// address: " 2/3 14 ...",
// },
]);
watch(tab, () => {
if (tab.value !== "doc") {
@ -272,6 +266,43 @@ const fecthlistInsignia = async () => {
hideLoader();
});
};
const uploadFile = async (event: any, action: string) => {
console.log(selectRound.value);
if (selectRound.value !== undefined) {
let id = selectRound.value.toString();
if (action === "result") {
const formdata = new FormData();
formdata.append("file", event);
await http
.put(config.API.uploadfilereceice(id), formdata)
.then(() => {
success($q, "อัพโหลดไฟล์สำเร็จ");
})
.catch((err) => {
console.log(err);
})
.finally(async () => {
await fecthlistInsignia();
fileResult.value = null;
});
} else if (action === "invoice") {
const formdata = new FormData();
formdata.append("file", event);
await http
.put(config.API.uploadfileinvoice(id), formdata)
.then(() => {
success($q, "อัพโหลดไฟล์สำเร็จ");
})
.catch((err) => {
console.log(err);
})
.finally(async () => {
await fecthlistInsignia();
fileinvoice.value = null;
});
}
}
};
const filterRef = ref<QInput>();
const filter = ref<string>("");
@ -285,9 +316,7 @@ const addData = () => {
action.value = "addData";
};
const editData = (data) => {
console.log(data);
const editData = (data: any) => {
personId.value = data.id;
profileType.value = data.profileType;
action.value = "editData";
@ -398,6 +427,7 @@ const resetFilter = () => {
v-model="fileResult"
label="บันทึกผลการได้รับพระราชทานเครื่องราชย์อิสริยสภรณ์"
style="min-width: auto"
accept=".xlsx"
>
<template v-slot:prepend>
<q-icon name="attach_file" />
@ -428,6 +458,20 @@ const resetFilter = () => {
</q-menu>
</q-btn> -->
</div>
<div v-if="fileResult !== null">
<q-btn
size="12px"
flat
round
color="add"
icon="mdi-upload"
@click="uploadFile(fileResult, 'result')"
>
<q-tooltip
>พโหลดไฟลนทกผลการไดบพระราชทานเครองราชยสรยสภรณ</q-tooltip
>
</q-btn>
</div>
<div>
<q-file
dense
@ -436,7 +480,7 @@ const resetFilter = () => {
v-model="fileinvoice"
label="บันทึกผลการจ่ายใบกำกับ"
style="min-width: auto"
accept=".pdf"
accept=".xlsx"
>
<template v-slot:prepend>
<q-icon name="attach_file" />
@ -444,6 +488,18 @@ const resetFilter = () => {
<q-tooltip>พโหลดไฟลนทกผลการจายใบกำก</q-tooltip>
</q-file>
</div>
<div v-if="fileinvoice !== null">
<q-btn
size="12px"
flat
round
color="add"
icon="mdi-upload"
@click="uploadFile(fileinvoice, 'invoice')"
>
<q-tooltip>พโหลดไฟลนทกผลการจายใบกำก</q-tooltip>
</q-btn>
</div>
<q-space />