2023-12-14 10:43:13 +07:00
|
|
|
<script setup lang="ts">
|
2023-12-20 13:50:54 +07:00
|
|
|
import { onMounted, ref, watch, useAttrs } from "vue";
|
2023-12-14 10:43:13 +07:00
|
|
|
import { useQuasar } from "quasar";
|
|
|
|
|
import { useRouter } from "vue-router";
|
|
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
|
|
|
|
|
2023-12-15 13:30:39 +07:00
|
|
|
import Table from "@/modules/12_evaluatePersonal/components/Table.vue";
|
2023-12-14 10:43:13 +07:00
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
2023-12-15 13:30:39 +07:00
|
|
|
import { useEvalutuonStore } from "@/modules/12_evaluatePersonal/store/Evaluate";
|
2023-12-14 10:43:13 +07:00
|
|
|
import type { Pagination } from "@/modules/03_recruiting/interface/index/Main";
|
|
|
|
|
|
|
|
|
|
const $q = useQuasar(); // show dialog
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
//search data table
|
|
|
|
|
const mixin = useCounterMixin();
|
2023-12-14 11:31:12 +07:00
|
|
|
const store = useEvalutuonStore();
|
2023-12-14 10:43:13 +07:00
|
|
|
const { showLoader, hideLoader, messageError } = mixin;
|
2023-12-20 13:50:54 +07:00
|
|
|
const attrs = ref<any>(useAttrs());
|
2023-12-27 10:39:58 +07:00
|
|
|
|
2023-12-20 12:43:08 +07:00
|
|
|
function Detailpage(id: string) {
|
2023-12-19 15:05:48 +07:00
|
|
|
router.push(`/evaluate/detail/${id}`);
|
2023-12-14 19:39:58 +07:00
|
|
|
}
|
2023-12-14 10:43:13 +07:00
|
|
|
|
2023-12-20 12:43:08 +07:00
|
|
|
const currentPage = ref<number>(1);
|
2023-12-27 10:39:58 +07:00
|
|
|
const maxPage = ref<number>(0);
|
2023-12-20 12:43:08 +07:00
|
|
|
const page = ref<number>(1);
|
2023-12-25 18:51:07 +07:00
|
|
|
const total = ref<number>(0);
|
2023-12-14 10:43:13 +07:00
|
|
|
const filter = ref<string>("");
|
2023-12-27 10:39:58 +07:00
|
|
|
const pageSize = ref<number>(10);
|
|
|
|
|
|
2023-12-20 12:43:08 +07:00
|
|
|
/**
|
|
|
|
|
*pagination ของตาราง
|
|
|
|
|
*/
|
2023-12-27 10:39:58 +07:00
|
|
|
const initialPagination = ref<any>({
|
|
|
|
|
sortBy: null,
|
2023-12-20 12:43:08 +07:00
|
|
|
descending: false,
|
2023-12-27 10:39:58 +07:00
|
|
|
page: 1,
|
|
|
|
|
rowsPerPage: pageSize,
|
2023-12-20 12:43:08 +07:00
|
|
|
});
|
|
|
|
|
|
2023-12-25 18:51:07 +07:00
|
|
|
// Pagination - update rowsPerPage
|
|
|
|
|
async function updatePagination(initialPagination: any) {
|
|
|
|
|
currentPage.value = 1;
|
2023-12-27 10:39:58 +07:00
|
|
|
pageSize.value = initialPagination.rowsPerPage;
|
2023-12-25 18:51:07 +07:00
|
|
|
page.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
|
|
|
|
}
|
2023-12-27 10:39:58 +07:00
|
|
|
// Pagination - page & change page & get new data
|
2023-12-20 12:43:08 +07:00
|
|
|
watch(
|
2023-12-27 10:39:58 +07:00
|
|
|
[
|
|
|
|
|
() => currentPage.value,
|
|
|
|
|
() => (pageSize.value = initialPagination.value.rowsPerPage),
|
|
|
|
|
],
|
|
|
|
|
async () => {
|
2023-12-20 12:43:08 +07:00
|
|
|
getList();
|
|
|
|
|
}
|
|
|
|
|
);
|
2023-12-27 10:39:58 +07:00
|
|
|
// Pagination - page & change page & get new data
|
2023-12-20 12:43:08 +07:00
|
|
|
watch(
|
2023-12-27 10:39:58 +07:00
|
|
|
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
|
|
|
|
async () => {
|
|
|
|
|
page.value = currentPage.value;
|
|
|
|
|
await getList();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
watch(
|
|
|
|
|
() => initialPagination.value.rowsPerPage,
|
2023-12-20 12:43:08 +07:00
|
|
|
() => {
|
2023-12-27 10:39:58 +07:00
|
|
|
pageSize.value = initialPagination.value.rowsPerPage;
|
2023-12-20 12:43:08 +07:00
|
|
|
currentPage.value = 1;
|
|
|
|
|
getList();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2023-12-27 10:39:58 +07:00
|
|
|
/**
|
|
|
|
|
* filter function
|
|
|
|
|
*/
|
|
|
|
|
const filterRef = ref<HTMLInputElement | null>(null);
|
2023-12-21 11:58:37 +07:00
|
|
|
function filterFn() {
|
2023-12-27 10:39:58 +07:00
|
|
|
updatePagination(filter.value);
|
|
|
|
|
pageSize.value = initialPagination.value.rowsPerPage;
|
2023-12-21 11:58:37 +07:00
|
|
|
getList();
|
|
|
|
|
}
|
2023-12-27 10:39:58 +07:00
|
|
|
const resetFilter = () => {
|
|
|
|
|
filter.value = "";
|
|
|
|
|
getList();
|
|
|
|
|
if (filterRef.value) {
|
|
|
|
|
filterRef.value.focus();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-20 12:43:08 +07:00
|
|
|
function getList() {
|
|
|
|
|
showLoader();
|
|
|
|
|
http
|
|
|
|
|
.get(
|
2023-12-27 10:39:58 +07:00
|
|
|
config.API.evaluationMain(currentPage.value, pageSize.value, filter.value)
|
2023-12-20 12:43:08 +07:00
|
|
|
)
|
2023-12-25 18:51:07 +07:00
|
|
|
.then(async (res) => {
|
2023-12-27 10:39:58 +07:00
|
|
|
const data = res.data.result.data;
|
2023-12-25 18:51:07 +07:00
|
|
|
total.value = res.data.result.total;
|
|
|
|
|
console.log(res.data.result.total);
|
2023-12-27 10:39:58 +07:00
|
|
|
maxPage.value = await Math.ceil(total.value / pageSize.value);
|
|
|
|
|
maxPage.value = maxPage.value < 1 ? 1 : maxPage.value;
|
|
|
|
|
console.log(total.value);
|
|
|
|
|
console.log(pageSize.value);
|
2023-12-25 18:51:07 +07:00
|
|
|
console.log(maxPage.value);
|
|
|
|
|
|
2023-12-20 12:43:08 +07:00
|
|
|
store.fetchData(data);
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-12-14 10:43:13 +07:00
|
|
|
|
|
|
|
|
/**เมื่อเริ่มโหลดหน้า
|
|
|
|
|
* ส่งข้อมูลจำลองไปยัง store
|
|
|
|
|
*/
|
2023-12-14 19:39:58 +07:00
|
|
|
onMounted(async () => {
|
2023-12-20 12:43:08 +07:00
|
|
|
getList();
|
2023-12-14 19:39:58 +07:00
|
|
|
});
|
2023-12-14 10:43:13 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="toptitle text-dark col-12 row items-center">
|
|
|
|
|
รายการคำขอประเมิน
|
|
|
|
|
</div>
|
|
|
|
|
<q-card flat bordered class="col-12 q-mt-sm q-pt-sm q-pa-md">
|
2023-12-21 11:58:37 +07:00
|
|
|
<div class="row col-12 q-col-gutter-sm q-mb-sm">
|
|
|
|
|
<q-space />
|
|
|
|
|
<q-input
|
|
|
|
|
class="col-xs-12 col-sm-3 col-md-2"
|
|
|
|
|
id="filterTable"
|
|
|
|
|
for="filterTable"
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
v-model="filter"
|
|
|
|
|
label="ค้นหา"
|
|
|
|
|
debounce="300"
|
|
|
|
|
@keydown.enter.prevent="filterFn"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:append>
|
2023-12-27 10:39:58 +07:00
|
|
|
<q-icon v-if="filter == ''" name="search" />
|
|
|
|
|
<q-icon
|
|
|
|
|
v-if="filter !== ''"
|
|
|
|
|
name="clear"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
@click="resetFilter"
|
|
|
|
|
/>
|
2023-12-21 11:58:37 +07:00
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
|
|
|
|
|
<q-select
|
|
|
|
|
id="visibleColumns"
|
|
|
|
|
for="visibleColumns"
|
|
|
|
|
v-model="store.visibleColumns"
|
|
|
|
|
multiple
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
options-dense
|
|
|
|
|
:display-value="$q.lang.table.columns"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
:options="store.columns"
|
|
|
|
|
option-value="name"
|
|
|
|
|
options-cover
|
|
|
|
|
class="col-xs-12 col-sm-3 col-md-2"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2023-12-14 10:43:13 +07:00
|
|
|
<div>
|
2023-12-20 13:50:54 +07:00
|
|
|
<d-table
|
|
|
|
|
ref="table"
|
2023-12-14 10:43:13 +07:00
|
|
|
:columns="store.columns"
|
2023-12-20 13:50:54 +07:00
|
|
|
:rows="store.rows"
|
|
|
|
|
row-key="interrogated"
|
|
|
|
|
flat
|
|
|
|
|
bordered
|
2023-12-27 10:39:58 +07:00
|
|
|
:paging="false"
|
2023-12-20 13:50:54 +07:00
|
|
|
dense
|
|
|
|
|
class="custom-header-table"
|
|
|
|
|
:visible-columns="store.visibleColumns"
|
2023-12-27 10:39:58 +07:00
|
|
|
v-model:pagination="initialPagination"
|
2024-01-03 14:44:55 +07:00
|
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
2023-12-25 18:51:07 +07:00
|
|
|
@update:pagination="updatePagination"
|
2023-12-14 10:43:13 +07:00
|
|
|
>
|
2023-12-25 18:51:07 +07:00
|
|
|
<template v-slot:pagination="scope">
|
|
|
|
|
ทั้งหมด {{ total }} รายการ
|
|
|
|
|
<q-pagination
|
|
|
|
|
v-model="currentPage"
|
|
|
|
|
active-color="primary"
|
|
|
|
|
color="dark"
|
|
|
|
|
:max="Number(maxPage)"
|
|
|
|
|
size="sm"
|
|
|
|
|
boundary-links
|
|
|
|
|
direction-links
|
|
|
|
|
></q-pagination>
|
|
|
|
|
</template>
|
2023-12-20 13:50:54 +07:00
|
|
|
<template v-slot:header="props">
|
|
|
|
|
<q-tr :props="props">
|
|
|
|
|
<q-th auto-width></q-th>
|
2023-12-25 18:51:07 +07:00
|
|
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
2023-12-20 13:50:54 +07:00
|
|
|
<span class="text-weight-medium">{{ col.label }}</span>
|
|
|
|
|
</q-th>
|
|
|
|
|
<q-th auto-width></q-th>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:body="props">
|
2023-12-14 10:43:13 +07:00
|
|
|
<q-tr :props="props" class="cursor-pointer">
|
2023-12-26 09:18:03 +07:00
|
|
|
<!-- <q-td v-for="col in props.cols" :key="col.name" :props="props">
|
2023-12-25 18:51:07 +07:00
|
|
|
<div v-if="col.name == 'no'">
|
|
|
|
|
{{ (page - 1) * rowsPerPage + props.rowIndex + 1 }}
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
{{ col.value }}
|
|
|
|
|
</div>
|
2023-12-26 09:18:03 +07:00
|
|
|
</q-td> -->
|
2023-12-20 13:50:54 +07:00
|
|
|
<q-td auto-width>
|
|
|
|
|
<q-icon
|
|
|
|
|
v-if="props.row.isDefault === true"
|
|
|
|
|
name="mdi-bookmark"
|
|
|
|
|
size="xs"
|
|
|
|
|
color="primary"
|
|
|
|
|
>
|
|
|
|
|
<q-tooltip>เวลา Default</q-tooltip>
|
|
|
|
|
</q-icon>
|
|
|
|
|
</q-td>
|
2023-12-20 12:43:08 +07:00
|
|
|
<q-td
|
|
|
|
|
v-for="col in props.cols"
|
|
|
|
|
:key="col.name"
|
|
|
|
|
:props="props"
|
|
|
|
|
@click="Detailpage(props.row.id)"
|
|
|
|
|
>
|
2023-12-14 10:43:13 +07:00
|
|
|
<div v-if="col.name == 'no'">
|
2023-12-27 10:39:58 +07:00
|
|
|
{{ (page - 1) * pageSize + props.rowIndex + 1 }}
|
2023-12-14 10:43:13 +07:00
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
{{ col.value }}
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
2023-12-20 13:50:54 +07:00
|
|
|
</d-table>
|
2023-12-14 10:43:13 +07:00
|
|
|
</div>
|
|
|
|
|
</q-card>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style></style>
|