import { ref, computed } from "vue"; import { defineStore } from "pinia"; import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import type { RequestItemsHistoryObject as RequestItemsPrefix } from "@/modules/01_metadata/interface/request/person/Prefix"; import type { RequestItemsHistoryObject as RequestItemsBlood } from "@/modules/01_metadata/interface/request/person/Blood"; import type { RequestItemsHistoryObject as RequestItemsGender } from "@/modules/01_metadata/interface/request/person/Gender"; import type { RequestItemsHistoryObject as RequestItemsReligion } from "@/modules/01_metadata/interface/request/person/Religion"; import type { RequestItemsHistoryObject as RequestItemsRelationship } from "@/modules/01_metadata/interface/request/person/Relationship"; import type { RequestItemsHistoryObject as RequestItemsEducation } from "@/modules/01_metadata/interface/request/person/Education"; import type { RequestItemsHistoryObject as RequestItemsProvince } 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"; import type { RequestItemsHistoryObject as positionEmployeeSideResponse } from "@/modules/01_metadata/interface/request/positionEmployee/PositionSide"; import type { RequestItemsHistoryObject as positionEmployeeGroupResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Group"; import type { RequestItemsHistoryObject as positionEmployeeLineResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Line"; 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(); const { success, messageError, showLoader, hideLoader } = mixin; export const useManageDataStore = defineStore("manage", () => { const dataPrefix = ref<{ data: RequestItemsPrefix[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPrefix = ref<{ data: RequestItemsPrefix[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataBlood = ref<{ data: RequestItemsBlood[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftBlood = ref<{ data: RequestItemsBlood[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataGender = ref<{ data: RequestItemsGender[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftGender = ref<{ data: RequestItemsGender[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataReligion = ref<{ data: RequestItemsReligion[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftReligion = ref<{ data: RequestItemsReligion[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataRelationship = ref<{ data: RequestItemsRelationship[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftRelationship = ref<{ data: RequestItemsRelationship[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataEducation = ref<{ data: RequestItemsEducation[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftEducation = ref<{ data: RequestItemsEducation[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataProvince = ref<{ data: RequestItemsProvince[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftProvince = ref<{ data: RequestItemsProvince[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataInsignia = ref<{ data: InsigniaResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftInsignia = ref<{ data: InsigniaResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataInsigniaType = ref<{ data: InsigniaTypeResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftInsigniaType = ref<{ data: InsigniaTypeResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionEmployee = ref<{ data: positionEmployeeResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionEmployee = ref<{ data: positionEmployeeResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionEmployeeSide = ref<{ data: positionEmployeeSideResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionEmployeeSide = ref<{ data: positionEmployeeSideResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionEmployeeGroup = ref<{ data: positionEmployeeGroupResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionEmployeeGroup = ref<{ data: positionEmployeeGroupResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionEmployeeLine = ref<{ data: positionEmployeeLineResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionEmployeeLine = ref<{ data: positionEmployeeLineResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionEmployeeLevel = ref<{ data: positionEmployeeLevelResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionEmployeeLevel = ref<{ data: positionEmployeeLevelResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionEmployeeStatus = ref<{ data: positionEmployeeStatusResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionEmployeeStatus = ref<{ data: positionEmployeeStatusResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionPath = ref<{ data: positionPathResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionPath = ref<{ data: positionPathResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionPathSide = ref<{ data: positionPathSideResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionPathSide = ref<{ data: positionPathSideResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionExecutive = ref<{ data: positionExecutiveResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionExecutive = ref<{ data: positionExecutiveResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionExecutiveSide = ref<{ data: positionExecutiveSideResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionExecutiveSide = ref<{ data: positionExecutiveSideResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionType = ref<{ data: positionTypeResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionType = ref<{ data: positionTypeResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionLine = ref<{ data: positionLineResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionLine = ref<{ data: positionLineResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionLevel = ref<{ data: positionLevelResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionLevel = ref<{ data: positionLevelResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataPositionStatus = ref<{ data: positionStatusResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftPositionStatus = ref<{ data: positionStatusResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataOrganization = ref<{ data: organizationResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftOrganization = ref<{ data: organizationResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataOrganizationShortName = ref<{ data: organizationShortNameResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftOrganizationShortName = ref<{ data: organizationShortNameResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataOrganizationType = ref<{ data: organizationTypeResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftOrganizationType = ref<{ data: organizationTypeResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataOrganizationLevel = ref<{ data: organizationLevelResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftOrganizationLevel = ref<{ data: organizationLevelResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataOrganizationStatus = ref<{ data: organizationStatusResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftOrganizationStatus = ref<{ data: organizationStatusResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataOrganizationTelInternal = ref<{ data: organizationTelInternalResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftOrganizationTelInternal = ref<{ data: organizationTelInternalResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataOrganizationTelExternal = ref<{ data: organizationTelExternalResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftOrganizationTelExternal = ref<{ data: organizationTelExternalResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const dataOrganizationFax = ref<{ data: organizationFaxResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const draftOrganizationFax = ref<{ data: organizationFaxResponse[]; idversion: string; version: string; }>({ data: [], idversion: "", version: "published" }); //list data table const storeIdVersion = ref(""); //id data ใน mongodb const storeVersion = ref("published"); //รายการข้อมูลล่าสุดได้เผยแพร่หรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ interface manage { link: number; person: { name: string; prefix: { columns: String[] }; blood: { columns: String[] }; gender: { columns: String[] }; religion: { columns: String[] }; relationship: { columns: String[] }; education: { columns: String[] }; province: { columns: String[] }; district: { columns: String[] }; subDistrict: { columns: String[] }; }; organization: { name: string; organization: { columns: String[] }; shortName: { columns: String[] }; type: { columns: String[] }; level: { columns: String[] }; agency: { columns: String[] }; governmentAgency: { columns: String[] }; status: { columns: String[] }; telInternal: { columns: String[] }; telExternal: { columns: String[] }; fax: { columns: String[] }; }; position: { name: string; path: { columns: String[] }; executiveSide: { columns: String[] }; type: { columns: String[] }; line: { columns: String[] }; pathSide: { columns: String[] }; executive: { columns: String[] }; level: { columns: String[] }; status: { columns: String[] }; }; positionEmployee: { name: string; position: { columns: String[] }; positionSide: { columns: String[] }; group: { columns: String[] }; line: { columns: String[] }; level: { columns: String[] }; status: { columns: String[] }; }; calendar: { name: string; tree: { columns: String[] }; list: { columns: String[] }; }; insignia: { name: string; class: { columns: String[] }; type: { columns: String[] }; // badge: { columns: String[] }; }; } const manageData = ref({ link: 1, person: { name: "", prefix: { columns: [] }, blood: { columns: [] }, gender: { columns: [] }, religion: { columns: [] }, relationship: { columns: [] }, education: { columns: [] }, province: { columns: [] }, district: { columns: [] }, subDistrict: { columns: [] }, }, organization: { name: "", organization: { columns: [] }, shortName: { columns: [] }, type: { columns: [] }, level: { columns: [] }, agency: { columns: [] }, governmentAgency: { columns: [] }, status: { columns: [] }, telInternal: { columns: [] }, telExternal: { columns: [] }, fax: { columns: [] }, }, position: { name: "", path: { columns: [] }, executiveSide: { columns: [] }, type: { columns: [] }, line: { columns: [] }, pathSide: { columns: [] }, executive: { columns: [] }, level: { columns: [] }, status: { columns: [] }, }, positionEmployee: { name: "", position: { columns: [] }, positionSide: { columns: [] }, group: { columns: [] }, line: { columns: [] }, level: { columns: [] }, status: { columns: [] }, }, calendar: { name: "", tree: { columns: [] }, list: { columns: [] }, }, insignia: { name: "", class: { columns: [] }, type: { columns: [] }, // badge: { columns: [] }, }, }); const changeManageCurrentTab = (type: number, val: string) => { if (type == 1) manageData.value.person.name = val; if (type == 2) manageData.value.organization.name = val; if (type == 3) manageData.value.position.name = val; if (type == 4) manageData.value.positionEmployee.name = val; if (type == 5) manageData.value.calendar.name = val; if (type == 6) manageData.value.insignia.name = val; localStorage.setItem("manage", JSON.stringify(manageData.value)); }; const changeManageColumns = (type: number, tab: String, val: String[]) => { if (type == 1) { if (tab == "blood") manageData.value.person.blood.columns = val; if (tab == "district") manageData.value.person.district.columns = val; if (tab == "education") manageData.value.person.education.columns = val; if (tab == "gender") manageData.value.person.gender.columns = val; if (tab == "prefix") manageData.value.person.prefix.columns = val; if (tab == "province") manageData.value.person.province.columns = val; if (tab == "religion") manageData.value.person.religion.columns = val; if (tab == "relationship") manageData.value.person.relationship.columns = val; if (tab == "subDistrict") manageData.value.person.subDistrict.columns = val; } if (type == 2) { if (tab == "agency") manageData.value.organization.agency.columns = val; if (tab == "fax") manageData.value.organization.fax.columns = val; if (tab == "governmentAgency") manageData.value.organization.governmentAgency.columns = val; if (tab == "shortName") manageData.value.organization.shortName.columns = val; if (tab == "level") manageData.value.organization.level.columns = val; if (tab == "organization") manageData.value.organization.organization.columns = val; if (tab == "status") manageData.value.organization.status.columns = val; if (tab == "telExternal") manageData.value.organization.telExternal.columns = val; if (tab == "telInternal") manageData.value.organization.telInternal.columns = val; if (tab == "type") manageData.value.organization.type.columns = val; } if (type == 3) { if (tab == "executive") manageData.value.position.executive.columns = val; if (tab == "executiveSide") manageData.value.position.executiveSide.columns = val; if (tab == "level") manageData.value.position.level.columns = val; if (tab == "line") manageData.value.position.line.columns = val; if (tab == "path") manageData.value.position.path.columns = val; if (tab == "pathSide") manageData.value.position.pathSide.columns = val; if (tab == "status") manageData.value.position.status.columns = val; if (tab == "type") manageData.value.position.type.columns = val; } if (type == 4) { if (tab == "group") manageData.value.positionEmployee.group.columns = val; if (tab == "level") manageData.value.positionEmployee.level.columns = val; if (tab == "line") manageData.value.positionEmployee.line.columns = val; if (tab == "position") manageData.value.positionEmployee.position.columns = val; if (tab == "positionSide") manageData.value.positionEmployee.positionSide.columns = val; if (tab == "status") manageData.value.positionEmployee.status.columns = val; } if (type == 5) { if (tab == "tree") manageData.value.calendar.tree.columns = val; if (tab == "list") manageData.value.calendar.list.columns = val; } if (type == 6) { // if (tab == "badge") manageData.value.insignia.badge.columns = val; if (tab == "class") manageData.value.insignia.class.columns = val; if (tab == "type") manageData.value.insignia.type.columns = val; } localStorage.setItem("manage", JSON.stringify(manageData.value)); }; const changeManageLink = (val: number) => { manageData.value.link = val; localStorage.setItem("manage", JSON.stringify(manageData.value)); }; if (localStorage.getItem("manage")) { const data = JSON.parse(localStorage.getItem("manage") || "{}"); const isDataValid = Object.getOwnPropertyNames(manageData.value).every( (val1) => { const descriptor1 = Object.getOwnPropertyDescriptor( manageData.value, val1 ); return ( descriptor1 && descriptor1.configurable && Object.getOwnPropertyNames(descriptor1.value).every((val2) => { return data[val1] && data[val1].hasOwnProperty(val2); }) ); } ); if (isDataValid) { manageData.value = data; } else { localStorage.setItem("manage", JSON.stringify(manageData.value)); } } const getPrefix = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPrefix.value.data.length === 0) { await fetchPrefix(true, selector); return draftPrefix.value; } else { if (newFetch) { await fetchPrefix(true, selector); return draftPrefix.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPrefix.value.data) == JSON.stringify(draftPrefix.value.data) ) { return draftPrefix.value; } else { await fetchPrefix(false, selector); return draftPrefix.value; } } } }; const getBlood = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataBlood.value.data.length === 0) { await fetchBlood(true, selector); return draftBlood.value; } else { if (newFetch) { await fetchBlood(true, selector); return draftBlood.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataBlood.value.data) == JSON.stringify(draftBlood.value.data) ) { return draftBlood.value; } else { await fetchBlood(false, selector); return draftBlood.value; } } } }; const getGender = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataGender.value.data.length === 0) { await fetchGender(true, selector); return draftGender.value; } else { if (newFetch) { await fetchGender(true, selector); return draftGender.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataGender.value.data) == JSON.stringify(draftGender.value.data) ) { return draftGender.value; } else { await fetchGender(false, selector); return draftGender.value; } } } }; const getReligion = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataReligion.value.data.length === 0) { await fetchReligion(true, selector); return draftReligion.value; } else { if (newFetch) { await fetchReligion(true, selector); return draftReligion.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataReligion.value.data) == JSON.stringify(draftReligion.value.data) ) { return draftReligion.value; } else { await fetchReligion(false, selector); return draftReligion.value; } } } }; const getRelationship = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataRelationship.value.data.length === 0) { await fetchRelationship(true, selector); return draftRelationship.value; } else { if (newFetch) { await fetchRelationship(true, selector); return draftRelationship.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataRelationship.value.data) == JSON.stringify(draftRelationship.value.data) ) { return draftRelationship.value; } else { await fetchRelationship(false, selector); return draftRelationship.value; } } } }; const getEducation = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataEducation.value.data.length === 0) { await fetchEducation(true, selector); return draftEducation.value; } else { if (newFetch) { await fetchEducation(true, selector); return draftEducation.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataEducation.value.data) == JSON.stringify(draftEducation.value.data) ) { return draftEducation.value; } else { await fetchEducation(false, selector); return draftEducation.value; } } } }; const getProvince = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataProvince.value.data.length === 0) { await fetchProvince(true, selector); return draftProvince.value; } else { if (newFetch) { await fetchProvince(true, selector); return draftProvince.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataProvince.value.data) == JSON.stringify(draftProvince.value.data) ) { return draftProvince.value; } else { await fetchProvince(false, selector); return draftProvince.value; } } } }; // const getDistrict = async ( // selector: boolean = false, // newFetch: boolean = false // ) => { // if (dataDistrict.value.data.length === 0) { // // await fetchDistrict(true, selector); // return draftDistrict.value; // } else { // if (newFetch) { // // await fetchDistrict(true, selector); // return draftDistrict.value; // } else { // // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า // if ( // JSON.stringify(dataDistrict.value.data) == // JSON.stringify(draftDistrict.value.data) // ) { // return draftDistrict.value; // } else { // // await fetchDistrict(false, selector); // return draftDistrict.value; // } // } // } // }; // const getSubDistrict = async ( // selector: boolean = false, // newFetch: boolean = false // ) => { // if (dataSubDistrict.value.data.length === 0) { // // await fetchSubDistrict(true, selector); // return draftSubDistrict.value; // } else { // if (newFetch) { // // await fetchSubDistrict(true, selector); // return draftSubDistrict.value; // } else { // // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า // if ( // JSON.stringify(dataSubDistrict.value.data) == // JSON.stringify(draftSubDistrict.value.data) // ) { // return draftSubDistrict.value; // } else { // // await fetchSubDistrict(false, selector); // return draftSubDistrict.value; // } // } // } // }; const getInsigniaType = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataInsignia.value.data.length === 0) { await fetchInsigniaType(true, selector); return draftInsigniaType.value; } else { if (newFetch) { await fetchInsigniaType(true, selector); return draftInsigniaType.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataInsigniaType.value.data) == JSON.stringify(draftInsigniaType.value.data) ) { draftInsigniaType.value && await fetchInsigniaType(false, selector); return draftInsigniaType.value; } else { await fetchInsigniaType(false, selector); return draftInsigniaType.value; } } } }; const getInsignia = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataInsignia.value.data.length === 0) { await fetchInsignia(true, selector); return draftInsignia.value; } else { if (newFetch) { await fetchInsignia(true, selector); return draftInsignia.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataInsignia.value.data) == JSON.stringify(draftInsignia.value.data) ) { return draftInsignia.value; } else { await fetchInsignia(false, selector); return draftInsignia.value; } } } }; const getPositionEmployee = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionEmployee.value.data.length === 0) { await fetchPositionEmployee(true, selector); return draftPositionEmployee.value; } else { if (newFetch) { await fetchPositionEmployee(true, selector); return draftPositionEmployee.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionEmployee.value.data) == JSON.stringify(draftPositionEmployee.value.data) ) { return draftPositionEmployee.value; } else { await fetchPositionEmployee(false, selector); return draftPositionEmployee.value; } } } }; const getPositionEmployeeSide = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionEmployeeSide.value.data.length === 0) { await fetchPositionEmployeeSide(true, selector); return draftPositionEmployeeSide.value; } else { if (newFetch) { await fetchPositionEmployeeSide(true, selector); return draftPositionEmployeeSide.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionEmployeeSide.value.data) == JSON.stringify(draftPositionEmployeeSide.value.data) ) { return draftPositionEmployeeSide.value; } else { await fetchPositionEmployeeSide(false, selector); return draftPositionEmployeeSide.value; } } } }; const getPositionEmployeeGroup = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionEmployeeGroup.value.data.length === 0) { await fetchPositionEmployeeGroup(true, selector); return draftPositionEmployeeGroup.value; } else { if (newFetch) { await fetchPositionEmployeeGroup(true, selector); return draftPositionEmployeeGroup.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionEmployeeGroup.value.data) == JSON.stringify(draftPositionEmployeeGroup.value.data) ) { return draftPositionEmployeeGroup.value; } else { await fetchPositionEmployeeGroup(false, selector); return draftPositionEmployeeGroup.value; } } } }; const getPositionEmployeeLine = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionEmployeeLine.value.data.length === 0) { await fetchPositionEmployeeLine(true, selector); return draftPositionEmployeeLine.value; } else { if (newFetch) { await fetchPositionEmployeeLine(true, selector); return draftPositionEmployeeLine.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionEmployeeLine.value.data) == JSON.stringify(draftPositionEmployeeLine.value.data) ) { return draftPositionEmployeeLine.value; } else { await fetchPositionEmployeeLine(false, selector); return draftPositionEmployeeLine.value; } } } }; const getPositionEmployeeLevel = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionEmployeeLevel.value.data.length === 0) { await fetchPositionEmployeeLevel(true, selector); return draftPositionEmployeeLevel.value; } else { if (newFetch) { await fetchPositionEmployeeLevel(true, selector); return draftPositionEmployeeLevel.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionEmployeeLevel.value.data) == JSON.stringify(draftPositionEmployeeLevel.value.data) ) { return draftPositionEmployeeLevel.value; } else { await fetchPositionEmployeeLevel(false, selector); return draftPositionEmployeeLevel.value; } } } }; const getPositionEmployeeStatus = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionEmployeeStatus.value.data.length === 0) { await fetchPositionEmployeeStatus(true, selector); return draftPositionEmployeeStatus.value; } else { if (newFetch) { await fetchPositionEmployeeStatus(true, selector); return draftPositionEmployeeStatus.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionEmployeeStatus.value.data) == JSON.stringify(draftPositionEmployeeStatus.value.data) ) { return draftPositionEmployeeStatus.value; } else { await fetchPositionEmployeeStatus(false, selector); return draftPositionEmployeeStatus.value; } } } }; const getPositionPath = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionPath.value.data.length === 0) { await fetchPositionPath(true, selector); return draftPositionPath.value; } else { if (newFetch) { await fetchPositionPath(true, selector); return draftPositionPath.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionPath.value.data) == JSON.stringify(draftPositionPath.value.data) ) { return draftPositionPath.value; } else { await fetchPositionPath(false, selector); return draftPositionPath.value; } } } }; const getPositionExecutive = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionExecutive.value.data.length === 0) { await fetchPositionExecutive(true, selector); return draftPositionExecutive.value; } else { if (newFetch) { await fetchPositionExecutive(true, selector); return draftPositionExecutive.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionExecutive.value.data) == JSON.stringify(draftPositionExecutive.value.data) ) { return draftPositionExecutive.value; } else { await fetchPositionExecutive(false, selector); return draftPositionExecutive.value; } } } }; const fetchPrefix = async (loader: boolean, selector: boolean) => { let apiPrefix = ""; if (loader) { showLoader(); } if (selector) { apiPrefix = config.API.prefix; } else { apiPrefix = config.API.listPrefixHistory; } await http .get(apiPrefix) .then((res) => { const data = res.data.result; let rows: RequestItemsPrefix[] = []; let version: string = ""; let id: string = ""; if (selector) { version = ""; id = ""; data.map((e: RequestItemsPrefix) => { rows.push({ ...e, }); }); } else { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: RequestItemsPrefix) => { rows.push({ ...e, }); }); } draftPrefix.value = { idversion: id, version: version, data: rows }; if (loader) { dataPrefix.value = { idversion: id, version: version, data: rows }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; 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: RequestItemsBlood[] = []; let version: string = ""; let id: string = ""; if (selector) { version = ""; id = ""; data.map((e: RequestItemsBlood) => { rows.push({ ...e, }); }); } else { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: RequestItemsBlood) => { rows.push({ ...e, }); }); } draftBlood.value = { idversion: id, version: version, data: rows }; if (loader) { dataBlood.value = { idversion: id, version: version, data: 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: RequestItemsGender[] = []; let version: string = ""; let id: string = ""; if (selector) { version = ""; id = ""; data.map((e: RequestItemsGender) => { rows.push({ ...e, }); }); } else { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: RequestItemsGender) => { rows.push({ ...e, }); }); } draftGender.value = { idversion: id, version: version, data: rows }; if (loader) { dataGender.value = { idversion: id, version: version, data: 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: RequestItemsReligion[] = []; let version: string = ""; let id: string = ""; if (selector) { version = ""; id = ""; data.map((e: RequestItemsReligion) => { rows.push({ ...e, }); }); } else { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: RequestItemsReligion) => { rows.push({ ...e, }); }); } draftReligion.value = { idversion: id, version: version, data: rows }; if (loader) { dataReligion.value = { idversion: id, version: version, data: 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: RequestItemsRelationship[] = []; let version: string = ""; let id: string = ""; if (selector) { version = ""; id = ""; data.map((e: RequestItemsRelationship) => { rows.push({ ...e, }); }); } else { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: RequestItemsRelationship) => { rows.push({ ...e, }); }); } draftRelationship.value = { idversion: id, version: version, data: rows, }; if (loader) { dataRelationship.value = { idversion: id, version: version, data: 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: RequestItemsEducation[] = []; let version: string = ""; let id: string = ""; if (selector) { version = ""; id = ""; data.map((e: RequestItemsEducation) => { rows.push({ ...e, }); }); } else { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: RequestItemsEducation) => { rows.push({ ...e, }); }); } draftEducation.value = { idversion: id, version: version, data: rows, }; if (loader) { dataEducation.value = { idversion: id, version: version, data: 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: RequestItemsProvince[] = []; let version: string = ""; let id: string = ""; if (selector) { version = ""; id = ""; data.map((e: RequestItemsProvince) => { rows.push({ ...e, }); }); } else { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: RequestItemsProvince) => { rows.push({ ...e, }); }); } draftProvince.value = { idversion: id, version: version, data: rows, }; if (loader) { dataProvince.value = { idversion: id, version: version, data: rows, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; const getPositionExecutiveSide = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionExecutiveSide.value.data.length === 0) { await fetchPositionExecutiveSide(true, selector); return draftPositionExecutiveSide.value; } else { if (newFetch) { await fetchPositionExecutiveSide(true, selector); return draftPositionExecutiveSide.value; } else { return draftPositionExecutiveSide.value; } } }; const getPositionPathSide = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionPathSide.value.data.length === 0) { await fetchPositionPathSide(true, selector); return draftPositionPathSide.value; } else { if (newFetch) { await fetchPositionPathSide(true, selector); return draftPositionPathSide.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionPathSide.value.data) == JSON.stringify(draftPositionPathSide.value.data) ) { return draftPositionPathSide.value; } else { await fetchPositionPathSide(false, selector); return draftPositionPathSide.value; } } } }; const getPositionType = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionType.value.data.length === 0) { await fetchPositionType(true, selector); return draftPositionType.value; } else { if (newFetch) { await fetchPositionType(true, selector); return draftPositionType.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionType.value.data) == JSON.stringify(draftPositionType.value.data) ) { return draftPositionType.value; } else { await fetchPositionType(false, selector); return draftPositionType.value; } } } }; const getPositionLine = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionLine.value.data.length === 0) { await fetchPositionLine(true, selector); return draftPositionLine.value; } else { if (newFetch) { await fetchPositionLine(true, selector); return draftPositionLine.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionLine.value.data) == JSON.stringify(draftPositionLine.value.data) ) { return draftPositionLine.value; } else { await fetchPositionLine(false, selector); return draftPositionLine.value; } } } }; const getPositionLevel = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionLevel.value.data.length === 0) { await fetchPositionLevel(true, selector); return draftPositionLevel.value; } else { if (newFetch) { await fetchPositionLevel(true, selector); return draftPositionLevel.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionLevel.value.data) == JSON.stringify(draftPositionLevel.value.data) ) { return draftPositionLevel.value; } else { await fetchPositionLevel(false, selector); return draftPositionLevel.value; } } } }; const getPositionStatus = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataPositionStatus.value.data.length === 0) { await fetchPositionStatus(true, selector); return draftPositionStatus.value; } else { if (newFetch) { await fetchPositionStatus(true, selector); return draftPositionStatus.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataPositionStatus.value.data) == JSON.stringify(draftPositionStatus.value.data) ) { return draftPositionStatus.value; } else { await fetchPositionStatus(false, selector); return draftPositionStatus.value; } } } }; const getOrganization = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataOrganization.value.data.length === 0) { await fetchOrganization(true, selector); return draftOrganization.value; } else { if (newFetch) { await fetchOrganization(true, selector); return draftOrganization.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataOrganization.value.data) == JSON.stringify(draftOrganization.value.data) ) { return draftOrganization.value; } else { await fetchOrganization(false, selector); return draftOrganization.value; } } } }; const getOrganizationShortName = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataOrganizationShortName.value.data.length === 0) { await fetchOrganizationShortName(true, selector); return draftOrganizationShortName.value; } else { if (newFetch) { await fetchOrganizationShortName(true, selector); return draftOrganizationShortName.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataOrganizationShortName.value.data) == JSON.stringify(draftOrganizationShortName.value.data) ) { return draftOrganizationShortName.value; } else { await fetchOrganizationShortName(false, selector); return draftOrganizationShortName.value; } } } }; const getOrganizationType = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataOrganizationType.value.data.length === 0) { await fetchOrganizationType(true, selector); return draftOrganizationType.value; } else { if (newFetch) { await fetchOrganizationType(true, selector); return draftOrganizationType.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataOrganizationType.value.data) == JSON.stringify(draftOrganizationType.value.data) ) { return draftOrganizationType.value; } else { await fetchOrganizationType(false, selector); return draftOrganizationType.value; } } } }; const getOrganizationLevel = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataOrganizationLevel.value.data.length === 0) { await fetchOrganizationLevel(true, selector); return draftOrganizationLevel.value; } else { if (newFetch) { await fetchOrganizationLevel(true, selector); return draftOrganizationLevel.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataOrganizationLevel.value.data) == JSON.stringify(draftOrganizationLevel.value.data) ) { return draftOrganizationLevel.value; } else { await fetchOrganizationLevel(false, selector); return draftOrganizationLevel.value; } } } }; const getOrganizationStatus = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataOrganizationStatus.value.data.length === 0) { await fetchOrganizationStatus(true, selector); return draftOrganizationStatus.value; } else { if (newFetch) { await fetchOrganizationStatus(true, selector); return draftOrganizationStatus.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataOrganizationStatus.value.data) == JSON.stringify(draftOrganizationStatus.value.data) ) { return draftOrganizationStatus.value; } else { await fetchOrganizationStatus(false, selector); return draftOrganizationStatus.value; } } } }; const getOrganizationTelInternal = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataOrganizationTelInternal.value.data.length === 0) { await fetchOrganizationTelInternal(true, selector); return draftOrganizationTelInternal.value; } else { if (newFetch) { await fetchOrganizationTelInternal(true, selector); return draftOrganizationTelInternal.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataOrganizationTelInternal.value.data) == JSON.stringify(draftOrganizationTelInternal.value.data) ) { return draftOrganizationTelInternal.value; } else { await fetchOrganizationTelInternal(false, selector); return draftOrganizationTelInternal.value; } } } }; const getOrganizationTelExternal = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataOrganizationTelExternal.value.data.length === 0) { await fetchOrganizationTelExternal(true, selector); return draftOrganizationTelExternal.value; } else { if (newFetch) { await fetchOrganizationTelExternal(true, selector); return draftOrganizationTelExternal.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataOrganizationTelExternal.value.data) == JSON.stringify(draftOrganizationTelExternal.value.data) ) { return draftOrganizationTelExternal.value; } else { await fetchOrganizationTelExternal(false, selector); return draftOrganizationTelExternal.value; } } } }; const getOrganizationFax = async ( selector: boolean = false, newFetch: boolean = false ) => { if (dataOrganizationFax.value.data.length === 0) { await fetchOrganizationFax(true, selector); return draftOrganizationFax.value; } else { if (newFetch) { await fetchOrganizationFax(true, selector); return draftOrganizationFax.value; } else { // เทียบ กรณี fetch data selector ไม่เหมือนกัน หรือ กรณี ดราฟ ดาต้า if ( JSON.stringify(dataOrganizationFax.value.data) == JSON.stringify(draftOrganizationFax.value.data) ) { return draftOrganizationFax.value; } else { await fetchOrganizationFax(false, selector); return draftOrganizationFax.value; } } } }; const fetchInsignia = async (loader: boolean, selector: boolean) => { let apiInsignia = ""; if (loader) { showLoader(); } if (selector) { apiInsignia = config.API.insignia; } else { apiInsignia = config.API.listInsigniaHistory; } await http .get(apiInsignia) .then((res) => { const data = res.data.result; let rows: InsigniaResponse[] = []; let version: string = ""; let id: string = ""; if (selector) { data.map((e: InsigniaResponse) => { rows.push({ id: e.id, name: e.name, shortName: e.shortName, level: e.level, createdAt: e.createdAt, lastUpdatedAt: e.lastUpdatedAt, lastUpdateFullName: e.lastUpdateFullName, isActive: e.isActive, createdFullName: e.createdFullName, createdUserId: e.createdUserId, lastUpdateUserId: e.lastUpdateUserId, insigniaType: e.insigniaType, note: e.note, }); }); } else { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: InsigniaResponse) => { rows.push({ id: e.id, name: e.name, shortName: e.shortName, level: e.level, createdAt: e.createdAt, lastUpdatedAt: e.lastUpdatedAt, lastUpdateFullName: e.lastUpdateFullName, isActive: e.isActive, createdFullName: e.createdFullName, createdUserId: e.createdUserId, lastUpdateUserId: e.lastUpdateUserId, insigniaType: e.insigniaType, note: e.note, }); }); } draftInsignia.value = { idversion: id, version: version, data: rows }; if (loader) { dataInsignia.value = { idversion: id, version: version, data: rows }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; const fetchInsigniaType = async (loader: boolean, selector: boolean) => { let apiInsigniaType = ""; if (loader) { showLoader(); } if (selector) { apiInsigniaType = config.API.insigniaType; } else { apiInsigniaType = config.API.listInsigniaTypeHistory; } await http .get(apiInsigniaType) .then((res) => { const data = res.data.result; let rows: InsigniaTypeResponse[] = []; let version: string = ""; let id: string = ""; if (selector) { data.map((e: InsigniaTypeResponse) => { 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: InsigniaTypeResponse) => { 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, }); }); } draftInsigniaType.value = { idversion: id, version: version, data: rows, }; if (loader) { dataInsigniaType.value = { idversion: id, version: version, data: rows, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; const fetchPositionEmployee = async (loader: boolean, selector: boolean) => { let apiPositionEmployee = ""; if (loader) { showLoader(); } if (selector) { apiPositionEmployee = config.API.positionEmployeePosition; } else { apiPositionEmployee = config.API.listPositionEmployeePositionHistory; } await http .get(apiPositionEmployee) .then((res) => { const data = res.data.result; let rows: positionEmployeeResponse[] = []; let version: string = ""; let id: string = ""; if (selector) { data.map((e: positionEmployeeResponse) => { 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: positionEmployeeResponse) => { 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, }); }); } draftPositionEmployee.value = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionEmployee.value = { idversion: id, version: version, data: rows, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; const fetchPositionEmployeeSide = async ( loader: boolean, selector: boolean ) => { let apiPositionEmployeeSide = ""; if (loader) { showLoader(); } if (selector) { apiPositionEmployeeSide = config.API.positionEmployeePositionSide; } else { apiPositionEmployeeSide = config.API.listPositionEmployeePositionSideHistory; } await http .get(apiPositionEmployeeSide) .then((res) => { const data = res.data.result; let rows: positionEmployeeSideResponse[] = []; let version: string = ""; let id: string = ""; if (selector) { data.map((e: positionEmployeeSideResponse) => { 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: positionEmployeeSideResponse) => { 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, }); }); } draftPositionEmployeeSide.value = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionEmployeeSide.value = { idversion: id, version: version, data: rows, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; const fetchPositionEmployeeGroup = async ( loader: boolean, selector: boolean ) => { let apiPositionEmployeeGroup = ""; if (loader) { showLoader(); } if (selector) { apiPositionEmployeeGroup = config.API.positionEmployeeGroup; } else { apiPositionEmployeeGroup = config.API.listPositionEmployeeGroupHistory; } await http .get(apiPositionEmployeeGroup) .then((res) => { const data = res.data.result; let rows: positionEmployeeGroupResponse[] = []; let version: string = ""; let id: string = ""; if (selector) { data.map((e: positionEmployeeGroupResponse) => { 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: positionEmployeeGroupResponse) => { 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, }); }); } draftPositionEmployeeGroup.value = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionEmployeeGroup.value = { idversion: id, version: version, data: rows, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; const fetchPositionEmployeeLine = async ( loader: boolean, selector: boolean ) => { let apiPositionEmployeeLine = ""; if (loader) { showLoader(); } if (selector) { apiPositionEmployeeLine = config.API.positionEmployeeLine; } else { apiPositionEmployeeLine = config.API.listPositionEmployeeLineHistory; } await http .get(apiPositionEmployeeLine) .then((res) => { const data = res.data.result; let rows: positionEmployeeLineResponse[] = []; let version: string = ""; let id: string = ""; if (selector) { data.map((e: positionEmployeeLineResponse) => { 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: positionEmployeeLineResponse) => { 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, }); }); } draftPositionEmployeeLine.value = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionEmployeeLine.value = { idversion: id, version: version, data: rows, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; const fetchPositionEmployeeLevel = async ( loader: boolean, selector: boolean ) => { let apiPositionEmployeeLevel = ""; if (loader) { showLoader(); } if (selector) { apiPositionEmployeeLevel = config.API.positionEmployeeLevel; } else { apiPositionEmployeeLevel = config.API.listPositionEmployeeLevelHistory; } await http .get(apiPositionEmployeeLevel) .then((res) => { const data = res.data.result; let rows: positionEmployeeLevelResponse[] = []; let version: string = ""; let id: string = ""; if (selector) { data.map((e: positionEmployeeLevelResponse) => { 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: positionEmployeeLevelResponse) => { 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, }); }); } draftPositionEmployeeLevel.value = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionEmployeeLevel.value = { idversion: id, version: version, data: rows, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; const fetchPositionEmployeeStatus = async ( loader: boolean, selector: boolean ) => { let apiPositionEmployeeStatus = ""; if (loader) { showLoader(); } if (selector) { apiPositionEmployeeStatus = config.API.positionEmployeeStatus; } else { apiPositionEmployeeStatus = config.API.listPositionEmployeeStatusHistory; } await http .get(apiPositionEmployeeStatus) .then((res) => { const data = res.data.result; let rows: positionEmployeeStatusResponse[] = []; let version: string = ""; let id: string = ""; if (selector) { data.map((e: positionEmployeeStatusResponse) => { 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: positionEmployeeStatusResponse) => { 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, }); }); } draftPositionEmployeeStatus.value = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionEmployeeStatus.value = { idversion: id, version: version, data: rows, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; const fetchPositionPath = async (loader: boolean, selector: boolean) => { let apiPositionPath = ""; if (loader) { showLoader(); } if (selector) { apiPositionPath = config.API.positionPath; } else { apiPositionPath = config.API.listPositionPathHistory; } await http .get(apiPositionPath) .then((res) => { const data = res.data.result; let rows: positionPathResponse[] = []; let version: string = ""; let id: string = ""; if (selector) { data.map((e: positionPathResponse) => { 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = data.id; //เลข id ใน mongodb data.items.map((e: positionPathResponse) => { 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, }); }); } draftPositionPath.value = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionPath.value = { idversion: id, version: version, data: rows, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; 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[] = []; let version: string = ""; let id: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionPathSide.value = { idversion: id, version: version, data: 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[] = []; let version: string = ""; let id: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionExecutive.value = { idversion: id, version: version, data: 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[] = []; let version: string = ""; let id: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionExecutiveSide.value = { idversion: id, version: version, data: 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[] = []; let version: string = ""; let id: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionType.value = { idversion: id, version: version, data: 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[] = []; let version: string = ""; let id: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionLine.value = { idversion: id, version: version, data: 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[] = []; let version: string = ""; let id: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionLevel.value = { idversion: id, version: version, data: 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[] = []; let version: string = ""; let id: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { idversion: id, version: version, data: rows, }; if (loader) { dataPositionStatus.value = { idversion: id, version: version, data: 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[] = []; let id: string = ""; let version: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { data: rows, idversion: id, version: version, }; if (loader) { dataOrganization.value = { data: rows, idversion: id, version: version, }; } }) .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[] = []; let id: string = ""; let version: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { data: rows, idversion: id, version: version, }; if (loader) { dataOrganizationShortName.value = { data: rows, idversion: id, version: version, }; } }) .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[] = []; let id: string = ""; let version: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { data: rows, idversion: id, version: version, }; if (loader) { dataOrganizationType.value = { data: rows, idversion: id, version: version, }; } }) .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[] = []; let id: string = ""; let version: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { data: rows, idversion: id, version: version, }; if (loader) { dataOrganizationLevel.value = { data: rows, idversion: id, version: version, }; } }) .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[] = []; let id: string = ""; let version: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { data: rows, idversion: id, version: version, }; if (loader) { dataOrganizationStatus.value = { data: rows, idversion: id, version: version, }; } }) .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[] = []; let id: string = ""; let version: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { data: rows, idversion: id, version: version, }; if (loader) { dataOrganizationTelInternal.value = { data: rows, idversion: id, version: version, }; } }) .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[] = []; let id: string = ""; let version: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { data: rows, idversion: id, version: version, }; if (loader) { dataOrganizationTelExternal.value = { data: rows, idversion: id, version: version, }; } }) .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[] = []; let id: string = ""; let version: string = ""; 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 { version = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่ id = 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 = { data: rows, idversion: id, version: version, }; if (loader) { dataOrganizationFax.value = { data: rows, idversion: id, version: version, }; } }) .catch((e) => { messageError($q, e); }) .finally(() => { if (loader) { hideLoader(); } }); }; return { dataPrefix, dataBlood, dataGender, dataReligion, dataRelationship, dataEducation, dataProvince, dataInsignia, dataInsigniaType, dataPositionEmployee, dataPositionEmployeeSide, dataPositionEmployeeGroup, dataPositionEmployeeLine, 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, getInsignia, getInsigniaType, getPositionEmployee, getPositionEmployeeSide, getPositionEmployeeGroup, getPositionEmployeeLine, getPositionEmployeeLevel, getPositionEmployeeStatus, getPositionPath, getPositionPathSide, getPositionExecutive, getPositionExecutiveSide, getPositionType, getPositionLine, getPositionLevel, getPositionStatus, getOrganization, getOrganizationShortName, getOrganizationType, getOrganizationLevel, getOrganizationStatus, getOrganizationTelInternal, getOrganizationTelExternal, getOrganizationFax, }; });