update format

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-02 13:40:15 +07:00
parent b44076d99d
commit 36b3eef7fd
10 changed files with 222 additions and 226 deletions

View file

@ -1,19 +1,21 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
env: {
node: true,
es2022: true,
},
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/typescript/recommended',
'@vue/eslint-config-typescript/recommended',
'@vue/eslint-config-prettier/recommended',
],
rules: {
// 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
// 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
'vue/no-mutating-props': 'off',
// '@typescript-eslint/no-explicit-any': 'off',
'vue/multi-word-component-names': 'off'
overrides: [
{
files: ['cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}'],
extends: ['plugin:cypress/recommended'],
},
],
parserOptions: {
ecmaVersion: 'latest',
},
}

View file

@ -1,8 +1,4 @@
<template>
<!-- <nav>
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</nav> -->
<router-view />
</template>

View file

@ -1,7 +1,7 @@
import env from "./index";
const leave = `${env.API_URI}/leave`;
import env from './index'
const leave = `${env.API_URI}/leave`
export default {
checkin: () => `${leave}/check-in`,
checkTime: () => `${leave}/check-time`,
};
}

View file

@ -1,71 +1,71 @@
const ACCESS_TOKEN = "BMAHRIS_KEYCLOAK_IDENTITY";
const ACCESS_TOKEN = 'BMAHRIS_KEYCLOAK_IDENTITY'
interface AuthResponse {
access_token: string;
expires_in: number;
refresh_token: string;
access_token: string
expires_in: number
refresh_token: string
}
const authenticated = async () => ((await getToken()) ? true : false);
const authenticated = async () => ((await getToken()) ? true : false)
async function setAuthen(r: AuthResponse) {
await setCookie(ACCESS_TOKEN, r.access_token, r.expires_in);
window.location.href = "/";
await setCookie(ACCESS_TOKEN, r.access_token, r.expires_in)
window.location.href = '/'
}
async function logout() {
await deleteCookie(ACCESS_TOKEN);
window.location.href = "/login";
await deleteCookie(ACCESS_TOKEN)
window.location.href = '/login'
}
async function getToken() {
return getCookie(ACCESS_TOKEN);
return getCookie(ACCESS_TOKEN)
}
// 2024-08-29T02:55:13.000Z
function setCookie(name: string, value: any, time: number) {
let expires = "";
let expires = ''
if (time) {
const date = new Date();
date.setTime(date.getTime() + time * 1000);
const date = new Date()
date.setTime(date.getTime() + time * 1000)
// date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
expires = "; expires=" + date.toUTCString();
expires = '; expires=' + date.toUTCString()
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
document.cookie = name + '=' + (value || '') + expires + '; path=/'
}
function getCookie(name: string) {
const nameEQ = name + "=";
const ca = document.cookie.split(";");
const nameEQ = name + '='
const ca = document.cookie.split(';')
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == " ") c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
let c = ca[i]
while (c.charAt(0) == ' ') c = c.substring(1, c.length)
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length)
}
return null;
return null
}
function deleteCookie(name: string) {
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`
}
async function tokenParsed() {
const token = await getCookie(ACCESS_TOKEN);
const token = await getCookie(ACCESS_TOKEN)
if (!token) {
return null;
return null
}
const base64Url = token.split(".")[1];
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
const base64Url = token.split('.')[1]
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
const jsonPayload = decodeURIComponent(
window
.atob(base64)
.split("")
.split('')
.map(function (c) {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
})
.join("")
);
.join('')
)
return JSON.parse(jsonPayload);
return JSON.parse(jsonPayload)
}
export { getToken, authenticated, logout, setAuthen, tokenParsed };
export { getToken, authenticated, logout, setAuthen, tokenParsed }

View file

@ -3,9 +3,7 @@
* - Helper Functions
*/
const filters = {
/**
* compactNumber Social Media 1,000 1K 1,000,000 1M
* : {{ $filters.compactNumber(value) }}
@ -16,7 +14,7 @@ const filters = {
compactNumber(val: number) {
const formatter = Intl.NumberFormat('en', { notation: 'compact' })
return formatter.format(val)
}
},
}
export default filters;
export default filters

View file

@ -1,9 +1,9 @@
<script lang="ts">
import { defineComponent } from "vue";
import { defineComponent } from 'vue'
export default defineComponent({
name: "Error404NotFound",
});
name: 'Error404NotFound',
})
</script>
<template>

View file

@ -384,7 +384,7 @@ onMounted(async () => {
v-model="model"
:options="options"
prefix="ระบุสถานที่ :"
:rules="[(val) => !!val || 'กรุณาระบุสถานที่']"
:rules="[(val:string) => !!val || 'กรุณาระบุสถานที่']"
lazy-rules
@update:model-value="selectLocation()"
hide-bottom-space
@ -401,7 +401,7 @@ onMounted(async () => {
outlined
v-model="useLocation"
label="ระบุสถานที่"
:rules="[(val) => !!val || 'กรุณาระบุสถานที่']"
:rules="[(val:string) => !!val || 'กรุณาระบุสถานที่']"
lazy-rules
/>
</div>
@ -470,9 +470,7 @@ onMounted(async () => {
{{ date2Thai(Thai) }}
</div>
<div class="row col-12 justify-center q-pt-sm">
<div class="text-h3 text-weight-bold">
<!-- {{ formattedH }}<span class="q-ma-md">:</span> -->
</div>
<div class="text-h3 text-weight-bold"></div>
<div class="text-h3 text-weight-bold">{{ timeChickin }}</div>
</div>
</div>

View file

@ -1,13 +1,14 @@
<script setup lang="ts">
import { ref, onMounted, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useQuasar } from 'quasar'
import { useRouter } from 'vue-router'
import http from '@/plugins/http'
import config from '@/app.config'
import { logout, tokenParsed } from '@/plugins/auth'
import { useCounterMixin } from '@/stores/mixin'
import type { notiType } from '@/interface/index/Main'
import { useCounterMixin } from '@/stores/mixin'
import type { Noti } from '@/interface/response/Main'
const mixin = useCounterMixin()
@ -15,21 +16,32 @@ const { date2Thai, hideLoader, messageError, dialogRemove, success } = mixin
const router = useRouter()
const $q = useQuasar()
const notiTrigger = ref<boolean>(false)
const notiList = ref<notiType[]>([])
const totalNotiList = ref<number>(0)
const totalNoti = ref<number>(0)
/*** ฟังก์ชั่นดึงข้อมูลจำนวนการแจ้งเตือน */
async function fetchTotolNotificate() {
await http.get(config.API.msgNotificateTotal).then((res) => {
totalNoti.value = res.data.result
})
// .catch((err) => {
// messageError($q, err)
// })
const fullName = ref<string>('') //
const notiTrigger = ref<boolean>(false) // ,
const notiList = ref<notiType[]>([]) //
const totalNotiList = ref<number>(0) //
const totalNoti = ref<number>(0) //
const statusLoad = ref<boolean>(false) //
//
const thaiOptions: Intl.DateTimeFormatOptions = {
hour: '2-digit',
minute: '2-digit',
}
/**
* งกนดงขอมลจำนวนการแจงเตอน
*/
async function fetchTotolNotificate() {
await http
.get(config.API.msgNotificateTotal)
.then(async (res) => {
totalNoti.value = await res.data.result
})
.catch((err) => {
messageError($q, err)
})
}
const statusLoad = ref<boolean>(false)
/**
* งกนดงขอมลรายการแจงเตอน
* @param index page องการโหลดขอม
@ -45,7 +57,6 @@ async function fetchNotifications(index: number, type: string) {
if (type === 'DEL') {
notiList.value = []
}
response.map((e: Noti) => {
list.push({
id: e.id,
@ -61,9 +72,9 @@ async function fetchNotifications(index: number, type: string) {
notiList.value.push(...list)
statusLoad.value = totalNotiList.value === 0 ? true : false
})
// .catch((err) => {
// messageError($q, err)
// })
.catch((err) => {
messageError($q, err)
})
}
/**
@ -74,22 +85,24 @@ async function onClickDelete(id: string, index: number) {
dialogRemove($q, async () => {
await http
.delete(config.API.msgId(id))
.then(() => {
.then(async () => {
notiList.value.splice(index, 1)
totalNotiList.value--
notiList.value.length === 14 && (await fetchNotifications(1, 'DEL'))
success($q, 'ลบข้อมูลสำเร็จ')
})
.catch((e) => {
messageError($q, e)
})
.finally(async () => {
notiList.value.length === 14 && fetchNotifications(1, 'DEL')
hideLoader()
})
})
}
/** function logout*/
/**
* function logout
*/
function onClickLogout() {
$q.dialog({
title: 'ยืนยันการออกจากระบบ',
@ -102,18 +115,14 @@ function onClickLogout() {
})
}
const thaiOptions: Intl.DateTimeFormatOptions = {
hour: '2-digit',
minute: '2-digit',
}
const page = ref<number>(0)
/**
* โหลดรายการแจงเตอนเพมเม scroll
* @param index
* @param done
*/
function onLoad(index: any, done: any) {
function onLoad(index: number, done: Function) {
if (
notiList.value.length < totalNotiList.value ||
(notiList.value.length == 0 && totalNotiList.value === 0)
@ -140,7 +149,6 @@ watch(
}
)
const fullName = ref<string>('')
onMounted(async () => {
fetchTotolNotificate()
const checkTokenParsed = await tokenParsed()
@ -251,12 +259,6 @@ onMounted(async () => {
}}
. <q-space />
</q-item-label>
<!-- <q-item-label
caption
class="row items-center text-grey-7"
style="font-size: 12px"
>{{ item.timereceive }}</q-item-label
> -->
</q-item-section>
<div>
<q-btn