diff --git a/src/modules/02_users/views/01_user.vue b/src/modules/02_users/views/01_user.vue index a2f5bddb..6c5d5aa7 100644 --- a/src/modules/02_users/views/01_user.vue +++ b/src/modules/02_users/views/01_user.vue @@ -6,6 +6,7 @@ import { useRouter } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; +import { updateCurrentPage } from "@/utils/functions"; /** importType*/ import type { QTableProps } from "quasar"; @@ -233,12 +234,17 @@ function openDialog() { * @param id รายการผู้ใช้งาน * ลบข้อมูลรายชื่อเสร็จแล้วทำการดึงข้อมูลรายชื่อผู้ใช้งานใหม่ */ -function onDeleteUser(id: string) { +async function onDeleteUser(id: string) { dialogRemove($q, () => { showLoader(); http .delete(config.API.managementUser + `/${id}`) .then(async () => { + currentPage.value = await updateCurrentPage( + currentPage.value, + maxPage.value, + rows.value.length + ); await fetchListUsers(); success($q, "ลบข้อมูลสำเร็จ"); }) diff --git a/src/modules/05_command/interface/index/Main.ts b/src/modules/05_command/interface/index/Main.ts index 3bd5516b..7447d2ed 100644 --- a/src/modules/05_command/interface/index/Main.ts +++ b/src/modules/05_command/interface/index/Main.ts @@ -30,6 +30,7 @@ interface ListOrder { isActive: boolean; isAttachment: boolean; category?: string; + code: string; commandSysId: string; isUploadAttachment: boolean; } diff --git a/src/modules/05_command/views/lists.vue b/src/modules/05_command/views/lists.vue index 1fd5a240..4ff20d52 100644 --- a/src/modules/05_command/views/lists.vue +++ b/src/modules/05_command/views/lists.vue @@ -54,6 +54,7 @@ const filteredTabs = computed(() => : tabs.value.filter((tab) => tab.value !== "attachment") ); +const isCode = ref(""); // ตัวแปรเก็บ code const isActive = ref(true); // สถานะของรายการคำสั่ง const isAttachment = ref(true); // บัญชีแนบท้าย const isSalary = ref(true); // แก้ไขเงินเดือน @@ -206,6 +207,12 @@ function onSubmit() { * เก็บ id list คำสั่งที่เลือก เพื่อใช้ class */ function selectInbox(data: ListOrder) { + isCode.value = data.code; + if (data.code === "C-PM-47") { + isAttachmentShow.value = false; + activeCommandId.value = ""; + return; + } store.currentTab = !data.isAttachment && store.currentTab == "attachment" ? "cover" @@ -404,6 +411,15 @@ onMounted(async () => { +
+
+
{ }; function monthYear2Thai(month: number, year: number, isFullMonth = false) { - const date = new Date(`${year}-${month + 1}-1`); + if ( + month < 0 || + month > 11 || + !Number.isFinite(month) || + !Number.isFinite(year) + ) + return ""; const fullMonthThai = [ "มกราคม", "กุมภาพันธ์", @@ -218,19 +224,12 @@ export const useCounterMixin = defineStore("mixin", () => { "พ.ย.", "ธ.ค.", ]; - let dstYear = 0; - if (date.getFullYear() > 2500) { - dstYear = date.getFullYear(); - } else { - dstYear = date.getFullYear() + 543; - } - let dstMonth = ""; - if (isFullMonth) { - dstMonth = fullMonthThai[date.getMonth()]; - } else { - dstMonth = abbrMonthThai[date.getMonth()]; - } - return dstMonth + " " + dstYear; + + // assume year is in BE if > 2500 + let dstYear = year > 2500 ? year : year + 543; + // month is already 0-based + let dstMonth = isFullMonth ? fullMonthThai[month] : abbrMonthThai[month]; + return `${dstMonth} ${dstYear}`; } function dateToISO(date: Date) { diff --git a/src/utils/functions.ts b/src/utils/functions.ts new file mode 100644 index 00000000..2c3d4874 --- /dev/null +++ b/src/utils/functions.ts @@ -0,0 +1,19 @@ +/** + * คำนวณหน้าที่จะแสดงหลังจากลบข้อมูล + * + * @param page หน้าปัจจุบัน + * @param maxPage หน้าสุดท้าย + * @param total จำนวนข้อมูลในหน้าปัจจุบัน + * @returns หน้าที่ควรแสดง + */ +export async function updateCurrentPage( + page: number, + maxPage: number, + total: number +) { + // ถ้าหน้าปัจจุบันไม่ใช่หน้าแรก และเป็นหน้าสุดท้าย และมีข้อมูลเหลือ 1 รายการ ให้กลับไปหน้าก่อนหน้า + if (page > 1 && page === maxPage && total === 1) { + return page - 1; + } + return page; +}