2024-02-15 11:46:25 +07:00
|
|
|
<script setup lang="ts">
|
2024-04-03 11:14:26 +07:00
|
|
|
import { ref, onMounted, reactive, watch } from "vue";
|
2024-03-25 18:01:33 +07:00
|
|
|
import { useQuasar, type QTableProps } from "quasar";
|
2024-02-15 11:46:25 +07:00
|
|
|
import { useRouter } from "vue-router";
|
2024-04-03 11:14:26 +07:00
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
|
|
|
|
|
2024-04-09 16:26:10 +07:00
|
|
|
import genReportXLSX from "@/plugins/genreportxlsx";
|
|
|
|
|
|
2024-04-03 11:14:26 +07:00
|
|
|
/**importType*/
|
|
|
|
|
import type {
|
2024-04-09 13:03:18 +07:00
|
|
|
DataOption,
|
2024-04-03 11:14:26 +07:00
|
|
|
ItemsMenu,
|
|
|
|
|
NewPagination,
|
|
|
|
|
} from "@/modules/15_development/interface/index/Main";
|
|
|
|
|
import type { FormQueryListProject } from "@/modules/15_development/interface/request/Main";
|
|
|
|
|
import type { ResListProject } from "@/modules/15_development/interface/response/Main";
|
2024-02-15 11:46:25 +07:00
|
|
|
|
2024-03-25 18:01:33 +07:00
|
|
|
/** importStore*/
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
|
|
2024-02-15 11:46:25 +07:00
|
|
|
/** use*/
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
const router = useRouter();
|
2024-04-03 11:14:26 +07:00
|
|
|
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
2024-03-25 18:01:33 +07:00
|
|
|
|
|
|
|
|
/** หัวตาราง */
|
2024-04-09 13:03:18 +07:00
|
|
|
const rows = ref<ResListProject[]>([]); // ข้อมูลรายการ
|
2024-03-25 18:01:33 +07:00
|
|
|
const columns = ref<QTableProps["columns"]>([
|
|
|
|
|
{
|
|
|
|
|
name: "year",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ปีงบประมาณ ",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "year",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
2024-04-03 17:51:00 +07:00
|
|
|
style: "font-size: 14px ; width:10%",
|
2024-04-03 11:14:26 +07:00
|
|
|
format: (val) => val + 543,
|
2024-03-25 18:01:33 +07:00
|
|
|
},
|
|
|
|
|
{
|
2024-04-03 11:14:26 +07:00
|
|
|
name: "projectName",
|
2024-03-25 18:01:33 +07:00
|
|
|
align: "left",
|
|
|
|
|
label: "ชื่อโครงการ/กิจกรรม/หลักสูตร",
|
|
|
|
|
sortable: true,
|
2024-04-03 11:14:26 +07:00
|
|
|
field: "projectName",
|
2024-03-25 18:01:33 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
2024-04-03 17:51:00 +07:00
|
|
|
style: "font-size: 14px;width:45% ",
|
2024-03-25 18:01:33 +07:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
name: "org",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "หน่วยงานที่รับผิดชอบ",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "org",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
2024-04-03 17:51:00 +07:00
|
|
|
style: "font-size: 14px ; width:45% ",
|
2024-03-25 18:01:33 +07:00
|
|
|
},
|
|
|
|
|
]);
|
2024-04-03 11:14:26 +07:00
|
|
|
const visibleColumns = ref<string[]>(["year", "projectName", "org"]);
|
2024-03-25 18:01:33 +07:00
|
|
|
|
2024-04-03 11:14:26 +07:00
|
|
|
/** เมนูดาวน์โหลด*/
|
|
|
|
|
const itemDownload = ref<ItemsMenu[]>([
|
2024-04-02 10:23:22 +07:00
|
|
|
{
|
2024-04-09 16:26:10 +07:00
|
|
|
label: "Excel",
|
|
|
|
|
value: "EXCEL",
|
2024-04-02 10:23:22 +07:00
|
|
|
icon: "mdi-file-pdf-box",
|
|
|
|
|
color: "green",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "ดาวน์โหลด 2",
|
2024-04-09 16:26:10 +07:00
|
|
|
value: "PDF",
|
2024-04-02 10:23:22 +07:00
|
|
|
icon: "mdi-file-table",
|
|
|
|
|
color: "red",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "ดาวน์โหลด 3",
|
2024-04-09 16:26:10 +07:00
|
|
|
value: "WORD",
|
2024-04-02 10:23:22 +07:00
|
|
|
icon: "mdi-file-word",
|
|
|
|
|
color: "blue",
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
|
2024-04-03 11:14:26 +07:00
|
|
|
/** formQuery*/
|
|
|
|
|
const formQuery = reactive<FormQueryListProject>({
|
|
|
|
|
year: new Date().getFullYear(),
|
|
|
|
|
page: 1,
|
|
|
|
|
pageSize: 10,
|
2024-04-09 13:03:18 +07:00
|
|
|
org: "1",
|
2024-04-03 11:14:26 +07:00
|
|
|
keyword: "",
|
|
|
|
|
});
|
2024-04-09 13:03:18 +07:00
|
|
|
const orgOp = ref<DataOption[]>([{ id: "1", name: "หน่วยงาน 1" }]);
|
|
|
|
|
|
2024-04-03 11:14:26 +07:00
|
|
|
const totalList = ref<number>(1); //จำนวนข้อมูลรายการ
|
|
|
|
|
|
|
|
|
|
/** funciton fetch รายการโครงการ*/
|
2024-03-25 18:01:33 +07:00
|
|
|
function fetchListProject() {
|
|
|
|
|
showLoader();
|
2024-04-03 11:14:26 +07:00
|
|
|
http
|
|
|
|
|
.get(
|
|
|
|
|
config.API.developmentMain +
|
|
|
|
|
`?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}&year=${formQuery.year}`
|
|
|
|
|
)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
const data = res.data.result.data;
|
|
|
|
|
totalList.value = Math.ceil(res.data.result.total / formQuery.pageSize);
|
|
|
|
|
rows.value = data;
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2024-03-25 18:01:33 +07:00
|
|
|
}
|
|
|
|
|
|
2024-04-03 11:14:26 +07:00
|
|
|
/**
|
|
|
|
|
* funciotn redirect to page เพิ่มหริอแก้ไข รายการโครงการ
|
|
|
|
|
* @param status สถานะแก่ไข
|
|
|
|
|
* @param id รายการโครงการ
|
|
|
|
|
*/
|
2024-03-25 18:01:33 +07:00
|
|
|
function onClickAddOrView(status: boolean = false, id: string = "") {
|
2024-04-03 17:51:00 +07:00
|
|
|
status ? router.push(`/development/${id}`) : router.push("/development/add");
|
2024-03-25 18:01:33 +07:00
|
|
|
}
|
|
|
|
|
|
2024-04-03 11:14:26 +07:00
|
|
|
/**
|
|
|
|
|
* function updatePagination
|
|
|
|
|
* @param newPagination ข้อมูล Pagination ใหม่
|
|
|
|
|
*/
|
|
|
|
|
function updatePagination(newPagination: NewPagination) {
|
|
|
|
|
formQuery.page = 1;
|
|
|
|
|
formQuery.pageSize = newPagination.rowsPerPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** callbackFunction ทำเมื่อมีการอัปเดท pageSize*/
|
|
|
|
|
watch(
|
|
|
|
|
() => formQuery.pageSize,
|
|
|
|
|
() => {
|
|
|
|
|
fetchListProject();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2024-04-09 13:03:18 +07:00
|
|
|
function fetchListProjectNew() {
|
|
|
|
|
formQuery.page = 1;
|
|
|
|
|
fetchListProject();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-09 16:26:10 +07:00
|
|
|
function onDownload() {
|
|
|
|
|
showLoader();
|
|
|
|
|
http
|
|
|
|
|
.get(config.API.developmentReportMain())
|
|
|
|
|
.then((res) => {
|
|
|
|
|
const dataList = res.data.result;
|
|
|
|
|
genReportXLSX(
|
|
|
|
|
dataList,
|
|
|
|
|
"รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด"
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-25 18:01:33 +07:00
|
|
|
onMounted(() => {
|
|
|
|
|
fetchListProject();
|
|
|
|
|
});
|
2024-02-15 11:46:25 +07:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-25 18:01:33 +07:00
|
|
|
<template>
|
|
|
|
|
<div class="toptitle text-dark col-12 row items-center">
|
|
|
|
|
รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด
|
|
|
|
|
</div>
|
|
|
|
|
<q-card flat bordered class="q-pa-md">
|
2024-04-04 16:27:17 +07:00
|
|
|
<q-toolbar style="padding: 0">
|
2024-04-09 13:03:18 +07:00
|
|
|
<div class="row q-gutter-sm">
|
|
|
|
|
<datepicker
|
|
|
|
|
menu-class-name="modalfix"
|
|
|
|
|
v-model="formQuery.year"
|
|
|
|
|
:locale="'th'"
|
|
|
|
|
autoApply
|
|
|
|
|
year-picker
|
|
|
|
|
:enableTimePicker="false"
|
|
|
|
|
@update:model-value="fetchListProjectNew"
|
|
|
|
|
>
|
|
|
|
|
<template #year="{ year }">{{ year + 543 }}</template>
|
|
|
|
|
<template #year-overlay-value="{ value }">{{
|
|
|
|
|
parseInt(value + 543)
|
|
|
|
|
}}</template>
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
lazy-rules
|
|
|
|
|
outlined
|
2024-04-09 16:49:15 +07:00
|
|
|
:model-value="
|
|
|
|
|
formQuery.year === 0 ? 'ทั้งหมด' : Number(formQuery.year) + 543
|
|
|
|
|
"
|
2024-04-09 13:03:18 +07:00
|
|
|
:label="`${'ปีงบประมาณ'}`"
|
|
|
|
|
>
|
2024-04-09 16:49:15 +07:00
|
|
|
<template v-if="formQuery.year" v-slot:append>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="cancel"
|
|
|
|
|
@click.stop.prevent="
|
|
|
|
|
(formQuery.year = 0), fetchListProjectNew()
|
|
|
|
|
"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
2024-04-09 13:03:18 +07:00
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="event"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
style="color: var(--q-primary)"
|
|
|
|
|
>
|
|
|
|
|
</q-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
|
|
|
|
<q-select
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
v-model="formQuery.org"
|
|
|
|
|
:options="orgOp"
|
|
|
|
|
label="หน่วยงาน"
|
|
|
|
|
option-label="name"
|
|
|
|
|
option-value="id"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
@update:model-value="fetchListProjectNew"
|
|
|
|
|
/>
|
|
|
|
|
<q-toolbar-title>
|
|
|
|
|
<q-btn
|
|
|
|
|
flat
|
|
|
|
|
round
|
2024-03-25 18:01:33 +07:00
|
|
|
dense
|
2024-04-09 13:03:18 +07:00
|
|
|
icon="add"
|
|
|
|
|
color="primary"
|
|
|
|
|
@click="onClickAddOrView()"
|
2024-03-25 18:01:33 +07:00
|
|
|
>
|
2024-04-09 13:03:18 +07:00
|
|
|
<q-tooltip>เพิ่ม</q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</q-toolbar-title>
|
|
|
|
|
</div>
|
2024-03-25 18:01:33 +07:00
|
|
|
|
2024-04-04 16:27:17 +07:00
|
|
|
<q-space />
|
|
|
|
|
<div class="row q-gutter-sm">
|
|
|
|
|
<div>
|
|
|
|
|
<q-btn
|
2024-04-09 16:26:10 +07:00
|
|
|
flat
|
|
|
|
|
round
|
|
|
|
|
dense
|
|
|
|
|
icon="mdi-arrow-down-bold-circle-outline"
|
|
|
|
|
color="blue"
|
|
|
|
|
@click="onDownload"
|
|
|
|
|
>
|
|
|
|
|
<q-tooltip>ดาวน์โหลด</q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
<!-- <q-btn
|
2024-04-04 16:27:17 +07:00
|
|
|
flat
|
|
|
|
|
round
|
|
|
|
|
color="blue"
|
|
|
|
|
icon="mdi-arrow-down-bold-circle-outline"
|
|
|
|
|
>
|
|
|
|
|
<q-menu>
|
|
|
|
|
<q-list style="min-width: 100px" dense>
|
2024-04-09 16:26:10 +07:00
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
v-close-popup
|
|
|
|
|
v-for="items in itemDownload"
|
|
|
|
|
:key="items.value"
|
|
|
|
|
@click="onDownload(items.value)"
|
|
|
|
|
>
|
2024-04-04 16:27:17 +07:00
|
|
|
<q-item-section avatar>
|
|
|
|
|
<q-icon :color="items.color" :name="items.icon" />
|
|
|
|
|
</q-item-section>
|
|
|
|
|
<q-item-section :class="`text-${items.color}`">{{
|
|
|
|
|
items.label
|
|
|
|
|
}}</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-menu>
|
|
|
|
|
<q-tooltip>ดาวน์โหลด</q-tooltip>
|
2024-04-09 16:26:10 +07:00
|
|
|
</q-btn> -->
|
2024-04-04 16:27:17 +07:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<q-input
|
|
|
|
|
standout
|
|
|
|
|
dense
|
|
|
|
|
v-model="formQuery.keyword"
|
|
|
|
|
ref="filterRef"
|
|
|
|
|
outlined
|
|
|
|
|
placeholder="ค้นหา"
|
2024-04-09 13:03:18 +07:00
|
|
|
@keyup.enter="fetchListProjectNew"
|
2024-04-04 16:27:17 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:append>
|
|
|
|
|
<q-icon v-if="formQuery.keyword == ''" name="search" />
|
|
|
|
|
<q-icon
|
|
|
|
|
v-if="formQuery.keyword !== ''"
|
|
|
|
|
name="clear"
|
|
|
|
|
class="cursor-pointer"
|
2024-04-05 16:31:36 +07:00
|
|
|
@click="
|
|
|
|
|
(formQuery.keyword = ''),
|
|
|
|
|
fetchListProject(),
|
|
|
|
|
(formQuery.page = 1)
|
|
|
|
|
"
|
2024-04-04 16:27:17 +07:00
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<q-select
|
|
|
|
|
v-model="visibleColumns"
|
|
|
|
|
multiple
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
options-dense
|
|
|
|
|
:display-value="$q.lang.table.columns"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
:options="columns"
|
|
|
|
|
option-value="name"
|
|
|
|
|
options-cover
|
|
|
|
|
style="min-width: 150px"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-03-25 18:01:33 +07:00
|
|
|
</div>
|
|
|
|
|
</q-toolbar>
|
|
|
|
|
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<d-table
|
|
|
|
|
for="table"
|
|
|
|
|
ref="table"
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:rows="rows"
|
2024-04-03 11:14:26 +07:00
|
|
|
row-key="id"
|
2024-03-25 18:01:33 +07:00
|
|
|
flat
|
|
|
|
|
bordered
|
|
|
|
|
dense
|
|
|
|
|
class="custom-header-table"
|
2024-04-03 11:14:26 +07:00
|
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
2024-03-25 18:01:33 +07:00
|
|
|
:visible-columns="visibleColumns"
|
2024-04-03 11:14:26 +07:00
|
|
|
@update:pagination="updatePagination"
|
2024-03-25 18:01:33 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:header="props">
|
|
|
|
|
<q-tr :props="props">
|
|
|
|
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
|
|
|
|
<span class="text-weight-medium">{{ col.label }}</span>
|
|
|
|
|
</q-th>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:body="props">
|
|
|
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
|
|
|
<q-td
|
|
|
|
|
v-for="col in props.cols"
|
|
|
|
|
:key="col.name"
|
|
|
|
|
:props="props"
|
|
|
|
|
@click="onClickAddOrView(true, props.row.id)"
|
|
|
|
|
>
|
|
|
|
|
<div class="table_ellipsis">
|
|
|
|
|
{{ col.value ? col.value : "-" }}
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
2024-04-03 11:14:26 +07:00
|
|
|
<template v-slot:pagination="scope">
|
|
|
|
|
<q-pagination
|
|
|
|
|
v-model="formQuery.page"
|
|
|
|
|
active-color="primary"
|
|
|
|
|
color="dark"
|
|
|
|
|
:max="Number(totalList)"
|
|
|
|
|
size="sm"
|
|
|
|
|
boundary-links
|
|
|
|
|
direction-links
|
|
|
|
|
:max-pages="5"
|
|
|
|
|
@update:model-value="fetchListProject"
|
|
|
|
|
></q-pagination>
|
|
|
|
|
</template>
|
2024-03-25 18:01:33 +07:00
|
|
|
</d-table>
|
|
|
|
|
</div>
|
|
|
|
|
</q-card>
|
|
|
|
|
</template>
|
2024-02-15 11:46:25 +07:00
|
|
|
|
2024-04-04 11:18:30 +07:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.table_ellipsis {
|
|
|
|
|
max-width: 400px;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
|
|
|
|
</style>
|