ระยะเวลาดำลงตำแหน่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-03-03 15:04:42 +07:00
parent 0e5e7ac5be
commit 42301c4830
4 changed files with 184 additions and 76 deletions

View file

@ -111,6 +111,9 @@ export default {
dataUserSalaryNopaidHistoryByType: (emType: string, id: string) =>
`${org}/profile${emType}/nopaid/history/${id}`,
salaryTenurePosition: (emType: string) =>
`${org}/profile${emType}/salary/tenure/user`,
dataUserCertificateHistory: (type: string, id: string) =>
`${profileOrg}/${type}/history/${id}`,
dataUserCertificateHistoryByType: (

View file

@ -7,7 +7,10 @@ import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useDataStore } from "@/stores/data";
import type { SalaryFormType } from "@/modules/10_registry/interface/index/Main";
import type {
SalaryFormType,
CardDataPos,
} from "@/modules/10_registry/interface/index/Main";
//history dialog
import DialogHistory from "@/modules/10_registry/Dialog/DialogHistory.vue";
@ -16,8 +19,14 @@ const link = ref<string>("");
const $q = useQuasar();
const dataPerson = useDataStore();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai, onSearchDataTable } =
mixin;
const {
showLoader,
hideLoader,
messageError,
date2Thai,
onSearchDataTable,
formatDatePosition,
} = mixin;
const idByRow = ref<string>("");
const rows = ref<SalaryFormType[]>([]);
@ -30,7 +39,20 @@ const checkType = ref<boolean>(
dataPerson.officerType == "OFFICER" ? true : false
);
const modalHistory = ref<boolean>(false);
/** ตัวแปรข้อมูล */
const cardData = ref<CardDataPos[]>([
{
label: "ระยะเวลาดำรงตำแหน่งในสายงาน",
data: [],
},
{
label: "ระยะเวลาดำรงตำแหน่งตามระดับ",
data: [],
},
{
label: "ระยะเวลาดำรงตำแหน่งทางการบริหาร",
data: [],
},
]);
const visibleColumns = ref<string[]>([
"commandDateAffect",
@ -485,16 +507,69 @@ function onSearch() {
);
}
async function fetchDataTenure() {
await http
.get(config.API.salaryTenurePosition(link.value))
.then((res) => {
const data = res.data.result;
if (data) {
// map
const formatData = (list: any) =>
list.map((e: any) => ({
name: e.name ?? "",
time: formatDatePosition(e.year, e.month, e.day),
}));
// data
const position = formatData(data.position); //
const posLevel = formatData(data.posLevel); //
const posExecutive = formatData(data.posExecutive); //
// cardData
cardData.value[0].data = position;
cardData.value[1].data = posLevel;
cardData.value[2].data = posExecutive;
// cardData
if (posExecutive.length === 0) {
cardData.value.splice(2, 2);
}
}
})
.catch((err) => {
messageError($q, err);
});
}
onMounted(async () => {
link.value = await dataPerson.getProFileType();
getData();
fetchDataTenure();
});
</script>
<template>
<!-- v-if="mode" -->
<div class="col-12">
<q-toolbar class="q-px-none">
<span class="text-blue-6 text-weight-bold text-body1">ตำแหน</span>
</q-toolbar>
<div class="row q-col-gutter-sm q-pb-sm" v-if="link === ''">
<div class="col" v-for="(item, index) in cardData" :key="index">
<q-card bordered class="col-12" style="border: 1px solid #d6dee1">
<div class="col-12 text-weight-medium bg-grey-1 q-py-xs q-px-md">
{{ item.label }}
</div>
<div class="col-12"><q-separator /></div>
<q-card-section class="q-pt-none" style="min-height: 200px">
<li v-for="data in item.data">{{ data.name }} {{ data.time }}</li>
</q-card-section>
</q-card>
</div>
</div>
<div class="row col-12">
<q-space />
<q-input
v-if="mode"
@ -525,90 +600,94 @@ onMounted(async () => {
:options="columns"
:display-value="$q.lang.table.columns"
/>
</q-toolbar>
<d-table
flat
dense
bordered
virtual-scroll
:rows="rows.length !== 0 ? rows : []"
:columns="columns"
:grid="!mode"
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
:virtual-scroll-sticky-size-start="48"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width />
</q-tr>
</template>
</div>
<template v-if="mode" v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="(col, index) in props.cols" :key="col.name">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'status'">
{{ props.row.status ? props.row.status : "-" }}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="onHistory(props.row.id)"
>
<q-tooltip>ประวแกไขตำแหน/เงนเดอน</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
<template v-else v-slot:item="props">
<div class="q-mb-xs col-xs-12 col-sm-6 col-md-4 col-lg-3">
<q-card bordered flat>
<q-list dense class="q-mt-lg relative-position">
<div class="col-12 q-mt-sm">
<d-table
flat
dense
bordered
virtual-scroll
:rows="rows.length !== 0 ? rows : []"
:columns="columns"
:grid="!mode"
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
:virtual-scroll-sticky-size-start="48"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width />
</q-tr>
</template>
<template v-if="mode" v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="(col, index) in props.cols" :key="col.name">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'status'">
{{ props.row.status ? props.row.status : "-" }}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td auto-width>
<q-btn
icon="mdi-history"
color="info"
flat
dense
round
size="14px"
class="absolute_button"
icon="mdi-history"
@click="onHistory(props.row.id)"
>
<q-tooltip>ประวแกไขตำแหน/เงนเดอน</q-tooltip>
</q-btn>
<q-item v-for="col in props.cols" :key="col.name">
<q-item-section class="fix_top">
<q-item-label class="text-grey-6 text-weight-medium">{{
col.label
}}</q-item-label>
</q-item-section>
<q-item-section class="fix_top">
<q-item-label class="text-dark text-weight-medium">{{
col.value ? col.value : "-"
}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-card>
</div>
</template>
</d-table>
</q-td>
</q-tr>
</template>
<template v-else v-slot:item="props">
<div class="q-mb-xs col-xs-12 col-sm-6 col-md-4 col-lg-3">
<q-card bordered flat>
<q-list dense class="q-mt-lg relative-position">
<q-btn
icon="mdi-history"
color="info"
flat
dense
round
size="14px"
class="absolute_button"
@click="onHistory(props.row.id)"
>
<q-tooltip>ประวแกไขตำแหน/เงนเดอน</q-tooltip>
</q-btn>
<q-item v-for="col in props.cols" :key="col.name">
<q-item-section class="fix_top">
<q-item-label class="text-grey-6 text-weight-medium">{{
col.label
}}</q-item-label>
</q-item-section>
<q-item-section class="fix_top">
<q-item-label class="text-dark text-weight-medium">{{
col.value ? col.value : "-"
}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-card>
</div>
</template>
</d-table>
</div>
</div>
<DialogHistory
v-model:modal="modalHistory"
:title="'ตำแหน่ง'"

View file

@ -367,6 +367,17 @@ interface FileFormType {
pathName: string;
fileName: string;
}
interface CardDataPos {
label: string;
data?: Data[];
}
interface Data {
name: string;
time: string;
}
export type {
DataOption,
NewPagination,
@ -386,4 +397,5 @@ export type {
AssessmentsFormType,
OtherFormType,
FileFormType,
CardDataPos,
};

View file

@ -1158,6 +1158,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,
@ -1197,5 +1210,6 @@ export const useCounterMixin = defineStore("mixin", () => {
findOrgNameOld,
findPosMasterNo,
onSearchDataTable,
formatDatePosition,
};
});