diff --git a/src/modules/10_order/views/Main.vue b/src/modules/10_order/views/Main.vue index 7a4dc48ae..ca84372ee 100644 --- a/src/modules/10_order/views/Main.vue +++ b/src/modules/10_order/views/Main.vue @@ -18,6 +18,35 @@ const mixin = useCounterMixin(); const { showLoader, hideLoader, messageError, date2Thai } = mixin; const DataStore = useOrderPlacementDataStore(); +const commandCodes = ref([ + "C-PM-01", + "C-PM-02", + "C-PM-03", + "C-PM-04", + "C-PM-05", + "C-PM-06", + "C-PM-07", + "C-PM-08", + "C-PM-09", + "C-PM-10", + "C-PM-11", + "C-PM-12", + "C-PM-13", + "C-PM-14", + "C-PM-15", + "C-PM-16", + "C-PM-17", + "C-PM-18", + "C-PM-21", + "C-PM-22", + "C-PM-23", + "C-PM-24", + "C-PM-38", + "C-PM-39", + "C-PM-40", + "C-PM-41", +]); + const pagination = ref({ descending: true, page: 1, @@ -112,14 +141,6 @@ const columns = ref([ }, ]); -onMounted(async () => { - await OriginalDataFetch(); - fiscalYearFilter(); - searchFilterTable(); - OrderStatusFilter(); - OrderTypeFilter(); -}); - // ข้อมูลตาราง const rows = ref([]); let OriginalData = ref([]); @@ -129,8 +150,8 @@ const OriginalDataFetch = async () => { showLoader(); await http .get(config.API.listOrder()) - .then((res: any) => { - rows.value = res.data.result.map((e: any) => ({ + .then(async (res: any) => { + let data = await res.data.result.map((e: any) => ({ orderId: e.orderId, Order: e.orderName, OrderNum: @@ -144,6 +165,10 @@ const OriginalDataFetch = async () => { OrderType: e.orderTypeName, orderTypeValue: e.orderTypeValue, })); + + const typeid = OrderTypeOption.value.map((e) => e.id); + + rows.value = data.filter((e: any) => typeid.includes(e.orderTypeValue)); // rows.value = data; }) .catch((e: any) => { messageError($q, e); @@ -213,11 +238,15 @@ const OrderTypeFilter = async () => { .get(config.API.typeOrder()) .then((res) => { const response = res.data.result; + const filterRes = response.filter((e: any) => + commandCodes.value.includes(e.commandCode) + ); + OrderTypeOption.value = [{ id: "", name: "ทั้งหมด" }]; - OrderTypeOption.value.push(...response); + OrderTypeOption.value.push(...filterRes); OrderTypeFilter1.value = [{ id: "", name: "ทั้งหมด" }]; - OrderTypeFilter1.value.push(...response); + OrderTypeFilter1.value.push(...filterRes); }) .catch((e) => { messageError($q, e); @@ -310,6 +339,14 @@ const paginationLabel = (start: string, end: string, total: string) => { if (paging.value == true) return " " + start + "-" + end + " ใน " + total; else return start + "-" + end + " ใน " + total; }; + +onMounted(async () => { + await OrderTypeFilter(); + await OriginalDataFetch(); + fiscalYearFilter(); + searchFilterTable(); + OrderStatusFilter(); +});