diff --git a/src/modules/04_registryPerson/components/detail/DialogHistory.vue b/src/modules/04_registryPerson/components/detail/DialogHistory.vue index 7207f5a8b..09d81b8c7 100644 --- a/src/modules/04_registryPerson/components/detail/DialogHistory.vue +++ b/src/modules/04_registryPerson/components/detail/DialogHistory.vue @@ -114,7 +114,10 @@ watch( diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_Discipline.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_Discipline.vue index 9f7c86464..8df002793 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_Discipline.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_Discipline.vue @@ -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( @@ -53,20 +54,16 @@ const disciplineData = reactive({ refCommandDate: null, //เอกสารอ้างอิง (ลงวันที่) }); -const rows = ref([]); //รายการวินัย -const rowsMain = ref([]); //รายการวินัย -const mode = ref("table"); //การแสดงผล Table card -const filterKeyword = ref(""); //คำค้นหา -const columns = ref([ +const baseColumns = ref([ { 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([ { name: "unStigma", align: "left", - label: "ประเภทคำสั่ง", + label: "ล้างมลทิน", sortable: true, field: "unStigma", headerStyle: "font-size: 14px", @@ -119,8 +116,19 @@ const columns = ref([ 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([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, ]); -const visibleColumns = ref([ +const baseVisibleColumns = ref([ "level", "detail", "unStigma", "refCommandNo", "refCommandDate", "date", + "lastUpdateFullName", "lastUpdatedAt", ]); + +const rows = ref([]); //รายการวินัย +const rowsMain = ref([]); //รายการวินัย +const mode = ref("table"); //การแสดงผล Table card +const filterKeyword = ref(""); //คำค้นหา + +const columns = ref( + baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName") +); +const visibleColumns = ref( + baseVisibleColumns.value.filter((e: string) => e !== "lastUpdateFullName") +); const pagination = ref({ sortBy: "lastUpdatedAt", }); @@ -157,6 +178,9 @@ const modal = ref(false); //แสดงข้อมูลวินั const modalHistory = ref(false); //แสดงประวัติแก้ไขวินัย const id = ref(""); //id ที่ต้แงการแก้ไข +const columnsHistory = ref(baseColumns.value); +const visibleColumnsHistory = ref(baseVisibleColumns.value); + const Ops = ref({ 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); }); + diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_DisciplineHistory.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_DisciplineHistory.vue deleted file mode 100644 index 17641c029..000000000 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_DisciplineHistory.vue +++ /dev/null @@ -1,271 +0,0 @@ - - - diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_Leave.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_Leave.vue index e98d8e134..8a3a31d27 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_Leave.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_Leave.vue @@ -1,6 +1,6 @@ + diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_LeaveHistory.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_LeaveHistory.vue deleted file mode 100644 index 0682c4a7f..000000000 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_LeaveHistory.vue +++ /dev/null @@ -1,334 +0,0 @@ - - - diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/04_PerformSpecialWork.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/04_PerformSpecialWork.vue index 74cae954c..2f8f17a77 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/04_PerformSpecialWork.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/04_PerformSpecialWork.vue @@ -1,6 +1,6 @@ - - diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPos.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPos.vue index b7ed1e294..cb189c9e0 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPos.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPos.vue @@ -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( @@ -40,12 +41,7 @@ const isLeave = defineModel("isLeave", { required: true, }); -/** Table*/ -const rows = ref([]); //รายการวินัย -const rowsMain = ref([]); //รายการวินัย -const mode = ref("table"); //การแสดงผล Table card -const filterKeyword = ref(""); //คำค้นหา -const columns = ref([ +const baseColumns = ref([ { name: "dateStart", align: "left", @@ -119,7 +115,17 @@ const columns = ref([ .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([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, ]); -const visibleColumns = ref([ +const baseVisibleColumns = ref([ "dateStart", "dateEnd", "posNo", "position", "refCommandNo", "status", + "lastUpdateFullName", "lastUpdatedAt", ]); + +/** Table*/ +const rows = ref([]); //รายการวินัย +const rowsMain = ref([]); //รายการวินัย +const mode = ref("table"); //การแสดงผล Table card +const filterKeyword = ref(""); //คำค้นหา +const columns = ref( + baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName") +); +const visibleColumns = ref( + baseVisibleColumns.value.filter((e: string) => e !== "lastUpdateFullName") +); const pagination = ref({ sortBy: "lastUpdatedAt", }); +const columnsHistory = ref(baseColumns.value); +const visibleColumnsHistory = ref(baseVisibleColumns.value); + /** Dialog*/ const isStatusEdit = ref(false); const modal = ref(false); @@ -164,15 +186,6 @@ const formData = reactive({ 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(() => { - + + -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("modal", { required: true }); -const id = defineModel("id", { required: true }); - -const route = useRoute(); -const $q = useQuasar(); -const mixin = useCounterMixin(); -const { - showLoader, - hideLoader, - messageError, - date2Thai, - pathRegistryEmp, - onSearchDataTable, -} = mixin; - -const empType = ref(pathRegistryEmp(route.name?.toString() ?? "")); - -const filterKeyword = ref(""); //คำค้นหา -const rows = ref([]); //data history -const rowsMain = ref([]); //data history -const columns = ref([ - { - 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([ - "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 = []; - } -}); - - - diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernment.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernment.vue index b28eedd98..080625fbd 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernment.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernment.vue @@ -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( @@ -44,12 +45,7 @@ const isLeave = defineModel("isLeave", { required: true, }); -/** Table*/ -const rows = ref([]); //รายการวินัย -const rowsMain = ref([]); //รายการวินัย -const mode = ref("table"); //การแสดงผล Table card -const filterKeyword = ref(""); //คำค้นหา -const columns = ref([ +const baseColumns = ref([ { name: "agency", align: "left", @@ -107,6 +103,17 @@ const columns = ref([ 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([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, ]); -const visibleColumns = ref([ +const baseVisibleColumns = ref([ "agency", "dateStart", "dateEnd", "commandNo", "document", + "lastUpdateFullName", "lastUpdatedAt", ]); +const columnsHistory = ref(baseColumns.value); +const visibleColumnsHistory = ref(baseVisibleColumns.value); + +/** Table*/ +const rows = ref([]); //รายการวินัย +const rowsMain = ref([]); //รายการวินัย +const mode = ref("table"); //การแสดงผล Table card +const filterKeyword = ref(""); //คำค้นหา + +const columns = ref( + baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName") +); +const visibleColumns = ref( + 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(() => { - + -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("modal", { required: true }); -const id = defineModel("id", { required: true }); - -const route = useRoute(); -const $q = useQuasar(); -const mixin = useCounterMixin(); -const { - showLoader, - hideLoader, - messageError, - date2Thai, - pathRegistryEmp, - onSearchDataTable, -} = mixin; - -const empType = ref(pathRegistryEmp(route.name?.toString() ?? "")); - -const filterKeyword = ref(""); //คำค้นหา -const rows = ref([]); //data history -const rowsMain = ref([]); //data history -const columns = ref([ - { - 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([ - "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 = ""; - } -}); - - - diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue index 29283c712..e3231224a 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue @@ -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(pathRegistryEmp(route.name?.toString() ?? "")); -//Table -const rows = ref([]); //รายการตำแหน่งเงินเดือน -const rowsMain = ref([]); //รายการตำแหน่งเงินเดือน -const keyword = ref(""); //คำค้นหา -const modalCommand = ref(false); -const command = ref(""); -const commandId = ref(""); -const baseColumns = ref([ +const baseColumns = ref([ { name: "commandDateAffect", align: "left", @@ -252,20 +245,35 @@ const baseColumns = ref([ 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([ +const baseVisibleColumns = ref([ "commandDateAffect", "posNo", "positionName", @@ -278,7 +286,29 @@ const visibleColumns = ref([ "commandDateSign", "organization", "remark", + "lastUpdateFullName", + "lastUpdatedAt", ]); + +//Table +const rows = ref([]); //รายการตำแหน่งเงินเดือน +const rowsMain = ref([]); //รายการตำแหน่งเงินเดือน +const keyword = ref(""); //คำค้นหา +const modalCommand = ref(false); +const command = ref(""); +const commandId = ref(""); + +const columns = ref( + baseColumns.value.filter( + (e: QTableColumn) => + e.name !== "lastUpdateFullName" && e.name !== "lastUpdatedAt" + ) +); +const visibleColumns = ref( + baseVisibleColumns.value.filter( + (e: string) => e !== "lastUpdateFullName" && e !== "lastUpdatedAt" + ) +); const pagination = ref({ sortBy: "", }); @@ -309,6 +339,9 @@ const formData = reactive({ remark: "", //หมายเหตุ }); +const columnsHistory = ref(baseColumns.value); +const visibleColumnsHistory = ref(baseVisibleColumns.value); + const modalDialogSalary = ref(false); //แสดง popup ตำแหน่งเงินเดือน const isStatusEdit = ref(false); //สถานะแก้ไขข้อมูลตำแหน่งเงินเดือน const salaryId = ref(""); //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 () => { - + -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("modal", { required: true }); -const salaryId = defineModel("salaryId", { required: true }); - -const empType = ref(pathRegistryEmp(route.name?.toString() ?? "")); - -const rows = ref([]); //รายการข้อมูลประวัติการแก้ไข -const rowsMain = ref([]); //รายการข้อมูลประวัติการแก้ไข -const keyword = ref(""); //คำค้นหา -const baseColumns = ref([ - { - 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([ - "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(); - } -); - - - -