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;
}