diff --git a/src/modules/10_order/interface/index/Main.ts b/src/modules/10_order/interface/index/Main.ts index 3b1bc8199..35077746a 100644 --- a/src/modules/10_order/interface/index/Main.ts +++ b/src/modules/10_order/interface/index/Main.ts @@ -4,8 +4,8 @@ interface DataOption { disable?: boolean; } interface DataOption1 { - id: string | null; - name: string | null; + id: string; + name: string; disable?: boolean; } interface DataOptionInsignia { @@ -196,28 +196,27 @@ interface Assign { updatedAt: Date; } interface OrderResult { - fiscalYear: string - orderBy: string - orderById: string - orderByOrganization: string - orderDate: Date - orderId: string - orderName: string - orderNo: string - orderStatusName: string - orderStatusValue: string - orderTypeName: string - orderTypeValue: string - signatoryBy: string - signatoryPosition: string + fiscalYear: string; + orderBy: string; + orderById: string; + orderByOrganization: string; + orderDate: Date; + orderId: string; + orderName: string; + orderNo: string; + orderStatusName: string; + orderStatusValue: string; + orderTypeName: string; + orderTypeValue: string; + signatoryBy: string; + signatoryPosition: string; } interface history { - citizenId: string, - fullName: string, - id: string - posNo: string, - position: string - + citizenId: string; + fullName: string; + id: string; + posNo: string; + position: string; } interface ColumnData { name: string; @@ -240,16 +239,16 @@ interface DataOptionInsigniaType { name: string; } interface OrederResult { - category?: string - commandCode: string - createdAt?: Date - createdFullName?: string - createdUserId?: string - id?: string - lastUpdateFullName?: string - lastUpdateUserId?: string - lastUpdatedAt?: string - name?: string + category?: string; + commandCode: string; + createdAt?: Date; + createdFullName?: string; + createdUserId?: string; + id?: string; + lastUpdateFullName?: string; + lastUpdateUserId?: string; + lastUpdatedAt?: string; + name?: string; } export type { DataOption, @@ -273,7 +272,7 @@ export type { history, ColumnData, DataOptionInsigniaType, - OrederResult + OrederResult, }; export { AddressDataDefualt, FamilyDataDefualt }; diff --git a/src/modules/13_salary/interface/response/Command.ts b/src/modules/13_salary/interface/response/Command.ts new file mode 100644 index 000000000..067f52889 --- /dev/null +++ b/src/modules/13_salary/interface/response/Command.ts @@ -0,0 +1,41 @@ +interface ResYear { + id: number; + name: number; +} + +interface ResType { + category: string; + commandCode: string; + createdAt: string; + createdFullName: string; + createdUserId: string; + id: string; + lastUpdateFullName: string; + lastUpdateUserId: string; + lastUpdatedAt: null | string | Date; + name: string; +} + +interface ResListOrder { + caseFault: string; + faultLevel: string; + fiscalYear: string; + fullName: string; + orderBy: string; + orderById: string; + orderByOrganization: string; + orderDate: string; + orderId: string; + orderName: string; + orderNo: string; + orderStatusName: string; + orderStatusValue: string; + orderTypeName: string; + orderTypeValue: string; + refRaw: string; + result: string; + signatoryBy: string; + signatoryPosition: string; +} + +export type { ResYear, ResType, ResListOrder }; diff --git a/src/modules/13_salary/views/commandSalary.vue b/src/modules/13_salary/views/commandSalary.vue index bb0ef3634..1d61e8662 100644 --- a/src/modules/13_salary/views/commandSalary.vue +++ b/src/modules/13_salary/views/commandSalary.vue @@ -5,13 +5,22 @@ import { useQuasar, type QTableProps } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; -import type { DataOption1 } from "@/modules/10_order/interface/index/Main"; +/** import type*/ +import type { + DataOption, + DataOption1, +} from "@/modules/10_order/interface/index/Main"; +import type { + ResYear, + ResType, + ResListOrder, +} from "@/modules/13_salary/interface/response/Command"; +/** import Store*/ import { useOrderStore } from "@/modules/11_discipline/store/OrderStore"; - import { useCounterMixin } from "@/stores/mixin"; -const rows = ref([]); +/** use */ const $q = useQuasar(); //ใช้ noti quasar const mixin = useCounterMixin(); const stroe = useOrderStore(); @@ -132,28 +141,20 @@ const visibleColumns = ref([ "orderStatusName", ]); -onMounted(async () => { - await fiscalYearFilter(); - await OrderTypeFilter(); - await fetchOrderlist(); - await OrderStatusFilter(); -}); - +/** funtion fetch รายการออกคำสั่งเลื่อนเงินเดือน/ค่าจ้าง */ async function fetchOrderlist() { showLoader(); await http .get(config.API.listOrder()) - .then((res: any) => { + .then((res) => { const data = res.data.result; - const typeid = OrderTypeOption.value.map((e) => e.id); - - const filterListOrder = data.filter((e: any) => + const typeid = OrderTypeOption.value.map((e: DataOption1) => e.id); + const filterListOrder = data.filter((e: ResListOrder) => typeid.includes(e.orderTypeValue) ); - stroe.fetchOrder(filterListOrder); }) - .catch((e: any) => { + .catch((e) => { messageError($q, e); }) .finally(async () => { @@ -168,29 +169,33 @@ const clickAdd = () => { // รายการข้อมูลปีงบประมาณ const fiscalyear = ref(0); -const fiscalyearOP = ref([{ id: 0, name: "ทั้งหมด" }]); -const fiscalyearFilter1 = ref([]); +const fiscalyearOP = ref([{ id: 0, name: "ทั้งหมด" }]); +const fiscalyearFilter1 = ref([]); const fiscalYearFilter = async () => { - await http.get(config.API.yearOptionsOrder()).then((res) => { - const response = res.data.result; - fiscalyearOP.value = [{ id: 0, name: "ทั้งหมด" }]; - response.map((r: any) => { - fiscalyearOP.value.push({ id: r.id, name: r.name.toString() }); - }); - - fiscalyearFilter1.value = [{ id: 0, name: "ทั้งหมด" }]; - response.map((r: any) => { - fiscalyearFilter1.value.push({ - id: r.id, - name: r.name.toString(), + await http + .get(config.API.yearOptionsOrder()) + .then((res) => { + const response = res.data.result; + fiscalyearOP.value = [{ id: 0, name: "ทั้งหมด" }]; + response.map((r: ResYear) => { + fiscalyearOP.value.push({ id: r.id, name: r.name.toString() }); }); + fiscalyearFilter1.value = [{ id: 0, name: "ทั้งหมด" }]; + response.map((r: ResYear) => { + fiscalyearFilter1.value.push({ + id: r.id, + name: r.name.toString(), + }); + }); + }) + .catch((err) => { + messageError($q, err); }); - }); }; // รายการข้อมูลประเภทคำสั่ง const OrderType = ref(""); -const OrderTypeFilter1 = ref([]); +const OrderTypeFilter1 = ref([]); const OrderTypeOption = ref([{ id: "", name: "ทั้งหมด" }]); // รายการข้อมูลสถานะคำสั่ง @@ -205,20 +210,18 @@ const addedOrderStatusValues: string[] = []; // ค้นหาในตาราง const filterKeyword = ref(""); -const filterRef = ref(null); function resetFilter() { filterKeyword.value = ""; - filterRef.value.focus(); } +/** function fetch ข้อมูลประเภทคำสั่ง*/ async function OrderTypeFilter() { await http .get(config.API.typeOrder()) .then((res) => { - console.log(res); const response = res.data.result; - const filterRes = response.filter((e: any) => + const filterRes = response.filter((e: ResType) => commandCodes.value.includes(e.commandCode) ); @@ -238,6 +241,7 @@ async function searchFilterTable() { stroe.filterListOrder(OrderType.value, OrderStatus.value, fiscalyear.value); } +/** fucnction หาสถานะทั่งหมด*/ async function OrderStatusFilter() { for (let data of stroe.mainData) { const OrderStatusValue = data.orderStatusName; @@ -265,26 +269,26 @@ async function OrderStatusFilter() { * @param update function จาก quasar * @param refData type ที่กำหนด ของ input นั้นๆ */ -function filterSelector(val: any, update: Function, refData: string) { +function filterSelector(val: string, update: Function, refData: string) { switch (refData) { case "fiscalyearOP": update(() => { fiscalyearOP.value = fiscalyearFilter1.value.filter( - (v: any) => v.name.indexOf(val) > -1 + (v: DataOption) => v.name.indexOf(val) > -1 ); }); break; case "OrderTypeOption": update(() => { OrderTypeOption.value = OrderTypeFilter1.value.filter( - (v: any) => v.name.indexOf(val) > -1 + (v: DataOption1) => v.name.indexOf(val) > -1 ); }); break; case "OrderStatusOption": update(() => { OrderStatusOption.value = OrderStatusFilter1.value.filter( - (v: any) => v.name.indexOf(val) > -1 + (v: DataOption1) => v.name.indexOf(val) > -1 ); }); break; @@ -293,6 +297,11 @@ function filterSelector(val: any, update: Function, refData: string) { } } +/** + * function redirect To Page Detail + * @param id รายการตำสั่ง + * @param status สถานะคำสั่ง + */ function redirectToPage(id: string, status: string) { let step = 1; switch (status) { @@ -311,6 +320,13 @@ function redirectToPage(id: string, status: string) { } router.push(`/salary/command/detail/${id}?step=${step}`); } + +onMounted(async () => { + await fiscalYearFilter(); + await OrderTypeFilter(); + await fetchOrderlist(); + await OrderStatusFilter(); +});