filter ==> ข้อมูลเกี่ยวกับบุคคล

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-12-12 13:32:48 +07:00
parent 404a47e78b
commit 6152fa3bef
11 changed files with 82 additions and 45 deletions

View file

@ -173,12 +173,13 @@ onMounted(async () => {
borderless borderless
dense dense
outlined outlined
clearable
v-model="filterKeyword" v-model="filterKeyword"
placeholder="ค้นหา" placeholder="ค้นหา"
@clear="filterKeyword = ''" @keydown.enter.pervent="
store.onSearchData(filterKeyword, TABLE_COLUMNS)
"
> >
<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>
@ -202,7 +203,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="TABLE_COLUMNS" :columns="TABLE_COLUMNS"
:rows="store.row" :rows="store.row"
:filter="filterKeyword"
row-key="name" row-key="name"
flat flat
bordered bordered

View file

@ -172,12 +172,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="store.onSearchData(filterKeyword, columns)"
> >
<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>
@ -201,7 +200,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="store.row" :rows="store.row"
:filter="filterKeyword"
row-key="name" row-key="name"
flat flat
bordered bordered

View file

@ -172,12 +172,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="store.onSearchData(filterKeyword, columns)"
> >
<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>
@ -201,7 +200,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="store.row" :rows="store.row"
:filter="filterKeyword"
row-key="name" row-key="name"
flat flat
bordered bordered

View file

@ -172,12 +172,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="store.onSearchData(filterKeyword, columns)"
> >
<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>
@ -201,7 +200,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="store.row" :rows="store.row"
:filter="filterKeyword"
row-key="name" row-key="name"
flat flat
bordered bordered

View file

@ -171,12 +171,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="store.onSearchData(filterKeyword, columns)"
> >
<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>
@ -200,7 +199,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="store.row" :rows="store.row"
:filter="filterKeyword"
row-key="name" row-key="name"
flat flat
bordered bordered

View file

@ -172,12 +172,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="store.onSearchData(filterKeyword, columns)"
> >
<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>
@ -201,7 +200,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="store.row" :rows="store.row"
:filter="filterKeyword"
row-key="name" row-key="name"
flat flat
bordered bordered

View file

@ -183,12 +183,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="store.onSearchData(filterKeyword, columns)"
> >
<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>
@ -212,7 +211,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="store.row" :rows="store.row"
:filter="filterKeyword"
row-key="name" row-key="name"
flat flat
bordered bordered

View file

@ -186,12 +186,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="store.onSearchData(filterKeyword, columns)"
> >
<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>
@ -215,7 +214,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="store.row" :rows="store.row"
:filter="filterKeyword"
row-key="name" row-key="name"
flat flat
bordered bordered

View file

@ -15,8 +15,14 @@ import DialogForm from "@/modules/01_metadata/components/personal/DialogForm.vue
const $q = useQuasar(); const $q = useQuasar();
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const { messageError, showLoader, hideLoader, success, date2Thai } = const {
useCounterMixin(); messageError,
showLoader,
hideLoader,
success,
date2Thai,
onSearchDataTable,
} = useCounterMixin();
/** /**
* Table * Table
@ -82,6 +88,7 @@ const dialog = ref<boolean>(false); // เพิ่มข้อมูล,แก
const dialogStatus = ref<string>(""); // , const dialogStatus = ref<string>(""); // ,
const personalName = ref<string>("เขต/อำเภอ"); //label input const personalName = ref<string>("เขต/อำเภอ"); //label input
const rows = ref<FormDistrict[]>([]); // / const rows = ref<FormDistrict[]>([]); // /
const rowsMain = ref<FormDistrict[]>([]); // /
const provinceName = ref<string>(""); // const provinceName = ref<string>(""); //
/** /**
@ -99,12 +106,13 @@ async function fetchData() {
const list = data.map((e: FormDistrict) => ({ const list = data.map((e: FormDistrict) => ({
...e, ...e,
createdAt: e.createdAt ? date2Thai(new Date(e.createdAt)) : "", createdAt: e.createdAt ? date2Thai(new Date(e.createdAt),false,true) : "",
lastUpdatedAt: e.lastUpdatedAt lastUpdatedAt: e.lastUpdatedAt
? date2Thai(new Date(e.lastUpdatedAt)) ? date2Thai(new Date(e.lastUpdatedAt),false,true)
: "", : "",
})); }));
rows.value = list; rows.value = list;
rowsMain.value = list;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -168,6 +176,14 @@ function nextPage(idSub: string) {
router.push(`/master-data/personal/sub-district/${id.value}/${idSub}`); router.push(`/master-data/personal/sub-district/${id.value}/${idSub}`);
} }
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns ? columns : []
);
}
/** /**
* hook ทำงานเม Components กเรยกใชงาน * hook ทำงานเม Components กเรยกใชงาน
* แลวเรยก function fetch อมลรายการระดบการเขต/อำเภอ * แลวเรยก function fetch อมลรายการระดบการเขต/อำเภอ
@ -217,7 +233,12 @@ onMounted(async () => {
dense dense
v-model="filterKeyword" v-model="filterKeyword"
label="ค้นหา" label="ค้นหา"
></q-input> @keydown.enter.pervent="serchDataTable"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
<q-select <q-select
v-model="visibleColumns" v-model="visibleColumns"
multiple multiple
@ -238,7 +259,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

@ -15,8 +15,14 @@ import DialogForm from "@/modules/01_metadata/components/personal/DialogForm.vue
const $q = useQuasar(); const $q = useQuasar();
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const { messageError, showLoader, hideLoader, success, date2Thai } = const {
useCounterMixin(); messageError,
showLoader,
hideLoader,
success,
date2Thai,
onSearchDataTable,
} = useCounterMixin();
/** /**
* Table * Table
@ -88,6 +94,7 @@ const visibleColumns = ref<string[]>([
const id = ref<string>(route.params.id as string); // / const id = ref<string>(route.params.id as string); // /
const rows = ref<FormSubDistrict[]>([]); // / const rows = ref<FormSubDistrict[]>([]); // /
const rowsMain = ref<FormSubDistrict[]>([]); // /
const editId = ref<string>(""); // id / const editId = ref<string>(""); // id /
const filterKeyword = ref<string>(""); // const filterKeyword = ref<string>(""); //
const dialog = ref<boolean>(false); // , const dialog = ref<boolean>(false); // ,
@ -111,12 +118,15 @@ async function fetchData() {
subdistrict.value = await res.data.result.name; subdistrict.value = await res.data.result.name;
const list = data.map((e: FormSubDistrict) => ({ const list = data.map((e: FormSubDistrict) => ({
...e, ...e,
createdAt: e.createdAt ? date2Thai(new Date(e.createdAt)) : "", createdAt: e.createdAt
? date2Thai(new Date(e.createdAt), false, true)
: "",
lastUpdatedAt: e.lastUpdatedAt lastUpdatedAt: e.lastUpdatedAt
? date2Thai(new Date(e.lastUpdatedAt)) ? date2Thai(new Date(e.lastUpdatedAt), false, true)
: "", : "",
})); }));
rows.value = list; rows.value = list;
rowsMain.value = list;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -173,6 +183,14 @@ async function editData(idRow: string) {
}); });
} }
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns ? columns : []
);
}
/** /**
* hook ทำงานเม Components กเรยกใชงาน * hook ทำงานเม Components กเรยกใชงาน
* แลวเรยก function fetch อมลรายการแขวง/ตำบล * แลวเรยก function fetch อมลรายการแขวง/ตำบล
@ -223,7 +241,12 @@ onMounted(async () => {
dense dense
v-model="filterKeyword" v-model="filterKeyword"
label="ค้นหา" label="ค้นหา"
></q-input> @keydown.enter.pervent="serchDataTable"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
<q-select <q-select
v-model="visibleColumns" v-model="visibleColumns"
multiple multiple
@ -244,7 +267,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

@ -7,10 +7,11 @@ import type {
DataRow, DataRow,
} from "../interface/response/personal/personal"; } from "../interface/response/personal/personal";
const { date2Thai } = useCounterMixin(); const { date2Thai, onSearchDataTable } = useCounterMixin();
export const usePersonalDataStore = defineStore("PersonalData", () => { export const usePersonalDataStore = defineStore("PersonalData", () => {
const row = ref<DataRow[]>([]); // ข้อมูลในตาราง const row = ref<DataRow[]>([]); // ข้อมูลในตาราง
const rowMain = ref<DataRow[]>([]); // ข้อมูลในตาราง
const currentTab = ref<string>("list_prefix"); // Tab ปัจจุบัน const currentTab = ref<string>("list_prefix"); // Tab ปัจจุบัน
/** /**
@ -19,6 +20,7 @@ export const usePersonalDataStore = defineStore("PersonalData", () => {
*/ */
async function save(data: DataResponse[]) { async function save(data: DataResponse[]) {
row.value = []; row.value = [];
rowMain.value = [];
const list = data.map((e) => ({ const list = data.map((e) => ({
...e, ...e,
createdAt: e.createdAt ? date2Thai(e.createdAt, false, true) : "-", createdAt: e.createdAt ? date2Thai(e.createdAt, false, true) : "-",
@ -26,12 +28,19 @@ export const usePersonalDataStore = defineStore("PersonalData", () => {
? date2Thai(e.lastUpdatedAt, false, true) ? date2Thai(e.lastUpdatedAt, false, true)
: "-", : "-",
})); }));
row.value = list; row.value = list;
rowMain.value = list;
}
function onSearchData(keyword: string, columns: any = []) {
row.value = onSearchDataTable(keyword, rowMain.value, columns);
} }
return { return {
save, save,
row, row,
currentTab, currentTab,
onSearchData,
}; };
}); });