ข้อมูลทะเบียนประวัติ => ปรับ filter

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-07-08 17:00:01 +07:00
parent 2c924d24d5
commit 3800da7166

View file

@ -6,7 +6,10 @@ import config from "@/app.config";
/** importType*/
import type { DataOption } from "@/modules/04_registryNew/interface/index/Main";
import type { DataPerson } from "@/modules/04_registryNew/interface/response/Main";
import type {
DataPerson,
DataType,
} from "@/modules/04_registryNew/interface/response/Main";
import type { FormFilter } from "@/modules/04_registryNew/interface/request/Main";
/** importComponents*/
@ -47,6 +50,7 @@ const formFilter = reactive<FormFilter>({
isProbation: false,
});
const maxPage = ref<number>(1);
const total = ref<number>(0);
const dataPersonMain = ref<DataPerson[]>([]);
@ -61,7 +65,9 @@ const conditionTotal = computed(() => {
return num;
});
/** function เรียกข้อมูลตำแหน่งประเภท*/
/**
* function เรยกขอมลตำแหนงประเภท
*/
function fetchType() {
http
.get(config.API.orgPosType)
@ -74,17 +80,20 @@ function fetchType() {
}
/** function เรียกข้อมูลระดับ*/
function fetchLevel() {
http
.get(config.API.orgPosLevel)
.then((res) => {
store.fetchLevel(res.data.result);
})
.catch((err) => {
messageError($q, err);
});
}
// function fetchLevel() {
// http
// .get(config.API.orgPosLevel)
// .then((res) => {
// store.fetchLevel(res.data.result);
// })
// .catch((err) => {
// messageError($q, err);
// });
// }
/**
* function เรยกขอมลกลมงาน
*/
function fetchOptionGroup() {
http
.get(config.API.orgEmployeeType)
@ -96,16 +105,16 @@ function fetchOptionGroup() {
});
}
function fetchLevelGroup() {
http
.get(config.API.orgEmployeelevel)
.then((res) => {
store.fetchLevel(res.data.result);
})
.catch((err) => {
messageError($q, err);
});
}
// function fetchLevelGroup() {
// http
// .get(config.API.orgEmployeelevel)
// .then((res) => {
// store.fetchLevel(res.data.result);
// })
// .catch((err) => {
// messageError($q, err);
// });
// }
function fetchYearOption() {
if (store.yearOps.length === 0) {
@ -121,16 +130,17 @@ function fetchYearOption() {
}
}
const total = ref<number>(0);
async function fetchDataPerson(search: boolean = false) {
/**
* function fetch รายชอขอมลทะเบยนประว
*/
function fetchDataPerson() {
showLoader();
let queryParams: any = {
page: formFilter.page,
pageSize: formFilter.pageSize,
};
if (search) {
if (formFilter.keyword) {
queryParams = Object.assign({}, queryParams, {
searchField: searchType.value,
searchKeyword: formFilter.keyword,
@ -180,6 +190,10 @@ async function fetchDataPerson(search: boolean = false) {
});
}
/**
* function fetch ปโปรไฟล
* @param items อมลคน
*/
function insertAvatar(items: DataPerson[]) {
items.map((x: any, index: number) => {
if (x.avatarName != null) {
@ -208,29 +222,39 @@ function insertAvatar(items: DataPerson[]) {
});
}
/**
* funciotn แสดงตวเลอกเพมเต
*/
function onClickShowFilter() {
isShowFilter.value = !isShowFilter.value;
isShowBtnFilter.value = false;
if (isShowFilter.value) {
fetchType();
fetchLevel();
// fetchLevel();
fetchYearOption();
}
}
/**
* funciotn นหาขอม
*/
function onclickSearch() {
isShowFilter.value = true;
isShowBtnFilter.value = false;
formFilter.page = 1;
if (isShowFilter.value) {
fetchType();
fetchLevel();
// fetchLevel();
fetchYearOption();
}
formFilter.keyword = formFilter.keyword === null ? "" : formFilter.keyword;
fetchDataPerson(true);
fetchDataPerson();
}
/**
* function เลอกประเภทขาราชการ
* @param item ประเภทขาราชการ
*/
function selectType(item: DataOption) {
labelOption.type = item.name;
empType.value = item.id;
@ -242,30 +266,46 @@ function selectType(item: DataOption) {
formFilter.isShowRetire = null;
formFilter.isProbation = null;
fetchOptionGroup();
fetchLevelGroup();
// fetchLevelGroup();
} else {
fetchType();
fetchLevel();
// fetchLevel();
}
fetchDataPerson(true);
fetchDataPerson();
}
/**
* function เลอกประเภทตำแหน
* @param item ประเภทตำแหน
*/
function selectPosType(item: DataOption) {
const dataType = store.posTypeMain.find((e: DataType) => e.id === item.id);
store.fetchLevel(dataType?.posLevels);
labelOption.posType = item.name;
labelOption.posLevel = "ทั้งหมด";
formFilter.page = 1;
fetchDataPerson();
}
/**
* function เลอกประเภทตำแหน
* @param item ประเภทระด
*/
function selectPosLevel(item: DataOption) {
labelOption.posLevel = item.name;
formFilter.page = 1;
fetchDataPerson();
}
/**
* function เคลวเลอก
* @param t ประเภทตวเลอก
*/
function clearSelect(t: string) {
if (t === "posType") {
labelOption.posType = "ทั้งหมด";
labelOption.posLevel = "ทั้งหมด";
} else if (t === "posLevel") {
labelOption.posLevel = "ทั้งหมด";
} else if (t === "retireYear") {
@ -425,7 +465,6 @@ onMounted(async () => {
</q-btn-dropdown>
<q-separator inset vertical class="lineFil" />
<q-btn-dropdown
flat
dense
@ -433,6 +472,7 @@ onMounted(async () => {
label-color="white"
dropdown-icon="mdi-chevron-down"
class="q-px-sm"
:disable="labelOption.posType === 'ทั้งหมด' ? true : false"
>
<template v-slot:label>
{{