filter ==> ข้อมูลตำแหน่งลูกจ้างประจำ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-12-12 14:17:48 +07:00
parent a8576f902c
commit b4c9762a2a
3 changed files with 32 additions and 20 deletions

View file

@ -360,10 +360,11 @@ onMounted(async () => {
<div class="col-xs-12 col-md-1"> <div class="col-xs-12 col-md-1">
<q-btn <q-btn
outline
color="primary" color="primary"
icon="search" icon="search"
label="ค้นหา" label="ค้นหา"
class="full-width" class="full-width full-height"
@click="fetchData()" @click="fetchData()"
/> />
</div> </div>

View file

@ -24,10 +24,12 @@ const {
showLoader, showLoader,
hideLoader, hideLoader,
date2Thai, date2Thai,
onSearchDataTable,
} = useCounterMixin(); } = useCounterMixin();
//Table //Table
const rows = ref<ResGroup[]>([]); // const rows = ref<ResGroup[]>([]); //
const rowsMain = ref<ResGroup[]>([]); //
const filterKeyword = ref<string>(""); // const filterKeyword = ref<string>(""); //
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
@ -114,7 +116,6 @@ const dialogStatus = ref<string>("");
/** /**
* งกนดงขอมลรายการกลมงาน API * งกนดงขอมลรายการกลมงาน API
*
* เกบขอมลรรายการกลมงานไวใน rows.value * เกบขอมลรรายการกลมงานไวใน rows.value
*/ */
async function fetchData() { async function fetchData() {
@ -123,6 +124,7 @@ async function fetchData() {
.get(config.API.orgEmployeeType) .get(config.API.orgEmployeeType)
.then(async (res) => { .then(async (res) => {
rows.value = await res.data.result; rows.value = await res.data.result;
rowsMain.value = await res.data.result;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -135,9 +137,7 @@ async function fetchData() {
/** /**
* งกนเป popup แกไขขอมลกลมงาน * งกนเป popup แกไขขอมลกลมงาน
* @param data อมลกลมงานทจะแกไข * @param data อมลกลมงานทจะแกไข
*
* กำหนด dialogStatus เป edit และกำหนดให ฟอรมขอมลกลมงาน เป อมลทจะแกไข * กำหนด dialogStatus เป edit และกำหนดให ฟอรมขอมลกลมงาน เป อมลทจะแกไข
*
*/ */
function onClickOpenDialogEdit(data: ResGroup) { function onClickOpenDialogEdit(data: ResGroup) {
dialogStatus.value = "edit"; dialogStatus.value = "edit";
@ -150,7 +150,6 @@ function onClickOpenDialogEdit(data: ResGroup) {
/** /**
* นยนการบนทกขอมลรายการกลมงาน * นยนการบนทกขอมลรายการกลมงาน
*
* dialogStatus เป 'create' จะทำการเพมขอมลรายการกลมงาน าไมจะทำการแกไขขอม * dialogStatus เป 'create' จะทำการเพมขอมลรายการกลมงาน าไมจะทำการแกไขขอม
* เมอบนทกขอมลเสรจจะเรยก function fetchData() เพอดงขอมลรายการกลมงานใหม * เมอบนทกขอมลเสรจจะเรยก function fetchData() เพอดงขอมลรายการกลมงานใหม
* *
@ -193,7 +192,6 @@ function onClickDetail(id: string) {
/** /**
* งกนป popup แกไขหรอเพมขอมลกลมงาน * งกนป popup แกไขหรอเพมขอมลกลมงาน
*
* และกำหนดให ฟอรมขอมลกลมงาน เปนคาวาง * และกำหนดให ฟอรมขอมลกลมงาน เปนคาวาง
*/ */
function closeDialog() { function closeDialog() {
@ -203,6 +201,14 @@ function closeDialog() {
formDataGroup.posTypeRank = null; formDataGroup.posTypeRank = null;
} }
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
/** /**
* hook ทำงานเม Components กเรยกใชงาน * hook ทำงานเม Components กเรยกใชงาน
*/ */
@ -232,12 +238,11 @@ onMounted(async () => {
<q-input <q-input
dense dense
outlined outlined
clearable
v-model="filterKeyword" v-model="filterKeyword"
placeholder="ค้นหา" placeholder="ค้นหา"
@clear="filterKeyword = ''" @keydown.enter.pervent="serchDataTable"
> >
<template v-slot:append v-if="filterKeyword === ''"> <template v-slot:append>
<q-icon name="search" /> <q-icon name="search" />
</template> </template>
</q-input> </q-input>
@ -261,7 +266,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="rows" :rows="rows"
:filter="filterKeyword"
row-key="name" row-key="name"
flat flat
bordered bordered

View file

@ -30,10 +30,12 @@ const {
messageError, messageError,
success, success,
date2Thai, date2Thai,
onSearchDataTable,
} = useCounterMixin(); } = useCounterMixin();
// Table // Table
const rows = ref<DataGroup[]>([]); // const rows = ref<DataGroup[]>([]); //
const rowsMain = ref<DataGroup[]>([]); //
const filter = ref<string>(""); // const filter = ref<string>(""); //
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
@ -138,16 +140,20 @@ const formDataLevel = reactive<FormDataLevel>({
* เกบขอมลรรายการระดบชนงานไวใน rows.value * เกบขอมลรรายการระดบชนงานไวใน rows.value
*/ */
async function fetchData() { async function fetchData() {
rows.value = [];
rowsMain.value = [];
showLoader(); showLoader();
await http await http
.get(config.API.orgEmployeeTypeById(posTypeId.value)) .get(config.API.orgEmployeeTypeById(posTypeId.value))
.then(async (res) => { .then(async (res) => {
titleName.value = res.data.result.posTypeName ?? null; titleName.value = res.data.result.posTypeName ?? null;
formDataLevel.posTypeName = res.data.result.posTypeName; formDataLevel.posTypeName = res.data.result.posTypeName;
rows.value = await res.data.result.posLevels.map((x: ResLevel) => ({ const lists = await res.data.result.posLevels.map((x: ResLevel) => ({
...x, ...x,
posTypeName: res.data.result.posTypeName, posTypeName: res.data.result.posTypeName,
})); }));
rows.value = lists;
rowsMain.value = lists;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -160,9 +166,7 @@ async function fetchData() {
/** /**
* งกนเป popup แกไขขอมลระดบชนงาน * งกนเป popup แกไขขอมลระดบชนงาน
* @param data อมลระดบชนงานทจะแกไข * @param data อมลระดบชนงานทจะแกไข
*
* กำหนด isStatusEdit เป true และกำหนดให ฟอรมขอมลระดบชนงาน เป อมลทจะแกไข * กำหนด isStatusEdit เป true และกำหนดให ฟอรมขอมลระดบชนงาน เป อมลทจะแกไข
*
*/ */
function onClickOpenDialog( function onClickOpenDialog(
statusEdit: boolean = false, statusEdit: boolean = false,
@ -183,7 +187,6 @@ function onClickOpenDialog(
/** /**
* งกนป popup แกไขหรอเพมขอมลระดบชนงาน * งกนป popup แกไขหรอเพมขอมลระดบชนงาน
*
* และกำหนดให ฟอรมขอมลระดบชนงาน เปนคาวาง * และกำหนดให ฟอรมขอมลระดบชนงาน เปนคาวาง
*/ */
function onClickCloseDialog() { function onClickCloseDialog() {
@ -195,7 +198,6 @@ function onClickCloseDialog() {
/** /**
* นยนการบนทกขอมลรายการระดบชนงาน * นยนการบนทกขอมลรายการระดบชนงาน
*
* dialogStatus เป 'false' จะทำการเพมขอมลรายการระดบชนงาน าไมจะทำการแกไขขอม * dialogStatus เป 'false' จะทำการเพมขอมลรายการระดบชนงาน าไมจะทำการแกไขขอม
* เมอบนทกขอมลเสรจจะเรยก function fetchData() เพอดงขอมลรายการระดบชนงานใหม * เมอบนทกขอมลเสรจจะเรยก function fetchData() เพอดงขอมลรายการระดบชนงานใหม
* *
@ -239,9 +241,16 @@ function convertPosLevelAuthority(val: string) {
return result?.label; return result?.label;
} }
function serchDataTable() {
rows.value = onSearchDataTable(
filter.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
/** /**
* hook ทำงานเม Components กเรยกใชงาน * hook ทำงานเม Components กเรยกใชงาน
*
* าม posTypeId จะดงขอมลรายการระดบชนงาน * าม posTypeId จะดงขอมลรายการระดบชนงาน
*/ */
onMounted(() => { onMounted(() => {
@ -281,12 +290,11 @@ onMounted(() => {
<q-input <q-input
dense dense
outlined outlined
clearable
v-model="filter" v-model="filter"
placeholder="ค้นหา" placeholder="ค้นหา"
@clear="filter = ''" @keydown.enter.pervent="serchDataTable"
> >
<template v-slot:append v-if="filter === ''"> <template v-slot:append>
<q-icon name="search" /> <q-icon name="search" />
</template> </template>
</q-input> </q-input>
@ -310,7 +318,6 @@ onMounted(() => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="rows" :rows="rows"
:filter="filter"
row-key="name" row-key="name"
flat flat
bordered bordered