เพิ่ม path ใน Dashboard สร้างเงื่อนไขในบันทึก

This commit is contained in:
AnandaTon 2023-10-06 13:33:54 +07:00
parent 0a507ce808
commit d3ddfc38d7
2 changed files with 192 additions and 251 deletions

View file

@ -1,21 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, Static } from "vue"; import { ref, onMounted, Static } from "vue"
const link = ref<number>(1); const link = ref<number>(1)
import { useQuasar } from "quasar"; import { useQuasar } from "quasar"
import router from "@/router"; import router from "@/router"
import http from "@/plugins/http"; import http from "@/plugins/http"
import config from "@/app.config"; import config from "@/app.config"
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin"
const $q = useQuasar(); const $q = useQuasar()
const mixin = useCounterMixin(); const mixin = useCounterMixin()
const { const { showLoader, hideLoader, date2Thai } = mixin
showLoader,
hideLoader,
date2Thai,
} = mixin;
const fullname = ref<string>("ธัญลักษณ์"); const fullname = ref<string>("ธัญลักษณ์")
const inboxList = ref<any>([ const inboxList = ref<any>([
// { // {
// no: 1, // no: 1,
@ -25,7 +21,7 @@ const inboxList = ref<any>([
// body: " -", // body: " -",
// ratingModel: 0, // ratingModel: 0,
// }, // },
]); ])
const items = ref<any>([ const items = ref<any>([
{ {
icon: "mdi-account-group-outline", icon: "mdi-account-group-outline",
@ -48,7 +44,7 @@ const items = ref<any>([
title: "การลา", title: "การลา",
sub: "ดู/ลงเวลา ทำเรื่องลา", sub: "ดู/ลงเวลา ทำเรื่องลา",
color: "cyan-3", color: "cyan-3",
path: "", path: "/leave",
active: false, active: false,
}, },
{ {
@ -75,87 +71,61 @@ const items = ref<any>([
path: "/retire", path: "/retire",
active: false, active: false,
}, },
]); ])
onMounted(async () => { onMounted(async () => {
await fetchlistInbox(); await fetchlistInbox()
}); })
const fetchlistInbox = async () => { const fetchlistInbox = async () => {
showLoader(); showLoader()
await http await http
.get(config.API.msgInbox) .get(config.API.msgInbox)
.then((res) => { .then(res => {
let data = res.data.result; let data = res.data.result
console.log(data); console.log(data)
let listItem: any = []; let listItem: any = []
data.map((e: any) => { data.map((e: any) => {
listItem.push({ listItem.push({
no: e.id ?? "", no: e.id ?? "",
sender: sender: e.createdFullName == "" || e.createdFullName == null ? "เจ้าหน้าที่" : e.createdFullName,
e.createdFullName == "" || e.createdFullName == null
? "เจ้าหน้าที่"
: e.createdFullName,
subject: e.subject ?? "", subject: e.subject ?? "",
timereceive: date2Thai(e.createdAt), timereceive: date2Thai(e.createdAt),
body: e.body ?? "", body: e.body ?? "",
ratingModel: 0, ratingModel: 0,
});
});
inboxList.value = listItem;
}) })
.catch((err) => { })
console.log(err); inboxList.value = listItem
})
.catch(err => {
console.log(err)
}) })
.finally(() => { .finally(() => {
hideLoader(); hideLoader()
}); })
}; }
const transferToPage = (path?: string) => { const transferToPage = (path?: string) => {
router.push(`${path}`); router.push(`${path}`)
}; }
</script> </script>
<template> <template>
<div class="col-12 row q-col-gutter-md" style="padding-top: 1.8%"> <div class="col-12 row q-col-gutter-md" style="padding-top: 1.8%">
<div class="col-12 row" v-if="!$q.screen.gt.xs"> <div class="col-12 row" v-if="!$q.screen.gt.xs">
<div class="text-white text-weight-light text-18px"> <div class="text-white text-weight-light text-18px">สวสด, {{ fullname }}</div>
สวสด, {{ fullname }} <div style="color: #ffffff" class="text-18px text-weight-medium col-12">ระบบทรพยากรบคคล</div>
</div>
<div style="color: #ffffff" class="text-18px text-weight-medium col-12">
ระบบทรพยากรบคคล
</div>
</div> </div>
<div class="col-xs-12 col-sm-12 col-md-9"> <div class="col-xs-12 col-sm-12 col-md-9">
<div class="row justify-start q-col-gutter-md"> <div class="row justify-start q-col-gutter-md">
<div <div class="col-xs-6 col-sm-4 col-md-4 col-lg-3 col-xl-2 row" v-for="(item, j) in items" :key="j">
class="col-xs-6 col-sm-4 col-md-4 col-lg-3 col-xl-2 row" <q-card bordered @click="transferToPage(item.path)" class="noactive col-12">
v-for="(item, j) in items"
:key="j"
>
<q-card
bordered
@click="transferToPage(item.path)"
class="noactive col-12"
>
<div class="col-12"> <div class="col-12">
<q-avatar <q-avatar :color="item.color" text-color="white" :size="$q.screen.gt.xs ? '55px' : '40px'">
:color="item.color" <q-icon :name="item.icon" :size="$q.screen.gt.xs ? '28px' : '20px'" color="black" />
text-color="white"
:size="$q.screen.gt.xs ? '55px' : '40px'"
>
<q-icon
:name="item.icon"
:size="$q.screen.gt.xs ? '28px' : '20px'"
color="black"
/>
</q-avatar> </q-avatar>
</div> </div>
<div class="q-pt-md col-12 text-left text-18px"> <div class="q-pt-md col-12 text-left text-18px">
{{ item.title }} {{ item.title }}
</div> </div>
<div <div class="col-12 text-left text-grey text-weight-regular gt-xs" style="font-size: 14px">
class="col-12 text-left text-grey text-weight-regular gt-xs"
style="font-size: 14px"
>
{{ item.sub }} {{ item.sub }}
</div> </div>
</q-card> </q-card>
@ -163,44 +133,18 @@ const transferToPage = (path?: string) => {
</div> </div>
</div> </div>
<div class="col-xs-12 col-sm-12 col-md-3 row"> <div class="col-xs-12 col-sm-12 col-md-3 row">
<q-card <q-card flat bordered :style="$q.screen.gt.xs ? 'max-height: 74vh' : 'height: auto;'" class="q-pb-md col-12">
flat
bordered
:style="$q.screen.gt.xs ? 'max-height: 74vh' : 'height: auto;'"
class="q-pb-md col-12"
>
<div class="col-12 row q-pa-md"> <div class="col-12 row q-pa-md">
<div class="text-subtitle1 text-weight-bold text-dark"> <div class="text-subtitle1 text-weight-bold text-dark">กลองขอความ</div>
กลองขอความ
</div>
<q-space /> <q-space />
<q-btn <q-btn dense icon="mdi-dots-vertical" color="grey-6" size="11px" flat />
dense
icon="mdi-dots-vertical"
color="grey-6"
size="11px"
flat
/>
</div> </div>
<q-scroll-area style="height: 64vh" v-if="inboxList.length > 1"> <q-scroll-area style="height: 64vh" v-if="inboxList.length > 1">
<q-list <q-list v-for="(contact, index) in inboxList" :key="index" class="q-px-md">
v-for="(contact, index) in inboxList" <q-item clickable v-ripple class="q-py-md q-mb-sm my-menu" :active="link === contact.no" @click="link = contact.no" active-class="my-menu-link">
:key="index"
class="q-px-md"
>
<q-item
clickable
v-ripple
class="q-py-md q-mb-sm my-menu"
:active="link === contact.no"
@click="link = contact.no"
active-class="my-menu-link"
>
<q-item-section> <q-item-section>
<q-item-label>{{ contact.sender }}</q-item-label> <q-item-label>{{ contact.sender }}</q-item-label>
<q-item-label caption class="text-grey-6" lines="2">{{ <q-item-label caption class="text-grey-6" lines="2">{{ contact.subject }}</q-item-label>
contact.subject
}}</q-item-label>
</q-item-section> </q-item-section>
<q-item-section side top> <q-item-section side top>
@ -209,18 +153,9 @@ const transferToPage = (path?: string) => {
</q-item> </q-item>
</q-list> </q-list>
</q-scroll-area> </q-scroll-area>
<q-banner <q-banner rounded class="bg-amber-1 text-center q-mx-sm" v-else>
rounded
class="bg-amber-1 text-center q-mx-sm"
v-else
>
<div class="text-yellow-10"> <div class="text-yellow-10">
<q-icon <q-icon name="mdi-alert-box" class="q-mx-xs" size="sm" color="yellow-10" />
name="mdi-alert-box"
class="q-mx-xs"
size="sm"
color="yellow-10"
/>
ไมพบขอความ ไมพบขอความ
</div> </div>
</q-banner> </q-banner>

View file

@ -108,19 +108,25 @@ const saveAbsence = () => {
}) })
.onOk(() => { .onOk(() => {
// createFormresign() // createFormresign()
})
.onCancel(() => {})
.onDismiss(() => {})
}
const saveData = () => {
if (model.value !== "ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน") { if (model.value !== "ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน") {
console.log(1) console.log(1)
} else if (model.value === "ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน") { } else if (model.value === "ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน") {
console.log(2) console.log(2)
} }
router.push(`/leave`) router.push(`/leave`)
})
.onCancel(() => {})
.onDismiss(() => {})
} }
// const saveData = () => {
// if (model.value !== " ") {
// console.log(1)
// } else if (model.value === " ") {
// console.log(2)
// }
// router.push(`/leave`)
// }
</script> </script>
<template> <template>
<div class="col-12 row justify-center"> <div class="col-12 row justify-center">
@ -382,7 +388,7 @@ const saveData = () => {
<q-separator /> <q-separator />
<div class="row col-12 q-pa-md"> <div class="row col-12 q-pa-md">
<q-space /> <q-space />
<q-btn unelevated dense class="q-px-md items-center btnBlue" label="บันทึก" @click="saveData" /> <q-btn unelevated dense class="q-px-md items-center btnBlue" label="บันทึก" @click="saveAbsence" />
</div> </div>
</q-card> </q-card>
</q-form> </q-form>