รักษาการในตำแหน่ง ==> ปรับโครงสร้าง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-16 11:34:33 +07:00
parent 115b41c922
commit 0da3f425a7
3 changed files with 94 additions and 40 deletions

View file

@ -1,9 +1,12 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import { checkPermission } from "@/utils/permissions";
import http from "@/plugins/http";
import config from "@/app.config";
import { checkPermission } from "@/utils/permissions";
import { useCounterMixin } from "@/stores/mixin";
import { useStructureTree } from "@/stores/structureTree";
/** importType*/
import type { QTableProps } from "quasar";
@ -14,10 +17,12 @@ import type {
} from "@/modules/17_acting/interface/response/Main";
/** importStore*/
import { useCounterMixin } from "@/stores/mixin";
/** use*/
const $q = useQuasar();
const { fetchTreeActing } = useStructureTree();
const storeTree = useStructureTree();
const { showLoader, hideLoader, messageError, dialogRemove } =
useCounterMixin();
@ -31,40 +36,26 @@ const isAll = ref<boolean>(false);
/**
* function เรยกขอมลโครงสราง แบบป
*/
function fetchOrganizationActive() {
showLoader();
http
.get(config.API.activeOrganization)
.then((res) => {
const data = res.data.result;
if (data) {
fetchOrganization(data.activeId);
}
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
/**
* function fetch อมลโครงสราาง
* @param id id โครงสรางป
*/
function fetchOrganization(id: string) {
showLoader();
http
.get(config.API.orgAct + `/${id}`)
.then((res) => {
const data = res.data.result;
nodeTree.value = data;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
async function fetchOrganizationActive() {
if (storeTree.dataActing.length > 0) {
nodeTree.value = await fetchTreeActing("");
} else {
showLoader();
http
.get(config.API.activeOrganization)
.then(async (res) => {
const data = res.data.result;
if (data) {
nodeTree.value = await fetchTreeActing(data.activeId);
}
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
}
/**