API ข้อมูลตำแหน่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-02-27 17:19:31 +07:00
parent a595c1a5e9
commit a6293efa69
5 changed files with 99 additions and 23 deletions

View file

@ -169,7 +169,8 @@ export default {
`${registryNew}${type}/leave/admin/${id}`, //noPermission
/** ตำแหน่ง*/
profileSalaryPositionNew: (type: string) => `${registryNew}${type}/salary/position`,
profileSalaryPositionNew: (type: string) =>
`${registryNew}${type}/salary/position`,
profileListSalaryPositionNew: (id: string, type: string) =>
`${registryNew}${type}/salary/position/${id}`,
profileListSalaryPositionHistoryNew: (profileId: string, type: string) =>
@ -178,6 +179,8 @@ export default {
`${registryNew}${type2}/salary/position/swap/${type}/${id}`,
salaryListCardPosition: (id: string, type: string) =>
`${registryNew}${type}/salary/position/admin/${id}`, //noPermission
salaryTenurePosition: (id: string, type: string) =>
`${registryNew}${type}/salary/tenure/${id}`, //noPermission
/** ตำแหน่งเงินเดือน*/
profileSalaryNew: (type: string) => `${registryNew}${type}/salary`,

View file

@ -47,6 +47,7 @@ const {
success,
pathRegistryEmp,
onSearchDataTable,
formatDatePosition,
} = useCounterMixin();
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
@ -292,21 +293,15 @@ const docOption = ref<DataOption2[]>(store.optionTemplateDoc);
const cardData = ref<any[]>([
{
label: "ระยะเวลาดำรงตำแหน่งในสายงาน",
data: [
{ name: "ตำแหน่ง", time: "1 ปี" },
{ name: "ตำแหน่ง", time: "1 ปี" },
{ name: "ตำแหน่ง", time: "1 ปี" },
{ name: "ตำแหน่ง", time: "1 ปี" },
{ name: "ตำแหน่ง", time: "1 ปี" },
],
data: [],
},
{
label: "ระยะเวลาดำรงตำแหน่งตามระดับ",
data: [{ name: "ละดับ", time: "1 ปี" }],
data: [],
},
{
label: "ระยะเวลาดำรงตำแหน่งทางการบริหาร",
data: [{ name: "ตำแหน่งทางการบริหาร", time: "1 ปี" }],
data: [],
},
]);
@ -731,9 +726,36 @@ function serchDataTable() {
);
}
async function fetchDataTenure() {
await http
.get(config.API.salaryTenurePosition(profileId.value, empType.value))
.then((res) => {
const data = res.data.result;
if (data) {
const formatData = (list: any) =>
list.map((e: any) => ({
name: e.name ?? "",
time: formatDatePosition(e.year, e.month, e.day),
}));
const position = formatData(data.position);
const posLevel = formatData(data.posLevel);
const posExecutive = formatData(data.posExecutive);
cardData.value[0].data = position;
cardData.value[1].data = posLevel;
cardData.value[2].data = posExecutive;
}
})
.catch((err) => {
messageError($q, err);
});
}
/** ทำงานเมื่อ Components ถูกเรียกใช้งาน*/
onMounted(() => {
fetchListSalary();
fetchDataTenure();
});
</script>

View file

@ -1,5 +1,13 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
const { messageError, formatDatePosition } = useCounterMixin();
/** props*/
const props = defineProps({
@ -14,27 +22,53 @@ const props = defineProps({
const cardData = ref<any[]>([
{
label: "ระยะเวลาดำรงตำแหน่งในสายงาน",
data: [
{ name: "ตำแหน่ง", time: "1 ปี" },
{ name: "ตำแหน่ง", time: "1 ปี" },
{ name: "ตำแหน่ง", time: "1 ปี" },
{ name: "ตำแหน่ง", time: "1 ปี" },
{ name: "ตำแหน่ง", time: "1 ปี" },
],
data: [],
},
{
label: "ระยะเวลาดำรงตำแหน่งตามระดับ",
data: [{ name: "ละดับ", time: "1 ปี" }],
data: [],
},
{
label: "ระยะเวลาดำรงตำแหน่งทางการบริหาร",
data: [{ name: "ตำแหน่งทางการบริหาร", time: "1 ปี" }],
data: [],
},
]);
async function fetchDataTenure() {
if (props?.id) {
await http
.get(
config.API.salaryTenurePosition(
props?.id,
props.type === "officer" ? "" : "-employee"
)
)
.then((res) => {
const data = res.data.result;
if (data) {
const formatData = (list: any) =>
list.map((e: any) => ({
name: e.name ?? "",
time: formatDatePosition(e.year, e.month, e.day),
}));
const position = formatData(data.position);
const posLevel = formatData(data.posLevel);
const posExecutive = formatData(data.posExecutive);
cardData.value[0].data = position;
cardData.value[1].data = posLevel;
cardData.value[2].data = posExecutive;
}
})
.catch((err) => {
messageError($q, err);
});
}
}
onMounted(() => {
console.log(props.id);
console.log(props.type);
fetchDataTenure();
});
</script>
@ -45,7 +79,7 @@ onMounted(() => {
<span class="q-ml-md">อมลตำแหน </span>
</div>
<div class="row q-pa-sm">
<q-list flat bordered class="col-12" style="border-radius: 5px;">
<q-list flat bordered class="col-12" style="border-radius: 5px">
<q-card flat v-for="(item, index) in cardData" :key="index">
<q-item>
<q-item-section>
@ -57,7 +91,7 @@ onMounted(() => {
</q-item-label>
</q-item-section>
</q-item>
<q-separator spaced v-if="index !== 2" />
<q-separator v-if="index !== 2" />
</q-card>
</q-list>
</div>

View file

@ -522,6 +522,9 @@ async function onSearch() {
sortBy: sortBy.value ? "dateAppoint" : "",
sort: sortBy.value ? sortBy.value : "ASC",
isRetireLaw: isRetireLaw.value,
tenureType: typeTerm.value ?? null,
tenureMin: typeTerm.value ? Number(rangeTerm.value.min) : null,
tenureMax: typeTerm.value ? Number(rangeTerm.value.max) : null,
};
showLoader();
await http

View file

@ -1149,6 +1149,19 @@ export const useCounterMixin = defineStore("mixin", () => {
});
}
function formatDatePosition(year: string, month: string, day: string) {
const y = parseInt(year);
const m = parseInt(month);
const d = parseInt(day);
const parts = [];
if (y > 0) parts.push(`${y}ปี`);
if (m > 0) parts.push(`${m}เดือน`);
if (d > 0) parts.push(`${d}วัน`);
return parts.length > 0 ? parts.join(" ") : ""; // กรณีที่ทั้งหมดเป็น 0
}
return {
calAge,
date2Thai,
@ -1195,5 +1208,6 @@ export const useCounterMixin = defineStore("mixin", () => {
downloadRenameFileByLink,
onSearchDataTable,
formatDatePosition,
};
});