From 5dfa5bea4f4fc6b4479ca9ab6609c5bf36be7b5b Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Wed, 9 Aug 2023 16:10:02 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B9=89=20API=20=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3?= =?UTF-8?q?=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=20Step2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/05_placement/api.placement.ts | 1 + .../components/OrderPlacement/step/step02.vue | 110 +++++++++++++----- .../05_placement/interface/response/Order.ts | 2 +- 3 files changed, 86 insertions(+), 27 deletions(-) diff --git a/src/api/05_placement/api.placement.ts b/src/api/05_placement/api.placement.ts index 108f63ad8..b9cc81f9b 100644 --- a/src/api/05_placement/api.placement.ts +++ b/src/api/05_placement/api.placement.ts @@ -70,6 +70,7 @@ export default { //ข้อมูลเลือกรายชื่อออกคำสั่ง, ลบรายชื่อ personsOrder: (orderId: string) => `${order}/order/persons/${orderId}`, + personsselectedOrder: (orderId: string) => `${order}/order/persons-selected/${orderId}`, //เปลี่ยน status ของคำสั่งไปขั้นตอนถัดไป nextOrder: (orderId: string) => `${order}/order/next/${orderId}`, diff --git a/src/modules/05_placement/components/OrderPlacement/step/step02.vue b/src/modules/05_placement/components/OrderPlacement/step/step02.vue index 49eb96d11..984d6d2fc 100644 --- a/src/modules/05_placement/components/OrderPlacement/step/step02.vue +++ b/src/modules/05_placement/components/OrderPlacement/step/step02.vue @@ -109,7 +109,7 @@ div flat round color="red" - @click="dialogDeleteData(props.row.personId)" + @click="dialogDeleteData(props.row.personalId)" icon="mdi-delete" > ลบข้อมูล @@ -226,7 +226,7 @@ div ([ }, ]); const rows = ref([]); +const rows2 = ref([]); const selected = ref([]); +const orderId = ref(route.params.orderid.toString()); onMounted(async () => { await conditionData(); @@ -390,17 +392,17 @@ const conditionData = async () => { const getData = async (id: string) => { showLoader(); await http - .get(config.API.personsOrder(id)) + .get(config.API.personsselectedOrder(id)) .then((res) => { const data = res.data.result; - // console.log(data); + console.log(data); let list: ResponseData[] = []; data.map((r: ResponseData) => { list.push({ education: r.education ?? "", idCard: r.idCard ?? "", name: r.name ?? "", - personId: r.personId ?? "", + personalId: r.personalId ?? "", selectStatus: r.selectStatus !== null ? r.selectStatus : false, sequence: r.sequence !== null ? r.sequence : 0, }); @@ -456,8 +458,9 @@ const deleteData = async (id: string) => { .catch((e) => { messageError($q, e); }) - .finally(() => { + .finally(async () => { hideLoader(); + await conditionData(); }); }; @@ -535,19 +538,74 @@ const modalOpenClose = () => { } }; -const modalAddChange = () => { +const modalAddChange = async () => { modalAdd.value = !modalAdd.value; + if (modalAdd.value == true) { + await fetchaddlist(orderId.value); + } else await conditionData(); +}; +const fetchaddlist = async (id: string) => { + showLoader(); + await http + .get(config.API.personsOrder(id)) + .then((res) => { + const data = res.data.result; + console.log(data); + let list = []; + list = data.map((r: ResponseData) => ({ + education: r.education ?? "", + idCard: r.idCard ?? "", + name: r.name ?? "", + personalId: r.personalId ?? "", + selectStatus: r.selectStatus !== null ? r.selectStatus : false, + sequence: r.sequence !== null ? r.sequence : 0, + })); + rows2.value = list.filter((e: any) => e.selectStatus === false); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); }; - const saveModalAdd = () => { if (myFormAdd.value !== null) { myFormAdd.value.validate().then(async (result: boolean) => { - if (result) { - modalAddChange(); + if (result && selected.value.length !== 0) { + $q.dialog({ + title: "ยืนยันการเพิ่มรายชื่อออกคำสั่ง", + message: "ต้องการยืนยันการเพิ่มรายชื่อออกคำสั่งนี้ใช่หรือไม่?", + cancel: { + flat: true, + color: "negative", + }, + persistent: true, + }).onOk(async () => { + let data = []; + data.push(...selected.value.map((e: any) => e.personalId)); + // console.log(data); + addlist(data); + }); } }); } }; +const addlist = async (data: Object) => { + await http + .post(config.API.personsOrder(orderId.value), data) + .then(() => { + // console.log(res); + success($q, "บันทึกสำเร็จ"); + }) + .catch((e: any) => { + console.log(e); + messageError($q, e); + }) + .finally(() => { + modalAddChange(); + }); +}; const click = (e: any) => { console.log(e); @@ -555,28 +613,28 @@ const click = (e: any) => { }; const save = () => { - // if (selected.value.length > 0) { - // next(); - // } else { - // dialogMessage( - // $q, - // "ข้อความแจ้งเตือน", - // "กรุณาเลือกรายชื่อ", - // "warning", - // undefined, - // "orange", - // undefined, - // undefined, - // true - // ); - // } + // if (selected.value.length > 0) { + // next(); + // } else { + // dialogMessage( + // $q, + // "ข้อความแจ้งเตือน", + // "กรุณาเลือกรายชื่อ", + // "warning", + // undefined, + // "orange", + // undefined, + // undefined, + // true + // ); + // } next(); }; const selectData = (row: any) => {}; const refresh = async () => { - await conditionData(); + // await conditionData(); modalAddChange(); selected.value = []; }; diff --git a/src/modules/05_placement/interface/response/Order.ts b/src/modules/05_placement/interface/response/Order.ts index 6dc958ff1..cb3d31be5 100644 --- a/src/modules/05_placement/interface/response/Order.ts +++ b/src/modules/05_placement/interface/response/Order.ts @@ -2,7 +2,7 @@ interface ResponseData { education: string; idCard: string; name: string; - personId: string; + personalId: string; selectStatus: boolean; sequence: number; }