diff --git a/src/modules/07_insignia/interface/index/Main.ts b/src/modules/07_insignia/interface/index/Main.ts index 2d1471482..d911dcfaa 100644 --- a/src/modules/07_insignia/interface/index/Main.ts +++ b/src/modules/07_insignia/interface/index/Main.ts @@ -174,6 +174,37 @@ interface DataManageList { statusMark: boolean; } +interface ResOrg { + labelName: string; + orgCode: string; + orgLevel: number; + orgName: string; + orgRevisionId: string; + orgRootName: string; + orgTreeCode: string; + orgTreeFax: string; + orgTreeId: string; + orgTreeName: string; + orgTreeOrder: number; + orgTreePhoneEx: string; + orgTreePhoneIn: string; + orgTreeRank: string; + orgTreeRankSub: string; + orgTreeShortName: string; + responsibility: string; + totalPosition: number; + totalPositionCurrentUse: number; + totalPositionCurrentVacant: number; + totalPositionNextUse: number; + totalPositionNextVacant: number; + totalRootPosition: number; + totalRootPositionCurrentUse: number; + totalRootPositionCurrentVacant: number; + totalRootPositionNextUse: number; + totalRootPositionNextVacant: number; + children: ResOrg[]; +} + export type { DataOption, OptionData, @@ -194,4 +225,5 @@ export type { DataProfileOtherSystem, Pagination, DataManageList, + ResOrg }; diff --git a/src/modules/15_development/views/MainPage.vue b/src/modules/15_development/views/MainPage.vue index f7c006988..f39a0c687 100644 --- a/src/modules/15_development/views/MainPage.vue +++ b/src/modules/15_development/views/MainPage.vue @@ -168,7 +168,7 @@ function fetchListProjectNew() { function onDownload() { showLoader(); http - .get(config.API.developmentReportMain()) + .get(config.API.developmentReportMain() + `?rootId=${formQuery.nodeId}`) .then((res) => { const dataList = res.data.result; genReportXLSX( @@ -436,6 +436,7 @@ onMounted(() => { (false); const year = ref(new Date().getFullYear()); -const employeeClass = ref("officer"); -const employeeClassOption = ref([ - { id: "officer", name: "ข้าราชการ กทม. สามัญ" }, - { id: "employee", name: "ลูกจ้างประจำ กทม." }, -]); -const typeReport = ref("main"); +const organization = ref(""); +const organizationOpsMain = ref([]); +const organizationOps = ref([]); + +const typeReport = ref(""); const optionReport = ref([ { id: "main", @@ -70,23 +75,33 @@ function backPage() { } async function getReport() { - loadingBtn.value = true; - pdfSrc.value = undefined; - await http - .get(config.API.developmentReport() + `${typeReport.value}`) - .then(async (res) => { - const data = res.data.result; - detailReport.value = data; - await fetchDocumentTemplate(data); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - setTimeout(() => { - loadingBtn.value = false; - }, 500); - }); + if (typeReport.value !== "main" && typeReport.value !== "report3") { + organization.value = ""; + } + if ( + (typeReport.value && + typeReport.value !== "main" && + typeReport.value !== "report3") || + (typeReport.value && organization.value) + ) { + loadingBtn.value = true; + pdfSrc.value = undefined; + await http + .get(config.API.developmentReport() + `${typeReport.value}${typeReport.value == 'main' || typeReport.value == 'report3' ? `?rootId=${organization.value}`:``}`) + .then(async (res) => { + const data = res.data.result; + detailReport.value = data; + await fetchDocumentTemplate(data); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + setTimeout(() => { + loadingBtn.value = false; + }, 500); + }); + } } /** @@ -117,9 +132,62 @@ async function fetchDocumentTemplate(data: any) { }); } +/** + * function ค้นหาคำใน select + * @param val คำค้นหา + * @param update function + */ +function filterSelector(val: string, update: Function) { + update(() => { + organizationOps.value = organizationOpsMain.value.filter( + (v: OptionData) => v.name.toLowerCase().indexOf(val) > -1 + ); + }); +} + +/** + * function fetch ข้อมูลโครงสร้างปัจจุบัน + */ +function getActiveId() { + showLoader(); + http + .get(config.API.activeOrganization) + .then((res) => { + const data = res.data.result; + getOrg(data.activeId); + }) + .catch((err) => { + messageError($q, err); + hideLoader(); + }); +} + +/** + * function fetch ข้อมูลหน่วยงาน + * @param id โครงสร้างปัจจุบัน + */ +async function getOrg(id: string) { + showLoader(); + await http + .get(config.API.orgByIdSystem(id, route.meta.Key as string)) + .then(async (res) => { + const data = await res.data.result.map((item: ResOrg) => ({ + id: item.orgTreeId, + name: item.orgName, + })); + organizationOpsMain.value = data; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + onMounted(async () => { showLoader(); - Promise.all([getReport()]) + Promise.all([getReport(), getActiveId()]) .then(() => { hideLoader(); }) @@ -164,6 +232,11 @@ onMounted(async () => { { -
+
-
- +
+ + + + + +
+
- - - - + + +