diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 19a34b306..91bc7790d 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -35,6 +35,8 @@ export default { orgPosPositionExecutive: () => `${orgPos}/position/executive`, orgPosExecutive: `${orgPos}/executive`, orgPosType: `${orgPos}/type`, + orgPosTypeSearch: `${orgPos}/position/search`, + orgPosTypeId: (id: string) => `${orgPos}/type/${id}`, orgPosLevel: `${orgPos}/level`, orgPosMaster: `${orgPos}/master`, @@ -66,7 +68,8 @@ export default { // ค้นหาคนตามเงื่อนไข orgSearchPersonal: () => `${organization}/profile/search-personal`, - orgSearchPersonalByType: (type:string) => `${organization}/profile${type}/search-personal`, + orgSearchPersonalByType: (type: string) => + `${organization}/profile${type}/search-personal`, /** บรรจุแต่งตั้ง*/ orgPosPlacement: `${orgPos}/placement/search`, @@ -158,5 +161,5 @@ export default { keycloakLogSSO: `${organization}/keycloak/log/sso`, - reportOrgByType:(type:string)=>`${reportOrg}/registry-${type}` + reportOrgByType: (type: string) => `${reportOrg}/registry-${type}`, }; diff --git a/src/modules/03_recruiting/views/02_qualify/PeriodAdd.vue b/src/modules/03_recruiting/views/02_qualify/PeriodAdd.vue index 79707be3d..81466990d 100644 --- a/src/modules/03_recruiting/views/02_qualify/PeriodAdd.vue +++ b/src/modules/03_recruiting/views/02_qualify/PeriodAdd.vue @@ -142,12 +142,13 @@ const columnsPosition = ref([ sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, + { - name: "position", + name: "highDegree", align: "left", - label: "ตำแหน่ง", + label: "ประเภทตำแหน่ง", sortable: true, - field: "position", + field: "highDegree", headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => @@ -165,16 +166,17 @@ const columnsPosition = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { - name: "highDegree", + name: "position", align: "left", - label: "ประเภทตำแหน่ง", + label: "ตำแหน่ง", sortable: true, - field: "highDegree", + field: "position", headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, + { name: "type", align: "left", @@ -358,18 +360,32 @@ async function fetchPositionLevel() { * @param update Function #quasar * @param refData เเยก case */ -function filterSelector(val: any, update: Function, refData: string) { +function filterSelector(val: string, update: Function, refData: string) { switch (refData) { - case "positionLevel": + case "positionLevel1": update(() => { - positionLevelOptions.value = positionLevelFilters.value.filter( + optionPosLevel1.value = filterOptionPosLevel1.value.filter( (v: DataOption2) => v.name.indexOf(val) > -1 ); }); break; - case "position": + case "positionLevel2": update(() => { - positionPathOptions.value = positionPathFilters.value.filter( + optionPosLevel2.value = filterOptionPosLevel2.value.filter( + (v: DataOption2) => v.name.indexOf(val) > -1 + ); + }); + break; + case "position1": + update(() => { + optionPosType1.value = filterOptionPosType1.value.filter( + (v: DataOption2) => v.name.indexOf(val) > -1 + ); + }); + break; + case "position2": + update(() => { + optionPosType2.value = filterOptionPosType2.value.filter( (v: DataOption2) => v.name.indexOf(val) > -1 ); }); @@ -495,16 +511,16 @@ async function editData(id: string) { showLoader(); await http .put(config.API.periodExamId(id), sendData()) - .then(async (res) => { - success($q, "แก้ไขรอบคัดเลือกสำเร็จ"); + .then(async () => { await uploadImgData(); await uploadDocData(); + success($q, "แก้ไขรอบคัดเลือกสำเร็จ"); await clickBack(); }) .catch((e) => { messageError($q, e); }) - .finally(async () => { + .finally(() => { hideLoader(); }); } @@ -656,7 +672,7 @@ function clickAddPosition() { position: null, type: { id: "normol", name: "ทั่วไป" }, code: null, - highDegree: "0", + highDegree: "", }); } }); @@ -704,6 +720,86 @@ function clearDateAnnounce() { dateAnnounce.value = null; } +const mainDataPosLevel = ref([]); +const optionPosLevel1 = ref([]); +const filterOptionPosLevel1 = ref([]); + +const optionPosLevel2 = ref([]); +const filterOptionPosLevel2 = ref([]); + +async function fetchPositionType() { + http + .get(config.API.orgPosType) + .then((res) => { + mainDataPosLevel.value = res.data.result.filter( + (e: any) => e.posTypeRank <= 2 + ); + + const getDataByRank = (rank: number) => { + const data = + res.data.result.find((e: any) => e.posTypeRank === rank)?.posLevels || + []; + return data + .filter((e: any) => e.posLevelRank === 1) + .map((e: any) => ({ + id: e.id.toString(), + name: e.posLevelName.toString(), + level: e.posLevelRank, + })); + }; + + optionPosLevel1.value = getDataByRank(1); + filterOptionPosLevel1.value = getDataByRank(1); + optionPosLevel2.value = getDataByRank(2); + filterOptionPosLevel2.value = getDataByRank(2); + + fetchPosition(1); + fetchPosition(2); + }) + .catch((err) => { + messageError($q, err); + }); +} + +const optionPosType1 = ref([]); +const filterOptionPosType1 = ref([]); + +const optionPosType2 = ref([]); +const filterOptionPosType2 = ref([]); + +function fetchPosition(level: number) { + http + .post(config.API.orgPosTypeSearch, { + posType: mainDataPosLevel.value.find((e: any) => e.posTypeRank === level) + .id, + posLevel: + level === 1 ? optionPosLevel1.value[0].id : optionPosLevel2.value[0].id, + }) + .then((res) => { + const option: DataOption2[] = res.data.result.map((r: any) => ({ + id: r.id.toString(), + name: r.positionName.toString(), + })); + + if (level === 1) { + optionPosType1.value = option; + filterOptionPosType1.value = option; + } else if (level === 2) { + optionPosType2.value = option; + filterOptionPosType2.value = option; + } + }) + .catch((err) => { + messageError($q, err); + }); +} + +function onUpdateHighDegree(val: string, index: string) { + rowsPosition.value[index].position = null; + rowsPosition.value[index].level = + val === "0" ? optionPosLevel1.value[0] : optionPosLevel2.value[0]; +} + watch(fee, () => { if (fee.value <= 0) { pay.value = ""; @@ -720,6 +816,7 @@ onMounted(async () => { pay.value = ""; edit.value = false; } + await fetchPositionType(); await fetchPositionPath(); await fetchPositionLevel(); }); @@ -1093,82 +1190,7 @@ onMounted(async () => { mask="###" /> - - - - - - - - - - - - + { color="teal" :disable="checkRoutePermisson" val="0" + @update:model-value=" + onUpdateHighDegree( + props.row.highDegree, + props.rowIndex + ) + " /> { color="teal" :disable="checkRoutePermisson" val="1" + @update:model-value=" + onUpdateHighDegree( + props.row.highDegree, + props.rowIndex + ) + " /> + + + + + + + + + + + +