filter ==> จัดการ web services
This commit is contained in:
parent
cc6c038218
commit
c4bcb0b755
4 changed files with 118 additions and 100 deletions
|
|
@ -1058,6 +1058,26 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
}
|
||||
}
|
||||
|
||||
function onSearchDataTable(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,
|
||||
|
|
@ -1099,5 +1119,7 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
findOrgNameOld,
|
||||
findPosMasterNo,
|
||||
findPosMasterNoOld,
|
||||
|
||||
onSearchDataTable,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue