@@ -15,11 +122,12 @@ const { searchDataFn, filterOption } = leaveStore;
map-options
outlined
dense
- v-model="leaveStore.selectYear"
- :options="leaveStore.optionYear"
+ v-model="filter.year"
+ :options="optionYear"
option-value="id"
option-label="name"
label="ปีงบประมาณ"
+ @update:model-value="filterListLeave"
/>
@@ -29,14 +137,12 @@ const { searchDataFn, filterOption } = leaveStore;
map-options
outlined
dense
- v-model="leaveStore.selectType"
- :options="leaveStore.leaveOps"
+ v-model="filter.type"
+ :options="optionType"
option-value="id"
option-label="name"
label="ประเภทการลา"
- @update:model-value="
- searchDataFn(leaveStore.selectType, leaveStore.selectStatus)
- "
+ @update:model-value="filterListLeave"
use-input
@filter="
(inputValue:any, doneFn:Function) =>
@@ -57,14 +163,12 @@ const { searchDataFn, filterOption } = leaveStore;
map-options
outlined
dense
- v-model="leaveStore.selectStatus"
- :options="leaveStore.statusOps"
+ v-model="filter.status"
+ :options="optionStatus"
option-value="id"
option-label="name"
label="สถานะ"
- @update:model-value="
- searchDataFn(leaveStore.selectType, leaveStore.selectStatus)
- "
+ @update:model-value="filterListLeave"
use-input
@filter="
(inputValue:any, doneFn:Function) =>
@@ -84,8 +188,9 @@ const { searchDataFn, filterOption } = leaveStore;
for="filterTable"
dense
outlined
- v-model="leaveStore.filterTable"
+ v-model="filter.keyword"
label="ค้นหา"
+ @keydown.enter.prevent="filterListLeave"
/>
diff --git a/src/modules/09_leave/interface/index/Main.ts b/src/modules/09_leave/interface/index/Main.ts
index 1a6136942..e76abc1f2 100644
--- a/src/modules/09_leave/interface/index/Main.ts
+++ b/src/modules/09_leave/interface/index/Main.ts
@@ -1,7 +1,9 @@
interface DataOption {
- id: string;
- name: string;
+ id: string;
+ name: string;
}
-export type {
- DataOption
-};
+interface DataOption2 {
+ id: number;
+ name: string;
+}
+export type { DataOption, DataOption2 };
diff --git a/src/modules/09_leave/interface/request/leave.ts b/src/modules/09_leave/interface/request/leave.ts
index 86a3b53dc..63d377e26 100644
--- a/src/modules/09_leave/interface/request/leave.ts
+++ b/src/modules/09_leave/interface/request/leave.ts
@@ -5,6 +5,21 @@ interface ListsData {
Date: Date;
status: string;
}
+interface QuerySting {
+ year: number; //*ปีในการยื่นขอใบลา(ใช้เป็น คศ.)
+ type: string; //*Id ประเภทการลา
+ status: string; //*สถานะการของลา
+ page: number; //*หน้า
+ pageSize: number; //*จำนวนแถวต่อหน้า
+ keyword: string; //keyword ค้นหา
+}
+
+interface DateFilter {
+ year: number; //*ปีในการยื่นขอใบลา(ใช้เป็น คศ.)
+ type: string; //*Id ประเภทการลา
+ status: string; //*สถานะการของลา
+ keyword: string; //keyword ค้นหา
+}
interface FremData {
id: string; //Id การยื่นขอลา
leaveTypeName: string | null; //Name ประเภทการลา
@@ -63,4 +78,4 @@ interface FremData {
coupleDaySumTotalHistory: string; //ประวัติ ในกรณีลาติดต่อกับครั้งก่อน รวมทั้งนี้ด้วย เป็นเวลา กี่ปี กี่เดือน กี่วัน (ลาติดตามคู่สมรส)
}
-export type { ListsData, FremData };
+export type { ListsData, FremData, QuerySting, DateFilter };
diff --git a/src/modules/09_leave/interface/response/leave.ts b/src/modules/09_leave/interface/response/leave.ts
index 55af334c5..9be01be87 100644
--- a/src/modules/09_leave/interface/response/leave.ts
+++ b/src/modules/09_leave/interface/response/leave.ts
@@ -1,8 +1,10 @@
interface DataRows {
- leaveType: string;
- name: string;
- Date: string;
- status: string;
+ id: string; //*Id การยื่นขอลา
+ leaveTypeName: string | null; //Name ประเภทการลา
+ leaveTypeId: string; //Id ประเภทการลา
+ fullname: string; //คำนำหน้า ชื่อ นามสกุล คนขอลา
+ dateSendLeave: string | null; //วันที่ยื่นใบลา
+ status: string | null; //ส
}
interface FormData {
id: string;
diff --git a/src/modules/09_leave/stores/LeaveStore.ts b/src/modules/09_leave/stores/LeaveStore.ts
index f12b658b6..7c131f81d 100644
--- a/src/modules/09_leave/stores/LeaveStore.ts
+++ b/src/modules/09_leave/stores/LeaveStore.ts
@@ -3,43 +3,20 @@ import { ref, onMounted } from "vue";
import { useCounterMixin } from "@/stores/mixin";
/** importType*/
-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,
- FremData,
-} from "@/modules/09_leave/interface/request/leave";
+import type { FremData } from "@/modules/09_leave/interface/request/leave";
const mixin = useCounterMixin();
const { date2Thai, showLoader, hideLoader } = mixin;
export const useLeavelistDataStore = defineStore("leave", () => {
- /** TABMENU*/
- const amounttab1 = ref
(0);
- const amounttab2 = ref(0);
-
/**ข้อมูลใน Table*/
const mainData = ref([]);
const rows = ref([]);
-
const columns = ref([]);
const visibleColumns = ref([]);
- const loadTable = ref(false);
- const leaveOp = [
- { id: "all", name: "ทั้งหมด" },
- { id: "leave1", name: "ลากิจส่วนตัว" },
- { id: "leave2", name: "ลาป่วย" },
- ];
- const statusOp = [
- { id: "all", name: "ทั้งหมด" },
- { id: "NEW", name: "ใหม่" },
- { id: "PENDING", name: "อยู่ระหว่างดำเนินการ" },
- { id: "APPROVE", name: "อนุมัติ" },
- { id: "REJECT", name: "ไม่อนุมัติ" },
- ];
- const leaveOps = ref(leaveOp);
- const statusOps = ref(statusOp);
+
/**
* ฟังก์ชั่น fetchList
* @param data รับข้อมูลจาก Page
@@ -55,101 +32,7 @@ export const useLeavelistDataStore = defineStore("leave", () => {
}));
console.log(datalist);
mainData.value = datalist;
- // 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("all");
- const selectType = ref("all");
- const selectStatus = ref("all");
- const optionYear = ref([{ id: "all", name: "ทั้งหมด" }]);
- const optionType = ref([]);
- const optionStatus = ref([]);
- const optionTypeMain = ref([]);
- const optionStatusMain = ref([]);
- const filterTable = ref("");
- /**
- * ฟังก์ชั่นค้นหาข้อมูลใน Table
- * @param type รับข้อมูลประเภท
- * @param status รับค่าสถานะ
- */
- function searchDataFn(type: string, status: string) {
- type = type || "all";
- status = convertSatatus(status) || "all";
- // showLoader()
- loadTable.value = true;
- if (selectYear.value == "all" && type == "all" && status == "all") {
- console.log(1);
- 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.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);
- } else if (
- selectYear.value !== "all" &&
- type !== "all" &&
- status == "all"
- ) {
- console.log(5);
- } else if (
- selectYear.value !== "all" &&
- type == "all" &&
- status !== "all"
- ) {
- console.log(6);
- } else if (
- selectYear.value == "all" &&
- type !== "all" &&
- status !== "all"
- ) {
- console.log(7);
- rows.value = mainData.value.filter(
- (e: any) => e.leaveTypeId === type && e.status === status
- );
- } else console.log("ค้นหาจากทั้งหมด");
- setTimeout(function () {
- loadTable.value = false;
- }, 500);
- }
-
- /**
- * ฟังก์ชั่นเคลียร์ข้อมูลค้นหา
- */
- function clearFilter() {
- selectYear.value = "all";
- selectType.value = "all";
- selectStatus.value = "all";
- filterTable.value = "";
- }
-
- /**
- * ฟังก์ชั่นค้นหาข้อมูลของ Option Filter
- * @param val คำที่ค้นหา
- * @param update Function
- * @param name ประเภทของ Select
- */
- function filterOption(val: string, update: any, name: string) {
- update(() => {
- const needle = val.toLowerCase();
- if (name === "type") {
- leaveOps.value = leaveOp.filter(
- (v: any) => v.name.toLowerCase().indexOf(needle) > -1
- );
- } else if (name === "status") {
- statusOps.value = statusOp.filter(
- (v: any) => v.name.toLowerCase().indexOf(needle) > -1
- );
- }
- });
+ rows.value = mainData.value;
}
/**
@@ -220,30 +103,12 @@ export const useLeavelistDataStore = defineStore("leave", () => {
}
return {
- amounttab1,
- amounttab2,
/**ข้อมูลใน Table */
rows,
fetchList,
- loadTable,
columns,
visibleColumns,
- /**ค้นหาข้อมูล */
- filterTable,
- selectYear,
- selectType,
- selectStatus,
- optionYear,
- optionType,
- optionStatus,
- clearFilter,
- searchDataFn,
- filterOption,
- leaveOp,
- statusOp,
- leaveOps,
- statusOps,
/** Function แปลงค่า */
convertLeave,
convertLeaveDaytype,
diff --git a/src/modules/09_leave/views/LeaveListMain.vue b/src/modules/09_leave/views/LeaveListMain.vue
index 14e88037b..8a5470b6e 100644
--- a/src/modules/09_leave/views/LeaveListMain.vue
+++ b/src/modules/09_leave/views/LeaveListMain.vue
@@ -1,7 +1,11 @@
รายการลา