@@ -66,13 +91,13 @@ const resetFilter = () => {
{{ year + 543 }}
{{
@@ -83,7 +108,7 @@ const resetFilter = () => {
dense
lazy-rules
outlined
- :model-value="Number(leaveStore.fiscalYearyear) + 543"
+ :model-value="Number(year) + 543"
:label="`${'ปีงบประมาณ'}`"
>
@@ -97,33 +122,11 @@ const resetFilter = () => {
-
{
hide-bottom-space
style="min-width: 150px"
class="col-xs-12 col-sm-auto"
- @update:model-value="searchFilterTable"
+ use-input
+ @update:model-value="filterTable"
@filter="(inputValue:any,
- doneFn:Function) => filterSelector(inputValue, doneFn,'LeaveTypeOption'
+ doneFn:Function) => filterOption(inputValue, doneFn,'LeaveTypeOption'
) "
- />
+ >
+
+
+ ไม่มีข้อมูล
+
+
{
hide-bottom-space
style="min-width: 150px"
class="col-xs-12 col-sm-auto"
- @update:model-value="searchFilterTable"
+ use-input
+ @update:model-value="filterTable"
@filter="(inputValue:any,
- doneFn:Function) => filterSelector(inputValue, doneFn,'LeaveStatusOption'
+ doneFn:Function) => filterOption(inputValue, doneFn,'LeaveStatusOption'
) "
- />
+ >
+
+
+ ไม่มีข้อมูล
+
+
{
style="max-width: 150px"
>
-
+
diff --git a/src/modules/05_leave/interface/index/main.ts b/src/modules/05_leave/interface/index/main.ts
index 486b8c3..026d18b 100644
--- a/src/modules/05_leave/interface/index/main.ts
+++ b/src/modules/05_leave/interface/index/main.ts
@@ -1,27 +1,40 @@
-import type { S } from "@fullcalendar/core/internal-common"
+import type { S } from "@fullcalendar/core/internal-common";
interface OptionData {
- id: string | undefined
- name: string | undefined
+ id: string | undefined;
+ name: string | undefined;
}
interface FormLeavetMainData {
- type: string
- numDate: string
- extend: string
- use: string
- numAll: string
- numDone: string
- numNot: string
- numCancel: string
+ type: string;
+ numDate: string;
+ extend: string;
+ use: string;
+ numAll: string;
+ numDone: string;
+ numNot: string;
+ numCancel: string;
}
interface formListLeaveData {
- no: string
- date: string | null
- type: string
- status: string
- year: string
+ no: string;
+ date: string | null;
+ type: string;
+ status: string;
+ year: string;
}
-export type { OptionData, FormLeavetMainData, formListLeaveData }
+interface TypeLeave {
+ code: string;
+ createdAt: Date;
+ createdFullName: string;
+ createdUserId: string;
+ id: string;
+ lastUpdateFullName: string;
+ lastUpdateUserId: string;
+ lastUpdatedAt: Date | null;
+ limit: number;
+ name: string;
+}
+
+export type { OptionData, FormLeavetMainData, formListLeaveData, TypeLeave };
diff --git a/src/modules/05_leave/store.ts b/src/modules/05_leave/store.ts
index 0c558ae..2fb968b 100644
--- a/src/modules/05_leave/store.ts
+++ b/src/modules/05_leave/store.ts
@@ -5,6 +5,7 @@ import type {
FormLeavetMainData,
OptionData,
formListLeaveData,
+ TypeLeave,
} from "@/modules/05_leave/interface/index/main";
import { useCounterMixin } from "@/stores/mixin";
@@ -19,6 +20,32 @@ export const useLeaveStore = defineStore("Leave", () => {
const rows = ref([]);
const DataMainOrig = ref([]); // ข้อมูลหลักดั้งเดิม
+ /** ประเภทการลา */
+ const typeOptions = ref([]);
+ const typeOptionsMain = ref([]);
+ async function fetchLeaveType(data: TypeLeave[]) {
+ typeOptionsMain.value = [
+ { id: "00000000-0000-0000-0000-000000000000", name: "ทั้งหมด" },
+ ];
+ const optionType = data.map((e: TypeLeave) => ({
+ id: e.id,
+ name: e.name,
+ }));
+ typeOptionsMain.value.push(...optionType);
+ typeOptions.value = typeOptionsMain.value;
+ }
+
+ /** สถานะของการลา */
+ const statusOptionsMain = ref([
+ { id: "ALL", name: "ทั้งหมด" },
+ { id: "NEW ", name: "ใหม่" },
+ { id: "PENDING ", name: "กำลังดำเนินการ" },
+ { id: "APPROVE ", name: "อนุมัติ " },
+ { id: "REJECT ", name: "ไม่อนุมัติ" },
+ { id: "DELETE ", name: "ยกเลิก" },
+ ]);
+ const statusOptions = ref(statusOptionsMain.value);
+
async function fecthList(data: formListLeaveData[]) {
let datalist: formListLeaveData[] = data.map((e: any) => ({
no: e.no,
@@ -102,72 +129,24 @@ export const useLeaveStore = defineStore("Leave", () => {
}
};
- //--------------|ฟิลเตอร์|--------------------------------------//
- const searchFilterTable = async () => {
- console.log("test");
-
- rows.value = [];
-
- if (LeaveType.value !== undefined && LeaveType.value !== null) {
- await DataUpdate(
- LeaveType.value === "0" ? "all" : LeaveType.value!,
- LeaveStatus.value === "0" ? "all" : LeaveStatus.value!,
- fiscalYearyear.value === 0 ? "all" : fiscalYearyear.value?.toString()!
- );
- let filteredData = DataMainOrig.value;
-
- if (LeaveType.value !== "0") {
- filteredData = filteredData.filter(
- (item: formListLeaveData) => item.type === LeaveType.value
- );
- }
- if (LeaveStatus.value !== "0") {
- filteredData = filteredData.filter(
- (item: formListLeaveData) => item.status === LeaveStatus.value
- );
- }
- if (fiscalYearyear.value !== 0) {
- filteredData = filteredData.filter(
- (item: formListLeaveData) =>
- item.year === fiscalYearyear.value?.toString()
- );
- }
- const dataArr: formListLeaveData[] = filteredData.map((e: any) => ({
- no: e.no,
- type: convertType(e.type) || "",
- status: convertStatus(e.status) || "",
- date: date2Thai(new Date(e.date)),
- year: e.year !== undefined ? e.year : "",
- }));
- rows.value = dataArr;
- }
- };
-
/**
*ฟังก์ชั่นเลือก selector ที่ใช่ในการฟิลเตอร์
* @param val ค่าที่ต้องการฟิลเตอร์
* @param update อัพเดทค่า
* @param refData ดาต้าที่ต้องการฟิลเตอร์
*/
- const filterSelector = (val: any, update: Function, refData: string) => {
+ const filterOption = (val: any, update: Function, refData: string) => {
switch (refData) {
- case "fiscalyearOP":
- update(() => {
- fiscalyearOP.value = fiscalyearOP.value.filter(
- (v: any) => v.name.indexOf(val) > -1
- );
- });
- break;
case "LeaveTypeOption":
update(() => {
- typeOptions.value = typeOptions.value.filter(
+ typeOptions.value = typeOptionsMain.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
break;
case "LeaveStatusOption":
update(() => {
- statusOptions.value = statusOptions.value.filter(
+ statusOptions.value = statusOptionsMain.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
@@ -224,21 +203,6 @@ export const useLeaveStore = defineStore("Leave", () => {
{ id: "11", name: "ลาไปฟื้นฟูสมรรถภาพด้านอาชีพ" },
]);
- /** filter ประเภทการลา */
- const typeOptions = ref([
- { id: "0", name: "ทั้งหมด" },
- ...options.value,
- ]);
-
- /** สถานะของการลา */
- const statusOptions = ref([
- { id: "0", name: "ทั้งหมด" },
- { id: "1", name: "อนุมัติ" },
- { id: "2", name: "ไม่อนุมัติ" },
- { id: "3", name: "อยู่ระหว่างดำเนินการ" },
- { id: "4", name: "ใหม่" },
- ]);
-
/**
*ฟังก์ชั่นค้นหาแสดง option ของสถานะ
* @param val ค่าที่เเสดง
@@ -348,13 +312,15 @@ export const useLeaveStore = defineStore("Leave", () => {
LeaveType,
LeaveStatus,
fecthList,
- filterSelector,
- searchFilterTable,
+
fiscalyearOP,
fiscalYearyear,
options,
optionsOrdination,
typeConvert,
typeLeave,
+
+ fetchLeaveType,
+ filterOption,
};
});
diff --git a/tsconfig.app.json b/tsconfig.app.json
index cdbea1d..c5e0e72 100644
--- a/tsconfig.app.json
+++ b/tsconfig.app.json
@@ -7,6 +7,8 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
- }
+ },
+ "target": "es2018",
+ "lib": ["dom", "es2015", "es2018", "es2018.promise"]
}
}