From 95d744f2b93a075a602113fc25fe5b1e057dc674 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 11 Feb 2025 18:22:42 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87?= =?UTF-8?q?=E0=B8=B2=E0=B8=99=E0=B8=A7=E0=B8=B4=E0=B8=99=E0=B8=B1=E0=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/9_DisciplineReport/Main.vue | 87 ++++++++++++------- 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/src/modules/11_discipline/components/9_DisciplineReport/Main.vue b/src/modules/11_discipline/components/9_DisciplineReport/Main.vue index 29c105fea..e5a00f728 100644 --- a/src/modules/11_discipline/components/9_DisciplineReport/Main.vue +++ b/src/modules/11_discipline/components/9_DisciplineReport/Main.vue @@ -121,30 +121,36 @@ function onSelectedNode(id: string, level: number) { async function onUpdateFilter() { isLoadPDF.value = true; pdfSrc.value = undefined; - - const body = { - nodeId: nodeId.value, - node: nodeLevel.value, - year: year.value, - offenseDetail: offenseDetail.value, - disciplinaryFaultLevel: disciplinaryFaultLevel.value, - status: status.value, - posType: posType.value ? posType.value : null, - posLevel: posLevel.value ? posLevel.value : null, - }; - await http - .post(config.API.disciplineReportByType(employeeClass.value), body) - .then(async (res) => { - const data = res.data.result; - detailReport.value = data; - data && (await genReportPreview(data)); - }) - .catch(async (e) => { - messageError($q, JSON.parse(await e.response.data.text())); - }) - .finally(() => { - isLoadPDF.value = false; - }); + if (nodeId) { + const body = { + nodeId: nodeId.value, + node: nodeLevel.value, + year: year.value, + offenseDetail: offenseDetail.value, + disciplinaryFaultLevel: disciplinaryFaultLevel.value, + status: status.value, + posType: posType.value + ? posTypeOp.value.find((e: any) => e.id === posType.value)?.posTypeName + : null, + posLevel: posLevel.value + ? posLevelOp.value.find((e: any) => e.id === posLevel.value) + ?.posLevelName + : null, + }; + await http + .post(config.API.disciplineReportByType(employeeClass.value), body) + .then(async (res) => { + const data = res.data.result; + detailReport.value = data; + data && (await genReportPreview(data)); + }) + .catch(async (e) => { + messageError($q, JSON.parse(await e.response.data.text())); + }) + .finally(() => { + isLoadPDF.value = false; + }); + } } /** @@ -195,14 +201,21 @@ function backPage() { } } -function downloadReport(type: string) {} - /** * ฟังก์เรียกข้อมูลรายการประเภทตำแหน่ง */ async function getType() { + posType.value = ""; + posLevel.value = ""; + posTypeMainOp.value = []; + posTypeOp.value = []; + posLevelOp.value = []; + const apiPath = + employeeClass.value === "officer" + ? config.API.orgPosType + : config.API.orgEmployeeType; await http - .get(config.API.orgPosType) + .get(apiPath) .then(async (res) => { posTypeMainOp.value = await res.data.result; }) @@ -226,7 +239,7 @@ function filterOption(val: string, update: any, typeOp: string) { ); } else if (typeOp == "level") { posLevelOp.value = posLevelMainOp.value.filter( - (v: any) => v.posLevelName.toLowerCase().indexOf(needle) > -1 + (v: any) => v.posLevelName.toString().toLowerCase().indexOf(needle) > -1 ); } }); @@ -234,10 +247,20 @@ function filterOption(val: string, update: any, typeOp: string) { function updateLevel(val: string) { if (val) { - const listData = posTypeMainOp.value.find( + const listData: any = posTypeMainOp.value.find( (item: PosType) => item.id == val ); - posLevelMainOp.value = listData ? listData.posLevels : []; + console.log(listData); + if (employeeClass.value === "officer") { + posLevelMainOp.value = listData ? listData.posLevels : []; + } else { + posLevelMainOp.value = listData + ? listData.posLevels.map((e: any) => ({ + ...e, + posLevelName: `${listData?.posTypeShortName} ${e.posLevelName}`, + })) + : []; + } } } onMounted(async () => { @@ -263,15 +286,15 @@ onMounted(async () => { option-label="name" option-value="id" style="width: 230px" - @update:model-value="onUpdateFilter" + @update:model-value="getType" >