diff --git a/src/components/Dialogs/PopupReplyInbox.vue b/src/components/Dialogs/PopupReplyInbox.vue
index 1eed8b25..272140c3 100644
--- a/src/components/Dialogs/PopupReplyInbox.vue
+++ b/src/components/Dialogs/PopupReplyInbox.vue
@@ -1,18 +1,20 @@
@@ -58,7 +61,7 @@ async function submit() {
-
+
@@ -71,7 +74,7 @@ async function submit() {
outlined
dense
lazy-rules
- :rules="[(val) => !!val || 'กรุณากรอกหัวข้อ']"
+ :rules="[(val:string) => !!val || 'กรุณากรอกหัวข้อ']"
v-model="subject"
label="หัวข้อ"
/>
@@ -83,7 +86,7 @@ async function submit() {
outlined
dense
lazy-rules
- :rules="[(val) => !!val || 'กรุณากรอกข้อความ']"
+ :rules="[(val:string) => !!val || 'กรุณากรอกข้อความ']"
v-model="body"
label="ข้อความ"
/>
@@ -93,15 +96,7 @@ async function submit() {
-
-
+
บันทึก
diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue
index 09bb224d..b66d1ed0 100644
--- a/src/views/Dashboard.vue
+++ b/src/views/Dashboard.vue
@@ -6,12 +6,13 @@ import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
-import PopupReplyInbox from "@/components/Dialogs/PopupReplyInbox.vue";
import type {
ResponseInbox,
DataInbox,
} from "@/interface/response/dashboard/dashboard";
+import PopupReplyInbox from "@/components/Dialogs/PopupReplyInbox.vue";
+
const $q = useQuasar();
const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง
const {
@@ -23,25 +24,35 @@ const {
dialogRemove,
} = mixin;
-const splitterModel = ref(30);
-const link = ref("0");
-const inboxList = ref([]);
-const data = ref([]);
+const splitterModel = ref(30); // ขนาดของกล่องข้อความ
+const link = ref("0"); // รายการกล่องข้อความ
+const inboxList = ref([]); //ข้อมูลรายการกล่องข้อความ
+const data = ref([]); //ข้อมูลกล่องข้อความ
+const totalInbox = ref(0); // จำนวนกล่องข้อความ
+const scrollTargetRef = ref(null);
+//กำหนดรูปแบบแสดงวนเวลา
+const thaiOptions: Intl.DateTimeFormatOptions = {
+ hour: "2-digit",
+ minute: "2-digit",
+};
+const isLoadInbox = ref(false); // สถานะการโหลด
+const modalReply = ref(false); // ตอบกลับข้อความ
-onMounted(async () => {
- await getData(1);
-});
-
-const isLoadInbox = ref(false);
-const getData = async (index: number) => {
+/**
+ * โหลดรายการกล่องข้องความ
+ * เมื่อ index = 1 โชว์โหลด ถ้าไม่ไม่แสดง
+ *
+ * @param index หน้าที่ต้องการโหลด
+ */
+async function getData(index: number) {
isLoadInbox.value = false;
index === 1 && showLoader();
index != 0 &&
(await http
.get(config.API.msgInbox + `?page=${index}&pageSize=${10}`)
- .then((res: any) => {
- const data = res.data.result.data;
- totalInbox.value = res.data.result.total;
+ .then(async (res) => {
+ const data = await res.data.result.data;
+ totalInbox.value = await res.data.result.total;
let list: DataInbox[] = [];
data.map((e: ResponseInbox) => {
@@ -66,15 +77,19 @@ const getData = async (index: number) => {
}
})
.catch((e) => {
- // messageError($q, e);
+ messageError($q, e);
})
.finally(() => {
isLoadInbox.value = true;
hideLoader();
}));
-};
+}
-const selectInbox = (id: string) => {
+/**
+ * เลือกแสดงกล่องข้อความ
+ * @param id ข้อความ
+ */
+function selectInbox(id: string) {
http
.get(config.API.msgInboxDelete(id))
.then(() => {
@@ -84,54 +99,71 @@ const selectInbox = (id: string) => {
item.isOpen = true;
}
})
- .catch((err) => {});
-};
-const deleteData = (id: string) => {
- dialogRemove($q, () => removeData(id));
-};
-
-//รอ api ลบ
-const removeData = async (id: string) => {
- showLoader();
- await http
- .delete(config.API.msgInboxDelete(id))
- .then(() => {
- success($q, "ลบข้อมูลสำเร็จ");
- const position = inboxList.value.findIndex((item) => item.no === id);
- if (position !== -1) {
- inboxList.value.splice(position, 1);
- data.value = [];
- }
- })
- .catch((e) => {
- messageError($q, e);
- })
- .finally(() => {
- if (inboxList.value.length === 6) {
- inboxList.value = [];
- getData(1);
- }
- hideLoader();
+ .catch((err) => {
+ messageError($q, err);
});
-};
-const fileOpen = (url: string) => {
- window.open(url, "_blank");
-};
+}
-// Dialog Reply
-const modalReply = ref(false);
+/**
+ * ยืนยันการลบกล่องข้อความ
+ * @param id
+ */
+function deleteData(id: string) {
+ dialogRemove($q, async () => {
+ showLoader();
+ await http
+ .delete(config.API.msgInboxDelete(id))
+ .then(() => {
+ // เมื่แ ข้อความเหลือ 6 เรียกโหลดรายการกล่องข้องความใหม่
+ if (inboxList.value.length === 6) {
+ inboxList.value = [];
+ getData(1);
+ }
+ const position = inboxList.value.findIndex((item) => item.no === id);
+ if (position !== -1) {
+ inboxList.value.splice(position, 1);
+ data.value = [];
+ }
+ success($q, "ลบข้อมูลสำเร็จ");
+ })
+ .catch((e) => {
+ messageError($q, e);
+ })
+ .finally(() => {
+ hideLoader();
+ });
+ });
+}
+
+/**
+ * ดาวน์โหลดเอกสารแนบ
+ * @param url ลิงก์โหลดเอกสาร
+ */
+function fileOpen(url: string) {
+ window.open(url, "_blank");
+}
+
+/**
+ * เปิด popup การตอบกลับข้อความ
+ */
function dialogRepleOpen() {
modalReply.value = true;
}
+/**
+ * ปิด popup การตอบกลับข้อความ
+ */
function modalReplyClose() {
modalReply.value = false;
}
-const scrollTargetRef = ref(null);
-const totalInbox = ref(0);
-
-function onLoad(index: number, done: any) {
+/**
+ * ฟังก์ชัน onLoad ทำงานเมื่อโหลดข้อมูลเพิ่มเติมในรายการแจ้งเตือน
+ *
+ * @param index - ของรายการที่กำลังโหลด
+ * @param done - ฟังก์ชันที่เรียกเมื่อการโหลดเสร็จสิ้น
+ */
+function onLoad(index: number, done: Function) {
const num = index === 1 ? 0 : index++;
if (inboxList.value.length < totalInbox.value && isLoadInbox) {
setTimeout(() => {
@@ -140,10 +172,10 @@ function onLoad(index: number, done: any) {
}, 3000);
}
}
-const thaiOptions: Intl.DateTimeFormatOptions = {
- hour: "2-digit",
- minute: "2-digit",
-};
+
+onMounted(async () => {
+ await getData(1);
+});
@@ -308,14 +340,6 @@ const thaiOptions: Intl.DateTimeFormatOptions = {
color="red"
@click="deleteData(d.no)"
/>
-
@@ -355,14 +379,6 @@ const thaiOptions: Intl.DateTimeFormatOptions = {
-
-
diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue
index db51afe2..32c6f0c5 100644
--- a/src/views/MainLayout.vue
+++ b/src/views/MainLayout.vue
@@ -1,14 +1,15 @@
diff --git a/src/views/login.vue b/src/views/login.vue
index 3fd79f58..8e5e8548 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -1,30 +1,31 @@