ทะเบียนประวัติลูกจ้างชั่วคราว
This commit is contained in:
parent
e2f17237ab
commit
7e6878a1b2
2 changed files with 54 additions and 213 deletions
|
|
@ -1,11 +1,12 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, watch, ref, reactive } from "vue";
|
import { onMounted, ref, reactive } from "vue";
|
||||||
import { checkPermission } from "@/utils/permissions";
|
import { checkPermission } from "@/utils/permissions";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
|
||||||
|
import type { QTableColumn } from "quasar";
|
||||||
import type { FormEmployee } from "@/modules/04_registryPerson/interface/request/Employee";
|
import type { FormEmployee } from "@/modules/04_registryPerson/interface/request/Employee";
|
||||||
import type {
|
import type {
|
||||||
EmployeeHistory,
|
EmployeeHistory,
|
||||||
|
|
@ -13,8 +14,7 @@ import type {
|
||||||
} from "@/modules/04_registryPerson/interface/response/Employee";
|
} from "@/modules/04_registryPerson/interface/response/Employee";
|
||||||
|
|
||||||
import DialogHeader from "@/components/DialogHeader.vue";
|
import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
|
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
|
||||||
import type { QTableColumn } from "quasar";
|
|
||||||
|
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
||||||
|
|
@ -145,9 +145,6 @@ function onSubmit() {
|
||||||
|
|
||||||
/** ประวัติข้อมูลลูกจ้างชั่วคราว */
|
/** ประวัติข้อมูลลูกจ้างชั่วคราว */
|
||||||
const modalHistory = ref<boolean>(false);
|
const modalHistory = ref<boolean>(false);
|
||||||
const filter = ref<string>("");
|
|
||||||
const rows = ref<EmployeeHistory[]>([]);
|
|
||||||
const rowsMain = ref<EmployeeHistory[]>([]);
|
|
||||||
const columns = ref<QTableColumn[]>([
|
const columns = ref<QTableColumn[]>([
|
||||||
{
|
{
|
||||||
name: "positionEmployeeGroupId",
|
name: "positionEmployeeGroupId",
|
||||||
|
|
@ -307,7 +304,7 @@ const columns = ref<QTableColumn[]>([
|
||||||
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const visibleColumns = ref<String[]>([
|
const visibleColumns = ref<string[]>([
|
||||||
"positionEmployeeGroupId",
|
"positionEmployeeGroupId",
|
||||||
"positionEmployeeLineId",
|
"positionEmployeeLineId",
|
||||||
"positionEmployeePositionId",
|
"positionEmployeePositionId",
|
||||||
|
|
@ -321,38 +318,23 @@ const visibleColumns = ref<String[]>([
|
||||||
"lastUpdateFullName",
|
"lastUpdateFullName",
|
||||||
"lastUpdatedAt",
|
"lastUpdatedAt",
|
||||||
]);
|
]);
|
||||||
const pagination = ref({
|
|
||||||
sortBy: "lastUpdatedAt",
|
|
||||||
});
|
|
||||||
|
|
||||||
function onClickHistory() {
|
function onClickHistory() {
|
||||||
showLoader();
|
|
||||||
modalHistory.value = true;
|
modalHistory.value = true;
|
||||||
http
|
|
||||||
.get(config.API.informationHistoryEmployee(profileId.value))
|
|
||||||
.then((res) => {
|
|
||||||
const data = res.data.result;
|
|
||||||
rows.value = data.sort(
|
|
||||||
(a: any, b: any) =>
|
|
||||||
new Date(b.lastUpdatedAt).getTime() -
|
|
||||||
new Date(a.lastUpdatedAt).getTime()
|
|
||||||
);
|
|
||||||
rowsMain.value = rows.value;
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
messageError($q, err);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
hideLoader();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function serchDataTable() {
|
async function fetchDataHistory() {
|
||||||
rows.value = onSearchDataTable(
|
showLoader();
|
||||||
filter.value,
|
try {
|
||||||
rowsMain.value,
|
const res = await http.get(
|
||||||
columns.value ? columns.value : []
|
config.API.informationHistoryEmployee(profileId.value)
|
||||||
);
|
);
|
||||||
|
return res.data.result;
|
||||||
|
} catch (err) {
|
||||||
|
messageError($q, err);
|
||||||
|
} finally {
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
@ -635,80 +617,13 @@ onMounted(() => {
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
||||||
<!-- Dialog ประวัติการแก้ไขข้อมูลลูกจ้างชั่วคราว -->
|
<!-- Dialog ประวัติการแก้ไขข้อมูลลูกจ้างชั่วคราว -->
|
||||||
<q-dialog v-model="modalHistory" persistent>
|
<DialogHistory
|
||||||
<q-card style="min-width: 80%">
|
v-model:modal="modalHistory"
|
||||||
<DialogHeader
|
:visible-columns="visibleColumns"
|
||||||
tittle="ประวัติแก้ไขข้อมูลส่วนตัว"
|
:title="`ประวัติแก้ไขข้อมูลส่วนตัว`"
|
||||||
:close="() => ((modalHistory = false), (filter = ''), (rows = []))"
|
:columns="columns"
|
||||||
/>
|
:fetch-data="fetchDataHistory"
|
||||||
<q-separator />
|
/>
|
||||||
|
|
||||||
<q-card-section style="max-height: 50vh" class="scroll">
|
|
||||||
<div class="row q-gutter-sm q-mb-sm">
|
|
||||||
<q-space />
|
|
||||||
<q-input
|
|
||||||
standout
|
|
||||||
dense
|
|
||||||
v-model="filter"
|
|
||||||
ref="filterRef"
|
|
||||||
outlined
|
|
||||||
placeholder="ค้นหา"
|
|
||||||
@keydown.enter.pervent="serchDataTable"
|
|
||||||
>
|
|
||||||
<template v-slot:append>
|
|
||||||
<q-icon name="search" />
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
<q-select
|
|
||||||
v-model="visibleColumns"
|
|
||||||
multiple
|
|
||||||
outlined
|
|
||||||
dense
|
|
||||||
options-dense
|
|
||||||
:display-value="$q.lang.table.columns"
|
|
||||||
emit-value
|
|
||||||
map-options
|
|
||||||
:options="columns"
|
|
||||||
option-value="name"
|
|
||||||
style="min-width: 140px"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<d-table
|
|
||||||
ref="table"
|
|
||||||
flat
|
|
||||||
bordered
|
|
||||||
dense
|
|
||||||
:columns="columns"
|
|
||||||
:rows="rows"
|
|
||||||
:visible-columns="visibleColumns"
|
|
||||||
v-model:pagination="pagination"
|
|
||||||
>
|
|
||||||
>
|
|
||||||
<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-tr>
|
|
||||||
</template>
|
|
||||||
<template v-slot:body="props">
|
|
||||||
<q-tr :props="props">
|
|
||||||
<q-td v-for="col in props.cols" :key="col.id">
|
|
||||||
<div>
|
|
||||||
{{ col.value ? col.value : "-" }}
|
|
||||||
</div>
|
|
||||||
</q-td>
|
|
||||||
</q-tr>
|
|
||||||
</template>
|
|
||||||
</d-table>
|
|
||||||
</q-card-section>
|
|
||||||
|
|
||||||
<q-separator />
|
|
||||||
|
|
||||||
<q-card-actions align="right"> </q-card-actions>
|
|
||||||
</q-card>
|
|
||||||
</q-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { useQuasar } from "quasar";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableColumn } from "quasar";
|
||||||
import type {
|
import type {
|
||||||
Employment,
|
Employment,
|
||||||
EmploymentHistory,
|
EmploymentHistory,
|
||||||
|
|
@ -14,6 +14,7 @@ import type {
|
||||||
import type { FormEmployment } from "@/modules/04_registryPerson/interface/request/Employee";
|
import type { FormEmployment } from "@/modules/04_registryPerson/interface/request/Employee";
|
||||||
|
|
||||||
import DialogHeader from "@/components/DialogHeader.vue";
|
import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
|
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
|
||||||
|
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
||||||
|
|
@ -28,6 +29,7 @@ const {
|
||||||
hideLoader,
|
hideLoader,
|
||||||
showLoader,
|
showLoader,
|
||||||
onSearchDataTable,
|
onSearchDataTable,
|
||||||
|
convertDateToAPI,
|
||||||
} = useCounterMixin();
|
} = useCounterMixin();
|
||||||
|
|
||||||
const profileId = ref<string>(route.params.id.toString());
|
const profileId = ref<string>(route.params.id.toString());
|
||||||
|
|
@ -41,7 +43,8 @@ const isLeave = defineModel<boolean>("isLeave", {
|
||||||
const rows = ref<Employment[]>([]);
|
const rows = ref<Employment[]>([]);
|
||||||
const rowsMain = ref<Employment[]>([]);
|
const rowsMain = ref<Employment[]>([]);
|
||||||
const filter = ref<string>("");
|
const filter = ref<string>("");
|
||||||
const columns = ref<QTableProps["columns"]>([
|
|
||||||
|
const columns = ref<QTableColumn[]>([
|
||||||
{
|
{
|
||||||
name: "date",
|
name: "date",
|
||||||
align: "left",
|
align: "left",
|
||||||
|
|
@ -106,9 +109,6 @@ const visibleColumns = ref<string[]>([
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
sortBy: "",
|
sortBy: "",
|
||||||
});
|
});
|
||||||
const paginationHistory = ref({
|
|
||||||
sortBy: "lastUpdatedAt",
|
|
||||||
});
|
|
||||||
|
|
||||||
const modalEmployment = ref<boolean>(false);
|
const modalEmployment = ref<boolean>(false);
|
||||||
const isEdit = ref<boolean>(false);
|
const isEdit = ref<boolean>(false);
|
||||||
|
|
@ -186,7 +186,10 @@ function onSubmit() {
|
||||||
showLoader();
|
showLoader();
|
||||||
const methods = isEdit.value ? "put" : "post";
|
const methods = isEdit.value ? "put" : "post";
|
||||||
const id = isEdit.value ? employmentId.value : profileId.value;
|
const id = isEdit.value ? employmentId.value : profileId.value;
|
||||||
http[methods](config.API.employmentEmployee(id), formData)
|
http[methods](config.API.employmentEmployee(id), {
|
||||||
|
...formData,
|
||||||
|
date: convertDateToAPI(formData.date),
|
||||||
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
await fetchListEmployment();
|
await fetchListEmployment();
|
||||||
await success($q, "บันทึกข้อมูลสำเร็จ");
|
await success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
|
|
@ -224,30 +227,29 @@ function onDeleteEmployment(id: string) {
|
||||||
|
|
||||||
/** ประวัติข้อมูลการจ้าง*/
|
/** ประวัติข้อมูลการจ้าง*/
|
||||||
const modalHistory = ref<boolean>(false);
|
const modalHistory = ref<boolean>(false);
|
||||||
const rowsHistory = ref<EmploymentHistory[]>([]);
|
const historyId = ref<string>("");
|
||||||
const rowsHistoryMain = ref<EmploymentHistory[]>([]);
|
|
||||||
const filterHistory = ref<string>("");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function เปิด dialog ประวัติการแก้ไขข้อมูลการจ้าง
|
* function เปิด dialog ประวัติการแก้ไขข้อมูลการจ้าง
|
||||||
* @param id รายการการจ้าง
|
* @param id รายการการจ้าง
|
||||||
*/
|
*/
|
||||||
function onClickHistory(id: string) {
|
function onClickHistory(id: string) {
|
||||||
|
historyId.value = id;
|
||||||
modalHistory.value = true;
|
modalHistory.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchDataHistory() {
|
||||||
showLoader();
|
showLoader();
|
||||||
http
|
try {
|
||||||
.get(config.API.employmentHistoryEmployee(id))
|
const res = await http.get(
|
||||||
.then((res) => {
|
config.API.employmentHistoryEmployee(historyId.value)
|
||||||
const data = res.data.result;
|
);
|
||||||
rowsHistory.value = data;
|
return res.data.result;
|
||||||
rowsHistoryMain.value = data;
|
} catch (err) {
|
||||||
})
|
messageError($q, err);
|
||||||
.catch((err) => {
|
} finally {
|
||||||
messageError($q, err);
|
hideLoader();
|
||||||
})
|
}
|
||||||
.finally(() => {
|
|
||||||
hideLoader();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function serchDataTable() {
|
function serchDataTable() {
|
||||||
|
|
@ -258,14 +260,6 @@ function serchDataTable() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serchDataTableHistory() {
|
|
||||||
rowsHistory.value = onSearchDataTable(
|
|
||||||
filterHistory.value,
|
|
||||||
rowsHistoryMain.value,
|
|
||||||
columns.value ? columns.value : []
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
profileId.value && fetchListEmployment();
|
profileId.value && fetchListEmployment();
|
||||||
});
|
});
|
||||||
|
|
@ -462,81 +456,13 @@ onMounted(() => {
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
||||||
<!-- Dialog ประวัติการแก้ไขข้อมูลลูกจ้างชั่วคราว -->
|
<!-- Dialog ประวัติการแก้ไขข้อมูลลูกจ้างชั่วคราว -->
|
||||||
<q-dialog v-model="modalHistory" persistent>
|
<DialogHistory
|
||||||
<q-card style="min-width: 80%">
|
v-model:modal="modalHistory"
|
||||||
<DialogHeader
|
:visible-columns="visibleColumns"
|
||||||
tittle="ประวัติแก้ไขข้อมูลส่วนตัว"
|
:title="`ประวัติแก้ไขข้อมูลการจ้าง`"
|
||||||
:close="
|
:columns="columns"
|
||||||
() => (
|
:fetch-data="fetchDataHistory"
|
||||||
(modalHistory = false), (filterHistory = ''), (rowsHistory = [])
|
/>
|
||||||
)
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
<q-separator />
|
|
||||||
|
|
||||||
<q-card-section style="max-height: 50vh" class="scroll">
|
|
||||||
<div class="row q-gutter-sm q-mb-sm">
|
|
||||||
<q-space />
|
|
||||||
<q-input
|
|
||||||
standout
|
|
||||||
dense
|
|
||||||
v-model="filterHistory"
|
|
||||||
outlined
|
|
||||||
placeholder="ค้นหา"
|
|
||||||
@keydown.enter.pervent="serchDataTableHistory"
|
|
||||||
>
|
|
||||||
<template v-slot:append>
|
|
||||||
<q-icon name="search" />
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
<q-select
|
|
||||||
v-model="visibleColumns"
|
|
||||||
multiple
|
|
||||||
outlined
|
|
||||||
dense
|
|
||||||
options-dense
|
|
||||||
:display-value="$q.lang.table.columns"
|
|
||||||
emit-value
|
|
||||||
map-options
|
|
||||||
:options="columns"
|
|
||||||
option-value="name"
|
|
||||||
style="min-width: 140px"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<d-table
|
|
||||||
ref="table"
|
|
||||||
flat
|
|
||||||
bordered
|
|
||||||
dense
|
|
||||||
:columns="columns"
|
|
||||||
:rows="rowsHistory"
|
|
||||||
:visible-columns="visibleColumns"
|
|
||||||
v-model:pagination="paginationHistory"
|
|
||||||
>
|
|
||||||
>
|
|
||||||
<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-tr>
|
|
||||||
</template>
|
|
||||||
<template v-slot:body="props">
|
|
||||||
<q-tr :props="props" class="cursor-pointer">
|
|
||||||
<q-td v-for="col in props.cols" :key="col.id">
|
|
||||||
<div>
|
|
||||||
{{ col.value ? col.value : "-" }}
|
|
||||||
</div>
|
|
||||||
</q-td>
|
|
||||||
</q-tr>
|
|
||||||
</template>
|
|
||||||
</d-table>
|
|
||||||
</q-card-section>
|
|
||||||
|
|
||||||
<q-separator />
|
|
||||||
</q-card>
|
|
||||||
</q-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue