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"
>