ทะเบียนประวัติ ==> ข้อมูลราชการ ปรับ date, history

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-03-12 15:33:22 +07:00
parent 9ea4794379
commit fafdeb68f4
14 changed files with 647 additions and 2197 deletions

View file

@ -114,7 +114,10 @@ watch(
<template v-slot:body="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.id">
<div>
<div v-if="col.name === 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>

View file

@ -8,13 +8,11 @@ import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type {
RequestItemsHistoryObject,
FormMain,
} from "@/modules/04_registryPerson/interface/index/government";
import type { QTableColumn } from "quasar";
import type { FormMain } from "@/modules/04_registryPerson/interface/index/government";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
const route = useRoute();
const $q = useQuasar();
@ -28,7 +26,7 @@ const {
hideLoader,
success,
pathRegistryEmp,
onSearchDataTable,
convertDateToAPI,
} = mixin;
/** props*/
@ -71,18 +69,16 @@ const reasonSameDateRef = ref<object | null>(null);
//
const filterKeyword = ref<string>(""); //
const modalHistory = ref<boolean>(false); // popup ;
const rowsHistory = ref<RequestItemsHistoryObject[]>([]);
const rowsHistoryMain = ref<RequestItemsHistoryObject[]>([]); //
const modalHistory = ref<boolean>(false); // popup ;
//
const visibleColumnsHistory = ref<String[]>([
const visibleColumnsHistory = ref<string[]>([
"dateAppoint",
"dateStart",
"reasonSameDate",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const columnsHistory = ref<QTableProps["columns"]>([
const columnsHistory = ref<QTableColumn[]>([
{
name: "dateAppoint",
align: "left",
@ -142,9 +138,55 @@ const columnsHistory = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const pagination = ref({
sortBy: "lastUpdatedAt",
});
/** ดึงข้อมูลราชการ*/
async function getData() {
showLoader();
await http
.get(config.API.profileNewGovernmentById(profileId.value, empType.value))
.then(async (res) => {
const data = await res.data.result;
formMain.ocId = data.org ?? "-"; //
formMain.positionId = data.position ?? "-"; //
formMain.positionLine = data.positionField ?? "-"; //
formMain.positionLevel = data.posLevel ?? "-"; //
formMain.numberId = data.posMasterNo ?? "-"; //
formMain.positionType = data.posType ?? "-"; //
formMain.positionExecutive = data.posExecutive ?? "-"; //
formMain.positionPathSide = data.positionArea ?? "-"; //
formMain.positionExecutiveSide = data.positionExecutiveField ?? "-"; //
formMain.containDate = data.dateAppoint;
formMain.workDate = data.dateStart;
formMain.reasonSameDate = data.reasonSameDate;
formMain.retireDate = data.dateLeave;
formMain.dateRetireLaw = data.dateRetireLaw;
formMain.ageAll = data.govAge;
formMain.absent = data.govAgeAbsent;
formMain.age = data.govAgePlus;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/** ดึงข้อมูลประวัติ */
async function fetchDataHistory() {
showLoader();
try {
const res = await http.get(
config.API.profileNewGovernmentHistory(profileId.value, empType.value)
);
const data = res.data.result;
return data;
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
/** เปิด dialog */
function openDialogEdit() {
@ -160,7 +202,6 @@ function openDialogEdit() {
function openDialogHistory() {
modalHistory.value = true;
filterKeyword.value = "";
getDataHistory();
}
/** ปิด dialog*/
@ -179,8 +220,8 @@ function onSubmit() {
.patch(
config.API.profileNewGovernmentById(profileId.value, empType.value),
{
dateAppoint: containDate.value,
dateStart: workDate.value,
dateAppoint: convertDateToAPI(containDate.value),
dateStart: convertDateToAPI(workDate.value),
reasonSameDate:
dateToISO(containDate.value as Date) ===
dateToISO(workDate.value as Date)
@ -202,93 +243,6 @@ function onSubmit() {
});
}
/** ดึงข้อมูลราชการ*/
async function getData() {
showLoader();
await http
.get(config.API.profileNewGovernmentById(profileId.value, empType.value))
.then(async (res) => {
const data = await res.data.result;
formMain.ocId = data.org ?? "-"; //
formMain.positionId = data.position ?? "-"; //
formMain.positionLine = data.positionField ?? "-"; //
formMain.positionLevel = data.posLevel ?? "-"; //
formMain.numberId = data.posMasterNo ?? "-"; //
formMain.positionType = data.posType ?? "-"; //
formMain.positionExecutive = data.posExecutive ?? "-"; //
formMain.positionPathSide = data.positionArea ?? "-"; //
formMain.positionExecutiveSide = data.positionExecutiveField ?? "-"; //
formMain.containDate = data.dateAppoint;
formMain.workDate = data.dateStart;
formMain.reasonSameDate = data.reasonSameDate;
formMain.retireDate = data.dateLeave;
formMain.dateRetireLaw = data.dateRetireLaw;
formMain.ageAll = data.govAge;
formMain.absent = data.govAgeAbsent;
formMain.age = data.govAgePlus;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/** ดึงข้อมูลประวัติ */
async function getDataHistory() {
showLoader();
await http
.get(config.API.profileNewGovernmentHistory(profileId.value, empType.value))
.then(async (res) => {
let data = await res.data.result;
rowsHistory.value = [];
data.map((e: RequestItemsHistoryObject) => {
rowsHistory.value.push({
oc: e.oc,
position: e.position,
positionPathSide: e.positionPathSide,
posNo: e.posNo,
positionLine: e.positionLine,
positionType: e.positionType,
positionLevel: e.positionLevel,
positionExecutive: e.positionExecutive,
positionExecutiveSide: e.positionExecutiveSide,
dateAppoint: new Date(e.dateAppoint),
dateStart: new Date(e.dateStart),
dateRetire: e.dateRetire,
dateRetireLaw: e.dateRetireLaw,
govAge: e.govAge,
govAgeAbsent: e.govAgeAbsent,
govAgePlus: e.govAgePlus,
reasonSameDate: e.reasonSameDate,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
lastUpdatedAt: e.lastUpdatedAt,
lastUpdateFullName: e.lastUpdateFullName,
});
});
rowsHistoryMain.value = rowsHistory.value;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/** ฟังก์ค้นหาข้อมูลรายการประวัติข้อมูลราชการ */
function serchDataTableHistory() {
rowsHistory.value = onSearchDataTable(
filterKeyword.value,
rowsHistoryMain.value,
columnsHistory.value ? columnsHistory.value : []
);
}
/** ทำงานเมื่อ Components ถูกเรียกใช้งาน*/
onMounted(() => {
getData();
@ -648,8 +602,16 @@ onMounted(() => {
</q-card>
</q-dialog>
<DialogHistory
v-model:modal="modalHistory"
:title="`ประวัติแก้ไขข้อมูลราชการ`"
:columns="columnsHistory"
:visible-columns="visibleColumnsHistory"
:fetch-data="fetchDataHistory"
/>
<!-- dialog History -->
<q-dialog v-model="modalHistory" persistent>
<!-- <q-dialog v-model="modalHistory" persistent>
<q-card style="min-width: 80%">
<DialogHeader
tittle="ประวัติแก้ไขข้อมูลราชการ"
@ -721,7 +683,7 @@ onMounted(() => {
</d-table>
</q-card-section>
</q-card>
</q-dialog>
</q-dialog> -->
</template>
<style scoped></style>

View file

@ -8,7 +8,7 @@ import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { QTableColumn } from "quasar";
import type {
RequestItemsObject,
DisciplineOps,
@ -16,7 +16,7 @@ import type {
} from "@/modules/04_registryPerson/interface/index/discipline";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/02_DisciplineHistory.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
const route = useRoute();
const $q = useQuasar();
@ -30,6 +30,7 @@ const {
success,
pathRegistryEmp,
onSearchDataTable,
convertDateToAPI,
} = mixin;
const profileId = ref<string>(
@ -53,20 +54,16 @@ const disciplineData = reactive<RequestItemsObject>({
refCommandDate: null, // ()
});
const rows = ref<RequestItemsObject[]>([]); //
const rowsMain = ref<RequestItemsObject[]>([]); //
const mode = ref<string>("table"); // Table card
const filterKeyword = ref<string>(""); //
const columns = ref<QTableProps["columns"]>([
const baseColumns = ref<QTableColumn[]>([
{
name: "date",
align: "left",
label: "วัน เดือน ปี",
sortable: true,
field: "date",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -95,7 +92,7 @@ const columns = ref<QTableProps["columns"]>([
{
name: "unStigma",
align: "left",
label: "ประเภทคำสั่ง",
label: "ล้างมลทิน",
sortable: true,
field: "unStigma",
headerStyle: "font-size: 14px",
@ -119,8 +116,19 @@ const columns = ref<QTableProps["columns"]>([
align: "left",
label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true,
field: "refCommandDate",
format: (v) => date2Thai(v),
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -139,15 +147,28 @@ const columns = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
const baseVisibleColumns = ref<string[]>([
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"date",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const rows = ref<RequestItemsObject[]>([]); //
const rowsMain = ref<RequestItemsObject[]>([]); //
const mode = ref<string>("table"); // Table card
const filterKeyword = ref<string>(""); //
const columns = ref<QTableColumn[]>(
baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName")
);
const visibleColumns = ref<String[]>(
baseVisibleColumns.value.filter((e: string) => e !== "lastUpdateFullName")
);
const pagination = ref({
sortBy: "lastUpdatedAt",
});
@ -157,6 +178,9 @@ const modal = ref<boolean>(false); //แสดงข้อมูลวินั
const modalHistory = ref<boolean>(false); //
const id = ref<string>(""); //id
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
const visibleColumnsHistory = ref<string[]>(baseVisibleColumns.value);
const Ops = ref<DisciplineOps>({
levelOptions: [
{ id: "0", name: "ไม่ร้ายแรง", disable: true },
@ -267,62 +291,6 @@ async function fetchData(id: string) {
});
}
/** funciton เพิ่มช้อมูลวินัย*/
function addData() {
showLoader();
const body = {
date: disciplineData.date,
level: disciplineData.level,
detail: disciplineData.detail,
unStigma: disciplineData.unStigma,
refCommandNo: disciplineData.refCommandNo,
profileId: empType.value === "" ? disciplineData.profileId : undefined,
profileEmployeeId:
empType.value !== "" ? disciplineData.profileId : undefined,
refCommandDate: disciplineData.refCommandDate,
};
http
.post(config.API.profileNewDiscipline(empType.value), body)
.then(async () => {
await fetchData(profileId.value);
await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* funciton นทกแกไขชอมลว
* @param idData id องการแกไข
*/
function editData(idData: string) {
showLoader();
http
.patch(
config.API.profileNewDisciplineByDisciplineId(idData, empType.value),
{
...disciplineData,
profileId: undefined,
}
)
.then(async () => {
await fetchData(profileId.value);
await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* กดเลอกขอมลทจะแกไข
* @param props props ใน row เลอก
@ -339,6 +307,52 @@ function openDialogEdit(props: RequestItemsObject) {
disciplineData.refCommandDate = props.refCommandDate;
}
/** function ยืนยันการบันทึกข้อมูล*/
function onSubmit() {
dialogConfirm(
$q,
async () => {
showLoader();
const url = edit.value
? config.API.profileNewDisciplineByDisciplineId(id.value, empType.value)
: config.API.profileNewDiscipline(empType.value);
const method = edit.value ? http.patch : http.post;
const body = {
...disciplineData,
date: convertDateToAPI(disciplineData.date),
refCommandDate: convertDateToAPI(disciplineData.refCommandDate),
profileId: edit.value
? undefined
: empType.value === ""
? disciplineData.profileId
: undefined,
profileEmployeeId: edit.value
? undefined
: empType.value !== ""
? disciplineData.profileId
: undefined,
};
await method(url, body)
.then(async () => {
await fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
/**
* function ประวการแไขรายการว
* @param idOrder
@ -348,16 +362,21 @@ function openDialogHistory(idOrder: string) {
id.value = idOrder;
}
/** function ยืนยันการบันทึกข้อมูล*/
function onSubmit() {
dialogConfirm(
$q,
() => {
edit.value ? editData(id.value) : addData();
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
/** fetch ข้อมูลประวัติการแก่ไขข้อมูลวินัย*/
async function fetchDataHistory() {
showLoader();
try {
const res = await http.get(
config.API.profileNewDisciplineHisByDisciplineId(id.value, empType.value)
);
const data = res.data.result;
return data;
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
/** ฟังก์ค้นหาข้อมูลรายการวินัย */
@ -374,6 +393,7 @@ onMounted(() => {
fetchData(profileId.value);
});
</script>
<template>
<div class="row items-center q-gutter-x-sm q-pb-sm">
<q-btn
@ -745,7 +765,13 @@ onMounted(() => {
</q-card>
</q-dialog>
<DialogHistory v-model:modal="modalHistory" v-model:id="id" />
<DialogHistory
v-model:modal="modalHistory"
:title="`ประวัติแก้ไขวินัย`"
:columns="columnsHistory"
:visible-columns="visibleColumnsHistory"
:fetch-data="fetchDataHistory"
/>
</template>
<style scoped></style>

View file

@ -1,271 +0,0 @@
<script setup lang="ts">
import { ref, watch, reactive } from "vue";
import { useQuasar, type QTableProps } from "quasar";
import { useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import type { RequestItemsObject } from "@/modules/04_registryPerson/interface/index/discipline";
import DialogHeader from "@/components/DialogHeader.vue";
const $q = useQuasar();
const route = useRoute();
const mixin = useCounterMixin();
const {
showLoader,
hideLoader,
messageError,
date2Thai,
pathRegistryEmp,
onSearchDataTable,
} = mixin;
/**
* props
*/
const modal = defineModel<boolean>("modal", { required: true }); //
const id = defineModel<string>("id", { required: true }); //id
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const filterKeyword = ref<string>(""); //
const rows = ref<RequestItemsObject[]>([]); //
const rowsMain = ref<RequestItemsObject[]>([]); //
const columns = ref<QTableProps["columns"]>([
{
name: "date",
align: "left",
label: "วัน เดือน ปี",
sortable: true,
field: "date",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "detail",
align: "left",
label: "รายละเอียด",
sortable: true,
field: "detail",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "level",
align: "left",
label: "ระดับการลงโทษทางวินัย",
sortable: true,
field: "level",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "unStigma",
align: "left",
label: "ล้างมลทิน",
sortable: true,
field: "unStigma",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "refCommandNo",
align: "left",
label: "เลขที่คำสั่ง",
sortable: true,
field: "refCommandNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "refCommandDate",
align: "left",
label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true,
format: (v) => date2Thai(v),
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
format: (v) => date2Thai(v, false, true),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"date",
"createdFullName",
"createdAt",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const pagination = ref({
sortBy: "lastUpdatedAt",
});
/** fetch ข้อมูลประวัติการแก่ไขข้อมูลวินัย*/
async function getHistory() {
showLoader();
await http
.get(
config.API.profileNewDisciplineHisByDisciplineId(id.value, empType.value)
)
.then(async (res) => {
let data = await res.data.result;
rows.value = [];
data.map((e: RequestItemsObject) => {
rows.value.push({
...e,
id: e.id,
level: e.level,
detail: e.detail,
unStigma: e.unStigma,
refCommandNo: e.refCommandNo,
refCommandDate:
e.refCommandDate == null ? null : new Date(e.refCommandDate),
});
});
rowsMain.value = rows.value;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/** ฟังก์ค้นหาข้อมูลรายการวินัย */
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
/**
* การเปลยนแปลงของ modal
* modal เป true เรยก getHistory เพอดงขอมลประวการแกไขว
*/
watch(modal, (status) => {
if (status == true) {
getHistory();
filterKeyword.value = "";
} else {
filterKeyword.value = "";
}
});
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 80%">
<DialogHeader
tittle="ประวัติแก้ไขวินัย"
:close="() => ((modal = false), (rows = []))"
/>
<q-separator color="grey-4" />
<q-card-section style="max-height: 60vh" class="scroll">
<div class="row q-gutter-sm q-mb-sm">
<q-space />
<q-input
standout
dense
v-model="filterKeyword"
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-card>
</q-dialog>
</template>

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar, type QTableProps } from "quasar";
import { useQuasar, type QTableColumn } from "quasar";
import { useRoute } from "vue-router";
import { checkPermission } from "@/utils/permissions";
@ -12,7 +12,6 @@ import type {
DetailData,
DataOptionLeave,
DataOption,
ResponseTotalObject,
} from "@/modules/04_registryPerson/interface/index/leave";
import type {
DataLeave,
@ -20,7 +19,7 @@ import type {
} from "@/modules/04_registryPerson/interface/response/Main";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/03_LeaveHistory.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
/**props*/
const isLeave = defineModel<boolean>("isLeave", {
@ -46,7 +45,6 @@ const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const rowsTotal = ref<ResponseTotalObject[]>([]);
const id = ref<string>("");
const mode = ref<string>("table");
@ -77,10 +75,7 @@ const statLeaveOptionFilter = ref<DataOption[]>([
{ id: "waitting", name: "รออนุมัติ" },
]);
//Table
const rows = ref<DetailData[]>([]);
const rowsMain = ref<DetailData[]>([]);
const columns = ref<QTableProps["columns"]>([
const baseColumns = ref<QTableColumn[]>([
{
name: "no",
align: "left",
@ -109,10 +104,10 @@ const columns = ref<QTableProps["columns"]>([
label: "วัน เดือน ปี ที่ลา",
sortable: true,
field: "dateLeave",
format(val, row) {
return dateThaiRange([row.dateStartLeave, row.dateEndLeave]);
},
headerStyle: "font-size: 14px",
format(val, row) {
return dateThaiRange([row.dateStartLeave, row.dateEndLeave]) || "";
},
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
@ -136,11 +131,11 @@ const columns = ref<QTableProps["columns"]>([
label: "สถานะ",
sortable: true,
field: "status",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
return statusLeave(val);
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -155,6 +150,17 @@ const columns = ref<QTableProps["columns"]>([
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
@ -168,43 +174,59 @@ const columns = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
const baseVisibleColumns = ref<string[]>([
"no",
"typeLeave",
"dateLeave",
"numLeave",
"status",
"reason",
"lastUpdateFullName",
"lastUpdatedAt",
]);
//Table
const rows = ref<DetailData[]>([]);
const rowsMain = ref<DetailData[]>([]);
const columns = ref<QTableColumn[]>(
baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName")
);
const visibleColumns = ref<String[]>(
baseVisibleColumns.value.filter((e: string) => e !== "lastUpdateFullName")
);
const pagination = ref({
sortBy: "lastUpdatedAt",
});
const statusLeave = (val: string) => {
switch (val) {
case "waitting":
return "รออนุมัติ";
case "reject":
return "ไม่ผ่านการอนุมัติ";
case "approve":
return "ผ่านการอนุมัติ";
case "cancel":
return "ยกเลิก";
default:
return "-";
}
};
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
const visibleColumnsHistory = ref<string[]>(baseVisibleColumns.value);
const clickEditRowType = () => {
const filter = typeLeaveOptionFilter.value.filter(
(v: DataOptionLeave) => v.id == typeLeave.value?.id
);
if (filter.length > 0) {
numUsedLeave.value = filter[0].totalLeave;
}
};
/** function fetch ข้อมูลรายการลา*/
async function getData() {
showLoader();
await http
.get(config.API.profileNewLeaveById(profileId.value, empType.value))
.then(async (res) => {
const data = await res.data.result;
rows.value = data.map((item: DataLeave) => ({
...item,
id: item.id,
typeLeave: item.leaveType.name,
code: item.leaveType.refCommandDate,
dateStartLeave: item.dateLeaveStart,
dateEndLeave: item.dateLeaveEnd,
numLeave: item.leaveDays,
typeLeaveId: item.leaveTypeId,
}));
rowsMain.value = rows.value;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/** function เปิด dialog ข้อมูลการลา*/
function openDialogAdd() {
@ -235,8 +257,7 @@ function openDialogAdd() {
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
function clickTotal() {
rowsTotal.value = [];
function fetchTypeLeave() {
showLoader();
http
.get(config.API.profileNewLeaveType())
@ -277,32 +298,53 @@ function openDialogEdit(props: DetailData) {
new Date(props.dateEndLeave as Date),
];
numLeave.value = props.numLeave;
clickTotal();
if (rowsTotal.value.length > 0) {
let data: DataOptionLeave[] = [];
rowsTotal.value.map((e: ResponseTotalObject) => {
data.push({
id: e.typeLeaveId,
name: e.typeLeave,
totalLeave: e.totalLeave,
});
});
typeLeaveOption.value = data;
typeLeaveOptionFilter.value = data;
}
fetchTypeLeave();
}
/** ปิด dialog ข้อมูลการลา*/
function closeDialog() {
modal.value = false;
edit.value = false;
id.value = "";
typeLeave.value = null;
statLeave.value = "";
reason.value = "";
dateRange.value = [new Date(), new Date()];
numLeave.value = 1;
numUsedLeave.value = 0;
/** function ยืนยันการบันทึกข้อมูล*/
function onSubmit() {
dialogConfirm($q, async () => {
showLoader();
const url = edit.value
? config.API.profileNewLeaveById(id.value, empType.value)
: config.API.profileNewLeave(empType.value);
const methods = edit.value ? http.patch : http.post;
const body = {
leaveTypeId: typeLeave.value?.id,
dateLeaveStart: dateToISO(dateRange.value[0]),
dateLeaveEnd: dateToISO(dateRange.value[1]),
leaveDays: numLeave.value,
leaveCount: 0,
totalLeave: 0,
status: statLeave.value,
reason: reason.value,
profileId: edit.value
? undefined
: empType.value === ""
? profileId.value
: undefined,
profileEmployeeId: edit.value
? undefined
: empType.value !== ""
? profileId.value
: undefined,
};
await methods(url, body)
.then(async () => {
await getData();
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
}
/**
@ -356,98 +398,34 @@ function openDialogHistory(idOrder: string) {
id.value = idOrder;
}
/** function ยืนยันการบันทึกข้อมูล*/
function onSubmit() {
dialogConfirm($q, async () => {
if (edit.value == false) {
saveData();
} else {
editData();
}
});
}
/** บันทึกเพิ่มข้อมูล*/
function saveData() {
async function fetchDataHistory() {
showLoader();
http
.post(config.API.profileNewLeave(empType.value), {
leaveTypeId: typeLeave.value?.id,
dateLeaveStart: dateToISO(dateRange.value[0]),
dateLeaveEnd: dateToISO(dateRange.value[1]),
leaveDays: numLeave.value,
leaveCount: 0,
totalLeave: 0,
status: statLeave.value,
reason: reason.value,
profileId: empType.value === "" ? profileId.value : undefined,
profileEmployeeId: empType.value !== "" ? profileId.value : undefined,
})
.then(async () => {
await getData();
await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
try {
const res = await http.get(
config.API.profileNewLeaveHistory(id.value, empType.value)
);
/** บันทึกแก้ไขข้อมูล*/
async function editData() {
showLoader();
http
.patch(config.API.profileNewLeaveById(id.value, empType.value), {
leaveTypeId: typeLeave.value?.id,
dateLeaveStart: dateToISO(dateRange.value[0]),
dateLeaveEnd: dateToISO(dateRange.value[1]),
leaveDays: numLeave.value,
leaveCount: 0,
totalLeave: 0,
status: statLeave.value,
reason: reason.value,
})
.then(async () => {
await getData();
await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/** function fetch ข้อมูลรายการลา*/
async function getData() {
showLoader();
await http
.get(config.API.profileNewLeaveById(profileId.value, empType.value))
.then(async (res) => {
const data = await res.data.result;
rows.value = data.map((item: DataLeave) => ({
...item,
id: item.id,
typeLeave: item.leaveType.name,
code: item.leaveType.refCommandDate,
dateStartLeave: item.dateLeaveStart,
dateEndLeave: item.dateLeaveEnd,
numLeave: item.leaveDays,
typeLeaveId: item.leaveTypeId,
}));
rowsMain.value = rows.value;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
const data = res.data.result.map((e: DataLeave) => ({
...e,
id: e.id,
typeLeave: e.leaveType.name,
code: e.leaveType.refCommandDate,
dateStartLeave: e.dateLeaveStart,
dateEndLeave: e.dateLeaveEnd,
numLeave: e.leaveDays,
status: e.status,
reason: e.reason,
typeLeaveId:
e.typeLeaveId !== "00000000-0000-0000-0000-000000000000"
? e.typeLeaveId
: "",
}));
return data;
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
/** ฟังก์ค้นหาข้อมูลรายการวินัย */
@ -459,13 +437,49 @@ function serchDataTable() {
);
}
/**
* ทำงานเม Components กเรยกใชงาน
*/
/** ปิด dialog ข้อมูลการลา*/
function closeDialog() {
modal.value = false;
edit.value = false;
id.value = "";
typeLeave.value = null;
statLeave.value = "";
reason.value = "";
dateRange.value = [new Date(), new Date()];
numLeave.value = 1;
numUsedLeave.value = 0;
}
function statusLeave(val: string) {
switch (val) {
case "waitting":
return "รออนุมัติ";
case "reject":
return "ไม่ผ่านการอนุมัติ";
case "approve":
return "ผ่านการอนุมัติ";
case "cancel":
return "ยกเลิก";
default:
return "-";
}
}
function clickEditRowType() {
const filter = typeLeaveOptionFilter.value.filter(
(v: DataOptionLeave) => v.id == typeLeave.value?.id
);
if (filter.length > 0) {
numUsedLeave.value = filter[0].totalLeave;
}
}
/** ทำงานเมื่อ Components ถูกเรียกใช้งาน*/
onMounted(() => {
getData();
});
</script>
<template>
<div class="row items-center q-gutter-x-sm q-pb-sm">
<q-btn
@ -805,7 +819,13 @@ onMounted(() => {
</q-card>
</q-dialog>
<DialogHistory v-model:modal="modalHistory" v-model:id="id" />
<DialogHistory
v-model:modal="modalHistory"
:title="`ประวัติแก้ไขการลา`"
:columns="columnsHistory"
:visible-columns="visibleColumnsHistory"
:fetch-data="fetchDataHistory"
/>
</template>
<style scoped></style>

View file

@ -1,334 +0,0 @@
<script setup lang="ts">
import { ref, watch, reactive } from "vue";
import { useQuasar, type QTableProps } from "quasar";
import { useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import type {
DetailData,
FormFilter,
} from "@/modules/04_registryPerson/interface/index/leave";
import type { DataLeave } from "@/modules/04_registryPerson/interface/response/Main";
import DialogHeader from "@/components/DialogHeader.vue";
const modal = defineModel<boolean>("modal", { required: true });
const id = defineModel<string>("id", { required: true });
const $q = useQuasar();
const route = useRoute();
const mixin = useCounterMixin();
const {
showLoader,
hideLoader,
messageError,
date2Thai,
pathRegistryEmp,
onSearchDataTable,
} = mixin;
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const filterKeyword = ref<string>("");
const rows = ref<DetailData[]>([]); //data history
const rowsMain = ref<DetailData[]>([]); //data history
const formFilter = reactive<FormFilter>({
page: 1,
pageSize: 12,
keyword: "",
type: "",
posType: "",
posLevel: "",
retireYear: "",
rangeYear: { min: 0, max: 60 },
isShowRetire: false,
isProbation: false,
});
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: false,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "typeLeave",
align: "left",
label: "ประเภทการลา",
sortable: true,
field: "typeLeave",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "dateLeave",
align: "left",
label: "วัน เดือน ปี ที่ลา",
sortable: true,
field: "dateLeave",
headerStyle: "font-size: 14px",
format(val, row) {
return dateThaiRange([row.dateStartLeave, row.dateEndLeave]);
},
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "numLeave",
align: "left",
label: "จำนวนวันลา",
sortable: true,
field: "numLeave",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "status",
align: "left",
label: "สถานะ",
sortable: true,
field: "status",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
return statusLeave(val);
},
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "reason",
align: "left",
label: "เหตุผล",
sortable: true,
field: "reason",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
format: (v) => date2Thai(v, false, true),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
"no",
"typeLeave",
"dateLeave",
"numLeave",
"sumLeave",
"totalLeave",
"status",
"reason",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const historyPagination = ref({
sortBy: "lastUpdatedAt",
});
/** function fetch ข้อมูลประวัติการแก้ไขการลา */
async function getHistory() {
showLoader();
await http
.get(config.API.profileNewLeaveHistory(id.value, empType.value))
.then(async (res) => {
let data = await res.data.result;
rows.value = [];
data.map((e: DataLeave) => {
rows.value.push({
...e,
id: e.id,
typeLeave: e.leaveType.name,
code: e.leaveType.refCommandDate,
dateStartLeave: e.dateLeaveStart,
dateEndLeave: e.dateLeaveEnd,
numLeave: e.leaveDays,
status: e.status,
reason: e.reason,
typeLeaveId:
e.typeLeaveId !== "00000000-0000-0000-0000-000000000000"
? e.typeLeaveId
: "",
});
});
rowsMain.value = rows.value;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* แปลงชวงวนทา2คาเปนวนเดยวกนจะโชววนเดยวแตาไมเทากนจะแสดงเปนชวง
* @param val วงวนท
*/
function dateThaiRange(val: [Date, Date]) {
if (val === null) {
} else if (date2Thai(val[0]) === date2Thai(val[1])) {
return `${date2Thai(val[0])}`;
} else {
return `${date2Thai(val[0])} - ${date2Thai(val[1])} `;
}
}
/**
* function convertStatus
* @param val
*/
function statusLeave(val: string) {
switch (val) {
case "waitting":
return "รออนุมัติ";
case "reject":
return "ไม่ผ่านการอนุมัติ";
case "approve":
return "ผ่านการอนุมัติ";
case "cancel":
return "ยกเลิก";
default:
return "-";
}
}
/** ฟังก์ค้นหาข้อมูลรายการประวัติแก้ไขการลา */
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
/**
* การเปลยนแปลงของ modal
* modal เป true เรยก getHistory เพอดงขอมลประวการแกไข
*/
watch(modal, (status) => {
if (status == true) {
getHistory();
filterKeyword.value = "";
} else {
filterKeyword.value = "";
}
});
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 80%">
<DialogHeader
tittle="ประวัติแก้ไขการลา"
:close="() => ((modal = false), (rows = []))"
/>
<q-separator color="grey-4" />
<q-card-section style="max-height: 60vh" class="scroll">
<div class="row q-gutter-sm q-mb-sm">
<q-space />
<q-input
standout
dense
v-model="filterKeyword"
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"
v-model:pagination="historyPagination"
:visible-columns="visibleColumns"
>
>
<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 v-if="col.name === 'no'">
{{
(formFilter.page - 1) * formFilter.pageSize +
props.rowIndex +
1
}}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</q-card-section>
</q-card>
</q-dialog>
</template>

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import { useQuasar, type QTableProps } from "quasar";
import { useQuasar, type QTableColumn } from "quasar";
import axios from "axios";
import { useRoute } from "vue-router";
@ -13,7 +13,9 @@ import type { RequestItemsObject } from "@/modules/04_registryPerson/interface/i
import type { ResFileData } from "@/modules/04_registryPerson/interface/index/Main";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/04_PerformSpecialWorkHistory.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
// import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/04_PerformSpecialWorkHistory.vue";
const route = useRoute();
@ -28,6 +30,7 @@ const {
success,
pathRegistryEmp,
onSearchDataTable,
convertDateToAPI,
} = mixin;
const profileId = ref<string>(
@ -61,11 +64,7 @@ const dutyData = reactive<RequestItemsObject>({
isUpload: false,
});
const mode = ref<string>("table"); // Table card
const filterKeyword = ref<string>(""); //
const rows = ref<RequestItemsObject[]>([]); //
const rowsMain = ref<RequestItemsObject[]>([]); //
const columns = ref<QTableProps["columns"]>([
const baseColumns = ref<QTableColumn[]>([
{
name: "dateStart",
align: "left",
@ -136,31 +135,90 @@ const columns = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
name: "lastUpdateFullName",
align: "left",
label: "วันที่แก้ไข",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdatedAt",
format: (v) => date2Thai(v, false, true),
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v, false, true),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
const baseVisibleColumns = ref<string[]>([
"dateStart",
"dateEnd",
"detail",
"reference",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const mode = ref<string>("table"); // Table card
const filterKeyword = ref<string>(""); //
const rows = ref<RequestItemsObject[]>([]); //
const rowsMain = ref<RequestItemsObject[]>([]); //
const columns = ref<QTableColumn[]>(
baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName")
);
const visibleColumns = ref<String[]>(
baseVisibleColumns.value.filter((e: string) => e !== "lastUpdateFullName")
);
const pagination = ref({
sortBy: "lastUpdatedAt",
});
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
const visibleColumnsHistory = ref<string[]>(baseVisibleColumns.value);
/** fetch ข้อมูลรายการพิเศษ*/
async function fetchData(id: string) {
showLoader();
await http
.get(config.API.profileNewDutyByProfileId(id, empType.value))
.then(async (res) => {
rows.value = await res.data.result;
rowsMain.value = await res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** function fetch ข้อมูลประวติการแก้ไขข้อมูล*/
async function fetchDataHistory() {
showLoader();
try {
const res = await http.get(
config.API.profileNewDutyHisByDutyId(id.value, empType.value)
);
const data = res.data.result;
return data;
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
/** เปิด dialog */
function openDialogAdd() {
modal.value = true;
@ -205,27 +263,21 @@ function closeDialog() {
dutyData.refCommandNo = "";
dutyData.refCommandDate = null;
fileUpload.value = null;
fileUpload.value = null;
isUpload.value = false;
fileData.value = null;
}
/** fetch ข้อมูลรายการพิเศษ*/
async function fetchData(id: string) {
showLoader();
await http
.get(config.API.profileNewDutyByProfileId(id, empType.value))
.then(async (res) => {
rows.value = await res.data.result;
rowsMain.value = await res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
/** ยืนยันการบันทึกข้อมูล*/
function onSubmit() {
dialogConfirm(
$q,
() => {
edit.value ? editData(id.value) : addData();
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
/** functoin บันทึกการเพิ่มข้อมูล*/
@ -234,12 +286,12 @@ function addData() {
const body = {
profileId: empType.value === "" ? profileId.value : undefined,
profileEmployeeId: empType.value !== "" ? profileId.value : undefined,
dateStart: dutyData.dateStart,
dateEnd: dutyData.dateEnd,
dateStart: convertDateToAPI(dutyData.dateStart),
dateEnd: convertDateToAPI(dutyData.dateEnd),
detail: dutyData.detail,
reference: dutyData.reference,
refCommandNo: dutyData.refCommandNo,
refCommandDate: dutyData.refCommandDate,
refCommandDate: convertDateToAPI(dutyData.refCommandDate),
};
http
.post(config.API.profileNewDuty(empType.value), body)
@ -265,10 +317,13 @@ function editData(idData: string) {
http
.patch(config.API.profileNewDutyByDutyId(idData, empType.value), {
...dutyData,
dateStart: convertDateToAPI(dutyData.dateStart),
dateEnd: convertDateToAPI(dutyData.dateEnd),
refCommandDate: convertDateToAPI(dutyData.refCommandDate),
profileId: undefined,
isUpload: !edit.value ? undefined : isUpload.value,
})
.then(async (res) => {
.then(async () => {
if (fileUpload.value && idData) {
await uploadProfile(idData);
}
@ -384,18 +439,6 @@ async function onDownloadFile(id: string, isLoad: boolean = true) {
});
}
/** ยืนยันการบันทึกข้อมูล*/
function onSubmit() {
dialogConfirm(
$q,
() => {
edit.value ? editData(id.value) : addData();
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
@ -917,7 +960,13 @@ onMounted(() => {
</q-card>
</q-dialog>
<DialogHistory v-model:modal="modalHistory" v-model:id="id" />
<DialogHistory
v-model:modal="modalHistory"
:title="`ประวัติแก้ไขปฏิบัติราชการพิเศษ`"
:columns="columnsHistory"
:visible-columns="visibleColumnsHistory"
:fetch-data="fetchDataHistory"
/>
</template>
<style scoped></style>

View file

@ -1,266 +0,0 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import DialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar, type QTableProps } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type { ResponseObject } from "@/modules/04_registryPerson/interface/index/performSpecialWork";
import { useRoute } from "vue-router";
const modal = defineModel<boolean>("modal", { required: true });
const id = defineModel<string>("id", { required: true });
const route = useRoute();
const $q = useQuasar();
const mixin = useCounterMixin();
const {
showLoader,
hideLoader,
messageError,
date2Thai,
pathRegistryEmp,
onSearchDataTable,
} = mixin;
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const filterKeyword = ref<string>(""); //
const rows = ref<ResponseObject[]>([]); //data history
const rowsMain = ref<ResponseObject[]>([]); //data history
const columns = ref<QTableProps["columns"]>([
{
name: "dateStart",
align: "left",
label: "เริ่มต้น",
sortable: true,
field: "dateStart",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "dateEnd",
align: "left",
label: "สิ้นสุด",
sortable: true,
field: "dateEnd",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "reference",
align: "left",
label: "เอกสารอ้างอิง",
sortable: true,
field: "reference",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "detail",
align: "left",
label: "รายละเอียด",
sortable: true,
field: "detail",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "refCommandNo",
align: "left",
label: "เลขที่คำสั่ง",
sortable: true,
field: "refCommandNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "refCommandDate",
align: "left",
label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true,
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v, false, true),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
"dateStart",
"dateEnd",
"detail",
"reference",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const historyPagination = ref({
sortBy: "lastUpdatedAt",
});
/** function fetch ข้อมูลประวติการแก้ไขข้อมูล*/
function getHistory() {
showLoader();
http
.get(config.API.profileNewDutyHisByDutyId(id.value, empType.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: ResponseObject) => {
rows.value.push({
id: e.id,
dateStart: new Date(e.dateStart),
dateEnd: new Date(e.dateEnd),
detail: e.detail,
reference: e.reference,
refCommandNo: e.refCommandNo,
refCommandDate:
e.refCommandDate == null ? null : new Date(e.refCommandDate),
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
lastUpdateFullName: e.lastUpdateFullName,
lastUpdatedAt: e.lastUpdatedAt,
});
});
rowsMain.value = rows.value;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
/**
* การเปลยนแปลงของ modal
* modal เป true เรยก getHistory เพอดงขอมลประวการแกไข
*/
watch(modal, (status) => {
if (status == true) {
getHistory();
filterKeyword.value = "";
} else {
filterKeyword.value = "";
}
});
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 80%">
<DialogHeader
tittle="ประวัติแก้ไขปฏิบัติราชการพิเศษ"
:close="() => ((modal = false), (rows = []))"
/>
<q-separator />
<q-card-section style="max-height: 60vh" class="scroll">
<div class="row q-gutter-sm q-mb-sm">
<q-space />
<q-input
standout
dense
v-model="filterKeyword"
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"
v-model:pagination="historyPagination"
:visible-columns="visibleColumns"
>
>
<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 class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</q-card-section>
</q-card>
</q-dialog>
</template>

View file

@ -8,12 +8,12 @@ import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { QTableColumn } from "quasar";
import type { DataActing } from "@/modules/04_registryPerson/interface/request/Government";
import type { ResActingPosData } from "@/modules/04_registryPerson/interface/response/Government";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPosHistory.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
import DialogPreviewCommand from "@/modules/18_command/components/DialogPreviewCommand.vue";
const route = useRoute();
@ -28,6 +28,7 @@ const {
success,
pathRegistryEmp,
onSearchDataTable,
convertDateToAPI,
} = mixin;
const profileId = ref<string>(
@ -40,12 +41,7 @@ const isLeave = defineModel<boolean>("isLeave", {
required: true,
});
/** Table*/
const rows = ref<ResActingPosData[]>([]); //
const rowsMain = ref<ResActingPosData[]>([]); //
const mode = ref<string>("table"); // Table card
const filterKeyword = ref<string>(""); //
const columns = ref<QTableProps["columns"]>([
const baseColumns = ref<QTableColumn[]>([
{
name: "dateStart",
align: "left",
@ -119,7 +115,17 @@ const columns = ref<QTableProps["columns"]>([
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
@ -133,19 +139,35 @@ const columns = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
const baseVisibleColumns = ref<string[]>([
"dateStart",
"dateEnd",
"posNo",
"position",
"refCommandNo",
"status",
"lastUpdateFullName",
"lastUpdatedAt",
]);
/** Table*/
const rows = ref<ResActingPosData[]>([]); //
const rowsMain = ref<ResActingPosData[]>([]); //
const mode = ref<string>("table"); // Table card
const filterKeyword = ref<string>(""); //
const columns = ref<QTableColumn[]>(
baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName")
);
const visibleColumns = ref<String[]>(
baseVisibleColumns.value.filter((e: string) => e !== "lastUpdateFullName")
);
const pagination = ref({
sortBy: "lastUpdatedAt",
});
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
const visibleColumnsHistory = ref<string[]>(baseVisibleColumns.value);
/** Dialog*/
const isStatusEdit = ref<boolean>(false);
const modal = ref<boolean>(false);
@ -164,15 +186,6 @@ const formData = reactive<DataActing>({
status: false,
});
/** ฟังก์ค้นหาข้อมูลรายการ */
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
async function fetchData() {
showLoader();
await http
@ -190,11 +203,28 @@ async function fetchData() {
});
}
/** function fetch ข้อมูลประวติการแก้ไขข้อมูล*/
async function fetchDataHistory() {
showLoader();
try {
const res = await http.get(
config.API.profileActpositionHistory(rowId.value, empType.value)
);
return res.data.result;
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
function onSubmit() {
dialogConfirm($q, async () => {
showLoader();
const body = {
...formData,
dateStart: convertDateToAPI(formData.dateStart),
dateEnd: convertDateToAPI(formData.dateEnd),
profileId: isStatusEdit.value ? undefined : profileId.value,
};
const method = isStatusEdit.value ? "patch" : "post";
@ -252,6 +282,15 @@ function closeDialogForm() {
formData.status = false;
}
/** ฟังก์ค้นหาข้อมูลรายการ */
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
onMounted(() => {
fetchData();
});
@ -618,7 +657,14 @@ onMounted(() => {
</q-card>
</q-dialog>
<DialogHistory v-model:modal="modalHistory" v-model:id="rowId" />
<!-- <DialogHistory v-model:modal="modalHistory" v-model:id="rowId" /> -->
<DialogHistory
v-model:modal="modalHistory"
:title="`ประวัติแก้ไขรักษาการในตำแหน่ง`"
:columns="columnsHistory"
:visible-columns="visibleColumnsHistory"
:fetch-data="fetchDataHistory"
/>
<DialogPreviewCommand
v-model:modal="modalCommand"

View file

@ -1,242 +0,0 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import DialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar, type QTableProps } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type { ResponseObject } from "@/modules/04_registryPerson/interface/index/performSpecialWork";
import { useRoute } from "vue-router";
const modal = defineModel<boolean>("modal", { required: true });
const id = defineModel<string>("id", { required: true });
const route = useRoute();
const $q = useQuasar();
const mixin = useCounterMixin();
const {
showLoader,
hideLoader,
messageError,
date2Thai,
pathRegistryEmp,
onSearchDataTable,
} = mixin;
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const filterKeyword = ref<string>(""); //
const rows = ref<ResponseObject[]>([]); //data history
const rowsMain = ref<ResponseObject[]>([]); //data history
const columns = ref<QTableProps["columns"]>([
{
name: "dateStart",
align: "left",
label: "วันที่เริ่มต้น",
sortable: true,
field: "dateStart",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "dateEnd",
align: "left",
label: "วันที่สิ้นสุด",
sortable: true,
field: "dateEnd",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "posNo",
align: "left",
label: "ตำแหน่งเลขที่",
sortable: true,
field: "posNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "position",
align: "left",
label: "ตำแหน่ง",
sortable: true,
field: "position",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "status",
align: "left",
label: "สถานะ",
sortable: true,
field: "status",
format(val, row) {
return row.status ? "ใช้งาน" : "-";
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v, false, true),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
"dateStart",
"dateEnd",
"posNo",
"position",
"status",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const historyPagination = ref({
sortBy: "lastUpdatedAt",
});
/** function fetch ข้อมูลประวติการแก้ไขข้อมูล*/
function fetchDataHistory() {
showLoader();
http
.get(config.API.profileActpositionHistory(id.value, empType.value))
.then((res) => {
let data = res.data.result;
rows.value = data;
rowsMain.value = data;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
/**
* การเปลยนแปลงของ modal
* modal เป true เรยก fetchDataHistory เพอดงขอมลประวการแกไข
*/
watch(modal, (status) => {
if (status == true) {
fetchDataHistory();
filterKeyword.value = "";
} else {
filterKeyword.value = "";
rows.value = [];
rowsMain.value = [];
}
});
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 80%">
<DialogHeader
tittle="ประวัติแก้ไขรักษาการในตำแหน่ง"
:close="() => ((modal = false), (rows = []))"
/>
<q-separator />
<q-card-section style="max-height: 60vh" class="scroll">
<div class="row q-gutter-sm q-mb-sm">
<q-space />
<q-input
standout
dense
v-model="filterKeyword"
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"
v-model:pagination="historyPagination"
:visible-columns="visibleColumns"
>
>
<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 class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</q-card-section>
</q-card>
</q-dialog>
</template>

View file

@ -9,7 +9,7 @@ import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { QTableColumn } from "quasar";
import type { DatAssistance } from "@/modules/04_registryPerson/interface/request/Government";
import type {
ResAssistanceData,
@ -17,7 +17,7 @@ import type {
} from "@/modules/04_registryPerson/interface/response/Government";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernmentHistory.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
import DialogPreviewCommand from "@/modules/18_command/components/DialogPreviewCommand.vue";
const route = useRoute();
@ -32,6 +32,7 @@ const {
success,
pathRegistryEmp,
onSearchDataTable,
convertDateToAPI,
} = mixin;
const profileId = ref<string>(
@ -44,12 +45,7 @@ const isLeave = defineModel<boolean>("isLeave", {
required: true,
});
/** Table*/
const rows = ref<ResAssistanceData[]>([]); //
const rowsMain = ref<ResAssistanceData[]>([]); //
const mode = ref<string>("table"); // Table card
const filterKeyword = ref<string>(""); //
const columns = ref<QTableProps["columns"]>([
const baseColumns = ref<QTableColumn[]>([
{
name: "agency",
align: "left",
@ -107,6 +103,17 @@ const columns = ref<QTableProps["columns"]>([
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
@ -120,15 +127,31 @@ const columns = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
const baseVisibleColumns = ref<string[]>([
"agency",
"dateStart",
"dateEnd",
"commandNo",
"document",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
const visibleColumnsHistory = ref<string[]>(baseVisibleColumns.value);
/** Table*/
const rows = ref<ResAssistanceData[]>([]); //
const rowsMain = ref<ResAssistanceData[]>([]); //
const mode = ref<string>("table"); // Table card
const filterKeyword = ref<string>(""); //
const columns = ref<QTableColumn[]>(
baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName")
);
const visibleColumns = ref<String[]>(
baseVisibleColumns.value.filter((e: string) => e !== "lastUpdateFullName")
);
const pagination = ref({
sortBy: "lastUpdatedAt",
});
@ -182,11 +205,28 @@ async function fetchData() {
});
}
/** function fetch ข้อมูลประวติการแก้ไขข้อมูล*/
async function fetchDataHistory() {
showLoader();
try {
const res = await http.get(
config.API.profileAssistanceHistory(rowId.value, empType.value)
);
return res.data.result;
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
function onSubmit() {
dialogConfirm($q, async () => {
showLoader();
const body = {
...formData,
dateStart: convertDateToAPI(formData.dateStart),
dateEnd: convertDateToAPI(formData.dateEnd),
profileId: isStatusEdit.value ? undefined : profileId.value,
isUpload: !isStatusEdit.value ? undefined : isUpload.value,
};
@ -825,7 +865,13 @@ onMounted(() => {
</q-card>
</q-dialog>
<DialogHistory v-model:modal="modalHistory" v-model:id="rowId" />
<DialogHistory
v-model:modal="modalHistory"
:title="`ประวัติแก้ไขรายการช่วยราชการ`"
:columns="columnsHistory"
:visible-columns="visibleColumnsHistory"
:fetch-data="fetchDataHistory"
/>
<DialogPreviewCommand
v-model:modal="modalCommand"

View file

@ -1,239 +0,0 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import DialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar, type QTableProps } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type { ResponseObject } from "@/modules/04_registryPerson/interface/index/performSpecialWork";
import { useRoute } from "vue-router";
const modal = defineModel<boolean>("modal", { required: true });
const id = defineModel<string>("id", { required: true });
const route = useRoute();
const $q = useQuasar();
const mixin = useCounterMixin();
const {
showLoader,
hideLoader,
messageError,
date2Thai,
pathRegistryEmp,
onSearchDataTable,
} = mixin;
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const filterKeyword = ref<string>(""); //
const rows = ref<ResponseObject[]>([]); //data history
const rowsMain = ref<ResponseObject[]>([]); //data history
const columns = ref<QTableProps["columns"]>([
{
name: "agency",
align: "left",
label: "หน่วยงานที่ให้ช่วยราชการ",
sortable: true,
field: "agency",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "dateStart",
align: "left",
label: "วันเริ่มช่วยราชการ",
sortable: true,
field: "dateStart",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "dateEnd",
align: "left",
label: "วันสิ้นสุดการช่วยราชการ",
sortable: true,
field: "dateEnd",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "commandNo",
align: "left",
label: "เลขที่คำสั่ง",
sortable: true,
field: "commandNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "document",
align: "left",
label: "เอกสารอ้างอิง",
sortable: true,
field: "document",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v, false, true),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([
"agency",
"dateStart",
"dateEnd",
"commandNo",
"document",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const historyPagination = ref({
sortBy: "lastUpdatedAt",
});
/** function fetch ข้อมูลประวติการแก้ไขข้อมูล*/
function fetchDataHistory() {
showLoader();
http
.get(config.API.profileAssistanceHistory(id.value, empType.value))
.then((res) => {
let data = res.data.result;
rows.value = data;
rowsMain.value = rows.value;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
/**
* การเปลยนแปลงของ modal
* modal เป true เรยก fetchDataHistory เพอดงขอมลประวการแกไข
*/
watch(modal, (status) => {
if (status == true) {
fetchDataHistory();
filterKeyword.value = "";
} else {
filterKeyword.value = "";
}
});
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 80%">
<DialogHeader
tittle="ประวัติแก้ไขรายการช่วยราชการ"
:close="() => ((modal = false), (rows = []))"
/>
<q-separator />
<q-card-section style="max-height: 60vh" class="scroll">
<div class="row q-gutter-sm q-mb-sm">
<q-space />
<q-input
standout
dense
v-model="filterKeyword"
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"
:paging="true"
v-model:pagination="historyPagination"
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
>
>
<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 class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</q-card-section>
</q-card>
</q-dialog>
</template>

View file

@ -9,7 +9,7 @@ import { useGovernmentPosDataStore } from "@/modules/04_registryPerson/stores/Po
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { QTableColumn } from "quasar";
import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main";
import type { FormPostition } from "@/modules/04_registryPerson/interface/index/government";
import type {
@ -25,7 +25,7 @@ import type { ResListSalary } from "@/modules/04_registryPerson/interface/respon
import type { DataCardPos } from "@/modules/04_registryPerson/interface/index/government";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/07_PositionHistory.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
import DialogPreviewCommand from "@/modules/18_command/components/DialogPreviewCommand.vue";
const $q = useQuasar();
@ -56,14 +56,7 @@ const {
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
//Table
const rows = ref<DataPositions[]>([]); //
const rowsMain = ref<DataPositions[]>([]); //
const keyword = ref<string>(""); //
const modalCommand = ref<boolean>(false);
const command = ref<string>("");
const commandId = ref<string>("");
const baseColumns = ref<QTableProps["columns"]>([
const baseColumns = ref<QTableColumn[]>([
{
name: "commandDateAffect",
align: "left",
@ -252,20 +245,35 @@ const baseColumns = ref<QTableProps["columns"]>([
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v, false, true),
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const columns = computed(() => {
if (empType.value === "-employee") {
if (baseColumns.value) {
return baseColumns.value.filter(
(column) =>
column.name !== "positionSalaryAmount" &&
column.name !== "mouthSalaryAmount"
);
}
}
return baseColumns.value;
});
const visibleColumns = ref<string[]>([
const baseVisibleColumns = ref<string[]>([
"commandDateAffect",
"posNo",
"positionName",
@ -278,7 +286,29 @@ const visibleColumns = ref<string[]>([
"commandDateSign",
"organization",
"remark",
"lastUpdateFullName",
"lastUpdatedAt",
]);
//Table
const rows = ref<DataPositions[]>([]); //
const rowsMain = ref<DataPositions[]>([]); //
const keyword = ref<string>(""); //
const modalCommand = ref<boolean>(false);
const command = ref<string>("");
const commandId = ref<string>("");
const columns = ref<QTableColumn[]>(
baseColumns.value.filter(
(e: QTableColumn) =>
e.name !== "lastUpdateFullName" && e.name !== "lastUpdatedAt"
)
);
const visibleColumns = ref<String[]>(
baseVisibleColumns.value.filter(
(e: string) => e !== "lastUpdateFullName" && e !== "lastUpdatedAt"
)
);
const pagination = ref({
sortBy: "",
});
@ -309,6 +339,9 @@ const formData = reactive<FormPostition>({
remark: "", //
});
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
const visibleColumnsHistory = ref<string[]>(baseVisibleColumns.value);
const modalDialogSalary = ref<boolean>(false); // popup
const isStatusEdit = ref<boolean>(false); //
const salaryId = ref<string>(""); //id
@ -741,6 +774,22 @@ function serchDataTable() {
);
}
/** function fetch ข้อมูลประวัติการแก้ไข*/
async function fetchDataHistory() {
showLoader();
try {
const res = await http.get(
config.API.profileListSalaryHistoryNew(salaryId.value, empType.value)
);
return res.data.result;
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
function classInput(val: boolean) {
return {
"full-width inputgreen cursor-pointer": val,
@ -1439,7 +1488,13 @@ onMounted(async () => {
</q-card>
</q-dialog>
<DialogHistory v-model:modal="modalHistory" v-model:salaryId="salaryId" />
<DialogHistory
v-model:modal="modalHistory"
:title="`ประวัติแก้ไขตำแหน่ง`"
:columns="columnsHistory"
:visible-columns="visibleColumnsHistory"
:fetch-data="fetchDataHistory"
/>
<DialogPreviewCommand
v-model:modal="modalCommand"
v-model:command="command"

View file

@ -1,405 +0,0 @@
<script setup lang="ts">
import { ref, watch, computed } from "vue";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useGovernmentPosDataStore } from "@/modules/04_registryPerson/stores/Position";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { DataPositions } from "@/modules/04_registryPerson/interface/response/Position";
import DialogHeader from "@/components/DialogHeader.vue";
const $q = useQuasar();
const route = useRoute();
const store = useGovernmentPosDataStore();
const {
date2Thai,
showLoader,
hideLoader,
messageError,
pathRegistryEmp,
onSearchDataTable,
findOrgName,
} = useCounterMixin();
/** props*/
const modal = defineModel<boolean>("modal", { required: true });
const salaryId = defineModel<string>("salaryId", { required: true });
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const rows = ref<DataPositions[]>([]); //
const rowsMain = ref<DataPositions[]>([]); //
const keyword = ref<string>(""); //
const baseColumns = ref<QTableProps["columns"]>([
{
name: "commandDateAffect",
align: "left",
label: "วันที่คำสั่งมีผล",
sortable: true,
field: "commandDateAffect",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "posNo",
align: "left",
label: "ตำแหน่งเลขที่",
sortable: true,
field: "posNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
return row.posNoAbb && row.posNo
? `${row.posNoAbb}${row.posNo}`
: row.posNo
? row.posNo
: "-";
},
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "positionName",
align: "left",
label: empType.value === "-employee" ? "ตำแหน่ง" : "ตำแหน่งในสายงาน",
sortable: true,
field: "positionName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "positionType",
align: "left",
label: empType.value === "-employee" ? "กลุ่มงาน" : "ประเภทตำแหน่ง",
sortable: true,
field: "positionType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "positionLevel",
align: "left",
label: empType.value === "-employee" ? "ระดับชั้นงาน" : "ระดับ",
sortable: true,
field: "positionLevel",
format(val, row) {
return `${
row.positionLevel
? row.positionLevel
: row.positionCee
? row.positionCee
: "-"
}`;
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "positionExecutive",
align: "left",
label: "ตำแหน่งทางการบริหาร",
sortable: true,
field: "positionExecutive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "amount",
align: "left",
label: empType.value === "-employee" ? "ค่าตอบแทนรายเดือน" : "เงินเดือน",
sortable: true,
field: "amount",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(v, row) {
return row.amount
? `${row.amount.toLocaleString()}${
row.amountSpecial !== 0 && row.amountSpecial
? ` (${row.amountSpecial.toLocaleString()})`
: ""
}`
: "-";
},
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "commandNo",
align: "left",
label: "เลขที่คำสั่ง",
sortable: true,
field: "commandNo",
format(val, row) {
return row.commandNo && row.commandYear
? `${row.commandNo}/${row.commandYear}`
: "";
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "commandCode",
align: "left",
label: "ประเภทคำสั่ง",
sortable: true,
field: "commandCode",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
return store.convertCommandCodeName(val);
},
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "commandDateSign",
align: "left",
label: "วันที่ลงนาม",
sortable: true,
field: "commandDateSign",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "organization",
align: "left",
label: "สังกัด",
sortable: true,
field: "organization",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
return findOrgName({
root: row.orgRoot,
child1: row.orgChild1,
child2: row.orgChild2,
child3: row.orgChild3,
child4: row.orgChild4,
});
},
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "remark",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "remark",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v, false, true),
sort: (a: string, b: string) =>
a
.toString()
.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<string[]>([
"commandDateAffect",
"posNo",
"positionName",
"positionType",
"positionLevel",
"positionExecutive",
"amount",
"commandNo",
"commandCode",
"commandDateSign",
"organization",
"remark",
"lastUpdateFullName",
"lastUpdatedAt",
]);
const columns = computed(() => {
if (empType.value === "-employee") {
if (baseColumns.value) {
return baseColumns.value.filter(
(column) =>
column.name !== "positionSalaryAmount" &&
column.name !== "mouthSalaryAmount"
);
}
}
return baseColumns.value;
});
const pagination = ref({
sortBy: "lastUpdatedAt",
});
/** function fetch ข้อมูลประวัติการแก้ไข*/
function fetchListHistory() {
showLoader();
http
.get(config.API.profileListSalaryHistoryNew(salaryId.value, empType.value))
.then((res) => {
rows.value = res.data.result;
rowsMain.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** ฟังก์ชันปิด Popup*/
function closeDialog() {
modal.value = false;
keyword.value = "";
rows.value = [];
}
/** ฟังก์ค้นหาข้อมูลรายการวินัย */
function serchDataTable() {
rows.value = onSearchDataTable(
keyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
/**
* การเปลยนแปลงของ modal
* modal เป true เรยก getHistory เพอดงขอมลประวการแกไข
*/
watch(
() => modal.value,
() => {
modal.value && fetchListHistory();
}
);
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 80%">
<DialogHeader
:tittle="'ประวัติแก้ไขตำแหน่ง/เงินเดือน'"
:close="closeDialog"
/>
<q-separator color="grey-4" />
<q-card-section style="max-height: 60vh" class="scroll">
<div class="row q-gutter-sm q-mb-sm">
<q-space />
<q-input
dense
outlined
v-model="keyword"
label="ค้นหา"
class="q-mr-sm"
@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"
row-key="id"
flat
bordered
dense
:columns="columns"
:rows="rows"
v-model:pagination="pagination"
:visible-columns="visibleColumns"
>
<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">
<div v-if="col.name == 'organization'" class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</q-card-section>
</q-card>
</q-dialog>
</template>
<style scoped></style>