fix:sortBy ,descending

- ทำ sortBy เฉพาะ API ที่มีการทำ paging
This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-09-15 13:52:27 +07:00
parent 4308f8887f
commit 1f18b56fbf
13 changed files with 98 additions and 67 deletions

View file

@ -50,8 +50,6 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "year",
@ -62,8 +60,6 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => v + 543,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "durationKPI",
@ -74,8 +70,6 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => (v == "OCT" ? "รอบที่ 2 ตุลาคม" : "รอบที่ 1 เมษายน"),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "evaluationStatus",
@ -86,8 +80,6 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => store.convertStatus(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "evaluationResults",
@ -98,8 +90,6 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => store.convertResults(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
@ -147,7 +137,7 @@ const formQuery = reactive({
const isRoundClose = ref<boolean>(false);
const pagination = ref<PropsTable.Pagination>({
sortBy: "desc",
sortBy: "",
descending: false,
page: 1,
rowsPerPage: 10,
@ -212,6 +202,10 @@ async function fetchList() {
status: formQuery.status === "" ? undefined : formQuery.status,
results: formQuery.results === "" ? undefined : formQuery.results,
year: year.value,
...(pagination.value.sortBy && {
sortBy: pagination.value.sortBy,
descending: pagination.value.descending,
}),
};
await http
.get(config.API.kpiEvaluation, {

View file

@ -28,22 +28,20 @@ const dataListMain = ref<ResEvaluatorAssessor[]>([]);
const roundOp = ref<DataOptions[]>([]);
const visibleColumns = ref<string[]>([
"name",
"firstName",
"createdAt",
"evaluationStatus",
"evaluationResults",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
name: "firstName",
align: "left",
label: "ผู้ขอรับการประเมิน",
sortable: true,
field: "name",
field: "firstName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
@ -54,8 +52,6 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "evaluationStatus",
@ -66,8 +62,6 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => store.convertStatus(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "evaluationResults",
@ -78,8 +72,6 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => store.convertResults(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
@ -147,6 +139,10 @@ async function fetchList() {
? "SUMMARY"
: undefined,
reqedit: store.tabMainevaluator === "3" ? "NEW" : undefined,
...(store.formQuery.sortBy && {
sortBy: store.formQuery.sortBy,
descending: store.formQuery.descending,
}),
};
await http