Merge branch 'nice' into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-16 14:30:05 +07:00
commit 0e290d0c94
7 changed files with 166 additions and 371 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, watch, onMounted } from "vue"; import { ref, reactive, onMounted } from "vue";
import { checkPermission } from "@/utils/permissions"; import { checkPermission } from "@/utils/permissions";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
@ -11,7 +11,6 @@ import DialogHeader from "@/components/DialogHeader.vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import type { QTableProps } from "quasar"; import type { QTableProps } 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";
@ -72,126 +71,14 @@ const workDateRef = ref<object | null>(null);
const reasonSameDateRef = ref<object | null>(null); const reasonSameDateRef = ref<object | null>(null);
const visibleColumnsHistory = ref<String[]>([ const visibleColumnsHistory = ref<String[]>([
// "oc",
// "position",
// "positionPathSide",
// "posNo",
// "positionLine",
// "positionType",
// "positionLevel",
// "positionExecutive",
// "positionExecutiveSide",
"dateAppoint", "dateAppoint",
"dateStart", "dateStart",
// "retireDate",
// "govAge",
// "govAgeAbsent",
// "govAgePlus",
"reasonSameDate", "reasonSameDate",
"lastUpdateFullName", "lastUpdateFullName",
"lastUpdatedAt", "lastUpdatedAt",
]); ]);
const columnsHistory = ref<QTableProps["columns"]>([ const columnsHistory = ref<QTableProps["columns"]>([
// {
// name: "oc",
// align: "left",
// label: "",
// sortable: true,
// field: "oc",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// sort: (a: string, b: string) =>
// a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
// },
// {
// name: "positionPathSide",
// align: "left",
// label: "",
// sortable: true,
// field: "positionPathSide",
// 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: "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: "positionLine",
// align: "left",
// label: "",
// sortable: true,
// field: "positionLine",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// sort: (a: string, b: string) =>
// a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
// },
// {
// name: "positionType",
// align: "left",
// label: "",
// sortable: true,
// field: "positionType",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// sort: (a: string, b: string) =>
// a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
// },
// {
// name: "positionLevel",
// align: "left",
// label: "",
// sortable: true,
// field: "positionLevel",
// 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: "positionExecutiveSide",
// align: "left",
// label: "",
// sortable: true,
// field: "positionExecutiveSide",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// sort: (a: string, b: string) =>
// a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
// },
{ {
name: "dateAppoint", name: "dateAppoint",
align: "left", align: "left",
@ -216,51 +103,6 @@ const columnsHistory = ref<QTableProps["columns"]>([
sort: (a: string, b: string) => sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
// {
// name: "retireDate",
// align: "left",
// label: "",
// sortable: true,
// field: "retireDate",
// 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: "govAge",
// align: "left",
// label: "",
// sortable: true,
// field: "govAge",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// sort: (a: string, b: string) =>
// a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
// },
// {
// name: "govAgeAbsent",
// align: "left",
// label: "",
// sortable: true,
// field: "govAgeAbsent",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// sort: (a: string, b: string) =>
// a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
// },
// {
// name: "govAgePlus",
// align: "left",
// label: "",
// sortable: true,
// field: "govAgePlus",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// sort: (a: string, b: string) =>
// a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
// },
{ {
name: "reasonSameDate", name: "reasonSameDate",
align: "left", align: "left",
@ -297,7 +139,9 @@ const columnsHistory = ref<QTableProps["columns"]>([
}, },
]); ]);
/** เปิด dialog */ /**
* เป dialog *
*/
function openDialogEdit() { function openDialogEdit() {
modalEdit.value = true; modalEdit.value = true;
containDate.value = formMain.containDate ? formMain.containDate : null; containDate.value = formMain.containDate ? formMain.containDate : null;
@ -307,12 +151,18 @@ function openDialogEdit() {
: null; : null;
} }
/**
* เป dialog ประวแกไขขอมลราชการ
*/
function openDialogHistory() { function openDialogHistory() {
modalHistory.value = true; modalHistory.value = true;
filterKeyword.value = ""; filterKeyword.value = "";
getDataHistory(); getDataHistory();
} }
/** ปิด dialog */
/**
* dialog
*/
function closeDialog() { function closeDialog() {
modalEdit.value = false; modalEdit.value = false;
containDate.value = null; containDate.value = null;
@ -320,6 +170,9 @@ function closeDialog() {
reasonSameDate.value = null; reasonSameDate.value = null;
} }
/**
* function นยนการบนทกขอมลราชการ
*/
function onSubmit() { function onSubmit() {
dialogConfirm($q, () => { dialogConfirm($q, () => {
showLoader(); showLoader();
@ -336,9 +189,9 @@ function onSubmit() {
: reasonSameDate.value, : reasonSameDate.value,
} }
) )
.then(() => { .then(async () => {
getData(); await getData();
success($q, "บันทึกข้อมูลสำเร็จ"); await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog(); closeDialog();
}) })
.catch((e) => { .catch((e) => {
@ -350,7 +203,9 @@ function onSubmit() {
}); });
} }
/** ดึงข้อมูลราชการ */ /**
* งขอมลราชการ
*/
function getData() { function getData() {
showLoader(); showLoader();
http http
@ -384,7 +239,9 @@ function getData() {
}); });
} }
/** ดึงข้อมูลประวัติ */ /**
* งขอมลประว
*/
function getDataHistory() { function getDataHistory() {
showLoader(); showLoader();
http http
@ -852,7 +709,7 @@ onMounted(() => {
</q-tr> </q-tr>
</template> </template>
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer"> <q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props"> <q-td v-for="col in props.cols" :key="col.name" :props="props">
<div> <div>
{{ col.value ? col.value : "-" }} {{ col.value ? col.value : "-" }}

View file

@ -28,7 +28,6 @@ const {
messageError, messageError,
success, success,
pathRegistryEmp, pathRegistryEmp,
dialogRemove,
} = mixin; } = mixin;
const profileId = ref<string>( const profileId = ref<string>(
@ -60,14 +59,10 @@ const formFilter = reactive<FormFilter>({
isShowRetire: false, isShowRetire: false,
isProbation: false, isProbation: false,
}); });
const currentPage = ref<number>(1);
const maxPage = ref<number>(1);
const pagination = ref({ const pagination = ref({
page: 1, page: 1,
rowsPerPage: 10, rowsPerPage: 10,
}); });
const visibleColumns = ref<String[]>([ const visibleColumns = ref<String[]>([
"level", "level",
"detail", "detail",
@ -199,6 +194,12 @@ const OpsFilter = ref<any>({
], ],
}); });
/**
* function นหา คำใน option
* @param val คำคนหา
* @param update function
* @param refData type select
*/
function filterSelector(val: string, update: Function, refData: string) { function filterSelector(val: string, update: Function, refData: string) {
switch (refData) { switch (refData) {
case "levelOptions": case "levelOptions":
@ -213,7 +214,9 @@ function filterSelector(val: string, update: Function, refData: string) {
} }
} }
/** ปิด dialog */ /**
* dialog อมลว
*/
function closeDialog() { function closeDialog() {
modal.value = false; modal.value = false;
edit.value = false; edit.value = false;
@ -225,15 +228,21 @@ function closeDialog() {
disciplineData.refCommandDate = null; disciplineData.refCommandDate = null;
} }
/**
* เป dialog อมลว
*/
function openDialogAdd() { function openDialogAdd() {
modal.value = true; modal.value = true;
} }
async function fetchData(id: string) { /**
* function fetch อมลรายการว
*/
function fetchData(id: string) {
showLoader(); showLoader();
await http http
.get(config.API.profileNewDisciplineByProfileId(id, empType.value)) .get(config.API.profileNewDisciplineByProfileId(id, empType.value))
.then(async (res) => { .then((res) => {
rows.value = res.data.result; rows.value = res.data.result;
}) })
.catch((err) => { .catch((err) => {
@ -244,7 +253,11 @@ async function fetchData(id: string) {
}); });
} }
async function addData() { /**
* funciton เพมชอมลว
*/
function addData() {
showLoader();
const body = { const body = {
date: disciplineData.date, date: disciplineData.date,
level: disciplineData.level, level: disciplineData.level,
@ -256,11 +269,12 @@ async function addData() {
empType.value !== "" ? disciplineData.profileId : undefined, empType.value !== "" ? disciplineData.profileId : undefined,
refCommandDate: disciplineData.refCommandDate, refCommandDate: disciplineData.refCommandDate,
}; };
await http http
.post(config.API.profileNewDiscipline(empType.value), body) .post(config.API.profileNewDiscipline(empType.value), body)
.then(() => { .then(async () => {
fetchData(profileId.value); await fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ"); await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -270,8 +284,12 @@ async function addData() {
}); });
} }
async function editData(idData: string) { /**
await http * funciton นทกแกไขชอมลว
*/
function editData(idData: string) {
showLoader();
http
.patch( .patch(
config.API.profileNewDisciplineByDisciplineId(idData, empType.value), config.API.profileNewDisciplineByDisciplineId(idData, empType.value),
{ {
@ -279,9 +297,10 @@ async function editData(idData: string) {
profileId: undefined, profileId: undefined,
} }
) )
.then(() => { .then(async () => {
fetchData(profileId.value); await fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ"); await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -291,22 +310,6 @@ async function editData(idData: string) {
}); });
} }
// function deleteData(idData: string) {
// dialogRemove($q, () =>
// http
// .delete(config.API.profileNewDisciplineByDisciplineId(idData))
// .then(() => {
// fetchData(profileId.value);
// success($q, "");
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// hideLoader();
// })
// );
// }
/** /**
* กดเลอกขอมลทจะแกไข * กดเลอกขอมลทจะแกไข
* @param props props ใน row เลอก * @param props props ใน row เลอก
@ -323,25 +326,31 @@ function openDialogEdit(props: RequestItemsObject) {
disciplineData.refCommandDate = props.refCommandDate; disciplineData.refCommandDate = props.refCommandDate;
} }
/**
* function ประวการแไขรายการว
* @param idOrder
*/
function openDialogHistory(idOrder: string) { function openDialogHistory(idOrder: string) {
modalHistory.value = true; modalHistory.value = true;
id.value = idOrder; id.value = idOrder;
} }
async function onSubmit() { /**
* function นยนการบนทกขอม
*/
function onSubmit() {
dialogConfirm( dialogConfirm(
$q, $q,
async () => { () => {
edit.value ? editData(id.value) : addData(); edit.value ? editData(id.value) : addData();
closeDialog();
}, },
"ยืนยันการบันทึกข้อมูล", "ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
); );
} }
onMounted(async () => { onMounted(() => {
await fetchData(profileId.value); fetchData(profileId.value);
}); });
</script> </script>
<template> <template>

View file

@ -8,10 +8,7 @@ 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 { import type { RequestItemsObject } from "@/modules/04_registryPerson/interface/index/discipline";
RequestItemsObject,
FormFilter,
} from "@/modules/04_registryPerson/interface/index/discipline";
const modal = defineModel<boolean>("modal", { required: true }); const modal = defineModel<boolean>("modal", { required: true });
const id = defineModel<string>("id", { required: true }); const id = defineModel<string>("id", { required: true });
@ -23,23 +20,9 @@ const { showLoader, hideLoader, messageError, date2Thai, pathRegistryEmp } =
mixin; mixin;
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? "")); const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const currentPage = ref<number>(1);
const maxPage = ref<number>(1);
const filterKeyword = ref<string>(""); const filterKeyword = ref<string>("");
const rows = ref<RequestItemsObject[]>([]); //select data history const rows = ref<RequestItemsObject[]>([]); //select 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 historyPagination = ref({ const historyPagination = ref({
page: 1, page: 1,
rowsPerPage: 10, rowsPerPage: 10,
@ -150,6 +133,9 @@ const columns = ref<QTableProps["columns"]>([
}, },
]); ]);
/**
* fetch อมลประวการแกไขขอมลว
*/
function getHistory() { function getHistory() {
showLoader(); showLoader();
http http
@ -262,14 +248,7 @@ watch(modal, (status) => {
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr :props="props"> <q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.id"> <q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name === 'no'"> <div>
{{
(formFilter.page - 1) * formFilter.pageSize +
props.rowIndex +
1
}}
</div>
<div v-else>
{{ col.value ? col.value : "-" }} {{ col.value ? col.value : "-" }}
</div> </div>
</q-td> </q-td>

View file

@ -9,11 +9,9 @@ import { useCounterMixin } from "@/stores/mixin";
import DialogHeader from "@/components/DialogHeader.vue"; import DialogHeader from "@/components/DialogHeader.vue";
import type { import type {
DetailData, DetailData,
FormFilter,
DataOptionLeave, DataOptionLeave,
DataOption, DataOption,
ResponseTotalObject, ResponseTotalObject,
MyObjectRef,
} from "@/modules/04_registryPerson/interface/index/leave"; } from "@/modules/04_registryPerson/interface/index/leave";
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/03_LeaveHistory.vue"; import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/03_LeaveHistory.vue";
@ -48,21 +46,8 @@ const pagination = ref({
}); });
const mode = ref<string>("table"); const mode = ref<string>("table");
const filterKeyword = ref<string>(""); const filterKeyword = ref<string>("");
const currentPage = ref<number>(1);
const maxPage = ref<number>(1);
const rows = ref<DetailData[]>([]); const rows = ref<DetailData[]>([]);
const formFilter = reactive<FormFilter>({
page: 1,
pageSize: 12,
keyword: "",
type: "",
posType: "",
posLevel: "",
retireYear: "",
rangeYear: { min: 0, max: 60 },
isShowRetire: false,
isProbation: false,
});
const modal = ref<boolean>(false); const modal = ref<boolean>(false);
const edit = ref<boolean>(false); const edit = ref<boolean>(false);
@ -114,19 +99,6 @@ const clickEditRowType = () => {
} }
}; };
const typeLeaveRef = ref<object | null>(null);
const dateRangeRef = ref<object | null>(null);
const numLeaveRef = ref<object | null>(null);
const statLeaveRef = ref<object | null>(null);
const reasonRef = ref<object | null>(null);
const objectRef: MyObjectRef = {
typeLeave: typeLeaveRef,
dateRange: dateRangeRef,
numLeave: numLeaveRef,
statLeave: statLeaveRef,
reason: reasonRef,
};
const visibleColumns = ref<String[]>([ const visibleColumns = ref<String[]>([
"no", "no",
"typeLeave", "typeLeave",
@ -205,6 +177,9 @@ const columns = ref<QTableProps["columns"]>([
}, },
]); ]);
/**
* function เป dialog อมลการลา
*/
function openDialogAdd() { function openDialogAdd() {
modal.value = true; modal.value = true;
edit.value = false; edit.value = false;
@ -255,6 +230,9 @@ function clickTotal() {
}); });
} }
/**
* function เป dialog แกไขขอมลการลา
*/
function openDialogEdit(props: DetailData) { function openDialogEdit(props: DetailData) {
edit.value = true; edit.value = true;
modal.value = true; modal.value = true;
@ -286,11 +264,12 @@ function openDialogEdit(props: DetailData) {
} }
} }
/** ปิด dialog */ /**
* dialog อมลการลา
*/
function closeDialog() { function closeDialog() {
modal.value = false; modal.value = false;
edit.value = false; edit.value = false;
id.value = ""; id.value = "";
typeLeave.value = ""; typeLeave.value = "";
statLeave.value = ""; statLeave.value = "";
@ -300,6 +279,12 @@ function closeDialog() {
numUsedLeave.value = 0; numUsedLeave.value = 0;
} }
/**
* function นหา คำใน option
* @param val คำคนหา
* @param update function
* @param filtername type select
*/
function filterSelector(val: any, update: Function, filtername: string) { function filterSelector(val: any, update: Function, filtername: string) {
switch (filtername) { switch (filtername) {
case "typeLeaveOption": case "typeLeaveOption":
@ -345,27 +330,17 @@ function openDialogHistory(idOrder: string) {
id.value = idOrder; id.value = idOrder;
} }
/** validate check*/ /**
function validateForm() { * function นยนการบนทกขอม
const hasError = []; */
for (const key in objectRef) { function onSubmit() {
if (Object.prototype.hasOwnProperty.call(objectRef, key)) { dialogConfirm($q, async () => {
const property = objectRef[key]; if (edit.value == false) {
if (property.value && typeof property.value.validate === "function") { saveData();
const isValid = property.value.validate(); } else {
hasError.push(isValid); editData();
}
} }
} });
if (hasError.every((result) => result === true)) {
dialogConfirm($q, async () => {
if (edit.value == false) {
saveData();
} else {
editData();
}
});
}
} }
/** /**
@ -373,7 +348,6 @@ function validateForm() {
*/ */
function saveData() { function saveData() {
showLoader(); showLoader();
http http
.post(config.API.profileNewLeave(empType.value), { .post(config.API.profileNewLeave(empType.value), {
leaveTypeId: typeLeave.value.id, leaveTypeId: typeLeave.value.id,
@ -387,15 +361,16 @@ function saveData() {
profileId: empType.value === "" ? profileId.value : undefined, profileId: empType.value === "" ? profileId.value : undefined,
profileEmployeeId: empType.value !== "" ? profileId.value : undefined, profileEmployeeId: empType.value !== "" ? profileId.value : undefined,
}) })
.then(() => { .then(async () => {
success($q, "บันทึกข้อมูลสำเร็จ"); await getData();
await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog(); closeDialog();
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => { .finally(() => {
getData(); hideLoader();
}); });
} }
@ -415,18 +390,22 @@ const editData = async () => {
status: statLeave.value, status: statLeave.value,
reason: reason.value, reason: reason.value,
}) })
.then(() => { .then(async () => {
success($q, "บันทึกข้อมูลสำเร็จ"); await getData();
await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog(); closeDialog();
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => { .finally(() => {
getData(); hideLoader();
}); });
}; };
/**
* function fetch อมลรายการว
*/
function getData() { function getData() {
showLoader(); showLoader();
http http
@ -594,9 +573,7 @@ onMounted(() => {
</q-td> </q-td>
<q-td v-for="col in props.cols" :key="col.id"> <q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name === 'no'"> <div v-if="col.name === 'no'">
{{ {{ props.rowIndex + 1 }}
(formFilter.page - 1) * formFilter.pageSize + props.rowIndex + 1
}}
</div> </div>
<div v-else-if="col.name == 'dateLeave'"> <div v-else-if="col.name == 'dateLeave'">
{{ {{
@ -684,7 +661,7 @@ onMounted(() => {
<!-- dialog add edit --> <!-- dialog add edit -->
<q-dialog v-model="modal" persistent> <q-dialog v-model="modal" persistent>
<q-card> <q-card>
<form @submit.prevent="validateForm"> <q-form @submit.prevent greedy @validation-success="onSubmit()">
<DialogHeader <DialogHeader
:tittle="edit ? 'แก้ไขข้อมูลการลา' : 'เพิ่มข้อมูลการลา'" :tittle="edit ? 'แก้ไขข้อมูลการลา' : 'เพิ่มข้อมูลการลา'"
:close="closeDialog" :close="closeDialog"
@ -814,7 +791,7 @@ onMounted(() => {
<q-tooltip>นทกขอม</q-tooltip> <q-tooltip>นทกขอม</q-tooltip>
</q-btn> </q-btn>
</q-card-actions> </q-card-actions>
</form> </q-form>
</q-card> </q-card>
</q-dialog> </q-dialog>

View file

@ -146,6 +146,10 @@ const columns = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
]); ]);
/**
* function fetch อมลประวการแกไขการลา
*/
function getHistory() { function getHistory() {
showLoader(); showLoader();
http http
@ -172,7 +176,7 @@ function getHistory() {
}); });
}) })
.catch((e) => { .catch((e) => {
// messageError($q, e); messageError($q, e);
}) })
.finally(() => { .finally(() => {
hideLoader(); hideLoader();
@ -192,6 +196,10 @@ function dateThaiRange(val: [Date, Date]) {
} }
} }
/**
* function convertStatus
* @param val
*/
function statusLeave(val: string) { function statusLeave(val: string) {
switch (val) { switch (val) {
case "waitting": case "waitting":

View file

@ -42,11 +42,6 @@ const modalHistory = ref<boolean>(false);
const id = ref<string>(""); const id = ref<string>("");
const dateStartRef = ref<object | null>(null);
const dateEndRef = ref<object | null>(null);
const detailRef = ref<object | null>(null);
const referenceRef = ref<object | null>(null);
const dutyData = reactive<RequestItemsObject>({ const dutyData = reactive<RequestItemsObject>({
profileId: profileId.value, profileId: profileId.value,
dateStart: new Date(), dateStart: new Date(),
@ -78,9 +73,6 @@ const formFilter = reactive<FormFilter>({
isProbation: false, isProbation: false,
}); });
const currentPage = ref<number>(1);
const maxPage = ref<number>(1);
const visibleColumns = ref<String[]>([ const visibleColumns = ref<String[]>([
"dateStart", "dateStart",
"dateEnd", "dateEnd",
@ -201,10 +193,12 @@ function closeDialog() {
dutyData.refCommandDate = null; dutyData.refCommandDate = null;
} }
/** fetch ข้อมูล */ /**
async function fetchData(id: string) { * fetch อมลรายการพเศษ
*/
function fetchData(id: string) {
showLoader(); showLoader();
await http http
.get(config.API.profileNewDutyByProfileId(id, empType.value)) .get(config.API.profileNewDutyByProfileId(id, empType.value))
.then(async (res) => { .then(async (res) => {
rows.value = res.data.result; rows.value = res.data.result;
@ -217,9 +211,11 @@ async function fetchData(id: string) {
}); });
} }
/** เพิ่มข้อมูล */ /**
* functoin นทกการเพมขอม
async function addData() { */
function addData() {
showLoader();
const body = { const body = {
profileId: empType.value === "" ? profileId.value : undefined, profileId: empType.value === "" ? profileId.value : undefined,
profileEmployeeId: empType.value !== "" ? profileId.value : undefined, profileEmployeeId: empType.value !== "" ? profileId.value : undefined,
@ -230,11 +226,12 @@ async function addData() {
refCommandNo: dutyData.refCommandNo, refCommandNo: dutyData.refCommandNo,
refCommandDate: dutyData.refCommandDate, refCommandDate: dutyData.refCommandDate,
}; };
await http http
.post(config.API.profileNewDuty(empType.value), body) .post(config.API.profileNewDuty(empType.value), body)
.then(() => { .then(async () => {
fetchData(profileId.value); await fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ"); await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -244,17 +241,20 @@ async function addData() {
}); });
} }
/** แก้ไขข้อมูล */ /**
* functoin นทกการแกไขขอม
async function editData(idData: string) { */
await http function editData(idData: string) {
showLoader();
http
.patch(config.API.profileNewDutyByDutyId(idData, empType.value), { .patch(config.API.profileNewDutyByDutyId(idData, empType.value), {
...dutyData, ...dutyData,
profileId: undefined, profileId: undefined,
}) })
.then(() => { .then(async () => {
fetchData(profileId.value); await fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ"); await success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -264,41 +264,22 @@ async function editData(idData: string) {
}); });
} }
/** ลบข้อมูล */ /**
* นยนการบนทกขอม
// function deleteData(idData: string) { */
// dialogRemove($q, () => function onSubmit() {
// http
// .delete(config.API.profileNewDutyByDutyId(idData))
// .then(() => {
// fetchData(profileId.value);
// success($q, "");
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// hideLoader();
// })
// );
// }
/** กด Submit */
async function onSubmit() {
dialogConfirm( dialogConfirm(
$q, $q,
async () => { () => {
edit.value ? editData(id.value) : addData(); edit.value ? editData(id.value) : addData();
closeDialog();
}, },
"ยืนยันการบันทึกข้อมูล", "ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
); );
} }
onMounted(async () => { onMounted(() => {
await fetchData(profileId.value); fetchData(profileId.value);
}); });
</script> </script>
<template> <template>
@ -547,6 +528,7 @@ onMounted(async () => {
autoApply autoApply
:enableTimePicker="false" :enableTimePicker="false"
week-start="0" week-start="0"
:max-date="dutyData.dateEnd"
> >
<template #year="{ year }">{{ year + 543 }}</template> <template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{ <template #year-overlay-value="{ value }">{{

View file

@ -24,22 +24,8 @@ const { showLoader, hideLoader, messageError, date2Thai, pathRegistryEmp } =
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? "")); const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const currentPage = ref<number>(1);
const maxPage = ref<number>(1);
const filterKeyword = ref<string>(""); const filterKeyword = ref<string>("");
const rows = ref<ResponseObject[]>([]); //select data history const rows = ref<ResponseObject[]>([]); //select 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 historyPagination = ref({ const historyPagination = ref({
page: 1, page: 1,
@ -149,6 +135,10 @@ const columns = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
]); ]);
/**
* function fetch อมลประวตการแกไขขอม
*/
function getHistory() { function getHistory() {
showLoader(); showLoader();
http http
@ -264,14 +254,7 @@ watch(modal, (status) => {
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr :props="props"> <q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.id"> <q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name === 'no'"> <div class="table_ellipsis">
{{
(formFilter.page - 1) * formFilter.pageSize +
props.rowIndex +
1
}}
</div>
<div v-else class="table_ellipsis">
{{ col.value ? col.value : "-" }} {{ col.value ? col.value : "-" }}
</div> </div>
</q-td> </q-td>