diff --git a/src/api/05_placement/api.placement.ts b/src/api/05_placement/api.placement.ts index 5ca86af6d..c2159003a 100644 --- a/src/api/05_placement/api.placement.ts +++ b/src/api/05_placement/api.placement.ts @@ -55,6 +55,7 @@ export default { // order yearOptionsOrder: () => `${order}/order/fiscal-year`, listOrder: () => `${order}/order`, + detailOrder:(orderId:string) => `${order}/order/${orderId}`, typeOrder: () => `${order}/order/order-type`, examroundOrder: () => `${order}/order/detail/exam-round`, }; diff --git a/src/modules/05_placement/components/OrderPlacement/MainOrderPlacement.vue b/src/modules/05_placement/components/OrderPlacement/MainOrderPlacement.vue index b00790382..8d0e90c74 100644 --- a/src/modules/05_placement/components/OrderPlacement/MainOrderPlacement.vue +++ b/src/modules/05_placement/components/OrderPlacement/MainOrderPlacement.vue @@ -156,7 +156,7 @@ {{ props.row.Order }} @@ -186,7 +186,7 @@ flat round color="red" - @click.stop="clickDelete(props.row.id)" + @click.stop="clickDelete(props.row.orderId)" icon="mdi-delete" > ลบข้อมูล @@ -217,7 +217,10 @@ import { onMounted, reactive, ref, useAttrs, computed } from "vue"; import type { QTableProps } from "quasar"; import type { FormOrderPlacementMainData } from "@/modules/05_placement/interface/request/Main"; -import type { DataOption } from "@/modules/05_placement/interface/index/Main"; +import type { + DataOption, + DataOption1, +} from "@/modules/05_placement/interface/index/Main"; import { useCounterMixin } from "@/stores/mixin"; import { useOrderPlacementDataStore } from "@/modules/05_placement/store"; import router from "@/router"; @@ -227,11 +230,10 @@ import config from "@/app.config"; const $q = useQuasar(); //ใช้ noti quasar const mixin = useCounterMixin(); -const { showLoader, hideLoader, messageError, date2Thai, dateText } = mixin; +const { showLoader, hideLoader, messageError, date2Thai, dateText, success } = + mixin; const DataStore = useOrderPlacementDataStore(); - - const pagination = ref({ sortBy: "desc", descending: false, @@ -344,146 +346,17 @@ const columns = ref([ // ข้อมูลตาราง (จำลอง) const rows = ref([ - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2565", - fiscalYear: 2565, - OrderDate: "30 พ.ค. 2565", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "จัดทำร่างคำสั่ง", - OrderType: "คำสั่งย้าย", - }, - - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2565", - fiscalYear: 2565, - OrderDate: "30 พ.ค. 2565", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "จัดทำร่างคำสั่ง", - OrderType: "คำสั่งบรรจุและแต่งตั้ง", - }, - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2564", - fiscalYear: 2564, - OrderDate: "30 พ.ค. 2564", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "บัญชีแนบท้าย", - OrderType: "คำสั่งบรรจุและแต่งตั้ง", - }, - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2564", - fiscalYear: 2564, - OrderDate: "30 พ.ค. 2564", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "บัญชีแนบท้าย", - OrderType: "คำสั่งย้าย", - }, - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2564", - fiscalYear: 2564, - OrderDate: "30 พ.ค. 2564", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "ส่งสำเนาคำสั่ง", - OrderType: "คำสั่งย้าย", - }, - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2564", - fiscalYear: 2564, - OrderDate: "30 พ.ค. 2564", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "ส่งสำเนาคำสั่ง", - OrderType: "คำสั่งบรรจุและแต่งตั้ง", - }, - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2566", - fiscalYear: 2566, - OrderDate: "30 พ.ค. 2566", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "รอลงนาม", - OrderType: "คำสั่งบรรจุและแต่งตั้ง", - }, - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2566", - fiscalYear: 2566, - OrderDate: "30 พ.ค. 2566", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "ออกคำสั่งแล้ว", - OrderType: "คำสั่งแต่งตั้ง", - }, - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2565", - fiscalYear: 2565, - OrderDate: "30 พ.ค. 2565", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "ออกคำสั่งแล้ว", - OrderType: "คำสั่งบรรจุและแต่งตั้ง", - }, - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2566", - fiscalYear: 2566, - OrderDate: "30 พ.ค. 2566", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "ออกคำสั่งแล้ว", - OrderType: "คำสั่งแต่งตั้ง", - }, - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2566", - fiscalYear: 2566, - OrderDate: "30 พ.ค. 2566", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "ออกคำสั่งแล้ว", - OrderType: "คำสั่งย้าย", - }, - - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2564", - fiscalYear: 2564, - OrderDate: "30 พ.ค. 2564", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "ออกคำสั่งแล้ว", - OrderType: "คำสั่งแต่งตั้ง", - }, - - { - Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", - OrderNum: "1/2566", - fiscalYear: 2566, - OrderDate: "30 พ.ค. 2566", - OrderBy: "สำนักงาน กทม.", - Signer: "นาม สมคิด ยอดใจ ", - OrderStatus: "ออกคำสั่งแล้ว", - OrderType: "คำสั่งแต่งตั้ง", - }, + // { + // Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", + // OrderNum: "1/2565", + // fiscalYear: 2565, + // OrderDate: "30 พ.ค. 2565", + // OrderBy: "สำนักงาน กทม.", + // Signer: "นาม สมคิด ยอดใจ ", + // OrderStatus: "จัดทำร่างคำสั่ง", + // OrderType: "คำสั่งย้าย", + // }, ]); -// const OrderStatusOption = [ -// "ทั้งหมด", -// "ยังไม่ได้บรรจุ", -// "บรรจุแล้ว", -// "ยังไม่ได้ออกคำสั่ง", -// ]; let OriginalData = ref([]); let UpdataData = ref([]); @@ -497,13 +370,27 @@ onMounted(async () => { }); const OriginalDataFetch = async () => { - // API - // await http.get(config.API.listOrder()).then((res: any) => { - // console.log("list", res); - // }); - // .catch((e: any) => { - // messageError($q, e); - // }) + await http + .get(config.API.listOrder()) + .then((res: any) => { + console.log("list", res); + rows.value = res.data.result.map((e: any) => ({ + orderId: e.orderId, + Order: e.orderName, + OrderNum: e.orderNo, + fiscalYear: Number(e.fiscalYear), + OrderDate: date2Thai(e.orderDate), + OrderBy: e.orderBy, + Signer: "นาม สมคิด ยอดใจ ", + OrderStatus: e.orderStatusName, + orderStatusValue: e.orderStatusValue, + OrderType: e.orderTypeName, + orderTypeValue: e.orderTypeValue, + })); + }) + .catch((e: any) => { + messageError($q, e); + }); // .finally(async () => { // }); await DataStore.DataMainOrder(rows.value); @@ -513,7 +400,6 @@ const OriginalDataFetch = async () => { // ดูรายการหน้าต่อไป const redirectToPage = (id?: string) => { - console.log(id); router.push(`/placement/order/detail/${id}`); }; @@ -528,27 +414,27 @@ const clickDelete = (id: string) => { persistent: true, }) .onOk(async () => { - // await deleteData(id); + await deleteData(id); }) .onCancel(() => {}) .onDismiss(() => {}); }; -// const deleteData = async (id: string) => { -// showLoader(); -// await http -// .delete(config.API.orderReplace(id)) -// .then((res) => { -// success($q, "ลบข้อมูลสำเร็จ"); -// }) -// .catch((e) => { -// messageError($q, e); -// }) -// .finally(async () => { -// hideLoader(); -// await fetchData(); -// }); -// }; +const deleteData = async (id: string) => { + showLoader(); + await http + .delete(config.API.detailOrder(id)) + .then((res) => { + success($q, "ลบข้อมูลสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + hideLoader(); + await OriginalDataFetch(); + }); +}; const clickAdd = () => { router.push({ name: "Orderplacementadd" }); @@ -568,14 +454,13 @@ const fiscalyearOP = reactive([{ id: 0, name: "ทั้งหม const addedfiscalYearValues: number[] = []; const fiscalYearFilter = async () => { await http.get(config.API.yearOptionsOrder()).then((res) => { - console.log(res); + // console.log(res); const response = res.data.result; fiscalyearOP.push(...response); // const maxNumber = fiscalyearOP.reduce((max: any, e: any) => { // return e.id > max ? e.id : max; // }, ""); // fiscalyear.value = maxNumber; - // console.log(fiscalyear.value); }); // API // await http @@ -607,13 +492,13 @@ const fiscalYearFilter = async () => { }; const OrderType = ref(""); -const OrderTypeOption = reactive([{ id: 0, name: "ทั้งหมด" }]); +const OrderTypeOption = reactive([{ id: "", name: "ทั้งหมด" }]); const addedOrderTypeValues: string[] = []; const OrderTypeFilter = async () => { await http .get(config.API.typeOrder()) .then((res) => { - console.log(res.data); + // console.log(res.data); const response = res.data.result; OrderTypeOption.push(...response); }) @@ -660,7 +545,9 @@ const OrderStatus = ref(""); const OrderStatusText = ref( DataStore.DataMainOrigOrder ); -const OrderStatusOption = reactive([{ id: 1, name: "ทั้งหมด" }]); +const OrderStatusOption = reactive([ + { id: "", name: "ทั้งหมด" }, +]); const addedOrderStatusValues: string[] = []; const OrderStatusFilter = async () => { // API @@ -677,7 +564,6 @@ const OrderStatusFilter = async () => { // }); for (let data of OriginalData.value) { const OrderStatusValue = data.OrderStatus; - console.log(OrderStatusValue); if ( OrderStatusValue === null || @@ -687,35 +573,17 @@ const OrderStatusFilter = async () => { } if (!addedOrderStatusValues.includes(OrderStatusValue)) { + // console.log(OrderStatusValue); + OrderStatusOption.push({ // id: OrderStatusValue, - id: OrderStatusOption.length, + id: OrderStatusOption.length.toString(), name: OrderStatusValue, }); addedOrderStatusValues.push(OrderStatusValue); } } }; - -// เลือกปีงบประมาณตาม API -const searchfiscalyear = async () => { - const yearNum = fiscalyear.value! + 543; - - await DataStore.DataUpdateOrder(OrderType.value, OrderStatus.value, yearNum); - UpdataData.value = DataStore.DataMainUpdateOrder; - - // API - // await http - // .get(config.API.// ตัวอย่าง) - // .then((res: any) => { - // }) - // .catch((e: any) => { - // messageError($q, e); - // }) - // .finally(async () => { - // }); -}; - // ค้นหาในตาราง const filterKeyword = ref(""); const filterRef = ref(null); @@ -727,22 +595,27 @@ const resetFilter = () => { const attrs = ref(useAttrs()); const searchFilterTable = async () => { - if (fiscalyear.value !== null && fiscalyear.value !== 0) { - fiscalyear.value += 543; + if (OrderType.value == "ทั้งหมด") { + OrderType.value = ""; } - console.log(fiscalyear.value, OrderType.value, OrderStatus.value); + if (OrderStatus.value == "ทั้งหมด") { + OrderStatus.value = ""; + } + console.log( + "Input value changed:", + OrderType.value, + OrderStatus.value, + fiscalyear.value + ); - // console.log('Input value changed:', examTime.value, examType.value, expiredAccount.value); await DataStore.DataUpdateOrder( OrderType.value, OrderStatus.value, fiscalyear.value ); UpdataData.value = DataStore.DataMainUpdateOrder; - console.log(UpdataData.value); + // console.log(UpdataData.value); }; -// UpdataData.value = DataStore.DataMainUpdate; -// console.log("Input value changed:", OrderStatus.value, OrderType.value); const paging = ref(true); const paginationLabel = (start: string, end: string, total: string) => { diff --git a/src/modules/05_placement/components/OrderPlacement/step/step01.vue b/src/modules/05_placement/components/OrderPlacement/step/step01.vue index 250093399..526d9a895 100644 --- a/src/modules/05_placement/components/OrderPlacement/step/step01.vue +++ b/src/modules/05_placement/components/OrderPlacement/step/step01.vue @@ -511,9 +511,10 @@ const clickEditRow = () => (editRow.value = true); onMounted(async () => { if (orderId) { await fetchdetailOrder(); + } else { + fecthTypeOption(); + fecthExamRoundOption(); } - fecthTypeOption(); - fecthExamRoundOption(); // const data = localStorage.getItem("formData"); // if (data) { @@ -537,6 +538,20 @@ onMounted(async () => { const fetchdetailOrder = async () => { showLoader(); console.log(orderId); + let orderIdString = orderId.toString(); + await http + .get(config.API.detailOrder(orderIdString)) + .then((res) => { + console.log(res); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + fecthTypeOption(); + fecthExamRoundOption(); + }); }; const fecthTypeOption = async () => { await http @@ -567,7 +582,7 @@ const submit = async () => { orderBy: byOrder.value, signatoryBy: nameCommand.value, signatoryPosition: positionCommand.value, - examRound: test.value, + examRound: examRound.value, registerPosition: position.value, conclusionRegisterNo: register.value, conclusionRegisterDate: dateRegister.value, @@ -586,9 +601,7 @@ const submit = async () => { persistent: true, }).onOk(async () => { showLoader(); - // localStorage.setItem("formData", JSON.stringify(formdata)); createListOrder(formdata); - // next(); }); } }); diff --git a/src/modules/05_placement/store.ts b/src/modules/05_placement/store.ts index 283530593..0fca902c5 100644 --- a/src/modules/05_placement/store.ts +++ b/src/modules/05_placement/store.ts @@ -269,6 +269,8 @@ export const useOrderPlacementDataStore = defineStore("placementOrder", () => { item.OrderStatus === filter_2 && item.fiscalYear === filterYear ); + } else if (filter_1 == "ทั้งหมด" && filter_2 == "ทั้งหมด" && filterYear !== null) { + DataMainUpdateOrder.value = DataMainOrigOrder.value; } };