From f899f05527fd1d28ed3c6aefb235455288a87050 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 24 Mar 2026 13:08:17 +0700 Subject: [PATCH] feat:Change Round Multiple --- .../components/03_ChangeRound/DialogForm.vue | 57 +- .../09_leave/interface/request/changeRound.ts | 2 + .../09_leave/stores/ChangeRoundStore.ts | 2 + .../09_leave/views/03_ChangeRoundMain.vue | 486 +++++++++++------- 4 files changed, 358 insertions(+), 189 deletions(-) diff --git a/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue b/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue index 0448729fb..59a5c8be2 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,35 @@ 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, + })); + } 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 +267,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..b00d7ffba 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; + selectNode: string; } interface DataOption { diff --git a/src/modules/09_leave/stores/ChangeRoundStore.ts b/src/modules/09_leave/stores/ChangeRoundStore.ts index eda800a4f..0b883fb4b 100644 --- a/src/modules/09_leave/stores/ChangeRoundStore.ts +++ b/src/modules/09_leave/stores/ChangeRoundStore.ts @@ -138,6 +138,8 @@ export const useChangeRoundDataStore = defineStore( page: dataDetail.page, //หน้า pageSize: dataDetail.pageSize || 10, //จำนวนแถวต่อหน้า keyword: dataDetail.keyword || "", //keyword ค้นหา + selectedNodeId: dataDetail.selectedNodeId, //id ต้นไม้ที่เลือก + selectNode: dataDetail.selectNode, //ระดับต้นไม้ที่เลือก }) .then((res) => { const apiData = res.data.result.data; diff --git a/src/modules/09_leave/views/03_ChangeRoundMain.vue b/src/modules/09_leave/views/03_ChangeRoundMain.vue index fdb7433d5..a123f3f0b 100644 --- a/src/modules/09_leave/views/03_ChangeRoundMain.vue +++ b/src/modules/09_leave/views/03_ChangeRoundMain.vue @@ -7,13 +7,17 @@ import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import { useChangeRoundDataStore } from "@/modules/09_leave/stores/ChangeRoundStore"; import { checkPermission } from "@/utils/permissions"; +import { useStructureTree } from "@/stores/structureTree"; +import { useRoute } from "vue-router"; import type { DataPost } from "@/modules/09_leave/interface/request/changeRound"; import Dialogform from "@/modules/09_leave/components/03_ChangeRound/DialogForm.vue"; /** useStore */ +const route = useRoute(); const mixin = useCounterMixin(); + const { showLoader, hideLoader, @@ -23,6 +27,7 @@ const { dialogConfirm, } = mixin; const dataStore = useChangeRoundDataStore(); +const { fetchStructureTree } = useStructureTree(); /** use */ const $q = useQuasar(); @@ -38,8 +43,23 @@ const formData = reactive({ lastName: "", page: 1, pageSize: 10, + selectedNodeId: null, + selectNode: "", }); +/** โครงสร้างข้อมูลต้นไม้ขององค์กร **/ +const nodeTree = ref([]); +const expanded = ref([]); +const orgTreeId = ref(null); +const filter = ref(""); +const selected = ref([]); +const isMultiple = ref(false); + +/** function fetch ข้อมูลของ Tree*/ +async function fetchDataTree() { + nodeTree.value = await fetchStructureTree(route.meta.Key as string, true); +} + /** * Function openPopup * @param check action edit,history @@ -87,6 +107,7 @@ async function OpenmodalFix(detail: any) { function closeDialog() { modal.value = false; modalFix.value = false; + isMultiple.value = false; } function save() { @@ -120,11 +141,26 @@ function updatePagination(newPagination: any) { /** Function ค้นหาข้อมูล */ async function searchData() { - if (formData.cardId || formData.firstName || formData.lastName) { - await dataStore.fetchDataForCardId(formData); - } else { - dialogMessageNotify($q, "กรุณากรอกข้อมูลอย่างน้อย 1 ช่อง"); - } + await dataStore.fetchDataForCardId(formData); +} + +function onSelectedOrgTree(data: any) { + selected.value = []; + orgTreeId.value = data.orgTreeId; + formData.selectedNodeId = data.orgTreeId; + formData.selectNode = data.orgLevel; + formData.page = 1; + searchData(); +} + +function handleSelectMultiple() { + modal.value = true; + isMultiple.value = true; + editCheck.value = "edit"; +} + +function resetSelected() { + selected.value = []; } watch( @@ -136,6 +172,7 @@ watch( ); onMounted(() => { + fetchDataTree(); dataStore.rows = []; }); @@ -143,181 +180,266 @@ onMounted(() => {
เปลี่ยนแปลงรอบการปฏิบัติงานของข้าราชการ
- -
- -
- ค้นหารายชื่อ + + + + +
+ + +
-
- + - - - ค้นหา + + +
+
+ + +
+ +
+ ค้นหารายชื่อ +
+
+ + + + ค้นหา +
+
+
+
+ ไม่พบข้อมูล
-
-
-
- ไม่พบข้อมูล -
-
- - - - + + +
+ +
@@ -328,6 +450,9 @@ onMounted(() => { :DataRow="DataRow" :personId="DataRow == null ? '' : DataRow.profileId" @update:change-page="dataStore.changePage" + v-model:isMultiple="isMultiple" + :selectedMultiple="selected" + @update:selected="resetSelected" /> @@ -384,4 +509,19 @@ onMounted(() => { .q-table tbody td:before.no-background { background: none; } + +.tree-container { + overflow: auto; + height: 75vh; + border: 1px solid #e6e6e7; + border-radius: 10px; +} + +.my-list-link { + color: rgb(118, 168, 222); + border-radius: 5px; + background: #a3d3fb48 !important; + font-weight: 600; + border: 1px solid rgba(175, 185, 196, 0.217); +}