diff --git a/src/modules/05_placement/components/probation/MainSurvey.vue b/src/modules/05_placement/components/probation/MainSurvey.vue index d765c76c3..6290b910e 100644 --- a/src/modules/05_placement/components/probation/MainSurvey.vue +++ b/src/modules/05_placement/components/probation/MainSurvey.vue @@ -6,7 +6,6 @@ import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import { usePagination } from "@/composables/usePagination"; -import { calculateFiscalYear } from "@/utils/function"; import type { MainData } from "@/modules/05_placement/interface/index/Survey"; @@ -15,7 +14,7 @@ const mixin = useCounterMixin(); const { showLoader, hideLoader, messageError, date2Thai } = mixin; const { pagination, params, onRequest } = usePagination("", getData); -const year = ref(calculateFiscalYear(new Date())); //ปีงบประมาณ +const year = ref(new Date().getFullYear()); const rows = ref([]); const filterKeyword = ref(""); diff --git a/src/modules/06_retirement/views/01_retirement.vue b/src/modules/06_retirement/views/01_retirement.vue index 60007ace4..a3483f52a 100644 --- a/src/modules/06_retirement/views/01_retirement.vue +++ b/src/modules/06_retirement/views/01_retirement.vue @@ -7,6 +7,7 @@ import { useRouter } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; import { useDataStoreRetirement } from "@/modules/06_retirement/store/storeRetirement"; import { checkPermission } from "@/utils/permissions"; +import { calculateFiscalYear } from "@/utils/function"; import http from "@/plugins/http"; import config from "@/app.config"; @@ -24,10 +25,7 @@ const { clickTab } = useStoreRetire; const { messageError, date2Thai, showLoader, hideLoader, onSearchDataTable } = mixin; -const fiscalyear = ref(); // ปี -const yearOptionsFilter = ref({ - yearOptions: [], -}); +const fiscalyear = ref(calculateFiscalYear(new Date())); // ปี const actionOption = ref([]); const pagination = ref({ @@ -90,10 +88,9 @@ const columns = ref([ ]); // ข้อมูลตาราง (จำลอง) -const currentYear = new Date().getFullYear(); +const currentYear = calculateFiscalYear(new Date()); const rows = ref([]); const rowsData = ref([]); -const yearOptions = ref([{ id: "", year: "ทั้งหมด" }]); // ประกาศเกษียณอายุราชการ async function fetchRetirement(type: string, year: any) { @@ -103,52 +100,30 @@ async function fetchRetirement(type: string, year: any) { .get(config.API.retirement(type, year)) .then((res) => { let data = res.data.result; - const listData = data.map((items: any) => ({ - id: items.id, - signDate: date2Thai(items.signDate) ?? "-", - Date: date2Thai(items.createdAt), - year: items.year + 543, - retireNumber: items.round, - total: items.total, - round: items.round, - typeReport: typeReportChangeName(items.typeReport), // เปลี่ยนสถานะ - json: items.json, - document: items.document, - })); - rows.value = listData; - rowsData.value = listData; - - let option: any[] = []; - data.map((items: any) => { - option.push({ - id: items.year, - year: (items.year + 543).toString(), + if (data.length !== 0) { + const listData = data.map((items: any) => ({ + id: items.id, + signDate: date2Thai(items.signDate) ?? "-", + Date: date2Thai(items.createdAt), + year: items.year + 543, + retireNumber: items.round, + total: items.total, + round: items.round, typeReport: typeReportChangeName(items.typeReport), // เปลี่ยนสถานะ - }); - }); - yearOptions.value = [{ id: 0, year: "ทั้งหมด" }]; - // yearOptions.value.push(...option); - if (option.length !== 0) { - const double_name = [...new Set(option.map((item: any) => item.id))]; - for (let i = 1; i <= double_name.length; i++) { - const type = double_name[i - 1]; - const listtype = { - id: type, - year: (Number(type) + 543).toString(), - }; - yearOptions.value.push(listtype); - } - } - yearOptionsFilter.value = yearOptions.value; - if (yearOptionsFilter.value.length == 1) { - fiscalyear.value = yearOptionsFilter.value[0].id; + json: items.json, + document: items.document, + })); + rows.value = listData; + rowsData.value = listData; + actionOption.value = rows.value; + rows.value.sort((a, b) => a.round - b.round); // เรียงรอบมากไปน้อย + checkststus(rows.value); } else { - fiscalyear.value = year; + rows.value = []; + rowsData.value = []; + actionOption.value = []; + checkjson.value = false; } - actionOption.value = rows.value; - - rows.value.sort((a, b) => a.round - b.round); // เรียงรอบมากไปน้อย - checkststus(rows.value); }) .catch((e) => { messageError($q, e); @@ -171,25 +146,6 @@ function checkststus(data: any) { const filterKeyword = ref(""); const filterRef = ref(null); -/** reset ฟิลเตอร์ */ -function resetFilter() { - filterKeyword.value = ""; - filterRef.value.focus(); -} - -/** - * ฟังชั่นฟิลเตอร์ input - * @param val input - * @param update Function quasar - */ -function filterSelector(val: any, update: Function) { - update(() => { - yearOptions.value = yearOptionsFilter.value.filter( - (v: any) => v.year.indexOf(val) > -1 - ); - }); -} - /** * ไปหน้าแก้ไขรายละเอียด * @param prop ข้อมูล @@ -270,40 +226,41 @@ onMounted(async () => {
- -