From 6a3da944bc7303fdf4f2588819ca4f81edf04cef Mon Sep 17 00:00:00 2001 From: AnandaTon <125332905+anandaAiemvong@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:47:16 +0700 Subject: [PATCH] =?UTF-8?q?pinia=20store=20data=20=E0=B8=82=E0=B9=89?= =?UTF-8?q?=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5=E0=B8=AB=E0=B8=A5=E0=B8=B1?= =?UTF-8?q?=E0=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ขาด District /sub district --- src/api/manage/api.organization.ts | 229 +- src/api/manage/api.person.ts | 1 + .../components/organization/Fax.vue | 72 +- .../components/organization/Level.vue | 72 +- .../components/organization/Organization.vue | 70 +- .../components/organization/ShortName.vue | 78 +- .../components/organization/Status.vue | 72 +- .../components/organization/TelExternal.vue | 72 +- .../components/organization/TelInternal.vue | 72 +- .../components/organization/Type.vue | 72 +- .../01_metadata/components/person/Blood.vue | 67 +- .../components/person/Education.vue | 67 +- .../01_metadata/components/person/Gender.vue | 67 +- .../components/person/Province.vue | 67 +- .../components/person/Relationship.vue | 68 +- .../components/person/Religion.vue | 67 +- .../components/position/Executive.vue | 72 +- .../components/position/ExecutiveSide.vue | 74 +- .../01_metadata/components/position/Level.vue | 84 +- .../01_metadata/components/position/Line.vue | 68 +- .../components/position/PathSide.vue | 74 +- .../components/position/Status.vue | 72 +- .../01_metadata/components/position/Type.vue | 68 +- src/modules/01_metadata/store.ts | 2080 +++++++++++++++++ 24 files changed, 3026 insertions(+), 779 deletions(-) diff --git a/src/api/manage/api.organization.ts b/src/api/manage/api.organization.ts index 57d2fccbf..064a3d5e5 100644 --- a/src/api/manage/api.organization.ts +++ b/src/api/manage/api.organization.ts @@ -2,129 +2,130 @@ * api ระบบจัดการข้อมูลหลัก * เมนูย่อย: ข้อมูลโครงสร้างหน่วยงาน */ -import env from "../index" -const organization = `${env.API_URI}/metadata/organization/` -const organizationOrganization = `${env.API_URI}/metadata/organization-organization/` -const organizationShortName = `${env.API_URI}/metadata/organization-shortname/` -const organizationCode = `${env.API_URI_ORG_SERVICE}/PositionMaster/` -const organizationType = `${env.API_URI}/metadata/organization-type/` -const organizationLevel = `${env.API_URI}/metadata/organization-level/` -const organizationStatus = `${env.API_URI}/metadata/organization-status/` -const organizationAgency = `${env.API_URI}/metadata/organization-agency/` -const organizationGovernmentAgency = `${env.API_URI}/metadata/organization-government-agency/` -const organizationTelExternal = `${env.API_URI}/metadata/organization-tel-external/` -const organizationTelInternal = `${env.API_URI}/metadata/organization-tel-internal/` -const organizationFax = `${env.API_URI}/metadata/organization-fax/` -const dashbord = `${env.API_URI}/metadata/dashbord/` +import env from "../index"; +const organization = `${env.API_URI}/metadata/organization/`; +const organizationOrganization = `${env.API_URI}/metadata/organization-organization/`; +const organizationShortName = `${env.API_URI}/metadata/organization-shortname/`; +const organizationCode = `${env.API_URI_ORG_SERVICE}/PositionMaster/`; +const organizationType = `${env.API_URI}/metadata/organization-type/`; +const organizationLevel = `${env.API_URI}/metadata/organization-level/`; +const organizationStatus = `${env.API_URI}/metadata/organization-status/`; +const organizationAgency = `${env.API_URI}/metadata/organization-agency/`; +const organizationGovernmentAgency = `${env.API_URI}/metadata/organization-government-agency/`; +const organizationTelExternal = `${env.API_URI}/metadata/organization-tel-external/`; +const organizationTelInternal = `${env.API_URI}/metadata/organization-tel-internal/`; +const organizationFax = `${env.API_URI}/metadata/organization-fax/`; +const dashbord = `${env.API_URI}/metadata/dashbord/`; export default { - /** - * api จำนวนข้อมูลใน ระบบจัดการข้อมูลหลัก tab ย่อยแต่ละ tab - */ - organization, - countDashbordSubHistory: (type: number) => `${dashbord}${type}`, - countDashbordHistory: `${dashbord}`, + /** + * api จำนวนข้อมูลใน ระบบจัดการข้อมูลหลัก tab ย่อยแต่ละ tab + */ + organization, + countDashbordSubHistory: (type: number) => `${dashbord}${type}`, + countDashbordHistory: `${dashbord}`, - /** - * api หน่วยงาน - */ - listOrganizationOrganizationHistory: `${organizationOrganization}history`, - listOrganizationOrganizationHistoryId: (id: string) => - `${organizationOrganization}history/${id}`, - listOrganizationOrganizationPublished: `${organizationOrganization}history/published`, - listOrganizationOrganizationPublishedHistory: `${organizationOrganization}history/published-history`, + /** + * api หน่วยงาน + */ + organizationOrganization, + listOrganizationOrganizationHistory: `${organizationOrganization}history`, + listOrganizationOrganizationHistoryId: (id: string) => + `${organizationOrganization}history/${id}`, + listOrganizationOrganizationPublished: `${organizationOrganization}history/published`, + listOrganizationOrganizationPublishedHistory: `${organizationOrganization}history/published-history`, - /** - * api ชื่อย่อหน่วยงาน - */ - organizationShortName, - listOrganizationShortNameHistory: `${organizationShortName}history`, - listOrganizationShortNameHistoryId: (id: string) => - `${organizationShortName}history/${id}`, - listOrganizationShortNamePublished: `${organizationShortName}history/published`, - listOrganizationShortNamePublishedHistory: `${organizationShortName}history/published-history`, - organizationCode: `${organizationCode}organization-code`, - organizationGovernmentCode: (id: string) => - `${organizationCode}government/${id}`, - organizationAgencyCode: (id: string) => `${organizationCode}agency/${id}`, + /** + * api ชื่อย่อหน่วยงาน + */ + organizationShortName, + listOrganizationShortNameHistory: `${organizationShortName}history`, + listOrganizationShortNameHistoryId: (id: string) => + `${organizationShortName}history/${id}`, + listOrganizationShortNamePublished: `${organizationShortName}history/published`, + listOrganizationShortNamePublishedHistory: `${organizationShortName}history/published-history`, + organizationCode: `${organizationCode}organization-code`, + organizationGovernmentCode: (id: string) => + `${organizationCode}government/${id}`, + organizationAgencyCode: (id: string) => `${organizationCode}agency/${id}`, - /** - * api ประเภท - */ - organizationType, - listOrganizationTypeHistory: `${organizationType}history`, - listOrganizationTypeHistoryId: (id: string) => - `${organizationType}history/${id}`, - listOrganizationTypePublished: `${organizationType}history/published`, - listOrganizationTypePublishedHistory: `${organizationType}history/published-history`, + /** + * api ประเภท + */ + organizationType, + listOrganizationTypeHistory: `${organizationType}history`, + listOrganizationTypeHistoryId: (id: string) => + `${organizationType}history/${id}`, + listOrganizationTypePublished: `${organizationType}history/published`, + listOrganizationTypePublishedHistory: `${organizationType}history/published-history`, - /** - * api ระดับ - */ - organizationLevel, - listOrganizationLevelHistory: `${organizationLevel}history`, - listOrganizationLevelHistoryId: (id: string) => - `${organizationLevel}history/${id}`, - listOrganizationLevelPublished: `${organizationLevel}history/published`, - listOrganizationLevelPublishedHistory: `${organizationLevel}history/published-history`, + /** + * api ระดับ + */ + organizationLevel, + listOrganizationLevelHistory: `${organizationLevel}history`, + listOrganizationLevelHistoryId: (id: string) => + `${organizationLevel}history/${id}`, + listOrganizationLevelPublished: `${organizationLevel}history/published`, + listOrganizationLevelPublishedHistory: `${organizationLevel}history/published-history`, - /** - * api สถานะ - */ - organizationStatus, - listOrganizationStatusHistory: `${organizationStatus}history`, - listOrganizationStatusHistoryId: (id: string) => - `${organizationStatus}history/${id}`, - listOrganizationStatusPublished: `${organizationStatus}history/published`, - listOrganizationStatusPublishedHistory: `${organizationStatus}history/published-history`, + /** + * api สถานะ + */ + organizationStatus, + listOrganizationStatusHistory: `${organizationStatus}history`, + listOrganizationStatusHistoryId: (id: string) => + `${organizationStatus}history/${id}`, + listOrganizationStatusPublished: `${organizationStatus}history/published`, + listOrganizationStatusPublishedHistory: `${organizationStatus}history/published-history`, - /** - * api หน่วยงานต้นสังกัด - */ - organizationAgency, - listOrganizationAgencyHistory: `${organizationAgency}history`, - listOrganizationAgencyHistoryId: (id: string) => - `${organizationAgency}history/${id}`, - listOrganizationAgencyPublished: `${organizationAgency}history/published`, - listOrganizationAgencyPublishedHistory: `${organizationAgency}history/published-history`, + /** + * api หน่วยงานต้นสังกัด + */ + organizationAgency, + listOrganizationAgencyHistory: `${organizationAgency}history`, + listOrganizationAgencyHistoryId: (id: string) => + `${organizationAgency}history/${id}`, + listOrganizationAgencyPublished: `${organizationAgency}history/published`, + listOrganizationAgencyPublishedHistory: `${organizationAgency}history/published-history`, - /** - * api ส่วนราชการต้นสังกัด - */ - organizationGovernmentAgency, - listOrganizationGovernmentAgencyHistory: `${organizationGovernmentAgency}history`, - listOrganizationGovernmentAgencyHistoryId: (id: string) => - `${organizationGovernmentAgency}history/${id}`, - listOrganizationGovernmentAgencyPublished: `${organizationGovernmentAgency}history/published`, - listOrganizationGovernmentAgencyPublishedHistory: `${organizationGovernmentAgency}history/published-history`, + /** + * api ส่วนราชการต้นสังกัด + */ + organizationGovernmentAgency, + listOrganizationGovernmentAgencyHistory: `${organizationGovernmentAgency}history`, + listOrganizationGovernmentAgencyHistoryId: (id: string) => + `${organizationGovernmentAgency}history/${id}`, + listOrganizationGovernmentAgencyPublished: `${organizationGovernmentAgency}history/published`, + listOrganizationGovernmentAgencyPublishedHistory: `${organizationGovernmentAgency}history/published-history`, - /** - * api เบอร์ติดต่อภายนอก - */ - organizationTelExternal, - listOrganizationTelExternalHistory: `${organizationTelExternal}history`, - listOrganizationTelExternalHistoryId: (id: string) => - `${organizationTelExternal}history/${id}`, - listOrganizationTelExternalPublished: `${organizationTelExternal}history/published`, - listOrganizationTelExternalPublishedHistory: `${organizationTelExternal}history/published-history`, + /** + * api เบอร์ติดต่อภายนอก + */ + organizationTelExternal, + listOrganizationTelExternalHistory: `${organizationTelExternal}history`, + listOrganizationTelExternalHistoryId: (id: string) => + `${organizationTelExternal}history/${id}`, + listOrganizationTelExternalPublished: `${organizationTelExternal}history/published`, + listOrganizationTelExternalPublishedHistory: `${organizationTelExternal}history/published-history`, - /** - * api เบอร์ติดต่อภายใน - */ - organizationTelInternal, - listOrganizationTelInternalHistory: `${organizationTelInternal}history`, - listOrganizationTelInternalHistoryId: (id: string) => - `${organizationTelInternal}history/${id}`, - listOrganizationTelInternalPublished: `${organizationTelInternal}history/published`, - listOrganizationTelInternalPublishedHistory: `${organizationTelInternal}history/published-history`, + /** + * api เบอร์ติดต่อภายใน + */ + organizationTelInternal, + listOrganizationTelInternalHistory: `${organizationTelInternal}history`, + listOrganizationTelInternalHistoryId: (id: string) => + `${organizationTelInternal}history/${id}`, + listOrganizationTelInternalPublished: `${organizationTelInternal}history/published`, + listOrganizationTelInternalPublishedHistory: `${organizationTelInternal}history/published-history`, - /** - * api เบอร์โทรสาร - */ - organizationFax, - listOrganizationFaxHistory: `${organizationFax}history`, - listOrganizationFaxHistoryId: (id: string) => - `${organizationFax}history/${id}`, - listOrganizationFaxPublished: `${organizationFax}history/published`, - listOrganizationFaxPublishedHistory: `${organizationFax}history/published-history`, -} + /** + * api เบอร์โทรสาร + */ + organizationFax, + listOrganizationFaxHistory: `${organizationFax}history`, + listOrganizationFaxHistoryId: (id: string) => + `${organizationFax}history/${id}`, + listOrganizationFaxPublished: `${organizationFax}history/published`, + listOrganizationFaxPublishedHistory: `${organizationFax}history/published-history`, +}; diff --git a/src/api/manage/api.person.ts b/src/api/manage/api.person.ts index db71b3cd2..cdc0c73bd 100644 --- a/src/api/manage/api.person.ts +++ b/src/api/manage/api.person.ts @@ -29,6 +29,7 @@ export default { /** * api เขต */ + district, listDistrict: (id: string) => `${district}${id}`, listDistrictHistory: `${district}history`, listDistrictHistoryId: (id: string | string[]) => `${district}history/${id}`, diff --git a/src/modules/01_metadata/components/organization/Fax.vue b/src/modules/01_metadata/components/organization/Fax.vue index e778fbbae..4ca08c1cd 100644 --- a/src/modules/01_metadata/components/organization/Fax.vue +++ b/src/modules/01_metadata/components/organization/Fax.vue @@ -204,7 +204,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getOrganizationFax, + dataOrganizationFax, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -363,37 +368,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listOrganizationFaxHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getOrganizationFax(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listOrganizationFaxHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/organization/Level.vue b/src/modules/01_metadata/components/organization/Level.vue index e7fc9bdf9..6ff4a3224 100644 --- a/src/modules/01_metadata/components/organization/Level.vue +++ b/src/modules/01_metadata/components/organization/Level.vue @@ -204,7 +204,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getOrganizationLevel, + dataOrganizationLevel, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -363,37 +368,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listOrganizationLevelHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getOrganizationLevel(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listOrganizationLevelHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/organization/Organization.vue b/src/modules/01_metadata/components/organization/Organization.vue index 3848e3449..cc211ee3c 100644 --- a/src/modules/01_metadata/components/organization/Organization.vue +++ b/src/modules/01_metadata/components/organization/Organization.vue @@ -216,7 +216,8 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getOrganization, dataOrganization } = + store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -399,38 +400,43 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listOrganizationOrganizationHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - note: e.note, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getOrganization(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listOrganizationOrganizationHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // note: e.note, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/organization/ShortName.vue b/src/modules/01_metadata/components/organization/ShortName.vue index 5e0bb01c0..b145fc4cc 100644 --- a/src/modules/01_metadata/components/organization/ShortName.vue +++ b/src/modules/01_metadata/components/organization/ShortName.vue @@ -257,7 +257,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getOrganizationShortName, + dataOrganizationShortName, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -488,40 +493,45 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listOrganizationShortNameHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - agencyCode: e.agencyCode, - governmentCode: e.governmentCode, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - note: e.note, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getOrganizationShortName(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listOrganizationShortNameHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // agencyCode: e.agencyCode, + // governmentCode: e.governmentCode, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // note: e.note, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/organization/Status.vue b/src/modules/01_metadata/components/organization/Status.vue index f905e1047..fa4acb234 100644 --- a/src/modules/01_metadata/components/organization/Status.vue +++ b/src/modules/01_metadata/components/organization/Status.vue @@ -204,7 +204,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getOrganizationStatus, + dataOrganizationStatus, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -363,37 +368,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listOrganizationStatusHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getOrganizationStatus(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listOrganizationStatusHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/organization/TelExternal.vue b/src/modules/01_metadata/components/organization/TelExternal.vue index ea9e3131c..8998ce81d 100644 --- a/src/modules/01_metadata/components/organization/TelExternal.vue +++ b/src/modules/01_metadata/components/organization/TelExternal.vue @@ -204,7 +204,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getOrganizationTelExternal, + dataOrganizationTelExternal, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -363,37 +368,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listOrganizationTelExternalHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getOrganizationTelExternal(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listOrganizationTelExternalHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/organization/TelInternal.vue b/src/modules/01_metadata/components/organization/TelInternal.vue index fde6cea92..4d83ae654 100644 --- a/src/modules/01_metadata/components/organization/TelInternal.vue +++ b/src/modules/01_metadata/components/organization/TelInternal.vue @@ -204,7 +204,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getOrganizationTelInternal, + dataOrganizationTelInternal, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -363,37 +368,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listOrganizationTelInternalHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getOrganizationTelInternal(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listOrganizationTelInternalHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/organization/Type.vue b/src/modules/01_metadata/components/organization/Type.vue index 4badf69e7..ce056c12b 100644 --- a/src/modules/01_metadata/components/organization/Type.vue +++ b/src/modules/01_metadata/components/organization/Type.vue @@ -204,7 +204,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getOrganizationType, + dataOrganizationType, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -363,37 +368,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listOrganizationTypeHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getOrganizationType(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listOrganizationTypeHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/person/Blood.vue b/src/modules/01_metadata/components/person/Blood.vue index 6fda942df..70f5ef86a 100644 --- a/src/modules/01_metadata/components/person/Blood.vue +++ b/src/modules/01_metadata/components/person/Blood.vue @@ -208,7 +208,7 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getBlood, dataBlood } = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -367,37 +367,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listBloodGroupHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getBlood(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listBloodGroupHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/person/Education.vue b/src/modules/01_metadata/components/person/Education.vue index a4a696381..807f08b4c 100644 --- a/src/modules/01_metadata/components/person/Education.vue +++ b/src/modules/01_metadata/components/person/Education.vue @@ -205,7 +205,7 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getEducation, dataEducation } = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -364,37 +364,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listEducationLevelHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getEducation(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listEducationLevelHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/person/Gender.vue b/src/modules/01_metadata/components/person/Gender.vue index 40ffa0e28..926c88f66 100644 --- a/src/modules/01_metadata/components/person/Gender.vue +++ b/src/modules/01_metadata/components/person/Gender.vue @@ -205,7 +205,7 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getGender, dataGenders } = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -364,37 +364,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listGenderHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getGender(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listGenderHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/person/Province.vue b/src/modules/01_metadata/components/person/Province.vue index 07cfdb53d..3bad1e2e4 100644 --- a/src/modules/01_metadata/components/person/Province.vue +++ b/src/modules/01_metadata/components/person/Province.vue @@ -217,7 +217,7 @@ const { loaderPage } = dataStore; //ขึ้นหน้า load ขณะเ const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getProvince, dataProvince } = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -376,37 +376,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listProvinceHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getProvince(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listProvinceHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/person/Relationship.vue b/src/modules/01_metadata/components/person/Relationship.vue index 31f56149f..563424270 100644 --- a/src/modules/01_metadata/components/person/Relationship.vue +++ b/src/modules/01_metadata/components/person/Relationship.vue @@ -205,7 +205,8 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getRelationship, dataRelationship } = + store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -364,37 +365,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listRelationshipHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getRelationship(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listRelationshipHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/person/Religion.vue b/src/modules/01_metadata/components/person/Religion.vue index dc5ecde94..dcbe43be5 100644 --- a/src/modules/01_metadata/components/person/Religion.vue +++ b/src/modules/01_metadata/components/person/Religion.vue @@ -205,7 +205,7 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getReligion, dataReligion } = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -364,37 +364,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listReligionHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getReligion(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listReligionHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/position/Executive.vue b/src/modules/01_metadata/components/position/Executive.vue index 6d1ccc198..e1b406282 100644 --- a/src/modules/01_metadata/components/position/Executive.vue +++ b/src/modules/01_metadata/components/position/Executive.vue @@ -205,7 +205,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getPositionExecutive, + dataPositionExecutive, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -364,37 +369,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listPositionExecutiveHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getPositionExecutive(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listPositionExecutiveHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/position/ExecutiveSide.vue b/src/modules/01_metadata/components/position/ExecutiveSide.vue index 0598667c8..a601a0d88 100644 --- a/src/modules/01_metadata/components/position/ExecutiveSide.vue +++ b/src/modules/01_metadata/components/position/ExecutiveSide.vue @@ -217,7 +217,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getPositionExecutiveSide, + dataPositionExecutiveSide, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -400,38 +405,43 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listPositionExecutiveSideHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - note: e.note, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getPositionExecutiveSide(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listPositionExecutiveSideHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // note: e.note, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/position/Level.vue b/src/modules/01_metadata/components/position/Level.vue index 73210d632..9ba9bd4ff 100644 --- a/src/modules/01_metadata/components/position/Level.vue +++ b/src/modules/01_metadata/components/position/Level.vue @@ -268,7 +268,8 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getPositionLevel, dataPositionLevel } = + store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -475,45 +476,50 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listPositionLevelHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - level: e.level, - name: e.name, - shortName: e.shortName, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - rows.value.sort( - ( - firstItem: RequestItemsHistoryObject, - secondItem: RequestItemsHistoryObject - ) => firstItem.level - secondItem.level - ); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getPositionLevel(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listPositionLevelHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // level: e.level, + // name: e.name, + // shortName: e.shortName, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // rows.value.sort( + // ( + // firstItem: RequestItemsHistoryObject, + // secondItem: RequestItemsHistoryObject + // ) => firstItem.level - secondItem.level + // ); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/position/Line.vue b/src/modules/01_metadata/components/position/Line.vue index 7801b6b5a..4ed4ec1ce 100644 --- a/src/modules/01_metadata/components/position/Line.vue +++ b/src/modules/01_metadata/components/position/Line.vue @@ -205,7 +205,8 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getPositionLine, dataPositionLine } = + store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -364,37 +365,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listPositionLineHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getPositionLine(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listPositionLineHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/position/PathSide.vue b/src/modules/01_metadata/components/position/PathSide.vue index eafb36d93..98f8ef868 100644 --- a/src/modules/01_metadata/components/position/PathSide.vue +++ b/src/modules/01_metadata/components/position/PathSide.vue @@ -217,7 +217,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getPositionPathSide, + dataPositionPathSide, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -400,38 +405,43 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listPositionSideHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - note: e.note, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getPositionPathSide(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listPositionSideHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // note: e.note, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/position/Status.vue b/src/modules/01_metadata/components/position/Status.vue index b0bb855ac..2adf4c7be 100644 --- a/src/modules/01_metadata/components/position/Status.vue +++ b/src/modules/01_metadata/components/position/Status.vue @@ -205,7 +205,12 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { + manageData, + changeManageColumns, + getPositionStatus, + dataPositionStatus, +} = store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -364,37 +369,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listPositionStatusHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getPositionStatus(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listPositionStatusHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/components/position/Type.vue b/src/modules/01_metadata/components/position/Type.vue index 736ece356..d3c92bed5 100644 --- a/src/modules/01_metadata/components/position/Type.vue +++ b/src/modules/01_metadata/components/position/Type.vue @@ -205,7 +205,8 @@ const { loaderPage } = dataStore; const mixin = useCounterMixin(); const { success, dateText, messageError, showLoader, hideLoader } = mixin; const store = useManageDataStore(); -const { manageData, changeManageColumns } = store; +const { manageData, changeManageColumns, getPositionType, dataPositionType } = + store; const rows = ref([]); //list data table const rowsHistory = ref([]); //select data history const rawHistory = ref([]); //raw data history @@ -364,37 +365,42 @@ const $q = useQuasar(); /** * ฟังก์ชัน get data ล่าสุด */ -const fetchData = async () => { +const fetchData = async (load: boolean = false) => { await props.fetchDataComponent(); - rows.value.splice(0); - showLoader(); - await http - .get(config.API.listPositionTypeHistory) - .then((res) => { - let data = res.data.result; - version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ - idVersion.value = data.id; //เลข id ใน mongodb - data.items.map((e: RequestItemsHistoryObject) => { - rows.value.push({ - id: e.id, - name: e.name, - createdAt: e.createdAt, - lastUpdatedAt: e.lastUpdatedAt, - lastUpdateFullName: e.lastUpdateFullName, - isActive: e.isActive, - createdFullName: e.createdFullName, - createdUserId: e.createdUserId, - lastUpdateUserId: e.lastUpdateUserId, - }); - }); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - updateData.value = false; - hideLoader(); - }); + const result = await getPositionType(false, load); + version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + idVersion.value = result.idversion; //เลข id ใน mongodb + rows.value = result.data; + updateData.value = false; + // rows.value.splice(0); + // showLoader(); + // await http + // .get(config.API.listPositionTypeHistory) + // .then((res) => { + // let data = res.data.result; + // version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + // idVersion.value = data.id; //เลข id ใน mongodb + // data.items.map((e: RequestItemsHistoryObject) => { + // rows.value.push({ + // id: e.id, + // name: e.name, + // createdAt: e.createdAt, + // lastUpdatedAt: e.lastUpdatedAt, + // lastUpdateFullName: e.lastUpdateFullName, + // isActive: e.isActive, + // createdFullName: e.createdFullName, + // createdUserId: e.createdUserId, + // lastUpdateUserId: e.lastUpdateUserId, + // }); + // }); + // }) + // .catch((e) => { + // messageError($q, e); + // }) + // .finally(() => { + // updateData.value = false; + // hideLoader(); + // }); }; /** diff --git a/src/modules/01_metadata/store.ts b/src/modules/01_metadata/store.ts index 01e310555..83712a69d 100644 --- a/src/modules/01_metadata/store.ts +++ b/src/modules/01_metadata/store.ts @@ -5,6 +5,13 @@ import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import type { RequestItemsHistoryObject } from "@/modules/01_metadata/interface/request/person/Prefix"; +import type { RequestItemsHistoryObject as bloodResponse } from "@/modules/01_metadata/interface/request/person/Blood"; +import type { RequestItemsHistoryObject as genderResponse } from "@/modules/01_metadata/interface/request/person/Gender"; +import type { RequestItemsHistoryObject as religionResponse } from "@/modules/01_metadata/interface/request/person/Religion"; +import type { RequestItemsHistoryObject as relationshipResponse } from "@/modules/01_metadata/interface/request/person/Relationship"; +import type { RequestItemsHistoryObject as educationResponse } from "@/modules/01_metadata/interface/request/person/Education"; +import type { RequestItemsHistoryObject as provinceResponse } from "@/modules/01_metadata/interface/request/person/Province"; + import type { RequestItemsHistoryObject as InsigniaResponse } from "@/modules/01_metadata/interface/request/insignia/Insignia"; import type { RequestItemsHistoryObject as InsigniaTypeResponse } from "@/modules/01_metadata/interface/request/insignia/InsigniaType"; import type { RequestItemsHistoryObject as positionEmployeeResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Position"; @@ -14,6 +21,21 @@ import type { RequestItemsHistoryObject as positionEmployeeLineResponse } from " import type { RequestItemsHistoryObject as positionEmployeeLevelResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Level"; import type { RequestItemsHistoryObject as positionEmployeeStatusResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Status"; import type { RequestItemsHistoryObject as positionPathResponse } from "@/modules/01_metadata/interface/request/position/Path"; +import type { RequestItemsHistoryObject as positionPathSideResponse } from "@/modules/01_metadata/interface/request/position/PathSide"; +import type { RequestItemsHistoryObject as positionExecutiveResponse } from "@/modules/01_metadata/interface/request/position/Executive"; +import type { RequestItemsHistoryObject as positionExecutiveSideResponse } from "@/modules/01_metadata/interface/request/position/ExecutiveSide"; +import type { RequestItemsHistoryObject as positionTypeResponse } from "@/modules/01_metadata/interface/request/position/Type"; +import type { RequestItemsHistoryObject as positionLineResponse } from "@/modules/01_metadata/interface/request/position/Line"; +import type { RequestItemsHistoryObject as positionLevelResponse } from "@/modules/01_metadata/interface/request/position/Level"; +import type { RequestItemsHistoryObject as positionStatusResponse } from "@/modules/01_metadata/interface/request/position/Status"; +import type { RequestItemsHistoryObject as organizationResponse } from "@/modules/01_metadata/interface/request/organization/Organization"; +import type { RequestItemsHistoryObject as organizationShortNameResponse } from "@/modules/01_metadata/interface/request/organization/ShortName"; +import type { RequestItemsHistoryObject as organizationTypeResponse } from "@/modules/01_metadata/interface/request/organization/Type"; +import type { RequestItemsHistoryObject as organizationLevelResponse } from "@/modules/01_metadata/interface/request/organization/Level"; +import type { RequestItemsHistoryObject as organizationStatusResponse } from "@/modules/01_metadata/interface/request/organization/Status"; +import type { RequestItemsHistoryObject as organizationTelInternalResponse } from "@/modules/01_metadata/interface/request/organization/TelInternal"; +import type { RequestItemsHistoryObject as organizationTelExternalResponse } from "@/modules/01_metadata/interface/request/organization/TelExternal"; +import type { RequestItemsHistoryObject as organizationFaxResponse } from "@/modules/01_metadata/interface/request/organization/Fax"; const $q = useQuasar(); const mixin = useCounterMixin(); @@ -22,6 +44,19 @@ const { success, messageError, showLoader, hideLoader } = mixin; export const useManageDataStore = defineStore("manage", () => { const dataPrefix = ref([]); //list data table const draftPrefix = ref([]); //list data table + const dataBlood = ref([]); //list data table + const draftBlood = ref([]); //list data table + const dataGender = ref([]); //list data table + const draftGender = ref([]); //list data table + const dataReligion = ref([]); //list data table + const draftReligion = ref([]); //list data table + const dataRelationship = ref([]); //list data table + const draftRelationship = ref([]); //list data table + const dataEducation = ref([]); //list data table + const draftEducation = ref([]); //list data table + const dataProvince = ref([]); //list data table + const draftProvince = ref([]); //list data table + const dataInsignia = ref([]); //list data table const draftInsignia = ref([]); //list data table const dataInsigniaType = ref([]); //list data table @@ -40,6 +75,44 @@ export const useManageDataStore = defineStore("manage", () => { const draftPositionEmployeeStatus = ref([]); //list data table const dataPositionPath = ref([]); //list data table const draftPositionPath = ref([]); //list data table + const dataPositionPathSide = ref([]); //list data table + const draftPositionPathSide = ref([]); //list data table + const dataPositionExecutive = ref([]); //list data table + const draftPositionExecutive = ref([]); //list data table + const dataPositionExecutiveSide = ref([]); //list data table + const draftPositionExecutiveSide = ref([]); //list data table + const dataPositionType = ref([]); //list data table + const draftPositionType = ref([]); //list data table + const dataPositionLine = ref([]); //list data table + const draftPositionLine = ref([]); //list data table + const dataPositionLevel = ref([]); //list data table + const draftPositionLevel = ref([]); //list data table + const dataPositionStatus = ref([]); //list data table + const draftPositionStatus = ref([]); //list data table + const dataOrganization = ref([]); //list data table + const draftOrganization = ref([]); //list data table + const dataOrganizationShortName = ref([]); //list data table + const draftOrganizationShortName = ref([]); //list data table + const dataOrganizationType = ref([]); //list data table + const draftOrganizationType = ref([]); //list data table + const dataOrganizationLevel = ref([]); //list data table + const draftOrganizationLevel = ref([]); //list data table + const dataOrganizationStatus = ref([]); //list data table + const draftOrganizationStatus = ref([]); //list data table + const dataOrganizationTelInternal = ref( + [] + ); //list data table + const draftOrganizationTelInternal = ref( + [] + ); //list data table + const dataOrganizationTelExternal = ref( + [] + ); //list data table + const draftOrganizationTelExternal = ref( + [] + ); //list data table + const dataOrganizationFax = ref([]); //list data table + const draftOrganizationFax = ref([]); //list data table const storeIdVersion = ref(""); //id data ใน mongodb const storeVersion = ref("published"); //รายการข้อมูลล่าสุดได้เผยแพร่หรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ @@ -297,6 +370,180 @@ export const useManageDataStore = defineStore("manage", () => { } }; + const getBlood = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataBlood.value.length === 0) { + await fetchBlood(true, selector); + return { + data: draftBlood.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchBlood(true, selector); + return { + data: draftBlood.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftBlood.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getGender = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataGender.value.length === 0) { + await fetchGender(true, selector); + return { + data: draftGender.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchGender(true, selector); + return { + data: draftGender.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftGender.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getReligion = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataReligion.value.length === 0) { + await fetchReligion(true, selector); + return { + data: draftReligion.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchReligion(true, selector); + return { + data: draftReligion.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftReligion.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getRelationship = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataRelationship.value.length === 0) { + await fetchRelationship(true, selector); + return { + data: draftRelationship.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchRelationship(true, selector); + return { + data: draftRelationship.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftRelationship.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getEducation = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataEducation.value.length === 0) { + await fetchEducation(true, selector); + return { + data: draftEducation.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchEducation(true, selector); + return { + data: draftEducation.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftEducation.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getProvince = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataProvince.value.length === 0) { + await fetchProvince(true, selector); + return { + data: draftProvince.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchProvince(true, selector); + return { + data: draftProvince.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftProvince.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + const getInsigniaType = async ( selector: boolean = false, newFetch: boolean = false @@ -558,6 +805,441 @@ export const useManageDataStore = defineStore("manage", () => { } }; + const getPositionExecutive = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataPositionExecutive.value.length === 0) { + await fetchPositionExecutive(true, selector); + return { + data: draftPositionExecutive.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchPositionExecutive(true, selector); + return { + data: draftPositionExecutive.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftPositionExecutive.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getPositionExecutiveSide = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataPositionExecutiveSide.value.length === 0) { + await fetchPositionExecutiveSide(true, selector); + return { + data: draftPositionExecutiveSide.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchPositionExecutiveSide(true, selector); + return { + data: draftPositionExecutiveSide.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftPositionExecutiveSide.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getPositionPathSide = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataPositionPathSide.value.length === 0) { + await fetchPositionPathSide(true, selector); + return { + data: draftPositionPathSide.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchPositionPathSide(true, selector); + return { + data: draftPositionPathSide.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftPositionPathSide.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getPositionType = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataPositionType.value.length === 0) { + await fetchPositionType(true, selector); + return { + data: draftPositionType.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchPositionType(true, selector); + return { + data: draftPositionType.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftPositionType.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getPositionLine = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataPositionLine.value.length === 0) { + await fetchPositionLine(true, selector); + return { + data: draftPositionLine.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchPositionLine(true, selector); + return { + data: draftPositionLine.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftPositionLine.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getPositionLevel = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataPositionLevel.value.length === 0) { + await fetchPositionLevel(true, selector); + return { + data: draftPositionLevel.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchPositionLevel(true, selector); + return { + data: draftPositionLevel.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftPositionLevel.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getPositionStatus = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataPositionStatus.value.length === 0) { + await fetchPositionStatus(true, selector); + return { + data: draftPositionStatus.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchPositionStatus(true, selector); + return { + data: draftPositionStatus.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftPositionStatus.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getOrganization = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataOrganization.value.length === 0) { + await fetchOrganization(true, selector); + return { + data: draftOrganization.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchOrganization(true, selector); + return { + data: draftOrganization.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftOrganization.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getOrganizationShortName = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataOrganizationShortName.value.length === 0) { + await fetchOrganizationShortName(true, selector); + return { + data: draftOrganizationShortName.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchOrganizationShortName(true, selector); + return { + data: draftOrganizationShortName.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftOrganizationShortName.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getOrganizationType = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataOrganizationType.value.length === 0) { + await fetchOrganizationType(true, selector); + return { + data: draftOrganizationType.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchOrganizationType(true, selector); + return { + data: draftOrganizationType.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftOrganizationType.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getOrganizationLevel = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataOrganizationLevel.value.length === 0) { + await fetchOrganizationLevel(true, selector); + return { + data: draftOrganizationLevel.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchOrganizationLevel(true, selector); + return { + data: draftOrganizationLevel.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftOrganizationLevel.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getOrganizationStatus = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataOrganizationStatus.value.length === 0) { + await fetchOrganizationStatus(true, selector); + return { + data: draftOrganizationStatus.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchOrganizationStatus(true, selector); + return { + data: draftOrganizationStatus.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftOrganizationStatus.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getOrganizationTelInternal = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataOrganizationTelInternal.value.length === 0) { + await fetchOrganizationTelInternal(true, selector); + return { + data: draftOrganizationTelInternal.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchOrganizationTelInternal(true, selector); + return { + data: draftOrganizationTelInternal.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftOrganizationTelInternal.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getOrganizationTelExternal = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataOrganizationTelExternal.value.length === 0) { + await fetchOrganizationTelExternal(true, selector); + return { + data: draftOrganizationTelExternal.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchOrganizationTelExternal(true, selector); + return { + data: draftOrganizationTelExternal.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftOrganizationTelExternal.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + + const getOrganizationFax = async ( + selector: boolean = false, + newFetch: boolean = false + ) => { + if (dataOrganizationFax.value.length === 0) { + await fetchOrganizationFax(true, selector); + return { + data: draftOrganizationFax.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + if (newFetch) { + await fetchOrganizationFax(true, selector); + return { + data: draftOrganizationFax.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } else { + return { + data: draftOrganizationFax.value, + version: storeVersion.value, + idversion: storeIdVersion.value, + }; + } + } + }; + const fetchPrefix = async (loader: boolean, selector: boolean) => { let apiPrefix = ""; if (loader) { @@ -605,6 +1287,384 @@ export const useManageDataStore = defineStore("manage", () => { }); }; + const fetchBlood = async (loader: boolean, selector: boolean) => { + let apiBlood = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiBlood = config.API.bloodGroup; + } else { + apiBlood = config.API.listBloodGroupHistory; + } + await http + .get(apiBlood) + .then((res) => { + const data = res.data.result; + let rows: bloodResponse[] = []; + if (selector) { + data.map((e: bloodResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: bloodResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftBlood.value = rows; + if (loader) { + dataBlood.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchGender = async (loader: boolean, selector: boolean) => { + let apiGender = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiGender = config.API.gender; + } else { + apiGender = config.API.listGenderHistory; + } + await http + .get(apiGender) + .then((res) => { + const data = res.data.result; + let rows: genderResponse[] = []; + if (selector) { + data.map((e: genderResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: genderResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftGender.value = rows; + if (loader) { + dataGender.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchReligion = async (loader: boolean, selector: boolean) => { + let apiReligion = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiReligion = config.API.religion; + } else { + apiReligion = config.API.listReligionHistory; + } + await http + .get(apiReligion) + .then((res) => { + const data = res.data.result; + let rows: religionResponse[] = []; + if (selector) { + data.map((e: religionResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: religionResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftReligion.value = rows; + if (loader) { + dataReligion.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchRelationship = async (loader: boolean, selector: boolean) => { + let apiRelationship = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiRelationship = config.API.relationship; + } else { + apiRelationship = config.API.listRelationshipHistory; + } + await http + .get(apiRelationship) + .then((res) => { + const data = res.data.result; + let rows: relationshipResponse[] = []; + if (selector) { + data.map((e: relationshipResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: relationshipResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftRelationship.value = rows; + if (loader) { + dataRelationship.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchEducation = async (loader: boolean, selector: boolean) => { + let apiEducation = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiEducation = config.API.educationLevel; + } else { + apiEducation = config.API.listEducationLevelHistory; + } + await http + .get(apiEducation) + .then((res) => { + const data = res.data.result; + let rows: educationResponse[] = []; + if (selector) { + data.map((e: educationResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: educationResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftEducation.value = rows; + if (loader) { + dataEducation.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchProvince = async (loader: boolean, selector: boolean) => { + let apiProvince = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiProvince = config.API.province; + } else { + apiProvince = config.API.listProvinceHistory; + } + await http + .get(apiProvince) + .then((res) => { + const data = res.data.result; + let rows: provinceResponse[] = []; + if (selector) { + data.map((e: provinceResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: provinceResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftProvince.value = rows; + if (loader) { + dataProvince.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + const fetchInsignia = async (loader: boolean, selector: boolean) => { let apiInsignia = ""; if (loader) { @@ -1202,8 +2262,992 @@ export const useManageDataStore = defineStore("manage", () => { }); }; + const fetchPositionPathSide = async (loader: boolean, selector: boolean) => { + let apiPositionPathSide = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiPositionPathSide = config.API.positionSide; + } else { + apiPositionPathSide = config.API.listPositionSideHistory; + } + await http + .get(apiPositionPathSide) + .then((res) => { + const data = res.data.result; + let rows: positionPathSideResponse[] = []; + if (selector) { + data.map((e: positionPathSideResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + note: e.note, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: positionPathSideResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + note: e.note, + }); + }); + } + + draftPositionPathSide.value = rows; + if (loader) { + dataPositionPathSide.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchPositionExecutive = async (loader: boolean, selector: boolean) => { + let apiPositionExecutive = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiPositionExecutive = config.API.positionExecutive; + } else { + apiPositionExecutive = config.API.listPositionExecutiveHistory; + } + await http + .get(apiPositionExecutive) + .then((res) => { + const data = res.data.result; + let rows: positionExecutiveResponse[] = []; + if (selector) { + data.map((e: positionExecutiveResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: positionExecutiveResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftPositionExecutive.value = rows; + if (loader) { + dataPositionExecutive.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchPositionExecutiveSide = async ( + loader: boolean, + selector: boolean + ) => { + let apiPositionExecutiveSide = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiPositionExecutiveSide = config.API.positionExecutiveSide; + } else { + apiPositionExecutiveSide = config.API.listPositionExecutiveSideHistory; + } + await http + .get(apiPositionExecutiveSide) + .then((res) => { + const data = res.data.result; + let rows: positionExecutiveSideResponse[] = []; + if (selector) { + data.map((e: positionExecutiveSideResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + note: e.note, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: positionExecutiveSideResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + note: e.note, + }); + }); + } + + draftPositionExecutiveSide.value = rows; + if (loader) { + dataPositionExecutiveSide.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchPositionType = async (loader: boolean, selector: boolean) => { + let apiPositionType = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiPositionType = config.API.positionType; + } else { + apiPositionType = config.API.listPositionTypeHistory; + } + await http + .get(apiPositionType) + .then((res) => { + const data = res.data.result; + let rows: positionTypeResponse[] = []; + if (selector) { + data.map((e: positionTypeResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: positionTypeResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftPositionType.value = rows; + if (loader) { + dataPositionType.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchPositionLine = async (loader: boolean, selector: boolean) => { + let apiPositionLine = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiPositionLine = config.API.positionLine; + } else { + apiPositionLine = config.API.listPositionLineHistory; + } + await http + .get(apiPositionLine) + .then((res) => { + const data = res.data.result; + let rows: positionLineResponse[] = []; + if (selector) { + data.map((e: positionLineResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: positionLineResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftPositionLine.value = rows; + if (loader) { + dataPositionLine.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchPositionLevel = async (loader: boolean, selector: boolean) => { + let apiPositionLevel = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiPositionLevel = config.API.positionLevel; + } else { + apiPositionLevel = config.API.listPositionLevelHistory; + } + await http + .get(apiPositionLevel) + .then((res) => { + const data = res.data.result; + let rows: positionLevelResponse[] = []; + if (selector) { + data.map((e: positionLevelResponse) => { + rows.push({ + id: e.id, + level: e.level, + name: e.name, + shortName: e.shortName, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: positionLevelResponse) => { + rows.push({ + id: e.id, + level: e.level, + name: e.name, + shortName: e.shortName, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftPositionLevel.value = rows; + if (loader) { + dataPositionLevel.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchPositionStatus = async (loader: boolean, selector: boolean) => { + let apiPositionStatus = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiPositionStatus = config.API.positionStatus; + } else { + apiPositionStatus = config.API.listPositionStatusHistory; + } + await http + .get(apiPositionStatus) + .then((res) => { + const data = res.data.result; + let rows: positionStatusResponse[] = []; + if (selector) { + data.map((e: positionStatusResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: positionStatusResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftPositionStatus.value = rows; + if (loader) { + dataPositionStatus.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchOrganization = async (loader: boolean, selector: boolean) => { + let apiOrganization = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiOrganization = config.API.organizationOrganization; + } else { + apiOrganization = config.API.listOrganizationOrganizationHistory; + } + await http + .get(apiOrganization) + .then((res) => { + const data = res.data.result; + let rows: organizationResponse[] = []; + if (selector) { + data.map((e: organizationResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + note: e.note, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: organizationResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + note: e.note, + }); + }); + } + + draftOrganization.value = rows; + if (loader) { + dataOrganization.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchOrganizationShortName = async ( + loader: boolean, + selector: boolean + ) => { + let apiOrganizationShortName = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiOrganizationShortName = config.API.organizationShortName; + } else { + apiOrganizationShortName = config.API.listOrganizationShortNameHistory; + } + await http + .get(apiOrganizationShortName) + .then((res) => { + const data = res.data.result; + let rows: organizationShortNameResponse[] = []; + if (selector) { + data.map((e: organizationShortNameResponse) => { + rows.push({ + id: e.id, + agencyCode: e.agencyCode, + governmentCode: e.governmentCode, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + note: e.note, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: organizationShortNameResponse) => { + rows.push({ + id: e.id, + agencyCode: e.agencyCode, + governmentCode: e.governmentCode, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + note: e.note, + }); + }); + } + + draftOrganizationShortName.value = rows; + if (loader) { + dataOrganizationShortName.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchOrganizationType = async (loader: boolean, selector: boolean) => { + let apiOrganizationType = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiOrganizationType = config.API.organizationType; + } else { + apiOrganizationType = config.API.listOrganizationTypeHistory; + } + await http + .get(apiOrganizationType) + .then((res) => { + const data = res.data.result; + let rows: organizationTypeResponse[] = []; + if (selector) { + data.map((e: organizationTypeResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: organizationTypeResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftOrganizationType.value = rows; + if (loader) { + dataOrganizationType.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchOrganizationLevel = async (loader: boolean, selector: boolean) => { + let apiOrganizationLevel = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiOrganizationLevel = config.API.organizationLevel; + } else { + apiOrganizationLevel = config.API.listOrganizationLevelHistory; + } + await http + .get(apiOrganizationLevel) + .then((res) => { + const data = res.data.result; + let rows: organizationLevelResponse[] = []; + if (selector) { + data.map((e: organizationLevelResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: organizationLevelResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftOrganizationLevel.value = rows; + if (loader) { + dataOrganizationLevel.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchOrganizationStatus = async ( + loader: boolean, + selector: boolean + ) => { + let apiOrganizationStatus = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiOrganizationStatus = config.API.organizationStatus; + } else { + apiOrganizationStatus = config.API.listOrganizationStatusHistory; + } + await http + .get(apiOrganizationStatus) + .then((res) => { + const data = res.data.result; + let rows: organizationStatusResponse[] = []; + if (selector) { + data.map((e: organizationStatusResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: organizationStatusResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftOrganizationStatus.value = rows; + if (loader) { + dataOrganizationStatus.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchOrganizationTelInternal = async ( + loader: boolean, + selector: boolean + ) => { + let apiOrganizationTelInternal = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiOrganizationTelInternal = config.API.organizationTelInternal; + } else { + apiOrganizationTelInternal = + config.API.listOrganizationTelInternalHistory; + } + await http + .get(apiOrganizationTelInternal) + .then((res) => { + const data = res.data.result; + let rows: organizationTelInternalResponse[] = []; + if (selector) { + data.map((e: organizationTelInternalResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: organizationTelInternalResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftOrganizationTelInternal.value = rows; + if (loader) { + dataOrganizationTelInternal.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchOrganizationTelExternal = async ( + loader: boolean, + selector: boolean + ) => { + let apiOrganizationTelExternal = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiOrganizationTelExternal = config.API.organizationTelExternal; + } else { + apiOrganizationTelExternal = + config.API.listOrganizationTelExternalHistory; + } + await http + .get(apiOrganizationTelExternal) + .then((res) => { + const data = res.data.result; + let rows: organizationTelExternalResponse[] = []; + if (selector) { + data.map((e: organizationTelExternalResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: organizationTelExternalResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftOrganizationTelExternal.value = rows; + if (loader) { + dataOrganizationTelExternal.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + + const fetchOrganizationFax = async (loader: boolean, selector: boolean) => { + let apiOrganizationFax = ""; + if (loader) { + showLoader(); + } + if (selector) { + apiOrganizationFax = config.API.organizationFax; + } else { + apiOrganizationFax = config.API.listOrganizationFaxHistory; + } + await http + .get(apiOrganizationFax) + .then((res) => { + const data = res.data.result; + let rows: organizationFaxResponse[] = []; + if (selector) { + data.map((e: organizationFaxResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } else { + storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ + storeIdVersion.value = data.id; //เลข id ใน mongodb + + data.items.map((e: organizationFaxResponse) => { + rows.push({ + id: e.id, + name: e.name, + createdAt: e.createdAt, + lastUpdatedAt: e.lastUpdatedAt, + lastUpdateFullName: e.lastUpdateFullName, + isActive: e.isActive, + createdFullName: e.createdFullName, + createdUserId: e.createdUserId, + lastUpdateUserId: e.lastUpdateUserId, + }); + }); + } + + draftOrganizationFax.value = rows; + if (loader) { + dataOrganizationFax.value = rows; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + if (loader) { + hideLoader(); + } + }); + }; + return { dataPrefix, + dataBlood, + dataGender, + dataReligion, + dataRelationship, + dataEducation, + dataProvince, dataInsignia, dataInsigniaType, dataPositionEmployee, @@ -1213,10 +3257,31 @@ export const useManageDataStore = defineStore("manage", () => { dataPositionEmployeeLevel, dataPositionEmployeeStatus, dataPositionPath, + dataPositionPathSide, + dataPositionExecutive, + dataPositionExecutiveSide, + dataPositionType, + dataPositionLine, + dataPositionLevel, + dataPositionStatus, + dataOrganization, + dataOrganizationShortName, + dataOrganizationType, + dataOrganizationLevel, + dataOrganizationStatus, + dataOrganizationTelInternal, + dataOrganizationTelExternal, + dataOrganizationFax, storeIdVersion, storeVersion, manageData, getPrefix, + getBlood, + getGender, + getReligion, + getRelationship, + getEducation, + getProvince, changeManageCurrentTab, changeManageLink, changeManageColumns, @@ -1229,5 +3294,20 @@ export const useManageDataStore = defineStore("manage", () => { getPositionEmployeeLevel, getPositionEmployeeStatus, getPositionPath, + getPositionPathSide, + getPositionExecutive, + getPositionExecutiveSide, + getPositionType, + getPositionLine, + getPositionLevel, + getPositionStatus, + getOrganization, + getOrganizationShortName, + getOrganizationType, + getOrganizationLevel, + getOrganizationStatus, + getOrganizationTelInternal, + getOrganizationTelExternal, + getOrganizationFax, }; });