Merge branch 'develop' into devTee

This commit is contained in:
setthawutttty 2024-12-17 17:06:53 +07:00
commit 77a3e7b57f
3 changed files with 96 additions and 28 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, watch } from "vue"; import { ref, onMounted, watch, nextTick } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { StructChart } from "structure-chart"; import { StructChart } from "structure-chart";
import "structure-chart/structure-chart.css"; import "structure-chart/structure-chart.css";
@ -19,19 +19,22 @@ const rootOrgID = ref(); // org id ของ root ตัวปัจจุบั
const dataSourceLock = ref(); // Chart home const dataSourceLock = ref(); // Chart home
const chartRef = ref(); // chart const chartRef = ref(); // chart
const loader = ref<boolean>(false); // Loader const loader = ref<boolean>(false); // Loader
const scrollContainer = ref<HTMLElement | null>(null);
/** /** function ดาวน์โหลดไฟล์โครงสร้าง PNG*/
* function ดาวนโหลดไฟลโครงสราง PNG async function savePNG() {
*/ showLoader();
function savePNG() { await scrollToCenter();
chartRef.value.savePNG(); await chartRef.value.savePNG();
hideLoader();
} }
/** /** function ดาวน์โหลดไฟล์โครงสร้าง PDF*/
* function ดาวนโหลดไฟลโครงสราง PDF async function savePDF() {
*/ showLoader();
function savePDF() { await scrollToCenter();
chartRef.value.savePDF(); await chartRef.value.savePDF();
hideLoader();
} }
/** /**
@ -178,6 +181,26 @@ watch(
} }
); );
/** ฟังก์ชันเลื่อน scroll ไปที่กึ่งกลาง*/
async function scrollToCenter() {
const container = scrollContainer.value;
if (container) {
container.scrollLeft = (container.scrollWidth - container.clientWidth) / 2;
}
}
// Watch dataSource
watch(
dataSource,
() => {
// nextTick DOM scroll
nextTick(() => {
scrollToCenter();
});
},
{ deep: true } //
);
onMounted(async () => { onMounted(async () => {
const id = const id =
store.typeOrganizational === "current" store.typeOrganizational === "current"
@ -221,7 +244,16 @@ onMounted(async () => {
</div> </div>
</div> </div>
<q-separator /> <q-separator />
<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"

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, watch, onBeforeMount } from "vue"; import { ref, onMounted, watch, onBeforeMount, nextTick } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { OrgChart } from "bma-org-chart"; import { OrgChart } from "bma-org-chart";
import "bma-org-chart/org-chart.css"; import "bma-org-chart/org-chart.css";
@ -24,10 +24,9 @@ const dataSource = ref(chartData); // ข้อมูล Chart
const rootOrgID = ref(); // org id root const rootOrgID = ref(); // org id root
const dataSourceLock = ref(); // Chart home const dataSourceLock = ref(); // Chart home
const chartRef = ref(); // chart const chartRef = ref(); // chart
const scrollContainer = ref<HTMLElement | null>(null);
/** /** fetch ข้อมูล Chart โครงสร้าง*/
* fetch อม Chart โครงสราง
*/
async function fetchOrgChart() { async function fetchOrgChart() {
if (rootOrgID.value) { if (rootOrgID.value) {
showLoader(); showLoader();
@ -97,18 +96,20 @@ async function refreshChart(data: any) {
if (data.value !== undefined) data.value = 0; if (data.value !== undefined) data.value = 0;
} }
/** /** โหลด Chart รูป*/
* โหลด Chart async function savePNG() {
*/ showLoader();
function savePNG() { await scrollToCenter();
chartRef.value.savePNG(); await chartRef.value.savePNG();
hideLoader();
} }
/** /** โหลด Chart PDF*/
* โหลด Chart PDF async function savePDF() {
*/ showLoader();
function savePDF() { await scrollToCenter();
chartRef.value.savePDF(); await chartRef.value.savePDF();
hideLoader();
} }
watch( watch(
@ -129,6 +130,14 @@ watch(
} }
); );
/** ฟังก์ชันเลื่อน scroll ไปที่กึ่งกลาง*/
async function scrollToCenter() {
const container = scrollContainer.value;
if (container) {
container.scrollLeft = (container.scrollWidth - container.clientWidth) / 2;
}
}
onMounted(async () => { onMounted(async () => {
rootOrgID.value = rootOrgID.value =
store.typeOrganizational === "current" store.typeOrganizational === "current"
@ -137,7 +146,8 @@ onMounted(async () => {
? store.draftId ? store.draftId
: store.historyId; : store.historyId;
fetchOrgChart(); await fetchOrgChart();
await scrollToCenter();
}); });
onBeforeMount(() => { onBeforeMount(() => {
@ -164,7 +174,16 @@ onBeforeMount(() => {
</q-btn> </q-btn>
</div> </div>
<q-separator /> <q-separator />
<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"
>
<OrgChart <OrgChart
v-if="storeOrg.dataSource" v-if="storeOrg.dataSource"
style="height: 70vh" style="height: 70vh"

View file

@ -115,6 +115,18 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
}, },
{
name: "positionIsSelected",
align: "left",
label: "คนครอง",
sortable: true,
field: "positionIsSelected",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
return val ? row.fullNameCurrentHolder : "-";
},
},
]); ]);
const columnsPostition = ref<QTableProps["columns"]>([ const columnsPostition = ref<QTableProps["columns"]>([
{ {
@ -197,6 +209,7 @@ const visibleColumns = ref<string[]>([
"positionName", "positionName",
"posTypeName", "posTypeName",
"posLevelName", "posLevelName",
"positionIsSelected",
]); ]);
/** Position*/ /** Position*/
@ -241,6 +254,7 @@ function updateSelected(data: TreeMain) {
nodeId.value = data.orgTreeId ? data.orgTreeId : ""; nodeId.value = data.orgTreeId ? data.orgTreeId : "";
nodeLevel.value = data.orgLevel; nodeLevel.value = data.orgLevel;
fetchDataTable(data.orgTreeId, data.orgLevel); fetchDataTable(data.orgTreeId, data.orgLevel);
} }
@ -283,6 +297,7 @@ async function fetchDataTable(id: string, level: number = 0) {
dataMain.push(data); dataMain.push(data);
} }
}); });
positionNo.value = dataMain; positionNo.value = dataMain;
positionNoMain.value = dataMain; positionNoMain.value = dataMain;
}) })
@ -440,6 +455,8 @@ watch(
await clearData(); await clearData();
if (props?.dataRow?.node !== null && props?.dataRow?.nodeId !== null) { if (props?.dataRow?.node !== null && props?.dataRow?.nodeId !== null) {
await fetchPosFind(props?.dataRow?.node, props?.dataRow?.nodeId); await fetchPosFind(props?.dataRow?.node, props?.dataRow?.nodeId);
nodeLevel.value = props?.dataRow?.node;
nodeId.value = props.dataRow?.nodeId;
} else { } else {
expanded.value = []; expanded.value = [];
} }