fix fetch StructrueTree
This commit is contained in:
parent
74fa0f664c
commit
e8c830454a
3 changed files with 59 additions and 17 deletions
|
|
@ -13,7 +13,7 @@ import http from "@/plugins/http";
|
|||
import config from "@/app.config";
|
||||
import { useRegistryNewDataStore } from "@/modules/04_registryPerson/store";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useRoute } from "vue-router";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import avatar from "@/assets/avatar_user.jpg";
|
||||
import { useStructureTree } from "@/stores/structureTree";
|
||||
|
||||
|
|
@ -40,6 +40,7 @@ const store = useRegistryNewDataStore();
|
|||
const { fetchStructureTree } = useStructureTree();
|
||||
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const empType = ref<string>("officer"); // officer / employee / perm
|
||||
const dataPersonMain = ref<DataPerson[]>([]); //ข้อมูลรายการที่ค้นหาข้อมูลทะเบียนประวัติ
|
||||
|
|
@ -391,6 +392,10 @@ function getSearch() {
|
|||
fetchDataPerson();
|
||||
}
|
||||
|
||||
function goToAdvancedSearch() {
|
||||
router.push("/report/registry");
|
||||
}
|
||||
|
||||
/** hook เมื่อมีการเรียกใช้ Components*/
|
||||
onMounted(async () => {
|
||||
await Promise.all([selectType(), fetchTree()]);
|
||||
|
|
@ -596,12 +601,23 @@ onMounted(async () => {
|
|||
|
||||
<q-space />
|
||||
<div class="q-pt-sm q-pr-sm">
|
||||
<a href="/report/registry" class="text-white">
|
||||
<!-- <a href="/report/registry" class="text-white">
|
||||
การค้นหาขั้นสูง
|
||||
<q-tooltip
|
||||
>ไปยังหน้าการค้นหาขั้นสูง (Advanced search)</q-tooltip
|
||||
>
|
||||
</a>
|
||||
</a> -->
|
||||
<q-btn
|
||||
flat
|
||||
@click="goToAdvancedSearch"
|
||||
class="text-white"
|
||||
style="text-decoration: underline"
|
||||
label="การค้นหาขั้นสูง"
|
||||
>
|
||||
<q-tooltip
|
||||
>ไปยังหน้าการค้นหาขั้นสูง (Advanced search)</q-tooltip
|
||||
>
|
||||
</q-btn>
|
||||
</div>
|
||||
|
||||
<q-separator
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { useCounterMixin } from "@/stores/mixin";
|
|||
import { useReportStore } from "@/modules/21_report/store";
|
||||
import { useRegistryNewDataStore } from "@/modules/04_registryPerson/store";
|
||||
import { useStructureTree } from "@/stores/structureTree";
|
||||
import { useMenuDataStore } from "@/stores/menuList";
|
||||
|
||||
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
|
||||
import type {
|
||||
|
|
@ -27,15 +28,18 @@ import type { DataStructureTree } from "@/interface/main";
|
|||
|
||||
import DialogOrg from "@/modules/21_report/components/01_org/DialogOrg.vue";
|
||||
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
||||
import LoadView from "@/components/LoadView.vue";
|
||||
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
const storeReport = useReportStore();
|
||||
const stroeRegistry = useRegistryNewDataStore();
|
||||
const { fetchStructureTree } = useStructureTree();
|
||||
const mixin = useCounterMixin();
|
||||
|
||||
const storeMenu = useMenuDataStore();
|
||||
|
||||
const { messageError, showLoader, hideLoader, date2Thai, formatDatePosition } =
|
||||
mixin;
|
||||
useCounterMixin();
|
||||
|
||||
const loadingBtn = ref<boolean>(false);
|
||||
const total = ref<number>(0);
|
||||
|
|
@ -325,6 +329,7 @@ const rangeTerm = ref<RangeAge>({
|
|||
min: 0,
|
||||
max: 20,
|
||||
});
|
||||
const isLoadStructureTree = ref<boolean>(true);
|
||||
|
||||
function onOpenOrg() {
|
||||
modalOrg.value = true;
|
||||
|
|
@ -660,21 +665,27 @@ const expandedModal = ref<boolean>(false);
|
|||
|
||||
async function fetchTree() {
|
||||
try {
|
||||
const res = await http.get(config.API.orgPermissionsSys);
|
||||
const response = res.data.result.roles;
|
||||
if (storeMenu.permissions) {
|
||||
isLoadStructureTree.value = true;
|
||||
const response = storeMenu.permissions.roles ?? [];
|
||||
|
||||
const sysName = response.find(
|
||||
(e: DataRoles) =>
|
||||
e.authSysId === "SYS_REGISTRY_OFFICER" ||
|
||||
e.authSysId === "REPORT_REGISTRY"
|
||||
)?.authSysId;
|
||||
const sysName = response
|
||||
?.find(
|
||||
(e: DataRoles) =>
|
||||
e.authSysId === "SYS_REGISTRY_OFFICER" ||
|
||||
e.authSysId === "REPORT_REGISTRY"
|
||||
)
|
||||
?.authSysId.toString();
|
||||
|
||||
const data = await fetchStructureTree(sysName ?? "REPORT_REGISTRY", true);
|
||||
if (data) {
|
||||
node.value = data;
|
||||
const data = await fetchStructureTree(sysName ?? "REPORT_REGISTRY");
|
||||
if (data) {
|
||||
node.value = data;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
} finally {
|
||||
isLoadStructureTree.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -712,7 +723,7 @@ onMounted(async () => {
|
|||
getOptions(),
|
||||
getExecutive(),
|
||||
getDataPerson(),
|
||||
getEducationLevel(),
|
||||
// getEducationLevel(),
|
||||
fetchTree(),
|
||||
])
|
||||
|
||||
|
|
@ -726,6 +737,15 @@ onMounted(async () => {
|
|||
}, 500);
|
||||
});
|
||||
});
|
||||
|
||||
watch(
|
||||
() => storeMenu.permissions,
|
||||
() => {
|
||||
if (storeMenu.permissions) {
|
||||
fetchTree();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -896,7 +916,10 @@ onMounted(async () => {
|
|||
</template>
|
||||
<q-separator />
|
||||
|
||||
<q-card-section>
|
||||
<q-card-section v-if="isLoadStructureTree">
|
||||
<LoadView />
|
||||
</q-card-section>
|
||||
<q-card-section v-else>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue