ปรับ เครื่องราชฯ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-09-06 12:02:13 +07:00
parent 388893395b
commit 981bab8061
4 changed files with 416 additions and 139 deletions

View file

@ -101,20 +101,20 @@ const fetchData = async () => {
.get(config.API.listRoundInsignia())
.then((res) => {
const data = res.data.result;
rows.value = data.map((e: FormProprsalsRound2) =>({
period_id: e.period_id,
period_name: e.period_name,
period_year: e.period_year + 543,
period_amount: e.period_amount,
period_start: e.period_start == null ? null : date2Thai(new Date(e.period_start)),
period_end: e.period_end == null ? null : date2Thai(new Date(e.period_end)),
period_isActive: e.period_isActive,
period_doc: e.period_doc,
period_status: e.period_status.result
})
);
console.log(rows.value)
rows.value = data.map((e: FormProprsalsRound2) => ({
period_id: e.period_id,
period_name: e.period_name,
period_year: e.period_year + 543,
period_amount: e.period_amount,
period_start:
e.period_start == null ? null : date2Thai(new Date(e.period_start)),
period_end:
e.period_end == null ? null : date2Thai(new Date(e.period_end)),
period_isActive: e.period_isActive,
period_doc: e.period_doc,
period_status: e.period_status.result,
}));
console.log(rows.value);
})
.catch((e) => {
messageError($q, e);
@ -179,6 +179,16 @@ const getRequest = async (id: string) => {
await fetchData();
});
};
// filename: string
const downloadFile = (response: any) => {
const link = document.createElement("a");
var fileName = "filename";
link.href = window.URL.createObjectURL(new Blob([response.data]));
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
//
const filterKeyword = ref<string>("");
@ -288,10 +298,18 @@ const paginationLabel = (start: string, end: string, total: string) => {
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td key="period_name" :props="props" @click="clickEdit(props.row)">
<q-td
key="period_name"
:props="props"
@click="clickEdit(props.row)"
>
{{ props.row.period_name }}
</q-td>
<q-td key="period_year" :props="props" @click="clickEdit(props.row)">
<q-td
key="period_year"
:props="props"
@click="clickEdit(props.row)"
>
{{ props.row.period_year }}
</q-td>
<q-td
@ -301,10 +319,18 @@ const paginationLabel = (start: string, end: string, total: string) => {
>
{{ props.row.period_start }}
</q-td>
<q-td key="period_end" :props="props" @click="clickEdit(props.row)">
<q-td
key="period_end"
:props="props"
@click="clickEdit(props.row)"
>
{{ props.row.period_end }}
</q-td>
<q-td key="period_isActive" :props="props" @click="clickEdit(props.row)">
<q-td
key="period_isActive"
:props="props"
@click="clickEdit(props.row)"
>
<q-icon
v-if="props.row.period_isActive == true"
name="mdi-close"
@ -358,9 +384,10 @@ const paginationLabel = (start: string, end: string, total: string) => {
target="_blank"
round
color="light-blue-8"
:href="props.row.period_doc"
icon="mdi-file-download"
@click="downloadFile(props.row.period_doc)"
>
<!-- :href="props.row.period_doc" -->
<q-tooltip>ดาวนโหลดเอกสารประกอบ </q-tooltip>
</q-btn>
</q-td>