fix รายงานโครงสร้างและกรอบอัตรากำลัง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-11 14:02:51 +07:00
parent 938b1f8e98
commit 584c5d6756
4 changed files with 73 additions and 476 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, reactive, onMounted, watch } from "vue";
import { ref, onMounted, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
@ -8,13 +8,7 @@ import { useOrganizational } from "@/modules/02_organization/store/organizationa
import { useCounterMixin } from "@/stores/mixin";
/** importType*/
import type {
OrgTree,
PosMaster,
Position,
PosMaster2,
} from "@/modules/02_organization/interface/response/organizational";
import type { FilterMaster } from "@/modules/02_organization/interface/request/organizational";
import type { OrgTree } from "@/modules/02_organization/interface/response/organizational";
/** importComponents*/
import TreeMain from "@/modules/21_report/components/01_org/TreeMain.vue";
@ -32,35 +26,15 @@ const count = defineModel<number>("count", { required: true });
const nodeTree = ref<OrgTree[]>(); // Tree
const nodeId = ref<string>(""); // id Tree
const orgRootId = ref<string>("");
const orgLevel = ref<number>(0); // levelTree
const orgRootId = ref<string>(""); // id Root
const isLoad = ref<boolean>(false); // loadTable
const isLoadTree = ref<boolean>(false); // loadTable
const mainTree = ref<OrgTree>();
const selected = ref<string>("");
const reqMaster = reactive<FilterMaster>({
id: "",
type: 0,
isAll: false,
page: 1,
pageSize: 10,
keyword: "",
revisionId: "",
});
const totalPage = ref<number>(1);
const totalData = ref<number>(1);
const action1 = ref<boolean>(false);
const posMaster = ref<PosMaster2[]>([]);
const shortName = ref<string>("");
const selected = ref<string>(""); // selected node
/**
* function fetch อมลของ Tree
* @param id id โครงสราง
*/
async function fetchDataTree(id: string) {
isLoadTree.value = false;
showLoader();
await http
.get(config.API.orgByid(id))
@ -80,120 +54,6 @@ async function fetchDataTree(id: string) {
});
}
/**
* function fetch อรายการตำแหน
* @param id idTree
* @param level levelTree
*/
async function fetchDataTable(id: string, level: number, action: boolean) {
searchAndReplaceOrgName(nodeTree.value, id);
orgLevel.value = level;
reqMaster.id = id;
reqMaster.type = level;
action1.value = action;
if (action) {
setTimeout(() => {
action1.value = false;
}, 1000);
reqMaster.isAll = false;
reqMaster.page = 1;
reqMaster.pageSize = 10;
reqMaster.keyword = "";
reqMaster.revisionId =
store.typeOrganizational == "draft"
? store.draftId
: store.typeOrganizational == "current"
? store.activeId
: store.historyId;
isLoad.value = true;
}
posMaster.value = [];
await http
.post(config.API.orgPosMasterList, {
...reqMaster,
keyword: reqMaster.keyword.trim(),
})
.then(async (res) => {
const dataMain: PosMaster[] = [];
totalPage.value = Math.ceil(res.data.result.total / reqMaster.pageSize);
totalData.value = res.data.result.total;
res.data.result.data.forEach((e: PosMaster) => {
const p = e.positions;
if (p.length !== 0) {
const a = p.find((el: Position) => el.positionIsSelected === true);
const { id, ...rest } = a ? a : p[0];
const test = {
...e,
...rest,
};
dataMain.push(test);
}
});
posMaster.value = store.fetchPosMaster(dataMain);
})
.catch((err) => {
messageError($q, err);
posMaster.value = [];
})
.finally(() => {
setTimeout(() => {
isLoad.value = false;
}, 1000);
});
}
/** ดึงข้อมูลสถิติจำนวนด้านบน*/
// function getSummary() {
// http
// .post(config.API.orgSummary, {
// id: reqMaster.id, //*Id node
// type: reqMaster.type, //*node
// isNode: reqMaster.isAll, //* node
// })
// .then(async (res: any) => {
// const data = await res.data.result;
// store.getSumPosition({
// totalPosition: data.totalPosition,
// totalPositionCurrentUse: data.totalPositionCurrentUse,
// totalPositionCurrentVacant: data.totalPositionCurrentVacant,
// totalPositionNextUse: data.totalPositionNextUse,
// totalPositionNextVacant: data.totalPositionNextVacant,
// totalRootPosition: data.totalPosition,
// totalRootPositionCurrentUse: data.totalPositionCurrentUse,
// totalRootPositionCurrentVacant: data.totalPositionCurrentVacant,
// totalRootPositionNextUse: data.totalPositionNextUse,
// totalRootPositionNextVacant: data.totalPositionNextVacant,
// });
// });
// }
/** funcion ค้นหาข้อมูลใน Table*/
async function filterKeyword() {
reqMaster.page = 1;
action1.value === false &&
fetchDataTable(reqMaster.id, reqMaster.type, false);
}
/**
* นหาโครงสรางในขอมลแบบลำดบชนเพอหาทตรงก orgTreeId
* @param data อมลโครงสราง
* @param targetId id ของโครงสรางทองการคนหา
*/
function searchAndReplaceOrgName(data: any, targetId: string) {
for (const child of data) {
if (child.orgTreeId === targetId) {
mainTree.value = child;
return true; // Found the targetId in this level
}
if (child.children && searchAndReplaceOrgName(child.children, targetId)) {
return true; // Found the targetId in the nested children
}
}
return false; // Not found in this branch
}
/** callback function ทำงาน ทำการ fetch ข้อมูล Tree เมื่อมีการเลือกประวัติโครงสร้าง*/
watch(
() => count.value,
@ -202,7 +62,7 @@ watch(
}
);
/** callblck function ทำการ fetch ข้อมูล Tree เมื่อมีการเปลี่ยนโครงสร้าง*/
/** callback function ทำการ fetch ข้อมูล Tree เมื่อมีการเปลี่ยนโครงสร้าง*/
watch(
() => store.typeOrganizational,
() => {
@ -215,44 +75,22 @@ watch(
}
);
/** callblck function ทำการ fetch ข้อมูล Table เมื่อมีการเปลี่ยนหน้า */
watch([() => reqMaster.page, () => reqMaster.pageSize], () => {
action1.value === false &&
fetchDataTable(reqMaster.id, reqMaster.type, false);
});
/** callblck function ทำการ fetch ข้อมูล Table เมื่อแสดงตำแหน่งทั้งหมด*/
// watch(
// () => reqMaster.isAll,
// () => {
// getSummary();
// if (reqMaster.page !== 1) {
// reqMaster.page = 1;
// } else {
// fetchDataTable(reqMaster.id, reqMaster.type, false);
// }
// }
// );
/** callback function ทำการ fetch ข้อมูล Tree เมื่อมีการเปลี่ยนแปลง activeId */
watch(
() => store.draftId,
() => store.activeId,
() => {
store.draftId && fetchDataTree(store.draftId?.toString());
store.activeId && fetchDataTree(store.activeId?.toString());
}
);
/**
* lifecycle Hook ทำเม Components กเรยกใชงาน
*
* และดงชอมลโครงสรางตาม ID ของประเภทโครงสราง จจ,แบบราง
*/
onMounted(async () => {
const id =
store.typeOrganizational === "current"
? store.activeId
: store.typeOrganizational === "draft"
? store.draftId
: historyId.value;
store.typeOrganizational === "current" ? store.activeId : historyId.value;
id && (await fetchDataTree(id));
});
</script>
@ -264,11 +102,8 @@ onMounted(async () => {
<div class="col-12 row no-wrap bg-grey-1">
<TreeMain
v-model:node-tree="nodeTree"
v-model:short-name="shortName"
v-model:node-id="nodeId"
v-model:org-root-id="orgRootId"
:fetch-data-table="fetchDataTable"
:fetch-data-tree="fetchDataTree"
/>
<div class="col-12 row">
@ -294,36 +129,18 @@ onMounted(async () => {
<q-space />
<q-badge
color="secondary"
:label="
reqMaster.isAll
? store.sumPosition.total
: store.sumPosition.totalRoot
"
:label="store.sumPosition.totalRoot"
/>
</div>
<div class="row col q-pa-sm item">
<div class="ellipsis">ตำแหนงทคนครอง</div>
<q-space />
<q-badge
color="primary"
:label="
reqMaster.isAll
? store.sumPosition.use
: store.sumPosition.useRoot
"
/>
<q-badge color="primary" :label="store.sumPosition.useRoot" />
</div>
<div class="row col q-pa-sm item">
<div class="ellipsis">ตำแหนงวาง</div>
<q-space />
<q-badge
color="red"
:label="
reqMaster.isAll
? store.sumPosition.vacant
: store.sumPosition.vacantRoot
"
/>
<q-badge color="red" :label="store.sumPosition.vacantRoot" />
</div>
</q-card>
@ -331,19 +148,7 @@ onMounted(async () => {
<div class="q-pa-sm">
<TreeTable
v-if="nodeId !== ''"
v-model:node-tree="nodeTree"
v-model:org-level="orgLevel"
v-model:tree-id="nodeId"
v-model:pos-master="posMaster"
v-model:req-master="reqMaster"
v-model:total-page="totalPage"
v-model:org-root-id="orgRootId"
v-model:total-data="totalData"
:short-name="shortName"
:main-tree="mainTree"
:fetch-data-table="fetchDataTable"
:filter-keyword="filterKeyword"
:fetch-data-tree="fetchDataTree"
/>
</div>
</q-card>

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { ref } from "vue";
import { useQuasar } from "quasar";
import axios from "axios";
import { VuePDF, usePDF } from "@tato30/vue-pdf";
@ -11,11 +11,8 @@ import { useCounterMixin } from "@/stores/mixin";
import genReportXLSX from "@/plugins/genreportxlsx";
import type { DataDocument } from "@/modules/02_organization/interface/index/Main";
import type { FilterMaster } from "@/modules/02_organization/interface/request/organizational";
import type { PosMaster2 } from "@/modules/02_organization/interface/response/organizational";
/** importComponents*/
import LoadView from "@/components/LoadView.vue";
const $q = useQuasar();
@ -27,36 +24,14 @@ const page = ref<number>(1);
const pdfSrc = ref<any>();
const splitterModel = ref(14);
/** prosp*/
/** props */
const isLoadPDF = ref<boolean>(false);
const detailReport = ref<any>();
const reqMaster = defineModel<FilterMaster>("reqMaster", { required: true });
const posMaster = defineModel<PosMaster2[]>("posMaster", { required: true });
const orgRootId = defineModel<string>("orgRootId", { required: true });
const props = defineProps({
filterKeyword: { type: Function, require: true, default: () => {} },
fetchDataTable: {
type: Function,
require: true,
default: () => {},
},
shortName: { type: String, required: true },
fetchDataTree: {
type: Function,
require: true,
default: () => {},
},
mainTree: {
type: Object,
require: true,
},
});
const title = ref<string>("");
/** ListMenu Table*/
const baseDocument = ref<DataDocument[]>([
{
name: "บัญชี 2",
@ -69,10 +44,9 @@ const baseDocument = ref<DataDocument[]>([
},
]);
const modalDialogMMove = ref<boolean>(false);
/**
* function DownloadReport
* งก DownloadReport
* @param list รายงานทองการดาวนโหลด
*/
async function getReport(list: string) {
const listFind = baseDocument.value.find(
@ -101,7 +75,7 @@ async function getReport(list: string) {
}
/**
* function เรยกไฟล PDF
* งกเรยกไฟล PDF
* @param data อมลบญชนลา
*/
async function fetchDocumentTemplate(data: any) {
@ -141,17 +115,6 @@ function backPage() {
page.value--;
}
}
watch(
() => modalDialogMMove.value,
() => {
if (!modalDialogMMove.value) {
if (posMaster.value.length === 0) {
props.fetchDataTable?.(reqMaster.value.id, reqMaster.value.type, false);
}
}
}
);
</script>
<template>

View file

@ -19,7 +19,7 @@ import { useCounterMixin } from "@/stores/mixin";
/** use*/
const $q = useQuasar();
const store = useOrganizational();
const { showLoader } = useCounterMixin();
const { showLoader, hideLoader, messageError } = useCounterMixin();
/** props*/
const nodeTEST = defineModel<OrgTree[]>("nodeTree", { default: [] });
@ -27,17 +27,6 @@ const nodeId = defineModel<string>("nodeId", { required: true });
const orgRootId = defineModel<string | undefined>("orgRootId", {
required: true,
});
const shortName = defineModel<string>("shortName", { required: true });
const props = defineProps({
fetchDataTree: {
type: Function,
require: true,
},
fetchDataTable: {
type: Function,
require: true,
},
});
const filter = ref<string>("");
const nodes = ref<Array<OrgTree>>([]);
@ -51,50 +40,31 @@ const orgLevel = ref<number>(0);
* funtion เลอกขอม Tree
* @param data อม Tree
*/
function updateSelected(data: DataTree) {
orgRootId.value = data?.orgLevel === 0 ? data?.orgTreeId : data?.orgRootId;
store.rootId = (
data.orgLevel === 0 ? data.orgTreeId : data.orgRootId
) as string;
shortName.value = data.orgTreeShortName;
async function updateSelected(data: DataTree) {
showLoader();
try {
orgRootId.value = data?.orgLevel === 0 ? data?.orgTreeId : data?.orgRootId;
store.rootId = (
data.orgLevel === 0 ? data.orgTreeId : data.orgRootId
) as string;
if (!store.treeId || store.treeId != data.orgTreeId) {
store.treeId = data.orgTreeId;
store.level = data.orgLevel;
if (!store.treeId || store.treeId != data.orgTreeId) {
store.treeId = data.orgTreeId;
store.level = data.orgLevel;
nodeId.value = data.orgTreeId ? data.orgTreeId : "111";
nodeId.value = data.orgTreeId ? data.orgTreeId : "";
data.orgTreeId &&
props.fetchDataTable?.(data.orgTreeId, data.orgLevel, true);
/** ดึงข้อมูลสถิติจำนวนด้านบน*/
http
.post(config.API.orgSummary, {
id: data.orgTreeId, //*Id node
type: data.orgLevel, //*node
isNode: true, //* node
})
.then(async (res: any) => {
const data = await res.data.result;
if (data) {
store.getSumPosition({
totalPosition: data.totalPosition,
totalPositionCurrentUse: data.totalPositionCurrentUse,
totalPositionCurrentVacant: data.totalPositionCurrentVacant,
totalPositionNextUse: data.totalPositionNextUse,
totalPositionNextVacant: data.totalPositionNextVacant,
totalRootPosition: data.totalPosition,
totalRootPositionCurrentUse: data.totalPositionCurrentUse,
totalRootPositionCurrentVacant: data.totalPositionCurrentVacant,
totalRootPositionNextUse: data.totalPositionNextUse,
totalRootPositionNextVacant: data.totalPositionNextVacant,
});
}
});
/** ดึงข้อมูลสถิติจำนวนด้านบน*/
await fetchSummary(data);
}
} catch (error) {
console.error("Error showing loader:", error);
} finally {
hideLoader();
}
}
const treeId = ref<string>("");
const dialogDetail = ref<boolean>(false);
/**
* funtion รายละเอยดโครงสราง
@ -108,6 +78,39 @@ function onClickDetail(id: string, level: number) {
orgLevel.value = level;
}
/**
* งกนดงขอมลสถ
* @param data ขอมลโครงสราง
*/
async function fetchSummary(data: DataTree) {
await http
.post(config.API.orgSummary, {
id: data.orgTreeId, //*Id node
type: data.orgLevel, //*node
isNode: true, //* node
})
.then(async (res: any) => {
const data = await res.data.result;
if (data) {
store.getSumPosition({
totalPosition: data.totalPosition,
totalPositionCurrentUse: data.totalPositionCurrentUse,
totalPositionCurrentVacant: data.totalPositionCurrentVacant,
totalPositionNextUse: data.totalPositionNextUse,
totalPositionNextVacant: data.totalPositionNextVacant,
totalRootPosition: data.totalPosition,
totalRootPositionCurrentUse: data.totalPositionCurrentUse,
totalRootPositionCurrentVacant: data.totalPositionCurrentVacant,
totalRootPositionNextUse: data.totalPositionNextUse,
totalRootPositionNextVacant: data.totalPositionNextVacant,
});
}
})
.catch((err) => {
messageError($q, err);
});
}
watch(
() => nodeTEST.value,
() => {

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
@ -16,31 +16,19 @@ import type { OrgRevision } from "@/modules/02_organization/interface/response/o
import TreeView from "@/modules/21_report/components/01_org/Main.vue";
import StructureView from "@/modules/02_organization/components/StructureMain.vue";
import StructureOrgMain from "@/modules/02_organization/components/StructureOrgMain.vue";
// import DialogHeader from "@/components/DialogHeader.vue";
/** use*/
const $q = useQuasar();
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
const store = useOrganizational();
/** ตัวแปร*/
const modalNewStructure = ref<boolean>(false); //
const modalDateTime = ref<boolean>(false); //
const isStatusData = ref<boolean>(false); //
const typeStructure = ref<string>(""); //
/** ประวัติโครงสร้าง*/
const itemHistory = ref<DataOrgRevision[]>([]); // List
const historyId = ref<string>(""); // ID
const labelHistory = ref<string>("ประวัติโครงสร้าง"); //
const count = ref<number>(0);
// const modalCommand = ref<boolean>(false); //
// const modalRemark = ref<boolean>(false); //
/**
* function เรยกขอมลโครงสราง แบบปนและ แบบราง
* เกบขอมลใน store
*/
/** ฟังก์ชันเรียกข้อมูลโครงสร้าง แบบปัจุบันและ แบบร่าง*/
async function fetchOrganizationActive() {
showLoader();
await http
@ -49,25 +37,6 @@ async function fetchOrganizationActive() {
const data = await res.data.result;
if (data) {
await store.fetchDataActive(data);
// id isLock
if (data.draftId) {
await fetchCheckIslock(data.draftId);
} else {
store.isLosck = false;
}
if (data.activeName === null && data.draftName === null) {
isStatusData.value = false;
} else {
isStatusData.value = true;
if (isStatusData.value) {
if (data.activeName === null) {
store.typeOrganizational = "draft";
} else if (data.draftName === null) {
store.typeOrganizational = "current";
}
}
}
}
})
.catch((err) => {
@ -76,7 +45,7 @@ async function fetchOrganizationActive() {
});
}
/** function เรียกข้อมูรายการลประวัติโครงสร้าง*/
/** ฟังก์ชันเรียกข้อมูลรายการประวัติโครงสร้าง*/
async function fetchHistory() {
await http
.get(config.API.organizationHistoryNew)
@ -99,20 +68,6 @@ async function fetchHistory() {
});
}
// /**
// * function openPopup
// * @param type
// */
// function ocClickAddStructure(type: string) {
// modalNewStructure.value = !modalNewStructure.value;
// typeStructure.value = type;
// }
// /** function openPopup */
// function onClickDateTime() {
// modalDateTime.value = !modalDateTime.value;
// }
/**
* function เปดประวโครงสราง
* @param id id โครงสราง
@ -125,46 +80,6 @@ function onClickHistory(id: string, name: string) {
count.value++;
}
// async function workflowSystem() {
// http
// .get(config.API.workflowKeycloakSystem("SYS_ORG"))
// .then((res) => {
// const data = res.data.result;
// store.isOfficer = data.isOfficer;
// store.isStaff = data.isStaff;
// })
// .catch((e) => {
// messageError($q, e);
// });
// }
async function fetchCheckIslock(id: string) {
http
.get(config.API.orgIsLock + `/${id}`)
.then((res) => {
const data = res.data.result;
store.isLosck = data;
})
.catch((e) => {
messageError($q, e);
});
}
// watch(
// () => store.typeOrganizational,
// () => {
// if (
// store.typeOrganizational === "draft" &&
// store.isOfficer === null &&
// store.isStaff === null
// ) {
// workflowSystem();
// } else if (store.typeOrganizational === "draft") {
// store.rootId = "";
// }
// }
// );
/**
* lifecycleHook ทำงานเมอมการเรยกใช Components
* งขอมลโครงสรางและรายการประวโครงสราง
@ -180,71 +95,9 @@ onMounted(async () => {
รายงานโครงสรางและกรอบอตรากำล
</div>
<q-space />
<!-- <div
class="toptitle row items-center"
v-if="store.typeOrganizational === 'draft'"
>
<div
v-if="store.isPublic && store.orgPublishDate"
class="q-pr-md text-caption"
>
นทเผยแพร :
<strong>{{ date2Thai(store.orgPublishDate) }}</strong>
</div>
<q-btn
v-if="checkPermission($route)?.attrOwnership == 'OWNER'"
dense
class="q-px-md"
color="indigo-9"
icon="alarm"
label="ตั้งเวลาเผยแพร่"
@click="onClickDateTime"
>
</q-btn>
</div> -->
</div>
<q-card flat bordered>
<!-- <div class="q-pa-xl" v-if="!isStatusData">
<q-card
flat
bordered
style="
height: 70vh;
border: 1px solid rgb(210, 210, 210);
border-radius: 5px;
"
>
<div
class="text-center row"
style="
display: flex;
align-items: center;
justify-content: center;
height: 100%;
"
>
<div>
<q-btn
v-if="checkPermission($route)?.attrIsCreate"
flat
style="background-color: #d8f5f2"
round
color="primary"
size="lg"
icon="add"
@click="ocClickAddStructure('NEW')"
>
<q-tooltip>เพมโครงสราง </q-tooltip>
</q-btn>
<div class="q-mt-sm">เพมโครงสราง</div>
</div>
</div>
</q-card>
</div>
<div v-else> -->
<q-card class="my-card">
<q-card-section class="q-pa-sm">
<q-toolbar class="q-gutter-md items-center" style="padding: 0px">
@ -294,17 +147,6 @@ onMounted(async () => {
</q-btn-dropdown>
</q-btn-group>
<!-- <q-btn
v-if="store.remark"
flat
round
color="info"
icon="info"
@click="modalRemark = true"
>
<q-tooltip>หมายเหต</q-tooltip>
</q-btn> -->
<q-space />
<q-btn
flat
@ -352,23 +194,7 @@ onMounted(async () => {
</q-tab-panels>
</q-card-section>
</q-card>
<!-- </div> -->
</q-card>
<!-- <q-dialog v-model="modalRemark">
<q-card style="width: 300px">
<DialogHeader tittle="หมายเหตุ" :close="() => (modalRemark = false)" />
<q-separator />
<q-card-section>
<div class="row">
<div class="col">
{{ store.remark }}
</div>
</div>
</q-card-section>
</q-card>
</q-dialog> -->
</template>
<style scoped></style>