fix ==> แผนผังองค์กร

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-12-17 18:22:12 +07:00
parent b7835fdd25
commit 4a837c3a2a

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from "vue"; import { ref, onMounted, nextTick, watch } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
@ -22,6 +22,7 @@ const rootOrgID = ref(); // org id ของ root ตัวปัจจุบั
const dataSource = ref(); // Chart const dataSource = ref(); // Chart
const idActive = ref<string>(""); const idActive = ref<string>("");
const dataSourceLock = ref(); // Chart home const dataSourceLock = ref(); // Chart home
const scrollContainer = ref<HTMLElement | null>(null);
/** /**
* สราง Path Breadcrumbs * สราง Path Breadcrumbs
@ -87,12 +88,38 @@ function findPath(id: any) {
} }
} }
function savePNG() { /** function ดาวน์โหลดไฟล์โครงสร้าง PNG*/
chartRef.value.savePNG(); async function savePNG() {
try {
showLoader();
await scrollToCenter();
await chartRef.value.savePNG();
} catch {
messageError($q);
} finally {
hideLoader();
}
} }
function savePDF() { /** function ดาวน์โหลดไฟล์โครงสร้าง PDF*/
chartRef.value.savePDF(); async function savePDF() {
try {
showLoader();
await scrollToCenter();
await chartRef.value.savePDF();
} catch {
messageError($q);
} finally {
hideLoader();
}
}
/** ฟังก์ชันเลื่อน scroll ไปที่กึ่งกลาง*/
async function scrollToCenter() {
const container = scrollContainer.value;
if (container) {
container.scrollLeft = (container.scrollWidth - container.clientWidth) / 2;
}
} }
/** /**
@ -146,7 +173,7 @@ function searchAndReplace(data: any, id: string) {
} }
} }
function getActive() { async function getActive() {
http http
.get(config.API.orgActive) .get(config.API.orgActive)
.then(async (res) => { .then(async (res) => {
@ -159,6 +186,19 @@ function getActive() {
}) })
.finally(() => {}); .finally(() => {});
} }
// Watch dataSource
watch(
dataSource,
() => {
// nextTick DOM scroll
nextTick(() => {
scrollToCenter();
});
},
{ deep: true } //
);
/** hook lifecycle*/ /** hook lifecycle*/
onMounted(async () => { onMounted(async () => {
await getActive(); await getActive();
@ -223,7 +263,16 @@ onMounted(async () => {
<div class="col-12"> <div class="col-12">
<q-separator /> <q-separator />
</div> </div>
<div style="overflow-x: auto; overflow-y: auto" class="q-pt-md"> <div
ref="scrollContainer"
style="
overflow-x: auto;
overflow-y: auto;
height: 70vh;
position: relative;
"
class="q-pt-md"
>
<StructChart <StructChart
style="height: 70vh" style="height: 70vh"
ref="chartRef" ref="chartRef"