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";
|
|
|
|
|
|
|
|
|
|
/**importType*/
|
|
|
|
|
import type {
|
|
|
|
|
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
|
|
|
|
|
|
|
|
/** หัวตาราง */
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
label: "ดาวน์โหลด 1",
|
|
|
|
|
value: "",
|
|
|
|
|
icon: "mdi-file-pdf-box",
|
|
|
|
|
color: "green",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "ดาวน์โหลด 2",
|
|
|
|
|
value: "",
|
|
|
|
|
icon: "mdi-file-table",
|
|
|
|
|
color: "red",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "ดาวน์โหลด 3",
|
|
|
|
|
value: "",
|
|
|
|
|
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,
|
|
|
|
|
keyword: "",
|
|
|
|
|
});
|
|
|
|
|
const totalList = ref<number>(1); //จำนวนข้อมูลรายการ
|
|
|
|
|
const rows = ref<ResListProject[]>([]); // ข้อมูลรายการ
|
|
|
|
|
|
|
|
|
|
/** 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-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">
|
|
|
|
|
<q-toolbar style="padding: 0px">
|
|
|
|
|
<datepicker
|
|
|
|
|
menu-class-name="modalfix"
|
2024-04-03 11:14:26 +07:00
|
|
|
v-model="formQuery.year"
|
2024-03-25 18:01:33 +07:00
|
|
|
:locale="'th'"
|
|
|
|
|
autoApply
|
|
|
|
|
year-picker
|
|
|
|
|
:enableTimePicker="false"
|
2024-04-03 11:14:26 +07:00
|
|
|
@update:model-value="fetchListProject"
|
2024-03-25 18:01:33 +07:00
|
|
|
>
|
|
|
|
|
<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-03 11:14:26 +07:00
|
|
|
:model-value="Number(formQuery.year) + 543"
|
2024-03-25 18:01:33 +07:00
|
|
|
:label="`${'ปีงบประมาณ'}`"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="event"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
style="color: var(--q-primary)"
|
|
|
|
|
>
|
|
|
|
|
</q-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
2024-04-02 10:23:22 +07:00
|
|
|
<q-btn
|
|
|
|
|
flat
|
|
|
|
|
round
|
|
|
|
|
dense
|
|
|
|
|
icon="add"
|
|
|
|
|
color="primary"
|
|
|
|
|
@click="onClickAddOrView()"
|
|
|
|
|
>
|
2024-03-25 18:01:33 +07:00
|
|
|
<q-tooltip>เพิ่ม</q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
<q-space />
|
|
|
|
|
<div class="row q-gutter-sm">
|
2024-04-02 17:25:48 +07:00
|
|
|
<q-btn
|
|
|
|
|
flat
|
|
|
|
|
round
|
|
|
|
|
color="blue"
|
|
|
|
|
icon="mdi-arrow-down-bold-circle-outline"
|
|
|
|
|
>
|
2024-04-02 10:23:22 +07:00
|
|
|
<q-menu>
|
|
|
|
|
<q-list style="min-width: 100px" dense>
|
|
|
|
|
<q-item clickable v-close-popup v-for="items in itemDownload">
|
|
|
|
|
<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>
|
2024-04-02 17:25:48 +07:00
|
|
|
<q-tooltip>ดาวน์โหลด</q-tooltip>
|
2024-04-02 10:23:22 +07:00
|
|
|
</q-btn>
|
|
|
|
|
|
2024-03-25 18:01:33 +07:00
|
|
|
<q-input
|
|
|
|
|
standout
|
|
|
|
|
dense
|
2024-04-03 11:14:26 +07:00
|
|
|
v-model="formQuery.keyword"
|
2024-03-25 18:01:33 +07:00
|
|
|
ref="filterRef"
|
|
|
|
|
outlined
|
|
|
|
|
placeholder="ค้นหา"
|
2024-04-03 11:14:26 +07:00
|
|
|
@keyup.enter="fetchListProject"
|
2024-03-25 18:01:33 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:append>
|
2024-04-03 11:14:26 +07:00
|
|
|
<q-icon v-if="formQuery.keyword == ''" name="search" />
|
2024-03-25 18:01:33 +07:00
|
|
|
<q-icon
|
2024-04-03 11:14:26 +07:00
|
|
|
v-if="formQuery.keyword !== ''"
|
2024-03-25 18:01:33 +07:00
|
|
|
name="clear"
|
|
|
|
|
class="cursor-pointer"
|
2024-04-03 11:14:26 +07:00
|
|
|
@click="(formQuery.keyword = ''), fetchListProject()"
|
2024-03-25 18:01:33 +07:00
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
</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
|
|
|
|
|
|
|
|
<style scoped></style>
|