diff --git a/src/modules/05_placement/components/OrderPlacement/detailOrderPlacement.vue b/src/modules/05_placement/components/OrderPlacement/detailOrderPlacement.vue index 2dd25af95..35f34e817 100644 --- a/src/modules/05_placement/components/OrderPlacement/detailOrderPlacement.vue +++ b/src/modules/05_placement/components/OrderPlacement/detailOrderPlacement.vue @@ -77,7 +77,7 @@ const nextStep = async () => { }; const previousStep = async () => { stepper.value!.previous(); - // localStorage.setItem("currentStep", step.value.toString()); + localStorage.setItem("currentStep", step.value.toString()); if (orderId.value) { await http .put(config.API.prevStep(orderId.value)) diff --git a/src/modules/05_placement/components/OrderPlacement/step/step02.vue b/src/modules/05_placement/components/OrderPlacement/step/step02.vue index 984d6d2fc..15087cc43 100644 --- a/src/modules/05_placement/components/OrderPlacement/step/step02.vue +++ b/src/modules/05_placement/components/OrderPlacement/step/step02.vue @@ -405,6 +405,7 @@ const getData = async (id: string) => { personalId: r.personalId ?? "", selectStatus: r.selectStatus !== null ? r.selectStatus : false, sequence: r.sequence !== null ? r.sequence : 0, + refRecordId: r.refRecordId, }); }); // console.log("list", list); @@ -418,21 +419,21 @@ const getData = async (id: string) => { }); }; -const saveSalary = async (id: string) => { - await http - .put(config.API.salaryOrder(id)) - .then((res) => { - // const data = res.data.result; - // console.log(res); - success($q, "บันทึกข้อมูลสำเร็จ"); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); - }); -}; +// const saveSalary = async (id: string) => { +// await http +// .put(config.API.salaryOrder(id)) +// .then((res) => { +// // const data = res.data.result; +// // console.log(res); +// success($q, "บันทึกข้อมูลสำเร็จ"); +// }) +// .catch((e) => { +// messageError($q, e); +// }) +// .finally(() => { +// hideLoader(); +// }); +// }; const dialogDeleteData = async (id: string) => { dialogMessage( @@ -501,11 +502,11 @@ const swapDown = async (id: string) => { const upDown = async (value: any, up: boolean = true) => { const indexCurrent = value.rowIndex; if (up) { - await swapUp(value.row.personId); + await swapUp(value.row.personalId); // rows.value[indexCurrent] = rows.value[indexCurrent - 1]; // rows.value[indexCurrent - 1] = value.row; } else { - await swapDown(value.row.personId); + await swapDown(value.row.personalId); // rows.value[indexCurrent] = rows.value[indexCurrent + 1]; // rows.value[indexCurrent + 1] = value.row; } @@ -515,27 +516,86 @@ const saveModal = () => { if (myForm.value !== null) { myForm.value.validate().then(async (result: boolean) => { if (result) { - modalOpenClose(); + putSalary(modalData.value); } }); } }; - +const personalId = ref(""); const selectModal = (e: any) => { + console.log(e); titleName.value = e.name; - modalData.value = { - salaryAmount: 0, - positionSalaryAmount: 0, - mouthSalaryAmount: 0, - }; - modalOpenClose(); + personalId.value = e.personalId; + // modalData.value = { + // salaryAmount: 0, + // positionSalaryAmount: 0, + // mouthSalaryAmount: 0, + // }; + + modalOpenClose(e.personalId); }; -const modalOpenClose = () => { +const modalOpenClose = async (personalId: string) => { modal.value = !modal.value; if (!modal.value) { titleName.value = ""; } + if (modal.value == true) { + await fetchSalary(personalId); + } +}; +const fetchSalary = async (personalId: string) => { + console.log(personalId); + showLoader(); + await http + .get(config.API.salaryOrder(personalId)) + .then((res: any) => { + console.log(res); + let salary = res.data.result; + modalData.value = { + salaryAmount: salary.salaryAmount, + positionSalaryAmount: salary.positionSalaryAmount, + mouthSalaryAmount: salary.monthSalaryAmount, + }; + }) + .catch((e) => { + console.log(e); + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +}; +const putSalary = async (salary: any) => { + modalData.value = { + salaryAmount: Number(salary.salaryAmount), + positionSalaryAmount: Number(salary.positionSalaryAmount), + mouthSalaryAmount: Number(salary.mouthSalaryAmount), + }; + $q.dialog({ + title: "ยืนยันการบันทึกข้อมูล", + message: "ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?", + cancel: { + flat: true, + color: "negative", + }, + persistent: true, + }).onOk(async () => { + await http + .put(config.API.salaryOrder(personalId.value), modalData.value) + .then((res: any) => { + console.log(res); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((e) => { + console.log(e); + messageError($q, e); + }) + .finally(async () => { + await conditionData(); + modal.value = false; + }); + }); }; const modalAddChange = async () => { @@ -559,6 +619,7 @@ const fetchaddlist = async (id: string) => { personalId: r.personalId ?? "", selectStatus: r.selectStatus !== null ? r.selectStatus : false, sequence: r.sequence !== null ? r.sequence : 0, + refRecordId: r.refRecordId, })); rows2.value = list.filter((e: any) => e.selectStatus === false); }) @@ -583,7 +644,7 @@ const saveModalAdd = () => { persistent: true, }).onOk(async () => { let data = []; - data.push(...selected.value.map((e: any) => e.personalId)); + data.push(...selected.value.map((e: any) => e.refRecordId)); // console.log(data); addlist(data); }); @@ -595,7 +656,6 @@ const addlist = async (data: Object) => { await http .post(config.API.personsOrder(orderId.value), data) .then(() => { - // console.log(res); success($q, "บันทึกสำเร็จ"); }) .catch((e: any) => { @@ -613,22 +673,33 @@ const click = (e: any) => { }; const save = () => { - // if (selected.value.length > 0) { - // next(); - // } else { - // dialogMessage( - // $q, - // "ข้อความแจ้งเตือน", - // "กรุณาเลือกรายชื่อ", - // "warning", - // undefined, - // "orange", - // undefined, - // undefined, - // true - // ); - // } - next(); + $q.dialog({ + title: "ยืนยันการบันทึกข้อมูล", + message: "ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?", + cancel: { + flat: true, + color: "negative", + }, + persistent: true, + }).onOk(async () => { + success($q, "บันทึกข้อมูลสำเร็จ"); + next(); + }); + // if (selected.value.length > 0) { + // next(); + // } else { + // dialogMessage( + // $q, + // "ข้อความแจ้งเตือน", + // "กรุณาเลือกรายชื่อ", + // "warning", + // undefined, + // "orange", + // undefined, + // undefined, + // true + // ); + // } }; const selectData = (row: any) => {}; diff --git a/src/modules/05_placement/components/probation/FormAssign.vue b/src/modules/05_placement/components/probation/FormAssign.vue index 118688674..a3511744f 100644 --- a/src/modules/05_placement/components/probation/FormAssign.vue +++ b/src/modules/05_placement/components/probation/FormAssign.vue @@ -1599,6 +1599,7 @@ interface MonthOption { label: string; } const monthOp: MonthOption[] = []; + //-----------------(3.1)-----------// const activityCount = ref(2); const activityDataArray = ref([]); @@ -1811,12 +1812,12 @@ const putData = (id: string) => { const assign_director = [ { - personal_id: caretakerFoot.value.personal_id, + personal_id: caretaker1.value.personal_id, role: "mentor", dated: date2.value instanceof Date ? dateToISO(date2.value) : null, }, { - personal_id: caretakerFoot2.value.personal_id, + personal_id: caretaker2.value.personal_id, role: "mentor", dated: date3.value instanceof Date ? dateToISO(date3.value) : null, }, @@ -1862,8 +1863,7 @@ const putData = (id: string) => { checked: item.checked, })), }; - console.log("test", data); - + return data }; const saveData = (id: string) => { @@ -1882,7 +1882,7 @@ const saveData = (id: string) => { http .post(config.API.saveFinish(id), data) .then((res) => { - console.log("🚀 ~ file: FormAssign.vue:1887 ~ .then ~ res:", res); + router.push(`/probation/detail/${id}`); }) .catch((e) => {}) .finally(() => { diff --git a/src/modules/05_placement/interface/response/Order.ts b/src/modules/05_placement/interface/response/Order.ts index cb3d31be5..375361a97 100644 --- a/src/modules/05_placement/interface/response/Order.ts +++ b/src/modules/05_placement/interface/response/Order.ts @@ -5,6 +5,7 @@ interface ResponseData { personalId: string; selectStatus: boolean; sequence: number; + refRecordId: string } interface ResponseOrganiz {