รายการเงินเดือน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-28 14:53:38 +07:00
parent 9955bc4fe0
commit 42badd9978
3 changed files with 105 additions and 36 deletions

View file

@ -1,42 +1,51 @@
<script setup lang="ts">
import type { DataPeriodLatest } from "@/modules/13_salary/interface/response/SalaryList";
import TabGroup from "@/modules/13_salary/components/SalaryLists/TabMain.vue";
import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsStore";
import { onMounted, ref } from "vue";
import { useQuasar } from "quasar";
import config from "@/app.config";
import http from "@/plugins/http";
/** importType*/
import type {
DataOption,
DataOptionShort,
} from "@/modules/13_salary/interface/index/Main";
import config from "@/app.config";
import http from "@/plugins/http";
import type {
DataRound,
DataAgency,
DataPeriodLatest,
} from "@/modules/13_salary/interface/response/SalaryList";
/** importComponents*/
import TabGroup from "@/modules/13_salary/components/SalaryLists/TabMain.vue";
/** importStore*/
import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsStore";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
const { messageError, showLoader, hideLoader } = useCounterMixin();
/** use*/
const store = useSalaryListSDataStore();
const $q = useQuasar();
const { messageError, showLoader, hideLoader } = useCounterMixin();
/** ตัวแปร*/
const roundFilter = ref<any>();
const roundOptions = ref<DataOptionShort[]>([]);
const agencyFilter = ref<string>("");
const agencyOptions = ref<DataOption[]>();
const snapFilter = ref<string>("");
const snapOptions = ref<DataOption[]>();
// const tabMain = ref<string>("first_snapshot");
const periodLatest = ref<DataPeriodLatest>();
const isLoad = ref<boolean>(false);
/**function เรียกข้อมูลรอบการขึ้นเงินเดือน*/
async function getRound() {
showLoader();
http
.get(config.API.salaryPeriod() + `?page=1&pageSise=10&keyword=&year=0`)
.then(async (res) => {
const data = res.data.result.data;
roundOptions.value = await data.map((x: any) => ({
roundOptions.value = await data.map((x: DataRound) => ({
id: x.id,
revisionId: x.revisionId,
shortCode: x.period,
@ -73,6 +82,7 @@ async function getRound() {
});
}
/** function เรียกรอบ*/
function getSnap(code: string) {
snapOptions.value =
code === "OCT"
@ -110,17 +120,19 @@ function getSnap(code: string) {
snapFilter.value = snapOptions.value[0].id;
}
/**
* function เรยกขอมลหนยวงาน
* @param id revisionId
*/
async function getAgency(id: string) {
await http
.get(config.API.activeOrganizationRootById(id))
.then(async (res) => {
const data = res.data.result;
agencyOptions.value = await data.map((x: any) => ({
agencyOptions.value = await data.map((x: DataAgency) => ({
id: x.id,
name: x.orgRootName,
}));
agencyFilter.value = store.rootId;
})
.catch((err) => {
@ -128,13 +140,18 @@ async function getAgency(id: string) {
});
}
/**
* function เรยกขอมลหนยวงานปจ
* @param id revisionId
*/
async function getAgencyPosition(id: string) {
await http
.get(config.API.keycloakPositionByid(id))
.then(async (res) => {
const data = res.data.result;
const position = agencyOptions.value?.find(
(e: any) => e.id === data.rootId
(e: DataOption) => e.id === data.rootId
);
agencyFilter.value = position ? position.id : "";
})
@ -143,12 +160,19 @@ async function getAgencyPosition(id: string) {
});
}
/**
*
* @param rootId id หนวยงาน
* @param periodId id รอบการขนเงนเดอน
* @param snap id รอบ
*/
async function fetchSalalyPeriod(
rootId: string,
periodId: string,
snap: string
) {
showLoader();
isLoad.value = false;
const body = {
rootId: rootId,
salaryPeriodId: periodId,
@ -157,12 +181,9 @@ async function fetchSalalyPeriod(
await http
.post(config.API.salaryListPeriodLatest, body)
.then(async (res) => {
const data = res.data.result;
if (Object.values(data).includes(null)) {
console.log("มีค่า null ในคุณสมบัติบางอย่าง");
isLoad.value = false;
} else {
data && store.fetchPeriodLatest(data, store.tabGroup);
@ -177,6 +198,8 @@ async function fetchSalalyPeriod(
hideLoader();
});
}
/** function เปลี่ยนรอบการขั้นเงินเดือน*/
async function onChangeRound() {
await getSnap(roundFilter.value.shortCode);
await getAgency(roundFilter.value.revisionId);
@ -190,6 +213,7 @@ async function onChangeRound() {
}
}
/** function เปลี่ยนรอบ*/
async function onChangeSnap() {
if (agencyFilter.value && roundFilter.value.id && snapFilter.value) {
await fetchSalalyPeriod(
@ -200,6 +224,7 @@ async function onChangeSnap() {
}
}
/** function เปลี่ยนหน่วยงาน*/
async function onChangeAgency() {
if (agencyFilter.value && roundFilter.value.id && snapFilter.value) {
await fetchSalalyPeriod(
@ -210,8 +235,8 @@ async function onChangeAgency() {
}
}
onMounted(() => {
getRound();
onMounted(async () => {
await getRound();
});
</script>