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

@ -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