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

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