remove checkin out of project & Refactoring code module 01_dashboard

This commit is contained in:
Warunee Tamkoo 2024-09-02 10:28:59 +07:00
parent ec80361a81
commit 75c0e27880
9 changed files with 105 additions and 1069 deletions

View file

@ -0,0 +1,34 @@
interface InboxList {
id: string;
subject: string;
body: string;
receiverUserId: string;
payload: Object | null;
isOpen: boolean;
receiveDate: Date | null;
openDate: Date | null;
createdFullName?: string;
createdAt?: Date;
}
interface InboxDetail {
no: string;
sender: string;
subject: string;
body: string;
ratingModel: number;
receiveDate?: string;
payload: Object | null;
isOpen: boolean;
}
interface MenuMainList {
icon: string;
title: string;
sub: string;
color: string;
path: string;
active: boolean;
}
export type { InboxList, InboxDetail, MenuMainList };

View file

@ -1,6 +1,5 @@
<script setup lang="ts">
import { ref, onMounted, Static } from "vue";
const link = ref<number>(1);
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import router from "@/router";
import http from "@/plugins/http";
@ -9,23 +8,21 @@ import { useCounterMixin } from "@/stores/mixin";
import PopupReplyInbox from "@/components/PopupReplyInbox.vue";
import PopupDetailInbox from "@/components/PopupDetailInbox.vue";
import { tokenParsed } from "@/plugins/auth";
import {
InboxDetail,
InboxList,
MenuMainList,
} from "@/modules/01_dashboard/interface/Main";
const $q = useQuasar();
const mixin = useCounterMixin();
const { showLoader, hideLoader, date2Thai, messageError } = mixin;
const fullname = ref<string>("");
const inboxList = ref<any>([
// {
// no: 1,
// sender: "",
// subject: "",
// timereceive: "13/12/2565",
// body: " -",
// ratingModel: 0,
// },
]);
const items = ref<any>([
const fullname = ref<string>(""); //
const inboxList = ref<InboxDetail[]>([]); //
const idInboxActive = ref<string>(); // Id
//
const items = ref<MenuMainList[]>([
{
icon: "mdi-account-group-outline",
title: "แผนผังองค์กร",
@ -74,14 +71,6 @@ const items = ref<any>([
path: "/transfer",
active: false,
},
/*{
icon: "mdi-account-remove-outline",
title: "ลาออก",
sub: "ทำเรื่องลาออก",
color: "orange-3",
path: "/retire",
active: false,
},*/
{
icon: "mdi-scale-balance",
title: "อุทธรณ์ร้องทุกข์",
@ -114,44 +103,41 @@ const items = ref<any>([
path: "/scholarship",
active: false,
},
// {
// icon: "mdi-school",
// title: "",
// sub: "",
// color: "teal-2",
// path: "/probation",
// active: false,
// },
]);
onMounted(async () => {
await fetchlistInbox(1);
await fetchlistInbox(1); //
//
const user = await tokenParsed();
if (user) {
fullname.value = user.name;
}
});
/**
* งกนดงขอมลกลองขอความ
* @param index หนาทโหลดขอม
*/
const fetchlistInbox = async (index: number) => {
index === 1 && showLoader();
index != 0 &&
(await http
.get(config.API.msgInbox + `?page=${index}&pageSize=${10}`)
.then((res) => {
let data = res.data.result.data;
let data: InboxList[] = res.data.result.data;
totalInbox.value = res.data.result.total;
let listItem: any = [];
let listItem: InboxDetail[] = [];
if (data && data.length > 0) {
data.map((e: any) => {
console.log(data);
data.map((e: InboxList) => {
listItem.push({
no: e.id ?? "",
sender:
e.createdFullName == "" || e.createdFullName == null
? "เจ้าหน้าที่"
: e.createdFullName,
sender: !e.createdFullName ? "เจ้าหน้าที่" : e.createdFullName,
subject: e.subject ?? "",
timereceive: date2Thai(e.createdAt),
body: e.body ?? "-",
ratingModel: 0,
receiveDate: e.receiveDate,
receiveDate: date2Thai(e.receiveDate, false, true),
payload: e.payload,
isOpen: e.isOpen,
});
@ -159,44 +145,57 @@ const fetchlistInbox = async (index: number) => {
inboxList.value.push(...listItem);
}
})
// .catch((err) => {
// console.log(err);
// })
.finally(() => {
hideLoader();
}));
};
const transferToPage = (path?: string) => {
/**
* งก redirect ไปหนาระบบ
* @param path อยหน
*/
const goToPage = (path?: string) => {
router.push(`${path}`);
};
// Dialog Reply
const modalReply = ref<boolean>(false);
const contactNo = ref<string>();
const modalReply = ref<boolean>(false); // / dialog /
const contactNo = ref<string>(); // id
/**
* งกนเป dialog ตอบกลบขอความ
* @param id id อความ
*/
function dialogRepleOpen(id: string) {
contactNo.value = id;
modalReply.value = true;
contactNo.value = id; // id
modalReply.value = true; // dialog
}
/**
* งกนป dialog ตอบกลบขอความ
*/
function modalReplyClose() {
contactNo.value = "";
modalReply.value = false;
contactNo.value = ""; // id
modalReply.value = false; // dialog
}
const dataInbox = ref<any>();
const modalDetial = ref<boolean>(false);
async function onClickOpenPopupDetail(data: any) {
const dataInbox = ref<InboxDetail>(); //
const modalDetial = ref<boolean>(false); // / dialog
/**
* งกนเป dialog รายละเอยดขอความ
* @param data รายละเอยดขอความ
*/
async function onClickOpenPopupDetail(data: InboxDetail) {
showLoader();
await http
.get(config.API.msgInboxRead(data.no))
.then(() => {
const filterDate = inboxList.value.filter((r: any) => r.no == data.no);
const filterDate = inboxList.value.filter(
(r: InboxDetail) => r.no == data.no
);
for (const item of filterDate) {
item.isOpen = true;
}
dataInbox.value = data;
link.value = data.no;
idInboxActive.value = data.no;
modalDetial.value = !modalDetial.value;
})
.catch((err) => {
@ -207,13 +206,21 @@ async function onClickOpenPopupDetail(data: any) {
});
}
/**
* งกนกำหนดรายละเอยดขอความ งไปย dialog
*/
function updateModalDetail(val: boolean) {
modalDetial.value = val;
modalDetial.value = val; //
}
const scrollTargetRef = ref<any>(null);
const totalInbox = ref<number>(0);
async function onLoad(index: number, done: any) {
const scrollTargetRef = ref<any>(null); // scroll
const totalInbox = ref<number>(0); //
/**
* งกนโหลดขอมลกลองขอความ
* @param index หนาทโหลดขอม
* @param done งกนเมอโหลดขอมลเสร
*/
async function onLoad(index: number, done: Function) {
const num = index === 1 ? 0 : index++;
if (inboxList.value.length < totalInbox.value) {
setTimeout(() => {
@ -222,10 +229,6 @@ async function onLoad(index: number, done: any) {
}, 3000);
}
}
const thaiOptions: Intl.DateTimeFormatOptions = {
hour: "2-digit",
minute: "2-digit",
};
</script>
<template>
@ -245,11 +248,7 @@ const thaiOptions: Intl.DateTimeFormatOptions = {
v-for="(item, j) in items"
:key="j"
>
<q-card
bordered
@click="transferToPage(item.path)"
class="noactive col-12"
>
<q-card bordered @click="goToPage(item.path)" class="noactive col-12">
<div class="col-12">
<q-avatar
:color="item.color"
@ -312,20 +311,14 @@ const thaiOptions: Intl.DateTimeFormatOptions = {
clickable
v-ripple
class="'q-py-md q-mb-sm my-menu'"
:active="link === item.no"
:active="idInboxActive === item.no"
active-class="my-menu-link"
@click.stop.prevent="onClickOpenPopupDetail(item)"
>
<q-item-section>
<q-item-label caption class="text-weight-light">
{{ date2Thai(item.receiveDate) }}
{{
new Date(item.receiveDate).toLocaleTimeString(
"th-TH",
thaiOptions
)
}}
. <q-space />
{{ item.receiveDate }}
<q-space />
</q-item-label>
<q-item-label
:class="!item.isOpen ? 'text-weight-medium' : 'text-grey-7'"
@ -345,10 +338,6 @@ const thaiOptions: Intl.DateTimeFormatOptions = {
>
</q-item-section>
<q-item-section side top>
<q-item-label caption>{{ item.timereceive }}</q-item-label>
</q-item-section>
<q-item-section side top>
<q-btn
flat
@ -375,54 +364,6 @@ const thaiOptions: Intl.DateTimeFormatOptions = {
</q-infinite-scroll>
</div>
<!-- <q-scroll-area style="height: 64vh" v-if="inboxList.length > 0">
<q-list
v-for="(contact, index) in inboxList"
:key="index"
class="q-px-md"
>
<q-item
clickable
v-ripple
class="q-py-md q-mb-sm my-menu"
:active="link === contact.no"
active-class="my-menu-link"
@click="onClickOpenPopupDetail(contact)"
>
<q-item-section>
<q-item-label>
{{ contact.sender }}
<q-icon
v-if="contact.payload"
name="mdi-paperclip"
color="grey-6"
size="18px"
/></q-item-label>
<q-item-label caption class="text-grey-6" lines="2">{{
contact.subject
}}</q-item-label>
</q-item-section>
<q-item-section side top>
<q-item-label caption>{{ contact.timereceive }}</q-item-label>
</q-item-section>
<q-item-section side top>
<q-btn
flat
round
dense
icon="mdi-reply"
size="10px"
color="grey-7"
@click="dialogRepleOpen(contact.no)"
>
<q-tooltip>ตอบกลบขอความ</q-tooltip>
</q-btn>
</q-item-section>
</q-item>
</q-list>
</q-scroll-area> -->
<q-banner rounded class="bg-amber-1 text-center q-mx-sm" v-else>
<div class="text-yellow-10">
<q-icon

View file

@ -1,61 +0,0 @@
<script setup lang="ts">
import Child from "@/components/TestUpgrade.vue";
import { ref, computed, watchEffect } from "vue";
const count = ref<number>(0);
const total = ref<number>(0);
const first = ref<string>("firstName");
const last = ref<string>("lastName");
const isEven = computed(() => count.value % 2 === 0);
// watchEffect(() => isEven.value && submit()); // logs true
const inputValue = ref<string>("");
function submit() {
console.log("test");
}
</script>
<template>
<q-card class="q-pa-md">
<!-- Parent.vue -->
<div class="q-mb-md">
<div>Parent count is: {{ count }}</div>
<q-btn @click="count = 0">Reset count</q-btn>
</div>
<q-separator />
<div class="q-mb-md">
<Child
v-model="count"
v-model:total="total"
v-model:firstname.lastNameModifiers="first"
v-model:lastname.uppercase="last"
:name2="inputValue"
/>
</div>
<!-- <div class="q-mb-md">
<q-btn @click="refs.update">count ++</q-btn>
</div> -->
</q-card>
<q-separator />
<q-card class="q-pa-md">
<!-- Parent.vue -->
<div class="q-mb-md q-gutter-sm">
<div><h4>Test Vue</h4></div>
<div>
<q-input outlined dense type="text" v-model="inputValue"></q-input>
</div>
<q-btn @click="submit">submit</q-btn>
</div>
<!-- <div class="q-mb-md">
<Child :name="first" />
</div> -->
</q-card>
</template>