diff --git a/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue b/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue index 0448729fb..954827e64 100644 --- a/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue +++ b/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue @@ -27,7 +27,11 @@ const { convertDateToAPI, } = mixin; -const emit = defineEmits(["update:change-page"]); +const emit = defineEmits(["update:change-page", "update:selected"]); + +const isMultiple = defineModel("isMultiple", { + default: false, +}); /**Props */ const props = defineProps({ @@ -40,6 +44,10 @@ const props = defineProps({ type: String, default: "", }, + selectedMultiple: { + type: Array, + default: () => [], + }, }); /**FormData */ @@ -118,18 +126,43 @@ function onSubmit() { async function changeRound() { const formattedDateForAPI = await convertDateToAPI(formData.effectiveDate); - const url = + const urlAPI = props.type == "emp" ? config.API.leaveRoundEMP() : config.API.leaveRound(); showLoader(); - await http - .post(url, { + + const urlFull = isMultiple.value ? urlAPI + `/multiple ` : urlAPI; + let payload: any; + if (isMultiple.value && props.selectedMultiple.length > 0) { + payload = props.selectedMultiple.map((item: any) => ({ + profileId: item.profileId, + roundId: formData.round, + effectiveDate: formattedDateForAPI, + remark: formData.reson, + firstName: item.firstName, + lastName: item.lastName, + prefix: item.prefix, + rootDnaId: item.rootDnaId, + child1DnaId: item.child1DnaId, + child2DnaId: item.child2DnaId, + child3DnaId: item.child3DnaId, + child4DnaId: item.child4DnaId, + })); + } else { + payload = { profileId: props.personId, roundId: formData.round, effectiveDate: formattedDateForAPI, remark: formData.reson, - }) + }; + } + await http + .post(urlFull, payload) .then(() => { success($q, "บันทึกข้อมูลเปลี่ยนรอบเวลา"); + if (isMultiple.value) { + emit("update:selected"); + isMultiple.value = false; + } props.closeDialog?.(); }) .catch((err) => { @@ -242,10 +275,10 @@ watch( ? "เปลี่ยนรอบการปฏิบัติงาน" : "ประวัติการเปลี่ยนรอบการปฏิบัติงาน" }} - {{ - props.DataRow ? props.DataRow.fullName : "" - }} + + {{ props.DataRow ? props.DataRow.fullName : "" }} + +
-
+
- รอบปัจจุบัน - {{ - props.DataRow ? `${props.DataRow.currentRound} น.` : "" - }} + + รอบปัจจุบัน + + + {{ props.DataRow ? `${props.DataRow.currentRound} น.` : "" }} +
diff --git a/src/modules/09_leave/interface/request/changeRound.ts b/src/modules/09_leave/interface/request/changeRound.ts index ed8c9347a..7dfc20841 100644 --- a/src/modules/09_leave/interface/request/changeRound.ts +++ b/src/modules/09_leave/interface/request/changeRound.ts @@ -4,6 +4,8 @@ interface DataPost { lastName: string; page: number; pageSize: number; + selectedNodeId: string | null; + selectedNode: string; } interface DataOption { diff --git a/src/modules/09_leave/stores/ChangeRoundStore.ts b/src/modules/09_leave/stores/ChangeRoundStore.ts index eda800a4f..8914ebd4f 100644 --- a/src/modules/09_leave/stores/ChangeRoundStore.ts +++ b/src/modules/09_leave/stores/ChangeRoundStore.ts @@ -125,7 +125,7 @@ export const useChangeRoundDataStore = defineStore( async function fetchDataForCardId(dataDetail: any, type?: string) { if (dataDetail) { - showLoader(); + // showLoader(); const url = type && type == "emp" ? config.API.leaveSearchEMP() @@ -138,6 +138,8 @@ export const useChangeRoundDataStore = defineStore( page: dataDetail.page, //หน้า pageSize: dataDetail.pageSize || 10, //จำนวนแถวต่อหน้า keyword: dataDetail.keyword || "", //keyword ค้นหา + selectedNodeId: dataDetail.selectedNodeId, //id ต้นไม้ที่เลือก + selectedNode: dataDetail.selectedNode, //ระดับต้นไม้ที่เลือก }) .then((res) => { const apiData = res.data.result.data; @@ -148,6 +150,7 @@ export const useChangeRoundDataStore = defineStore( if (apiData.length > 0) { checkCilck.value = false; rows.value = apiData.map((e: any) => ({ + ...e, profileId: e.profileId, cardId: e.citizenId, fullName: e.fullName, @@ -167,7 +170,7 @@ export const useChangeRoundDataStore = defineStore( console.log(e); }) .finally(() => { - hideLoader(); + // hideLoader(); }); } } diff --git a/src/modules/09_leave/views/03_ChangeRoundMain.vue b/src/modules/09_leave/views/03_ChangeRoundMain.vue index fdb7433d5..5bbb76fc5 100644 --- a/src/modules/09_leave/views/03_ChangeRoundMain.vue +++ b/src/modules/09_leave/views/03_ChangeRoundMain.vue @@ -1,5 +1,5 @@