Merge branch 'NiceDev' into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-12-17 18:22:29 +07:00
commit 420b6e9639

View file

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