diff --git a/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue b/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue index 6db8b64da..e22eeb689 100644 --- a/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue +++ b/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue @@ -8,11 +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 { RequestItemsObject } from "@/modules/04_registryPerson/interface/request/ProfesLicense"; import type { ResponseObject } from "@/modules/04_registryPerson/interface/response/ProfesLicense"; import dialogHeader from "@/components/DialogHeader.vue"; +import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue"; const route = useRoute(); const mixin = useCounterMixin(); @@ -26,6 +27,7 @@ const { date2Thai, pathRegistryEmp, onSearchDataTable, + convertDateToAPI, } = mixin; const id = ref(route.params.id.toString()); @@ -44,98 +46,7 @@ const dialogStatus = ref("create"); //สถานะการแก้ const editId = ref(""); //id ที่ต้องการแก้ไข //Table Main -const rows = ref([]); //รายการใบอนุญาตประกอบวิชาชีพ -const rowsMain = ref([]); //รายการใบอนุญาตประกอบวิชาชีพ -const keyword = ref(""); //คำค้นหา -const columns = ref([ - { - name: "certificateType", - align: "left", - label: "ชื่อใบอนุญาต", - sortable: true, - field: "certificateType", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "issuer", - align: "left", - label: "หน่วยงานผู้ออกใบอนุญาต", - sortable: true, - field: "issuer", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "certificateNo", - align: "left", - label: "เลขที่ใบอนุญาต", - sortable: true, - field: "certificateNo", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "issueDate", - align: "left", - label: "วันที่ออกใบอนุญาต", - sortable: true, - field: "issueDate", - 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: "expireDate", - align: "left", - label: "วันที่หมดอายุ", - sortable: true, - format: (v) => date2Thai(v), - field: "expireDate", - 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([ - "certificateType", - "issuer", - "certificateNo", - "issueDate", - "expireDate", - "lastUpdatedAt", -]); -const pagination = ref({ - sortBy: "lastUpdatedAt", -}); - -//Table ประวัติแก้ไขใบอนุญาตประกอบวิชาชีพ -const historyRows = ref([]); //รายการประวัติแก้ไขใบอนุญาตประกอบวิชาชีพ -const historyRowsMain = ref([]); //รายการประวัติแก้ไขใบอนุญาตประกอบวิชาชีพ - -const historyKeyword = ref(""); //คำค้นหาประวัติแก้ไข -const historyColumns = ref([ +const baseColumns = ref([ { name: "certificateType", align: "left", @@ -217,7 +128,7 @@ const historyColumns = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, ]); -const historyVisibleColumns = ref([ +const baseVisibleColumns = ref([ "certificateType", "issuer", "certificateNo", @@ -226,15 +137,30 @@ const historyVisibleColumns = ref([ "lastUpdateFullName", "lastUpdatedAt", ]); -const historyPagination = ref({ + +const rows = ref([]); //รายการใบอนุญาตประกอบวิชาชีพ +const rowsMain = ref([]); //รายการใบอนุญาตประกอบวิชาชีพ +const keyword = 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", }); +//Table ประวัติแก้ไขใบอนุญาตประกอบวิชาชีพ +const historyId = ref(""); +const columnsHistory = ref(baseColumns.value); +const visibleColumnsHistory = ref(baseVisibleColumns.value); + const profesLicenseData = reactive({ certificateType: "", //ชื่อใบอนุญาต issuer: "", //หน่วยงานผู้ออกใบอนุญาต certificateNo: "", //เลขที่ใบอนุญาต - issueDate: new Date(), //วันที่ออกใบอนุญาต + issueDate: null, //วันที่ออกใบอนุญาต expireDate: null, //วันที่หมดอายุ profileId: id.value, }); @@ -243,26 +169,49 @@ const profesLicenseData = reactive({ function onSubmit() { dialogConfirm( $q, - () => { - dialogStatus.value === "create" ? addData() : editData(editId.value); + async () => { + showLoader(); + const isEdit = dialogStatus.value === "create" ? false : true; + const url = isEdit + ? config.API.profileNewCertificateByCertificateId( + editId.value, + empType.value + ) + : config.API.profileNewCertificate(empType.value); + + const method = isEdit ? http.patch : http.post; + await method(url, { + ...profesLicenseData, + issueDate: convertDateToAPI(profesLicenseData.issueDate), + expireDate: convertDateToAPI(profesLicenseData.expireDate), + profileId: isEdit + ? undefined + : empType.value === "" + ? id.value + : undefined, + profileEmployeeId: isEdit + ? undefined + : empType.value !== "" + ? id.value + : undefined, + }) + .then(async () => { + await fetchData(id.value); + success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } -/** ปิด form ข้อมูลใบอนุญาตประกอบวิชาชีพ*/ -function closeDialog() { - dialog.value = false; -} - -/** ปิด popup ประวัติการแก้ไขข้อมูลใบอนุญาตประกอบวิชาชีพ*/ -function closeHistoryDialog() { - historyDialog.value = false; - historyRows.value = []; - historyKeyword.value = ""; -} - /** fetch ข้อมูลรายการใบอนุญาตประกอบวิชาชีพ*/ async function fetchData(id: string) { showLoader(); @@ -280,10 +229,15 @@ async function fetchData(id: string) { }); } +/** ปิด form ข้อมูลใบอนุญาตประกอบวิชาชีพ*/ +function closeDialog() { + dialog.value = false; +} + /** เคลียร์ form ข้อมูลใบอนุญาตประกอบวิชาชีพ*/ function clearForm() { profesLicenseData.expireDate = null; - profesLicenseData.issueDate = new Date(); + profesLicenseData.issueDate = null; profesLicenseData.certificateNo = ""; profesLicenseData.certificateType = ""; profesLicenseData.issuer = ""; @@ -293,7 +247,7 @@ function clearForm() { * เปิด form แก้ไขข้อมูลใบอนุญาตประกอบวิชาชีพ * @param row ข้อมูลใบอนุญาตประกอบวิชาชีพ */ -function editForm(row: any) { +function editForm(row: ResponseObject) { dialogStatus.value = "edit"; editId.value = row.id; profesLicenseData.certificateType = row.certificateType; @@ -304,72 +258,27 @@ function editForm(row: any) { dialog.value = true; } -/** - * เพิ่มรายการข้อมูลใบอนุญาตประกอบวิชาชีพ - */ -function addData() { - showLoader(); - http - .post(config.API.profileNewCertificate(empType.value), { - ...profesLicenseData, - profileId: empType.value === "" ? id.value : undefined, - profileEmployeeId: empType.value !== "" ? id.value : undefined, - }) - .then(async () => { - await fetchData(id.value); - await success($q, "บันทึกข้อมูลสำเร็จ"); - closeDialog(); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); -} - -/** - * แก้ไขข้อมูลใบอนุญาตประกอบวิชาชีพ - * @param idData รายการข้อมูลใบอนุญาตประกอบวิชาชีพ - */ -function editData(idData: string) { - showLoader(); - http - .patch( - config.API.profileNewCertificateByCertificateId(idData, empType.value), - { - ...profesLicenseData, - profileId: undefined, - } - ) - .then(async () => { - await fetchData(id.value); - await success($q, "บันทึกข้อมูลสำเร็จ"); - closeDialog(); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); +function onViewHistory(id: string) { + historyId.value = id; + historyDialog.value = true; } /** fetch ข้อมูลประวัติการแก้ไขข้อมูลใบอนุญาตประกอบวิชาชีพ*/ -function fetchHistoryData(id: string) { +async function fetchDataHistory() { showLoader(); - http - .get(config.API.profileNewCertificateHisByCertificateId(id, empType.value)) - .then(async (res) => { - historyRows.value = res.data.result; - historyRowsMain.value = res.data.result; - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); + try { + const res = await http.get( + config.API.profileNewCertificateHisByCertificateId( + historyId.value, + empType.value + ) + ); + return res.data.result; + } catch (err) { + messageError($q, err); + } finally { + hideLoader(); + } } function serchDataTable() { @@ -380,14 +289,6 @@ function serchDataTable() { ); } -function serchDataTableHistory() { - historyRows.value = onSearchDataTable( - historyKeyword.value, - historyRowsMain.value, - historyColumns.value ? historyColumns.value : [] - ); -} - /** * ทำงานเมื่อ Components ถูกเรียกใช้งาน */ @@ -503,9 +404,7 @@ onMounted(() => { round color="deep-purple" icon="mdi-history" - @click=" - () => (fetchHistoryData(props.row.id), (historyDialog = true)) - " + @click="() => onViewHistory(props.row.id)" > ประวัติแก้ไขใบอนุญาตประกอบวิชาชีพ @@ -544,9 +443,7 @@ onMounted(() => { round color="deep-purple" icon="mdi-history" - @click=" - () => (fetchHistoryData(props.row.id), (historyDialog = true)) - " + @click="() => onViewHistory(props.row.id)" > ประวัติแก้ไขใบอนุญาตประกอบวิชาชีพ @@ -737,79 +634,13 @@ onMounted(() => { - - - - - - -
- - - - - - -
- - - - -
-
-
+ diff --git a/src/modules/04_registryPerson/components/detail/Achievement/04_DeclarationHonor.vue b/src/modules/04_registryPerson/components/detail/Achievement/04_DeclarationHonor.vue index e64fa3808..58150d506 100644 --- a/src/modules/04_registryPerson/components/detail/Achievement/04_DeclarationHonor.vue +++ b/src/modules/04_registryPerson/components/detail/Achievement/04_DeclarationHonor.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 { RequestItemsObject } from "@/modules/04_registryPerson/interface/request/DeclarationHonor"; import type { DataOption, @@ -18,6 +18,7 @@ import type { import type { ResponseObject } from "@/modules/04_registryPerson/interface/response/DeclarationHonor"; import DialogHeader from "@/components/DialogHeader.vue"; +import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue"; const $q = useQuasar(); const route = useRoute(); @@ -31,6 +32,7 @@ const { dialogConfirm, pathRegistryEmp, onSearchDataTable, + convertDateToAPI, } = mixin; const profileId = ref( @@ -76,10 +78,7 @@ const modeView = ref("table"); //การแสดงผล Table,Card const modalHistory = ref(false); //แสดง popup ประวัติแก้ไข //Table Main -const rows = ref([]); -const rowsMain = ref([]); -const filterSearch = ref(""); -const columns = ref([ +const baseColumns = ref([ { name: "issueDate", align: "left", @@ -88,101 +87,8 @@ const columns = ref([ field: "issueDate", format(val, row) { return row.isDate - ? date2Thai(row.issueDate) - : new Date(row.issueDate).getFullYear() + 543; - }, - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "issuer", - align: "left", - label: "ผู้มีอำนาจลงนาม", - sortable: true, - field: "issuer", - 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: "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([ - "issuer", - "detail", - "issueDate", - "refCommandNo", - "refCommandDate", - "lastUpdatedAt", -]); -const pagination = ref({ - sortBy: "lastUpdatedAt", -}); - -//Table ประวัติแก้ไข -const rowsHistory = ref([]); -const rowsHistoryMain = ref([]); -const filterHistory = ref(""); -const columnsHistory = ref([ - { - name: "issueDate", - align: "left", - label: "วันที่ได้รับ", - sortable: true, - field: "issueDate", - format(val, row) { - return row.isDate - ? date2Thai(row.issueDate) - : new Date(row.issueDate).getFullYear() + 543; + ? date2Thai(row.issueDate).toString() + : (new Date(row.issueDate).getFullYear() + 543).toString(); }, headerStyle: "font-size: 14px", style: "font-size: 14px", @@ -260,7 +166,7 @@ const columnsHistory = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, ]); -const visibleColumnsHistory = ref([ +const baseVisibleColumns = ref([ "issuer", "detail", "issueDate", @@ -269,6 +175,27 @@ const visibleColumnsHistory = ref([ "lastUpdateFullName", "lastUpdatedAt", ]); + +const rows = ref([]); +const rowsMain = ref([]); +const filterSearch = 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", +}); + +//Table ประวัติแก้ไข +const rowsHistory = ref([]); +const rowsHistoryMain = ref([]); +const filterHistory = ref(""); +const historyId = ref(""); +const columnsHistory = ref(baseColumns.value); +const visibleColumnsHistory = ref(baseVisibleColumns.value); const historyPagination = ref({ sortBy: "lastUpdatedAt", }); @@ -303,7 +230,7 @@ async function addEditData(editStatus: boolean = false) { ? config.API.profileNewHonorById(id.value, empType.value) : config.API.profileNewHonor(empType.value); const method = editStatus ? "patch" : "post"; - const reqBody: RequestItemsObject = { + const reqBody = { ...declHonorForm, isUpload: !isEdit.value ? undefined : isUpload.value, profileEmployeeId: @@ -313,10 +240,10 @@ async function addEditData(editStatus: boolean = false) { isDate: declHonorForm.isDate === "true" ? true : false, issueDate: declHonorForm.isDate === "true" - ? declHonorForm.issueDate - : new Date(`${issueDateYear.value}-01-01`), + ? convertDateToAPI(declHonorForm.issueDate) + : convertDateToAPI(new Date(`${issueDateYear.value}-01-01`)), + refCommandDate: convertDateToAPI(declHonorForm.refCommandDate), }; - try { await http[method](url, reqBody).then(async (res) => { if ((fileUpload.value && id.value) || res.data.result) { @@ -324,7 +251,7 @@ async function addEditData(editStatus: boolean = false) { } }); await fetchData(); - await success($q, "บันทึกข้อมูลสำเร็จ"); + success($q, "บันทึกข้อมูลสำเร็จ"); modal.value = false; } catch (e) { messageError($q, e); @@ -469,15 +396,17 @@ async function clickClose() { /** fetch ช้อมูลประวัติการแก้ไขรายการข้อมูลประกาศเกียรติคุณ*/ async function clickHistory(row: ResponseObject) { + historyId.value = row.id; modalHistory.value = true; - filterSearch.value = ""; +} + +async function fetchDataHistory() { showLoader(); try { const res = await http.get( - config.API.profileNewHonorHisById(row.id, empType.value) + config.API.profileNewHonorHisById(historyId.value, empType.value) ); - rowsHistory.value = res.data.result; - rowsHistoryMain.value = res.data.result; + return res.data.result; } catch (e) { messageError($q, e); } finally { @@ -522,19 +451,12 @@ function serchDataTable() { ); } -function serchDataTableHistory() { - rowsHistory.value = onSearchDataTable( - filterHistory.value, - rowsHistoryMain.value, - columnsHistory.value ? columnsHistory.value : [] - ); -} - /** ทำงานเมื่อ Components ถูกเรียกใช้งาน*/ onMounted(() => { fetchData(); }); + diff --git a/src/modules/04_registryPerson/components/detail/Achievement/05_ResultsPerformance.vue b/src/modules/04_registryPerson/components/detail/Achievement/05_ResultsPerformance.vue index 5d4fb6d09..7fb80f998 100644 --- a/src/modules/04_registryPerson/components/detail/Achievement/05_ResultsPerformance.vue +++ b/src/modules/04_registryPerson/components/detail/Achievement/05_ResultsPerformance.vue @@ -9,7 +9,7 @@ import { useResultsPerformDataStore } from "@/modules/04_registryPerson/stores/R import http from "@/plugins/http"; import config from "@/app.config"; -import type { QTableProps } from "quasar"; +import type { QTableColumn } from "quasar"; import type { RequestItemsObject, DataOptions, @@ -18,6 +18,7 @@ import type { ResponseObject } from "@/modules/04_registryPerson/interface/respo import DialogHeader from "@/components/DialogHeader.vue"; import DialogDevelop from "@/modules/04_registryPerson/components/detail/Achievement/DialogDevelopmance.vue"; +import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue"; const $q = useQuasar(); const route = useRoute(); @@ -33,6 +34,7 @@ const { dialogConfirm, pathRegistryEmp, onSearchDataTable, + convertDateToAPI, } = mixin; const profileId = ref( @@ -80,266 +82,7 @@ const resPerformForm = reactive({ }); //Table ผลการประเมินการปฏิบัติราชการ -const rows = ref([]); -const rowsMain = ref([]); -const filterSearch = ref(""); -const columns = ref([ - { - 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 - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "year", - align: "left", - label: "ปีงบประมาณ", - sortable: true, - field: "year", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - format: (v) => { - return `${v ? Number(v) + 543 : "-"}`; - }, - sort: (a: string, b: string) => - a - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "period", - align: "left", - label: "รอบการประเมิน", - sortable: true, - field: "period", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - format: (v) => { - return ( - periodOp.value.find((item: DataOptions) => item.id === v)?.name || "-" - ); - }, - sort: (a: string, b: string) => - a - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "point1Total", - align: "left", - label: "ส่วนที่ 1 (น้ำหนัก)", - sortable: true, - field: "point1Total", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "point1", - align: "left", - label: "ผลประเมินส่วนที่ 1 (คะแนน)", - sortable: true, - field: "point1", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "point2Total", - align: "left", - label: "ส่วนที่ 2 (น้ำหนัก)", - sortable: true, - field: "point2Total", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "point2", - align: "left", - label: "ผลประเมินส่วนที่ 2 (คะแนน)", - sortable: true, - field: "point2", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "pointSumTotal", - align: "left", - label: "ผลรวม (น้ำหนัก)", - sortable: true, - field: "pointSumTotal", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "pointSum", - align: "left", - label: "ผลประเมินรวม (คะแนน)", - sortable: true, - field: "pointSum", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a - .toString() - .localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "name", - align: "left", - label: "ผลประเมิน", - sortable: true, - field: "name", - format(val, row) { - return `${textPoint(row.pointSum)} ${textRangePoint(row.pointSum)}`; - }, - 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", - 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([ - "point1Total", - "year", - "period", - "point1", - "point2Total", - "point2", - "pointSumTotal", - "pointSum", - "name", - "date", - "lastUpdatedAt", -]); -const pagination = ref({ - sortBy: "lastUpdatedAt", -}); - -//Table การพัฒนารายบุคคล (Individual Development Plan) -const rowsPlan = ref([]); -const filterSearchPlan = ref(""); -const columnsPlan = ref([ - { - name: "no", - align: "left", - label: "ลำดับ", - sortable: false, - field: "no", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - format: (v) => date2Thai(v), - }, - { - name: "name", - align: "left", - label: "ความรู้/ทักษะ/สมรรถนะที่ต้องได้รับการพัฒนา", - sortable: false, - field: "name", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "developmentProjects", - align: "left", - label: "วิธีการพัฒนา", - sortable: false, - field: "developmentProjects", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "developmentTarget", - align: "left", - label: "เป้าหมายการพัฒนา", - sortable: false, - field: "developmentTarget", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "developmentResults", - align: "left", - label: "วิธีการวัดผลการพัฒนา", - sortable: false, - field: "developmentResults", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "developmentReport", - align: "left", - label: "รายงานผลการพัฒนา", - sortable: false, - field: "developmentReport", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, -]); -const visibleColumnsPlan = ref([ - "no", - "name", - "developmentProjects", - "developmentTarget", - "developmentResults", - "developmentReport", -]); - -//Table ประวัติแก้ไข -const rowsHistory = ref([]); -const rowsHistoryMain = ref([]); -const filterHistory = ref(""); -const columnsHistory = ref([ +const baseColumns = ref([ { name: "date", align: "left", @@ -506,7 +249,7 @@ const columnsHistory = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, ]); -const visibleColumnsHistory = ref([ +const baseVisibleColumns = ref([ "point1Total", "year", "period", @@ -520,10 +263,106 @@ const visibleColumnsHistory = ref([ "lastUpdateFullName", "lastUpdatedAt", ]); -const historyPagination = ref({ + +const rows = ref([]); +const rowsMain = ref([]); +const filterSearch = 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", }); +//Table การพัฒนารายบุคคล (Individual Development Plan) +const rowsPlan = ref([]); +const filterSearchPlan = ref(""); +const columnsPlan = ref([ + { + name: "no", + align: "left", + label: "ลำดับ", + sortable: false, + field: "no", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + format: (v) => date2Thai(v), + }, + { + name: "name", + align: "left", + label: "ความรู้/ทักษะ/สมรรถนะที่ต้องได้รับการพัฒนา", + sortable: false, + field: "name", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "developmentProjects", + align: "left", + label: "วิธีการพัฒนา", + sortable: false, + field: "developmentProjects", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "developmentTarget", + align: "left", + label: "เป้าหมายการพัฒนา", + sortable: false, + field: "developmentTarget", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "developmentResults", + align: "left", + label: "วิธีการวัดผลการพัฒนา", + sortable: false, + field: "developmentResults", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "developmentReport", + align: "left", + label: "รายงานผลการพัฒนา", + sortable: false, + field: "developmentReport", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, +]); +const visibleColumnsPlan = ref([ + "no", + "name", + "developmentProjects", + "developmentTarget", + "developmentResults", + "developmentReport", +]); + +//Table ประวัติแก้ไข +const rowsHistory = ref([]); +const rowsHistoryMain = ref([]); +const historyId = ref(""); +const columnsHistory = ref(baseColumns.value); +const visibleColumnsHistory = ref(baseVisibleColumns.value); + /** fetch รายการข้อมูลผลการประเมินการปฏิบัติราชการ*/ async function fetchData() { if (!profileId.value) return; @@ -585,8 +424,9 @@ async function addEditData(editStatus: boolean = false) { ? config.API.profileNewAssessmentsById(id.value, empType.value) : config.API.profileNewAssessments(empType.value); const method = editStatus ? "patch" : "post"; - const reqBody: RequestItemsObject = { + const reqBody = { ...resPerformForm, + date: convertDateToAPI(resPerformForm.date), period: period.value, year: year.value, profileEmployeeId: @@ -636,16 +476,18 @@ async function clickClose() { /** fetch ช้อมูลประวัติการแก้ไขรายการข้อมูลผลการประเมินการปฏิบัติราชการ*/ async function clickHistory(row: ResponseObject) { + historyId.value = row.id; modalHistory.value = true; - filterSearch.value = ""; +} + +async function fetchDataHistory() { showLoader(); try { const res = await http.get( - config.API.profileNewAssessmentsHisById(row.id, empType.value) + config.API.profileNewAssessmentsHisById(historyId.value, empType.value) ); - rowsHistory.value = res.data.result; - rowsHistoryMain.value = res.data.result; + return res.data.result; } catch (e) { messageError($q, e); } finally { @@ -702,14 +544,6 @@ function serchDataTable() { ); } -function serchDataTableHistory() { - rowsHistory.value = onSearchDataTable( - filterHistory.value, - rowsHistoryMain.value, - columnsHistory.value ? columnsHistory.value : [] - ); -} - watch( () => paginationIdp.value.rowsPerPage, async () => { @@ -1391,78 +1225,13 @@ onMounted(async () => { - - - - - -
- - - - - -
- - > - - - -
-
-
+