From a2ff9264ee00416d0a6f254aaa73d3e9a9acfe45 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 20 Feb 2024 16:07:12 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=A5=E0=B8=B7=E0=B8=AD=E0=B8=81?= =?UTF-8?q?=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=A7=E0=B8=A2=E0=B8=87=E0=B8=B2?= =?UTF-8?q?=E0=B8=99=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B8=A3=E0=B8=B1=E0=B8=9A?= =?UTF-8?q?=E0=B8=9A=E0=B8=A3=E0=B8=A3=E0=B8=88=E0=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/02_organizational/api.organization.ts | 1 + .../components/PersonalList/CardPosition.vue | 59 ++++++++------ .../PersonalList/DialogSelectOrg.vue | 79 ++++++++++++++++--- .../components/PersonalList/Table.vue | 13 ++- .../05_placement/stores/storeSelect.ts | 5 ++ 5 files changed, 119 insertions(+), 38 deletions(-) diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index ff5072f0b..bde8568bc 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -54,4 +54,5 @@ export default { /** บรรจุแต่งตั้ง*/ orgPosPlacement: `${orgPos}/placement/search`, + orgPosFind: `${organization}/find/node`, }; diff --git a/src/modules/05_placement/components/PersonalList/CardPosition.vue b/src/modules/05_placement/components/PersonalList/CardPosition.vue index 12521db07..f21cfa7af 100644 --- a/src/modules/05_placement/components/PersonalList/CardPosition.vue +++ b/src/modules/05_placement/components/PersonalList/CardPosition.vue @@ -1,5 +1,5 @@ - diff --git a/src/modules/05_placement/components/PersonalList/DialogSelectOrg.vue b/src/modules/05_placement/components/PersonalList/DialogSelectOrg.vue index 8ba58a714..4b90d70cb 100644 --- a/src/modules/05_placement/components/PersonalList/DialogSelectOrg.vue +++ b/src/modules/05_placement/components/PersonalList/DialogSelectOrg.vue @@ -25,6 +25,7 @@ import { useSelectOrgStore } from "@/modules/05_placement/stores/storeSelect"; const $q = useQuasar(); const store = useSelectOrgStore(); const { + success, showLoader, hideLoader, messageError, @@ -41,6 +42,11 @@ const props = defineProps({ type: Object, require: true, }, + fetchTable: { + type: Function, + require: true, + }, + fetchStatCard: { type: Function, require: true }, }); /** Tree*/ @@ -53,6 +59,7 @@ const expanded = ref([]); const positionNo = ref(); const positionId = ref(""); +const seletcId = ref(""); const selectedPos = ref([]); const datePos = ref(new Date()); @@ -107,9 +114,18 @@ async function fetchDataTree(id: string) { * @param data ข่อมูล Tree */ function updateSelected(data: TreeMain) { + console.log(props?.dataRow?.nodeId === data.orgTreeId); + if (props?.dataRow?.nodeId === data.orgTreeId) { + positionId.value = props?.dataRow?.posmasterId; + seletcId.value = props?.dataRow?.positionId; + } else { + positionId.value = ""; + seletcId.value = ""; + selectedPos.value = []; + } + nodeId.value = data.orgTreeId ? data.orgTreeId : ""; nodeLevel.value = data.orgLevel; - selectedPos.value = []; datePos.value = new Date(); fetchDataTable(data.orgTreeId, data.orgLevel); } @@ -146,19 +162,59 @@ async function fetchDataTable(id: string, level: number = 0) { .finally(() => {}); } +async function fetchPosFind(level: number, id: string) { + showLoader(); + const body = { + node: level, + nodeId: id, + }; + await http + .post(config.API.orgPosFind, body) + .then((res) => { + const data = res.data.result; + console.log(data); + + expanded.value = data; + nodeId.value = id; + positionId.value = props?.dataRow?.posmasterId; + seletcId.value = props?.dataRow?.positionId; + + fetchDataTable(nodeId.value, level); + }) + .catch((e) => { + messageError($q, e); + hideLoader(); + }); +} + function onClickSubmit() { if (selectedPos.value.length === 0) { dialogMessageNotify($q, "กรุณาเลือกตำแหน่ง"); } else { - dialogConfirm($q, () => { + dialogConfirm($q, async () => { + showLoader(); const body = { + PersonalId: props?.dataRow?.personalId, node: nodeLevel.value, nodeId: nodeId.value, posmasterId: positionId.value, positionId: selectedPos.value[0].id, reportingDate: datePos.value, }; - console.log(body); + await http + .post(config.API.placementPass(), body) + .then(() => { + success($q, "บันทึกข้อมูลสำเร็จ"); + props.fetchStatCard?.(); + props.fetchTable?.(); + closePopup(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); }); } } @@ -174,15 +230,13 @@ watch( if (modal.value) { showLoader(); await fetchOrganizationActive(); - // console.log(props.dataRow); + console.log(props.dataRow); - expanded.value = []; - // expanded.value = [ - // "c6164a42-539d-401a-b289-653282c08e37", - // "277e5221-9c47-43ca-a7a5-0ba6e30039c4", - // ]; - // nodeId.value = "c6164a42-539d-401a-b289-653282c08e37"; - // fetchDataTable(nodeId.value); + if (props?.dataRow?.node !== null && props?.dataRow?.nodeId !== null) { + await fetchPosFind(props?.dataRow?.node, props?.dataRow?.nodeId); + } else { + expanded.value = []; + } } else { clearData(); } @@ -288,10 +342,11 @@ function filterItemsTaps(data: TreeMain[]) { :name="item" > diff --git a/src/modules/05_placement/components/PersonalList/Table.vue b/src/modules/05_placement/components/PersonalList/Table.vue index df4a1a970..e1937568c 100644 --- a/src/modules/05_placement/components/PersonalList/Table.vue +++ b/src/modules/05_placement/components/PersonalList/Table.vue @@ -302,6 +302,10 @@ async function getTable() { deferment: data.deferment, draft: convertDraft(data.draft), positionCandidate: data.positionCandidate, + node: data.node, + nodeId: data.nodeId, + posmasterId: data.posmasterId, + positionId: data.positionId, }; rowsAll.value.push(rowData); }); @@ -492,6 +496,8 @@ function openAppointModal(pid: string, data: DataList) { // personal.value = dataRes.value.filter( // (e: any) => e.personalId == personalId.value // ); + // console.log(personal.value); + dataRow.value = data; modalDialogSelectOrg.value = !modalDialogSelectOrg.value; } @@ -1222,7 +1228,12 @@ onMounted(async () => { - +