อัตรากำลังลูกจ้างประจำ ฯ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-12-03 13:49:17 +07:00
parent ac0bc84da3
commit 93fd5012eb
6 changed files with 114 additions and 91 deletions

View file

@ -224,7 +224,7 @@ async function searchInput() {
await http
.get(
config.API.orgEmployeePos +
`?keyword=${search.value}&type=${type.value}`
`?keyword=${search.value.trim()}&type=${type.value}`
)
.then((res) => {
rowsPositionSelect.value = res.data.result;
@ -556,15 +556,12 @@ watch(
<div class="col-12 col-sm-6 col-md-6">
<q-input
ref="searchRef"
:class="inputEdit(isReadonly)"
v-model="search"
outlined
clearable
dense
lazy-rules
label="คำค้น"
hide-bottom-space
:rules="[(val:string) => !!val || `กรุณากรอกคำค้น`]"
@keydown.enter.prevent="searchInput()"
/>
</div>
@ -575,6 +572,7 @@ watch(
icon="search"
label="ค้นหา"
class="full-width q-pa-sm"
outline
@click="searchInput()"
>
</q-btn>

View file

@ -41,6 +41,7 @@ const {
messageError,
dialogMessageNotify,
success,
filterTableQuasar,
} = useCounterMixin();
/**
@ -79,14 +80,7 @@ const levelTree = ref<number>(0);
const filterTable = ref<string>("");
const selectedFilter = ref<PosMaster2[]>([]);
/**
* function เช filter
*/
function resetFilter() {
filterTree.value = "";
filterRef.value.focus();
}
const dataMain = ref<PosMaster2[]>([...rows.value]);
/**
* function เลอกขอมลหนวยงาน
@ -155,12 +149,22 @@ const pagination = ref({
rowsPerPage: reqMaster.value.pageSize,
});
function onSerachDataTable() {
rows.value = filterTableQuasar(
filterTable.value,
dataMain.value,
columns.value ?? []
);
}
watch(
() => modal.value,
() => {
reqMaster.value.page = 1;
filterTree.value = "";
pagination.value.rowsPerPage = reqMaster.value.pageSize;
dataMain.value = rows.value;
filterTable.value = "";
title.value = `ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน ${props.mainTree.orgName}`;
if (modal.value && props.type === "SINGER") {
@ -200,75 +204,85 @@ watch(
<q-space />
<div>
<q-input outlined dense v-model="filterTable" label="ค้นหา" />
<q-input
outlined
dense
v-model="filterTable"
label="ค้นหา"
@keydown.enter="onSerachDataTable"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
</div>
</q-toolbar>
<div class="col-12">
<d-table
flat
bordered
:rows="rows"
:columns="columns"
row-key="id"
no-data-label="ไม่มีข้อมูล"
selection="multiple"
v-model:selected="selectedFilter"
:rows-per-page-options="[10, 25, 50, 100]"
v-model:pagination="pagination"
@update:pagination="updatePagination"
>
<template v-slot:header-selection="scope">
<q-checkbox
keep-color
color="primary"
dense
v-model="scope.selected"
/>
</template>
<template v-slot:body="props">
<q-tr :props="props">
<q-td>
<q-checkbox
keep-color
color="primary"
dense
v-model="props.selected"
/>
</q-td>
<d-table
flat
bordered
:rows="rows"
:columns="columns"
row-key="id"
:filter="filterTable"
no-data-label="ไม่มีข้อมูล"
selection="multiple"
v-model:selected="selectedFilter"
:rows-per-page-options="[10, 25, 50, 100]"
v-model:pagination="pagination"
@update:pagination="updatePagination"
>
<template v-slot:header-selection="scope">
<q-checkbox
keep-color
color="primary"
dense
v-model="scope.selected"
/>
</template>
<template v-slot:body="props">
<q-tr :props="props">
<q-td>
<q-checkbox
keep-color
color="primary"
dense
v-model="props.selected"
/>
</q-td>
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<div v-if="col.name == 'no'">
{{
(reqMaster.page - 1) * Number(reqMaster.pageSize) +
props.rowIndex +
1
}}
</div>
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<div v-if="col.name == 'no'">
{{
(reqMaster.page - 1) * Number(reqMaster.pageSize) +
props.rowIndex +
1
}}
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
<q-pagination
v-model="reqMaster.page"
active-color="primary"
color="dark"
:max="totalPage"
:max-pages="5"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
</d-table>
<div v-else>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
<q-pagination
v-model="reqMaster.page"
active-color="primary"
color="dark"
:max="totalPage"
:max-pages="5"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
</d-table>
</div>
</q-card>
<q-card
@ -290,12 +304,7 @@ watch(
label="ค้นหา"
>
<template v-slot:append>
<q-icon
v-if="filterTree !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
<q-icon name="search" />
</template>
</q-input>
<q-tree

View file

@ -94,12 +94,6 @@ watch(
<div class="col-12">
<q-input dense outlined v-model="filter" label="ค้นหา">
<template v-slot:append>
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
<q-icon name="search" color="grey-5" />
</template>
</q-input>
@ -113,7 +107,7 @@ watch(
:nodes="lazy"
node-key="orgTreeId"
label-key="labelName"
:filter="filter"
:filter="filter.trim()"
no-results-label="ไม่พบข้อมูลที่ค้นหา"
no-nodes-label="ไม่มีข้อมูล"
v-model:expanded="expanded"

View file

@ -20,7 +20,7 @@ import type { FilterMaster } from "@/modules/16_positionEmployee/interface/reque
/** importComponents*/
import TreeMain from "@/modules/16_positionEmployee/components/TreeMain.vue";
import TreeTable from "@/modules/16_positionEmployee/components/TreeTable.vue";
import TreeTable from "@/modules/16_positionEmployee/components/TableMain.vue";
import LoadView from "@/components/LoadView.vue";
/** use*/

View file

@ -1100,6 +1100,26 @@ export const useCounterMixin = defineStore("mixin", () => {
.catch((error) => console.error("ดาวน์โหลดไฟล์ไม่สำเร็จ:", error));
}
function filterTableQuasar(keyword: string, data: any[], columns: any[]) {
const searchText = keyword.trim().toLowerCase();
if (!searchText) {
return data; // คืนค่าทั้งหมดถ้าไม่มีข้อความค้นหา
}
// คืนค่าข้อมูลที่กรองแล้ว
return data.filter((row: any) => {
return columns.some((col: any) => {
const rawValue = row[col.field];
const formattedValue = col.format
? col.format(rawValue, row) // ใช้ `format` ถ้ามี
: rawValue;
return String(formattedValue).toLowerCase().includes(searchText);
});
});
}
return {
calAge,
date2Thai,
@ -1143,5 +1163,7 @@ export const useCounterMixin = defineStore("mixin", () => {
findPosMasterNoOld,
pathRegistryEmp,
downloadRenameFileByLink,
filterTableQuasar,
};
});