From 5fbfaa9a88bea6c20af7acd7c38c9e7ba62b5fcc Mon Sep 17 00:00:00 2001 From: Thanit Konmek Date: Thu, 15 Jun 2023 17:22:20 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=20fetch=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../01_metadata/components/person/Prefix.vue | 2 - .../03_recruiting/components/Profile.vue | 31 +++++------- .../components/Information/Family.vue | 49 ++++++++++++------- 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/modules/01_metadata/components/person/Prefix.vue b/src/modules/01_metadata/components/person/Prefix.vue index 2d0a39155..85f9bf5d4 100644 --- a/src/modules/01_metadata/components/person/Prefix.vue +++ b/src/modules/01_metadata/components/person/Prefix.vue @@ -210,8 +210,6 @@ const { changeManageColumns, getPrefix, dataPrefix, - storeIdVersion, - storeVersion, } = store; const rows = ref(dataPrefix); //list data table const rowsHistory = ref([]); //select data history diff --git a/src/modules/03_recruiting/components/Profile.vue b/src/modules/03_recruiting/components/Profile.vue index 482cd4648..8ce1e2660 100644 --- a/src/modules/03_recruiting/components/Profile.vue +++ b/src/modules/03_recruiting/components/Profile.vue @@ -60,9 +60,9 @@ import Occupation from "@/modules/03_recruiting/components/Occupation.vue"; import Education from "@/modules/03_recruiting/components/Education.vue"; import Career from "@/modules/03_recruiting/components/Career.vue"; import Document from "@/modules/03_recruiting/components/Document.vue"; -import { useDataStore } from "@/stores/data"; import { useQuasar } from "quasar"; import { useCounterMixin } from "@/stores/mixin"; +import { useManageDataStore } from "@/modules/01_metadata/store"; const props = defineProps({ status: { @@ -88,8 +88,9 @@ const props = defineProps({ }); const $q = useQuasar(); -const dataStore = useDataStore(); -const { loaderPage } = dataStore; + +const store = useManageDataStore(); +const { getPrefix } = store; const prefixOptions = ref([]); const relationshipOptions = ref([]); const provinceOptions = ref([]); @@ -131,23 +132,15 @@ onMounted(() => { }); const fetchPrefix = async () => { - showLoader(); - await http - .get(config.API.prefix) - .then((res) => { - const data = res.data.result; - let option: DataOption[] = []; - data.map((r: any) => { - option.push({ id: r.id.toString(), name: r.name.toString() }); - }); - prefixOptions.value = option; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); + const result = await getPrefix(true, false); + const data = result.data; + let option: DataOption[] = []; + if (data.length > 0) { + data.map((r: any) => { + option.push({ id: r.id.toString(), name: r.name.toString() }); }); + } + prefixOptions.value = option; }; const fetchRelationship = async () => { diff --git a/src/modules/04_registry/components/Information/Family.vue b/src/modules/04_registry/components/Information/Family.vue index f896a6308..95699902c 100644 --- a/src/modules/04_registry/components/Information/Family.vue +++ b/src/modules/04_registry/components/Information/Family.vue @@ -774,6 +774,7 @@ import type { import http from "@/plugins/http"; import config from "@/app.config"; import { useRoute } from "vue-router"; +import { useManageDataStore } from "@/modules/01_metadata/store"; const props = defineProps({ statusEdit: { @@ -789,8 +790,8 @@ const emit = defineEmits(["update:statusEdit"]); const route = useRoute(); const $q = useQuasar(); -const dataStore = useDataStore(); -const { loaderPage } = dataStore; +const store = useManageDataStore(); +const { getPrefix } = store; const mixin = useCounterMixin(); const { date2Thai, success, messageError, showLoader, hideLoader } = mixin; const edit = ref(false); @@ -857,24 +858,34 @@ const refreshData = async () => { }; const fetchPrefix = async () => { - showLoader(); - await http - .get(config.API.prefix) - .then((res) => { - const data = res.data.result; - let option: DataOption[] = []; - data.map((r: any) => { - option.push({ id: r.id.toString(), name: r.name.toString() }); - }); - Ops.value.prefixOps = option; - OpsFilter.value.prefixOps = option; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); + const result = await getPrefix(true, false); + const data = result.data; + let option: DataOption[] = []; + if (data.length > 0) { + data.map((r: any) => { + option.push({ id: r.id.toString(), name: r.name.toString() }); }); + } + Ops.value.prefixOps = option; + OpsFilter.value.prefixOps = option; +// showLoader(); +// await http +// .get(config.API.prefix) +// .then((res) => { +// const data = res.data.result; +// let option: DataOption[] = []; +// data.map((r: any) => { +// option.push({ id: r.id.toString(), name: r.name.toString() }); +// }); +// Ops.value.prefixOps = option; +// OpsFilter.value.prefixOps = option; +// }) +// .catch((e) => { +// messageError($q, e); +// }) +// .finally(() => { +// hideLoader(); +// }); }; const addChildren = async () => {