fix(rerirement): ปีงบ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-10-02 14:39:10 +07:00
parent e2c3c85a77
commit 878f136181
2 changed files with 57 additions and 100 deletions

View file

@ -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<number | null>(calculateFiscalYear(new Date())); //
const year = ref<number | null>(new Date().getFullYear());
const rows = ref<MainData[]>([]);
const filterKeyword = ref<string>("");

View file

@ -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<number>(); //
const yearOptionsFilter = ref<any>({
yearOptions: [],
});
const fiscalyear = ref<number>(calculateFiscalYear(new Date())); //
const actionOption = ref<resMain[]>([]);
const pagination = ref({
@ -90,10 +88,9 @@ const columns = ref<QTableProps["columns"]>([
]);
// ()
const currentYear = new Date().getFullYear();
const currentYear = calculateFiscalYear(new Date());
const rows = ref<resMain[]>([]);
const rowsData = ref<resMain[]>([]);
const yearOptions = ref<any>([{ 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<string>("");
const filterRef = ref<any>(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 () => {
<div class="col-12 row q-pa-md q-col-gutter-sm">
<div class="row col-12">
<div class="row col-12 q-col-gutter-sm">
<q-select
<datepicker
v-model="fiscalyear"
label="ปีงบประมาณ"
dense
emit-value
map-options
:options="yearOptions"
option-value="id"
option-label="year"
lazy-rules
hide-selected
fill-input
use-input
hide-bottom-space
:readonly="false"
:borderless="false"
:outlined="true"
@filter="(inputValue:any,
doneFn:Function) => filterSelector(inputValue, doneFn
) "
:hide-dropdown-icon="false"
style="min-width: 150px"
style="width: 150px"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
:max-date="`${calculateFiscalYear(new Date())}, 12, 31`"
@update:model-value="fetchRetirement(type, fiscalyear)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
outlined
hide-bottom-space
:model-value="
fiscalyear === null ? 'ทั้งหมด' : Number(fiscalyear) + 543
"
:label="`${'ปีพ.ศ.'}`"
>
</q-input>
</template>
</q-select>
</datepicker>
<!-- use-input -->
<div v-if="checkPermission($route)?.attrIsCreate">
<div
v-if="
checkPermission($route)?.attrIsCreate &&
fiscalyear === currentYear
"
>
<popupAdd
:type="useStoreRetire.type"
:year="fiscalyear"
@ -387,7 +344,8 @@ onMounted(async () => {
<q-btn
v-if="
checkPermission($route)?.attrIsGet &&
checkPermission($route)?.attrIsUpdate
checkPermission($route)?.attrIsUpdate &&
fiscalyear === currentYear
"
flat
round