เพิ่ม function fetchStructureTree
This commit is contained in:
parent
6ee3227f16
commit
3666cd61a9
2 changed files with 65 additions and 39 deletions
|
|
@ -20,9 +20,11 @@ import DialogHeader from "@/components/DialogHeader.vue";
|
|||
import { useRegistryNewDataStore } from "@/modules/04_registryPerson/store";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useRoute } from "vue-router";
|
||||
import { useStructureTree } from "@/stores/structureTree";
|
||||
|
||||
const $q = useQuasar();
|
||||
const store = useRegistryNewDataStore();
|
||||
const { fetchStructureTree } = useStructureTree();
|
||||
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
||||
const route = useRoute();
|
||||
|
||||
|
|
@ -331,36 +333,13 @@ function clearSelect(t: string) {
|
|||
fetchDataPerson();
|
||||
}
|
||||
|
||||
async function fetchTree(id: string) {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.orgByIdSystem(id, route.meta.Key as string))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
node.value = data;
|
||||
store.formFilter.node = nodeData.node;
|
||||
store.formFilter.nodeId = nodeData.nodeId;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function fetchActive() {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
fetchTree(data.activeId);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
hideLoader();
|
||||
});
|
||||
async function fetchTree() {
|
||||
const data = await fetchStructureTree(route.meta.Key as string);
|
||||
if (data) {
|
||||
node.value = data;
|
||||
store.formFilter.node = nodeData.node;
|
||||
store.formFilter.nodeId = nodeData.nodeId;
|
||||
}
|
||||
}
|
||||
|
||||
function sendNode() {
|
||||
|
|
@ -371,15 +350,6 @@ function sendNode() {
|
|||
fetchDataPerson();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => selectNode.value,
|
||||
() => {
|
||||
if (selectNode.value) {
|
||||
fetchActive();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function updateSelectedTreeMain(data: any) {
|
||||
if (nodeData.node === data.orgLevel && nodeData.nodeId === data.orgTreeId) {
|
||||
store.formFilter.node = null;
|
||||
|
|
@ -397,6 +367,7 @@ function updateSelectedTreeMain(data: any) {
|
|||
|
||||
onMounted(async () => {
|
||||
selectType();
|
||||
fetchTree();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue