diff --git a/src/modules/02_organizationalNew/components/DialogFormPosition.vue b/src/modules/02_organizationalNew/components/DialogFormPosition.vue index 254a2dd22..82c99b880 100644 --- a/src/modules/02_organizationalNew/components/DialogFormPosition.vue +++ b/src/modules/02_organizationalNew/components/DialogFormPosition.vue @@ -27,6 +27,7 @@ const props = defineProps({ close: Function, orgLevel: Number, treeId: String, + actionType: String, }); const isReadonly = ref(false); // อ่านได้อย่างเดียว @@ -210,6 +211,21 @@ const visibleColumns = ref([ "positionArea", ]); +async function fetchPosition(id: string) { + showLoader(); + await http + .get(config.API.orgPosPositionById(id)) + .then((res) => { + console.log(res); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + /** function เรียกรายการประเภทตำแหน่ง */ async function fetchType() { showLoader(); @@ -329,22 +345,21 @@ function onSubmit() { orgChild2Id: props.orgLevel === 2 ? props.treeId : null, orgChild3Id: props.orgLevel === 3 ? props.treeId : null, orgChild4Id: props.orgLevel === 4 ? props.treeId : null, - positions: [positionsData], + positions: positionsData, }; - console.log(body); - // showLoader(); - // await http - // .post(config.API.orgPosMaster, body) - // .then((res) => { - // success($q, "เพิ่มข้อมูลสำเร็จ"); - // }) - // .catch((err) => { - // messageError($q, err); - // }) - // .finally(() => { - // props.close?.(); - // hideLoader(); - // }); + showLoader(); + await http + .post(config.API.orgPosMaster, body) + .then((res) => { + success($q, "เพิ่มข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + props.close?.(); + hideLoader(); + }); }); } /** ฟังชั่น บันทึก */ @@ -443,10 +458,14 @@ watch( fetchType(); fetchLevel(); fetchExecutive(); - rowsPositionSelect.value = []; - search.value = ""; - rows.value = []; - clearFormPositionSelect(); + if (props.actionType === "ADD") { + rowsPositionSelect.value = []; + search.value = ""; + rows.value = []; + clearFormPositionSelect(); + } else { + // props.treeId && fetchPosition(props.treeId); + } } } ); @@ -502,7 +521,7 @@ async function clearFormPositionSelect() {