diff --git a/src/modules/04_registryPerson/components/DialogHistory.vue b/src/modules/04_registryPerson/components/DialogHistory.vue index a7d3f4d95..15d41a880 100644 --- a/src/modules/04_registryPerson/components/DialogHistory.vue +++ b/src/modules/04_registryPerson/components/DialogHistory.vue @@ -33,10 +33,7 @@ const employeeClass = ref( const typeKeyword = ref(""); const Keyword = ref(""); const positionKeyword = ref(""); -const employeeClassOps = ref([ - { id: "officer", name: "ข้าราชการ กทม.สามัญ" }, - { id: "perm", name: "ลูกจ้างประจำ" }, -]); + //ตัวเลือกประเภทการค้นหา const typeKeywordOps = ref([ { id: "no", name: "ตำแหน่งเลขที่" }, @@ -97,14 +94,6 @@ const columns = ref([ ]); const rows = ref([]); -/** function เปลี่ยนประเภท*/ -function changeEmployeeClass() { - typeKeyword.value = ""; - Keyword.value = ""; - positionKeyword.value = ""; - rows.value = []; -} - /** * function ค้นหาประวัติถือครองตำแหน่ง * @param type ประเภทข่าราชการ @@ -186,27 +175,6 @@ function closeDialog() {
- -
+import { ref, watch } from "vue"; +import { useCounterMixin } from "@/stores/mixin"; + +import type { QTableColumn, QTableProps } from "quasar"; + +import DialogHeader from "@/components/DialogHeader.vue"; + +const { onSearchDataTable } = useCounterMixin(); + +const modal = defineModel("modal", { required: true }); +const title = defineModel("title", { required: true }); +const columns = defineModel("columns", { + required: true, +}); +const visibleColumnsMain = defineModel("visibleColumns", { + required: true, +}); + +const props = defineProps({ + fetchData: { type: Function, required: true }, +}); + +const filter = ref(""); +const rows = ref([]); +const dataMain = ref([]); +const visibleColumns = ref([]); +const pagination = ref({ + sortBy: "lastUpdatedAt", +}); + +async function fetchDataTable() { + visibleColumns.value = visibleColumnsMain.value; + const data = await props?.fetchData?.(); + dataMain.value = data; + rows.value = data; +} + +/** ฟังก์ค้นหาข้อมูลรายการประวัติแก้ไขข้อมูลส่วนตัว */ +function serchDataTable() { + rows.value = onSearchDataTable(filter.value, dataMain.value, columns.value); +} + +watch( + () => modal.value, + () => { + if (modal.value) { + fetchDataTable(); + } else { + filter.value = ""; + dataMain.value = []; + rows.value = []; + pagination.value.sortBy = "lastUpdatedAt"; + } + } +); + + + + + diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue index 9915ecf7b..ac0565fcf 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue @@ -1,5 +1,5 @@ @@ -509,7 +478,6 @@ onMounted(async () => { bordered virtual-scroll ref="table" - v-bind="attrs" :rows="rows" :columns="columns" :visible-columns="visibleColumns" diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/03_Address.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/03_Address.vue index 4aa8531f5..ec28446c5 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/03_Address.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/03_Address.vue @@ -9,13 +9,13 @@ import { useAddressDataStore } from "@/modules/04_registryPerson/stores/Address" 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 { ResponseObject } from "@/modules/04_registryPerson/interface/response/Address"; import type { RequestObject } from "@/modules/04_registryPerson/interface/request/Address"; import DialogHeader from "@/components/DialogHeader.vue"; - +import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue"; const $q = useQuasar(); const store = useAddressDataStore(); @@ -36,7 +36,6 @@ const { hideLoader, dialogConfirm, pathRegistryEmp, - onSearchDataTable, } = mixin; /** @@ -81,10 +80,7 @@ const dataLabel = { }; const modalHistory = ref(false); //แสดง Popup ประวัติแก้ไขข้อมูลที่อยู่ -const rowsHistory = ref([]); //ข้อมูลรายการประวัติแก้ไขข้อมูลที่อยู่ -const rowsHistoryMain = ref([]); //ข้อมูลรายการประวัติแก้ไขข้อมูลที่อยู่ -const filterHistory = ref(""); //คำค้นหา -const visibleColumnsHistory = ref([ +const visibleColumnsHistory = ref([ "currentAddress", "currentDistrict", "currentSubDistrict", @@ -99,7 +95,7 @@ const visibleColumnsHistory = ref([ "lastUpdateFullName", "lastUpdatedAt", ]); -const columnsHistory = ref([ +const columnsHistory = ref([ { name: "registrationAddress", align: "left", @@ -252,9 +248,6 @@ const columnsHistory = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, ]); -const pagination = ref({ - sortBy: "lastUpdatedAt", -}); /** * ฟังก์ชันดึงข้อมูลที่อยู่ @@ -470,26 +463,23 @@ function clickClose() { modal.value = false; } -/** - * ฟังก์ชันเปิด popup ประวัติแก้ไขข้อมูลที่อยู่ - * และดึงข้อมูลรายการประวัติแก้ไขข้อมูลที่อยู่ - */ +/** ฟังก์ชันเปิด popup ประวัติแก้ไขข้อมูลที่อยู่*/ async function clickHistory() { - showLoader(); modalHistory.value = true; - filterHistory.value = ""; - await http - .get(config.API.profileNewAddressHisById(profileId.value, empType.value)) - .then(async (res) => { - rowsHistory.value = await res.data.result; - rowsHistoryMain.value = await res.data.result; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); - }); +} + +async function fetchDataHistory() { + showLoader(); + try { + const res = await http.get( + config.API.profileNewAddressHisById(profileId.value, empType.value) + ); + const data = res.data.result; + return data; + } catch (err) { + } finally { + hideLoader(); + } } /** @@ -508,15 +498,6 @@ function sameAddressToggle(v: string) { } } -/** ฟังก์ค้นหาข้อมูลรายการประวัติแก้ไขข้อมูลที่อยู่ */ -function serchDataTable() { - rowsHistory.value = onSearchDataTable( - filterHistory.value, - rowsHistoryMain.value, - columnsHistory.value ? columnsHistory.value : [] - ); -} - /** ดูการเปลี่ยนแปลงที่อยู่ปัจจุบันตรงกับที่อยู่ตามทะเบียนบ้า*/ watch( () => sameAddress.value, @@ -904,74 +885,13 @@ onMounted(async () => { - - - - - - -
- - - - - -
- - > - - - -
-
-
+ diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue index efed70aa5..6305f3d9c 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.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 { DataOption } from "@/modules/04_registryPerson/interface/index/Main"; import type { FormPerson, @@ -17,6 +17,7 @@ import type { } from "@/modules/04_registryPerson/interface/index/family"; import DialogHeader from "@/components/DialogHeader.vue"; +import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue"; const $q = useQuasar(); const route = useRoute(); @@ -30,7 +31,6 @@ const { messageError, success, pathRegistryEmp, - onSearchDataTable, } = useCounterMixin(); /** props*/ @@ -43,9 +43,7 @@ const profileId = ref( const empType = ref(pathRegistryEmp(route.name?.toString() ?? "")); /** TableHisoty*/ -const rows = ref([]); -const rowsMain = ref([]); -const visibleColumns = ref([ +const visibleColumns = ref([ "statusMarital", "citizenId", "prefix", @@ -57,7 +55,7 @@ const visibleColumns = ref([ "lastUpdateFullName", "lastUpdatedAt", ]); -const columns = ref([ +const columns = ref([ { name: "statusMarital", align: "left", @@ -151,9 +149,6 @@ const columns = ref([ format: (val) => date2Thai(val, false, true), }, ]); -const pagination = ref({ - sortBy: "lastUpdatedAt", -}); /** ข้อมูล*/ const fatherData = reactive({ @@ -190,6 +185,7 @@ const modalHistory = ref(false); const filterHistory = ref(""); const titleForm = ref(""); const typeForm = ref(""); +const historyId = ref(""); const isEdit = ref(false); const childernId = ref(""); @@ -353,7 +349,6 @@ function closeDialog() { fromData.job = ""; fromData.lastNameOld = ""; fromData.statusMarital = ""; - rows.value = []; filterHistory.value = ""; } @@ -418,10 +413,9 @@ function onOpenDialogForm( * @param id */ async function onOpenDialogHistory(type: string, id: string = "") { - modalHistory.value = true; typeForm.value = type; - const historyId = type === "children" ? id : profileId.value; - await fetchHistory(historyId, type); + historyId.value = type === "children" ? id : profileId.value; + modalHistory.value = true; } /** function fetch ข้อมูลความสัมพันธ์ */ @@ -453,59 +447,41 @@ function filterSelectorRelation(val: string, update: Function) { }); } -/** - * function fetch ข้อมูลประวัติการแก้ไขข้อมูล - * @param id - * @param type - */ -async function fetchHistory(id: string, type: string) { +async function fetchDataHistory() { showLoader(); - await http - .get(config.API.profileFamilyHistory(id, empType.value, type)) - .then(async (res) => { - const data = await res.data.result; - rows.value = await data.map((e: any) => ({ - citizenId: e[`${type}CitizenId`], - prefix: e[`${type}Prefix`], - firstName: e[`${type}FirstName`], - lastName: e[`${type}LastName`], - job: e[`${type}Career`], - isLive: e[`${type}Live`], - lastNameOld: - type === "couple" - ? e.coupleLastNameOld - : type === "mother" - ? e.motherLastNameOld - : undefined, - lastUpdateFullName: e.lastUpdateFullName, - lastUpdatedAt: e.lastUpdatedAt, - statusMarital: type === "couple" ? e.relationship : undefined, - })); - rowsMain.value = rows.value; - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); -} + try { + const res = await http.get( + config.API.profileFamilyHistory( + historyId.value, + empType.value, + typeForm.value + ) + ); -/** ฟังก์ค้นหาข้อมูลรายการประวัติแก้ไขข้อมูล */ -function serchDataTable() { - const baseColumns = - typeForm.value === "couple" - ? columns.value - : typeForm.value === "mother" - ? columns.value?.filter((e) => e.name !== "statusMarital") - : columns.value?.filter( - (e) => e.name !== "lastNameOld" && e.name !== "statusMarital" - ); - rows.value = onSearchDataTable( - filterHistory.value, - rowsMain.value, - baseColumns ? baseColumns : [] - ); + const data = await res.data.result.map((e: any) => ({ + citizenId: e[`${typeForm.value}CitizenId`], + prefix: e[`${typeForm.value}Prefix`], + firstName: e[`${typeForm.value}FirstName`], + lastName: e[`${typeForm.value}LastName`], + job: e[`${typeForm.value}Career`], + isLive: e[`${typeForm.value}Live`], + lastNameOld: + typeForm.value === "couple" + ? e.coupleLastNameOld + : typeForm.value === "mother" + ? e.motherLastNameOld + : undefined, + lastUpdateFullName: e.lastUpdateFullName, + lastUpdatedAt: e.lastUpdatedAt, + statusMarital: typeForm.value === "couple" ? e.relationship : undefined, + })); + + return data; + } catch (err) { + messageError($q, err); + } finally { + hideLoader(); + } } /** ทำงานเมื่อ Components ถูกเรียกใช้งาน*/ @@ -1073,100 +1049,29 @@ onMounted(async () => { - - - - - - -
- - - - - -
- - - > - - - -
-
-
+ diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue index 0dc06d5c4..222fa2033 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue @@ -1,4 +1,3 @@ -div