รายการเงินเดือน
This commit is contained in:
parent
9955bc4fe0
commit
42badd9978
3 changed files with 105 additions and 36 deletions
|
|
@ -11,33 +11,28 @@ import type { DataFilterPerson } from "@/modules/13_salary/interface/index/Salar
|
|||
import type { DataPersonReq } from "@/modules/13_salary/interface/request/SalaryList";
|
||||
import type { DataPerson } from "@/modules/13_salary/interface/response/SalaryList";
|
||||
|
||||
/** importComponents*/
|
||||
import Header from "@/components/DialogHeader.vue";
|
||||
|
||||
/** importStore*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsStore";
|
||||
|
||||
const store = useSalaryListSDataStore();
|
||||
|
||||
/** use*/
|
||||
const $q = useQuasar();
|
||||
const {
|
||||
date2Thai,
|
||||
dialogRemove,
|
||||
messageError,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
dialogConfirm,
|
||||
success,
|
||||
} = useCounterMixin();
|
||||
const store = useSalaryListSDataStore();
|
||||
const { messageError, showLoader, hideLoader, dialogConfirm, success } =
|
||||
useCounterMixin();
|
||||
|
||||
/** props*/
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
|
||||
const props = defineProps({
|
||||
fetchData: {
|
||||
type: Function,
|
||||
},
|
||||
});
|
||||
|
||||
/** Table*/
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
|
|
@ -96,6 +91,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
]);
|
||||
const rows = ref<DataPerson[]>([]);
|
||||
|
||||
/** ข้อมูุลค้นหา*/
|
||||
const formFilter = reactive<DataFilterPerson>({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
|
|
@ -103,10 +99,13 @@ const formFilter = reactive<DataFilterPerson>({
|
|||
});
|
||||
const maxPage = ref<number>(1);
|
||||
|
||||
/** function close popup*/
|
||||
function closeModal() {
|
||||
modal.value = false;
|
||||
formFilter.page = 1;
|
||||
}
|
||||
|
||||
/** function เรียกรายชื่อ คนเลื่อนเงินเดือน*/
|
||||
async function fetchListPerson() {
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -125,6 +124,10 @@ async function fetchListPerson() {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function ยืนยันการเพิ่มคนเลื่อนเงินเดือน
|
||||
* @param data ข้อมูลคนที่เพิ่ม
|
||||
*/
|
||||
async function onClickAddPerson(data: DataPerson) {
|
||||
const body: DataPersonReq = {
|
||||
id: store.groupId,
|
||||
|
|
@ -154,22 +157,24 @@ async function onClickAddPerson(data: DataPerson) {
|
|||
);
|
||||
}
|
||||
|
||||
/** function updatePage*/
|
||||
async function updatePagePagination() {
|
||||
fetchListPerson();
|
||||
}
|
||||
|
||||
/** function updatePageSize*/
|
||||
function updatePageSizePagination(newPagination: NewPagination) {
|
||||
console.log("teset");
|
||||
|
||||
formFilter.page = 1;
|
||||
formFilter.pageSize = newPagination.rowsPerPage;
|
||||
}
|
||||
|
||||
/** function ค้นหาข้อมูลตาม keyword*/
|
||||
function searchData() {
|
||||
formFilter.page = 1;
|
||||
fetchListPerson();
|
||||
}
|
||||
|
||||
/** callblack function เรียกข้อมูลรายชื่อคนเลื่อนเงินเดือน เมื่อมีการเปิด Popup*/
|
||||
watch(
|
||||
() => modal.value,
|
||||
async () => {
|
||||
|
|
@ -179,6 +184,7 @@ watch(
|
|||
}
|
||||
);
|
||||
|
||||
/** callblack function เรียกข้อมูลรายชื่อคนเลื่อนเงินเดือน เมื่อมีการเปลี่ยน PageSize*/
|
||||
watch(
|
||||
() => formFilter.pageSize,
|
||||
() => {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,38 @@ interface DataPeriodQuota {
|
|||
remaining: number; //คงเหลือโควตาnumber
|
||||
}
|
||||
|
||||
interface DataRound {
|
||||
effectiveDate: string;
|
||||
id: string;
|
||||
isActive: boolean;
|
||||
period: string;
|
||||
revisionId: string;
|
||||
status: string;
|
||||
year: number;
|
||||
}
|
||||
|
||||
interface DataAgency {
|
||||
ancestorDNA: string;
|
||||
createdAt: string;
|
||||
createdFullName: string;
|
||||
createdUserId: string;
|
||||
id: string;
|
||||
lastUpdateFullName: string;
|
||||
lastUpdateUserId: string;
|
||||
lastUpdatedAt: string;
|
||||
orgChild1s: any[];
|
||||
orgRevision: any[];
|
||||
orgRevisionId: string;
|
||||
orgRootCode: string;
|
||||
orgRootFax: string;
|
||||
orgRootName: string;
|
||||
orgRootOrder: number;
|
||||
orgRootPhoneEx: string;
|
||||
orgRootPhoneIn: string;
|
||||
orgRootRank: string;
|
||||
orgRootShortName: string;
|
||||
}
|
||||
|
||||
interface DataPerson {
|
||||
amount: number;
|
||||
child1: string;
|
||||
|
|
@ -42,4 +74,10 @@ interface DataPerson {
|
|||
root: string;
|
||||
rootId: string;
|
||||
}
|
||||
export type { DataPeriodLatest, DataPeriodQuota, DataPerson };
|
||||
export type {
|
||||
DataPeriodLatest,
|
||||
DataPeriodQuota,
|
||||
DataRound,
|
||||
DataAgency,
|
||||
DataPerson,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue