315 lines
9.3 KiB
Vue
315 lines
9.3 KiB
Vue
<script setup lang="ts">
|
|
import { onMounted, ref, watch, computed } from "vue";
|
|
import { useQuasar } from "quasar";
|
|
import { useRouter } from "vue-router";
|
|
import http from "@/plugins/http";
|
|
import config from "@/app.config";
|
|
|
|
/** importType*/
|
|
import type { OptionStatus } from "@/modules/12_evaluatePersonal/interface/index/Main";
|
|
|
|
/** importStore*/
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useEvalutuonStore } from "@/modules/12_evaluatePersonal/store/Evaluate";
|
|
|
|
/** use*/
|
|
const $q = useQuasar();
|
|
const router = useRouter();
|
|
const mixin = useCounterMixin();
|
|
const store = useEvalutuonStore();
|
|
const { showLoader, hideLoader, messageError } = mixin;
|
|
|
|
/** request body*/
|
|
const currentPage = ref<number>(1);
|
|
const maxPage = ref<number>(0);
|
|
const page = ref<number>(1);
|
|
const total = ref<number>(0);
|
|
const filter = ref<string>("");
|
|
const pageSize = ref<number>(10);
|
|
|
|
/** pagination ของตาราง*/
|
|
const initialPagination = ref<any>({
|
|
sortBy: null,
|
|
descending: false,
|
|
page: 1,
|
|
rowsPerPage: pageSize,
|
|
});
|
|
|
|
/**
|
|
* function อัปเดท paging
|
|
* @param initialPagination ข้อมูล pagination
|
|
*/
|
|
async function updatePagination(initialPagination: any) {
|
|
currentPage.value = 1;
|
|
pageSize.value = initialPagination.rowsPerPage;
|
|
page.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
|
}
|
|
|
|
/** function callback เมื่อมีการเปลี่ยนหน้า*/
|
|
watch(
|
|
[
|
|
() => currentPage.value,
|
|
() => (pageSize.value = initialPagination.value.rowsPerPage),
|
|
],
|
|
async () => {
|
|
fetchEvaluteList();
|
|
}
|
|
);
|
|
|
|
/** function callback เมื่อมีการเปลี่ยนหน้า*/
|
|
watch(
|
|
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
|
async () => {
|
|
page.value = currentPage.value;
|
|
await fetchEvaluteList();
|
|
}
|
|
);
|
|
|
|
/** function callback เมื่อมีการเปลี่ยนจำนวนแถว*/
|
|
watch(
|
|
() => initialPagination.value.rowsPerPage,
|
|
() => {
|
|
pageSize.value = initialPagination.value.rowsPerPage;
|
|
currentPage.value = 1;
|
|
fetchEvaluteList();
|
|
}
|
|
);
|
|
|
|
const filterRef = ref<HTMLInputElement | null>(null);
|
|
/** function ค้นหาตาม keyword*/
|
|
function filterFn() {
|
|
updatePagination(filter.value);
|
|
pageSize.value = initialPagination.value.rowsPerPage;
|
|
fetchEvaluteList();
|
|
}
|
|
|
|
/** functrion ล้างค้นหา*/
|
|
function resetFilter() {
|
|
filter.value = "";
|
|
fetchEvaluteList();
|
|
if (filterRef.value) {
|
|
filterRef.value.focus();
|
|
}
|
|
}
|
|
|
|
/** function เรียกรายการคำขอประเมิน*/
|
|
async function fetchEvaluteList() {
|
|
showLoader();
|
|
const body = {
|
|
page: currentPage.value,
|
|
pageSize: pageSize.value,
|
|
keyword: filter.value,
|
|
status: selectedStatus.value,
|
|
};
|
|
await http
|
|
.put(config.API.evaluationMain(), body)
|
|
.then(async (res) => {
|
|
const data = res.data.result.data;
|
|
total.value = res.data.result.total;
|
|
maxPage.value = await Math.ceil(total.value / pageSize.value);
|
|
maxPage.value = maxPage.value < 1 ? 1 : maxPage.value;
|
|
store.fetchData(data);
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* funcition redirectToDetail
|
|
* @param id รายการคำขอประเมิน
|
|
*/
|
|
function Detailpage(id: string) {
|
|
router.push(`/evaluate/detail/${id}`);
|
|
}
|
|
|
|
const selectedStatus = ref<string[]>([
|
|
"CHECK_SPEC",
|
|
"PREPARE_DOC_V1",
|
|
"CHECK_DOC_V1",
|
|
"WAIT_CHECK_DOC_V1",
|
|
"ANNOUNCE_WEB",
|
|
"PREPARE_DOC_V2",
|
|
"WAIT_CHECK_DOC_V2",
|
|
"CHECK_DOC_V2",
|
|
]);
|
|
const options = ref<OptionStatus[]>([]);
|
|
const optionsMain = ref<OptionStatus[]>([
|
|
{ val: "CHECK_SPEC", label: "ตรวจสอบคุณสมบัติด้วยตนเอง" },
|
|
{ val: "PREPARE_DOC_V1", label: "จัดเตรียมเอกสารเล่ม 1" },
|
|
{ val: "CHECK_DOC_V1", label: "ตรวจสอบความถูกต้องของเอกสารเล่ม 1" },
|
|
{ val: "WAIT_CHECK_DOC_V1", label: "รอตรวจสอบคุณสมบัติ" },
|
|
{ val: "ANNOUNCE_WEB", label: "ประกาศบนเว็บไซต์" },
|
|
{ val: "PREPARE_DOC_V2", label: "จัดเตรียมเอกสารเล่ม 2" },
|
|
{ val: "WAIT_CHECK_DOC_V2", label: "รอพิจารณาผลการประเมิน" },
|
|
{ val: "CHECK_DOC_V2", label: "ตรวจสอบความถูกต้องของเอกสารเล่ม" },
|
|
{ val: "DONE", label: "เสร็จสิ้น" },
|
|
]);
|
|
|
|
/** ชื่อค่าที่ค้นหาสภานะ*/
|
|
const label = computed(() => {
|
|
const filterOption = optionsMain.value.filter((option) =>
|
|
selectedStatus.value.includes(option.val)
|
|
);
|
|
const labelval = filterOption.map((e) => e.label);
|
|
if (labelval.length !== 0) {
|
|
return labelval.length <= 2
|
|
? `${labelval.slice(0, 2).join(", ")}`
|
|
: `${labelval.slice(0, 2).join(", ")}, อื่นๆ (${labelval.length - 2})`;
|
|
} else return "";
|
|
});
|
|
|
|
/**
|
|
* function ต้นหาข้อมูลของ Option
|
|
* @param val ค่าที่ต้องการฟิลเตอร์
|
|
* @param update อัพเดทค่า
|
|
* @param refData ดาต้าที่ต้องการฟิลเตอร์
|
|
*/
|
|
function filterOption(val: any, update: Function) {
|
|
update(() => {
|
|
options.value = optionsMain.value.filter(
|
|
(v: any) => v.label.indexOf(val) > -1
|
|
);
|
|
});
|
|
}
|
|
|
|
/** HookLifecycle */
|
|
onMounted(async () => {
|
|
await fetchEvaluteList(); // เรียกข้อมูลรายการปรัเมิน
|
|
});
|
|
</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">
|
|
<div class="row col-12 q-col-gutter-sm q-mb-sm">
|
|
<q-select
|
|
dense
|
|
outlined
|
|
multiple
|
|
v-model="selectedStatus"
|
|
emit-value
|
|
map-options
|
|
:options="options"
|
|
option-value="val"
|
|
label="ค้นหาสถานะ"
|
|
style="width: 35vw"
|
|
@update:model-value="fetchEvaluteList"
|
|
use-input
|
|
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) "
|
|
>
|
|
<template v-slot:selected>
|
|
<div>
|
|
{{ label }}
|
|
</div>
|
|
</template>
|
|
<template v-slot:no-option>
|
|
<q-item>
|
|
<q-item-section class="text-grey"> ไม่มีข้อมูล </q-item-section>
|
|
</q-item>
|
|
</template>
|
|
</q-select>
|
|
|
|
<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>
|
|
<q-icon v-if="filter == ''" name="search" />
|
|
<q-icon
|
|
v-if="filter !== ''"
|
|
name="clear"
|
|
class="cursor-pointer"
|
|
@click="resetFilter"
|
|
/>
|
|
</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>
|
|
<div>
|
|
<d-table
|
|
ref="table"
|
|
:columns="store.columns"
|
|
:rows="store.rows"
|
|
row-key="interrogated"
|
|
flat
|
|
bordered
|
|
:paging="false"
|
|
dense
|
|
class="custom-header-table"
|
|
:visible-columns="store.visibleColumns"
|
|
v-model:pagination="initialPagination"
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
|
@update:pagination="updatePagination"
|
|
>
|
|
<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="Detailpage(props.row.id)"
|
|
>
|
|
<div v-if="col.name == 'no'">
|
|
{{ (page - 1) * pageSize + props.rowIndex + 1 }}
|
|
</div>
|
|
<div v-else>
|
|
{{ col.value }}
|
|
</div>
|
|
</q-td>
|
|
</q-tr>
|
|
</template>
|
|
<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>
|
|
</d-table>
|
|
</div>
|
|
</q-card>
|
|
</template>
|
|
|
|
<style></style>
|