form รายละเอียดการลา
This commit is contained in:
parent
b49cdaf913
commit
5e7a544195
17 changed files with 1118 additions and 1107 deletions
|
|
@ -6,7 +6,10 @@ import { useCounterMixin } from "@/stores/mixin";
|
|||
import type { DataOption } from "@/modules/09_leave/interface/index/Main";
|
||||
import type { QTableProps } from "quasar";
|
||||
import type { DataRows } from "@/modules/09_leave/interface/response/leave";
|
||||
import type { ListsData } from "@/modules/09_leave/interface/request/leave";
|
||||
import type {
|
||||
ListsData,
|
||||
FremData,
|
||||
} from "@/modules/09_leave/interface/request/leave";
|
||||
|
||||
const mixin = useCounterMixin();
|
||||
const { date2Thai, showLoader, hideLoader } = mixin;
|
||||
|
|
@ -19,7 +22,7 @@ export const useLeavelistDataStore = defineStore("leave", () => {
|
|||
/**ข้อมูลใน Table*/
|
||||
const mainData = ref<any>([]);
|
||||
const rows = ref<DataRows[]>([]);
|
||||
const selectStatus = ref<string>("PENDING");
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([]);
|
||||
const visibleColumns = ref<string[]>([]);
|
||||
const loadTable = ref<boolean>(false);
|
||||
|
|
@ -41,25 +44,27 @@ export const useLeavelistDataStore = defineStore("leave", () => {
|
|||
* ฟังก์ชั่น fetchList
|
||||
* @param data รับข้อมูลจาก Page
|
||||
*/
|
||||
async function fetchList(data: ListsData[]) {
|
||||
let datalist = data.map((e: ListsData) => ({
|
||||
async function fetchList(data: any[]) {
|
||||
let datalist = data.map((e: FremData) => ({
|
||||
id: e.id,
|
||||
leaveType: e.leaveType,
|
||||
name: e.name,
|
||||
Date: date2Thai(e.Date),
|
||||
status: e.status,
|
||||
leaveTypeName: e.leaveTypeId && convertLeave(e.leaveTypeId),
|
||||
leaveTypeId: e.leaveTypeId,
|
||||
fullname: e.fullname,
|
||||
dateSendLeave: e.dateSendLeave && date2Thai(e.dateSendLeave),
|
||||
status: convertSatatus(e.status),
|
||||
}));
|
||||
console.log(datalist);
|
||||
mainData.value = datalist;
|
||||
const filteramounttab1 = datalist.filter((e) => e.status === "PENDING");
|
||||
amounttab1.value = filteramounttab1.length;
|
||||
amounttab2.value = datalist.length;
|
||||
// const filteramounttab1 = datalist.filter((e) => e.status === "PENDING");
|
||||
// amounttab1.value = filteramounttab1.length;
|
||||
// amounttab2.value = datalist.length;
|
||||
await searchDataFn(selectType.value, selectStatus.value);
|
||||
}
|
||||
|
||||
/**ref ของการค้นหาข้อมูล */
|
||||
const selectYear = ref<string>("all");
|
||||
const selectType = ref<string>("all");
|
||||
const selectStatus = ref<string>("all");
|
||||
const optionYear = ref<DataOption[]>([{ id: "all", name: "ทั้งหมด" }]);
|
||||
const optionType = ref<DataOption[]>([]);
|
||||
const optionStatus = ref<DataOption[]>([]);
|
||||
|
|
@ -73,43 +78,22 @@ export const useLeavelistDataStore = defineStore("leave", () => {
|
|||
*/
|
||||
function searchDataFn(type: string, status: string) {
|
||||
type = type || "all";
|
||||
status = status || "all";
|
||||
status = convertSatatus(status) || "all";
|
||||
// showLoader()
|
||||
loadTable.value = true;
|
||||
if (selectYear.value == "all" && type == "all" && status == "all") {
|
||||
console.log(1);
|
||||
rows.value = mainData.value.map((e: any) => ({
|
||||
id: e.id,
|
||||
leaveType: convertLeave(e.leaveType),
|
||||
name: e.name,
|
||||
Date: date2Thai(e.Date),
|
||||
status: convertSatatus(e.status),
|
||||
}));
|
||||
rows.value = mainData.value;
|
||||
} else if (selectYear.value !== "all" && type == "all" && status == "all") {
|
||||
console.log(2);
|
||||
} else if (selectYear.value == "all" && type !== "all" && status == "all") {
|
||||
console.log(3);
|
||||
rows.value = mainData.value
|
||||
.filter((e: any) => e.leaveType === type)
|
||||
.map((e: any) => ({
|
||||
id: e.id,
|
||||
leaveType: convertLeave(e.leaveType),
|
||||
name: e.name,
|
||||
Date: date2Thai(e.Date),
|
||||
status: convertSatatus(e.status), // แปลงค่า status เมื่อเป็น "PENDING"
|
||||
}));
|
||||
rows.value = mainData.value.filter((e: any) => e.leaveTypeId === type);
|
||||
} else if (selectYear.value == "all" && type == "all" && status !== "all") {
|
||||
console.log(4);
|
||||
console.log(status);
|
||||
rows.value = mainData.value
|
||||
.filter((e: any) => e.status === status)
|
||||
.map((e: any) => ({
|
||||
id: e.id,
|
||||
leaveType: convertLeave(e.leaveType),
|
||||
name: e.name,
|
||||
Date: date2Thai(e.Date),
|
||||
status: convertSatatus(e.status), // แปลงค่า status เมื่อเป็น "PENDING"
|
||||
}));
|
||||
|
||||
rows.value = mainData.value.filter((e: any) => e.status === status);
|
||||
} else if (
|
||||
selectYear.value !== "all" &&
|
||||
type !== "all" &&
|
||||
|
|
@ -128,16 +112,9 @@ export const useLeavelistDataStore = defineStore("leave", () => {
|
|||
status !== "all"
|
||||
) {
|
||||
console.log(7);
|
||||
console.log(type);
|
||||
rows.value = mainData.value
|
||||
.filter((e: any) => e.leaveType === type && e.status === status)
|
||||
.map((e: any) => ({
|
||||
id: e.id,
|
||||
leaveType: convertLeave(e.leaveType),
|
||||
name: e.name,
|
||||
Date: date2Thai(e.Date),
|
||||
status: convertSatatus(e.status), // แปลงค่า status เมื่อเป็น "PENDING"
|
||||
}));
|
||||
rows.value = mainData.value.filter(
|
||||
(e: any) => e.leaveTypeId === type && e.status === status
|
||||
);
|
||||
} else console.log("ค้นหาจากทั้งหมด");
|
||||
setTimeout(function () {
|
||||
loadTable.value = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue