Merge commit '47327cff40' into develop

This commit is contained in:
Tanyalak 2024-01-18 15:02:49 +07:00
commit 1c5a839fda
6 changed files with 187 additions and 154 deletions

View file

@ -4,7 +4,8 @@ const message = `${env.API_URI}/message`;
const reply = `${env.API_URI}/placement/noti`;
export default {
msgNotificate: `${message}/my-notifications`,
msgInbox: `${message}/my-inboxes`,
replyMessage: (id: string) => `${reply}/${id}`,
msgNotificate: `${message}/my-notifications`,
msgInbox: `${message}/my-inboxes`,
msgId: (id: string) => `${message}/my-notifications/${id}`,
replyMessage: (id: string) => `${reply}/${id}`,
};

View file

@ -214,9 +214,9 @@ async function onLoad(index: number, done: any) {
flat
bordered
:style="$q.screen.gt.xs ? 'max-height: 74vh' : 'height: 100px;'"
class="q-pb-md col-12"
class="q-pb-sm col-12"
>
<div class="col-12 row q-pa-md">
<div class="col-12 row q-px-md q-pt-md q-pb-sm">
<div class="text-subtitle1 text-weight-bold text-dark">
กลองขอความ
</div>
@ -232,13 +232,12 @@ async function onLoad(index: number, done: any) {
<div
v-if="totalInbox != 0"
ref="scrollTargetRef"
class="q-pa-md"
style="max-height: 90%; overflow: auto"
>
<q-infinite-scroll
@load="onLoad"
:offset="250"
class="q-pa-md"
class="q-px-md"
:scroll-target="scrollTargetRef"
>
<div

View file

@ -18,13 +18,17 @@ import RehabilitationForm from "@/modules/05_leave/components/FormLeave/13_Rehab
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import router from "@/router";
import { useRoute, useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useLeaveStore } from "@/modules/05_leave/store";
const route = useRoute();
const router = useRouter();
/**
* วแปรทใช
*/
const personalId = ref<string>(route.params.id as string);
const leaveId = ref<string>("");
const dataStore = useLeaveStore();
@ -201,12 +205,12 @@ async function fetchDataDetail(id: string) {
});
}
/**modal */
const model = computed(() => {
return (
dataStore.options.find((x) => x.id == formData.leaveTypeId)?.code ?? ""
);
});
const modelSpecific = computed(() => {
const code = dataStore.options.find(
(x) => x.id == formData.leaveTypeId
@ -225,6 +229,11 @@ const modelSpecific = computed(() => {
}
});
/**
* function นทกขอม
* @param formData อมลใน formdata
* @param isLeave วแปรเชควาใชหน edit หรอไม
*/
function onSubmit(formData: FormData, isLeave: boolean = true) {
if (isLeave) {
dialogConfirm($q, async () => {
@ -232,6 +241,7 @@ function onSubmit(formData: FormData, isLeave: boolean = true) {
await http
.put(config.API.leaveUserId(personalId.value), formData)
.then(() => {
fetchDataDetail(personalId.value);
success($q, "บันทึกสำเร็จ");
})
.catch((e: any) => {
@ -239,7 +249,6 @@ function onSubmit(formData: FormData, isLeave: boolean = true) {
})
.finally(() => {
hideLoader();
fetchDataDetail(personalId.value);
});
});
} else {
@ -247,6 +256,10 @@ function onSubmit(formData: FormData, isLeave: boolean = true) {
}
}
/**
* funciotn นใบลา
* @param id id ของใบลา
*/
function onConfirm(id: string) {
dialogConfirm(
$q,
@ -256,15 +269,14 @@ function onConfirm(id: string) {
.put(config.API.leaveUserSendId(personalId.value), { reason: "" })
.then(() => {
success($q, "ยื่นใบลาสำเร็จ");
// router.push("/leave");
})
.catch((e: any) => {
messageError($q, e);
})
.finally(() => {
router.push("/leave");
fetchDataDetail(personalId.value);
hideLoader();
router.push("/leave");
// fetchDataDetail(personalId.value);
});
},
"ยืนยันการยื่นใบลา",

View file

@ -607,7 +607,7 @@ onMounted(async () => {
}}
</div>
<q-space />
<div>
<div v-if="route.name !== 'evaluate-add'">
<q-btn
flat
round
@ -635,8 +635,8 @@ onMounted(async () => {
<div class="toptitle2">
{{ store.step }}.{{ store.title[store.step - 1] }}
</div>
<q-space/>
<div >
<q-space />
<div>
<q-btn
v-if="store.step === 1"
:href="externalLink"
@ -651,7 +651,7 @@ onMounted(async () => {
</q-btn>
</div>
</div>
<div class=" col-12 q-pt-sm">
<div class="col-12 q-pt-sm">
<div class="q-col-gutter-md col-12 row">
<div
:class="
@ -664,9 +664,17 @@ onMounted(async () => {
? 'col-12 row'
: 'col-xs-12 col-sm-5 row'
"
>
<q-card flat bordered class="col-12 shadow-0" :style="$q.screen.lt.sm ? '' : 'max-height: 60vh; overflow: scroll;' ">
<q-card
flat
bordered
class="col-12 shadow-0"
:style="
$q.screen.lt.sm
? ''
: 'max-height: 60vh; overflow: scroll;'
"
>
<Step1
v-if="store.step === 1"
@update:spec="updateCheckSpec"
@ -677,21 +685,29 @@ onMounted(async () => {
v-if="store.step === 2"
@update:form="updateformCommand"
/>
<Step3 v-if="store.step === 3" @update:file="updateFilePDF" />
<Step3
v-if="store.step === 3"
@update:file="updateFilePDF"
/>
<Step4 v-if="store.step === 4" />
<Step5 v-if="store.step === 5" />
<Step6
v-if="store.step === 6"
@update:form="updateformCommand"
/>
<Step7 v-if="store.step === 7" @update:file="updateFilePDF" />
<Step7
v-if="store.step === 7"
@update:file="updateFilePDF"
/>
<Step8 v-if="store.step === 8" />
<Step9 v-if="store.step === 9" />
</q-card>
</div>
<div
class="col-xs-12 col-sm-7"
v-if="store.step === 1 || store.step === 3 || store.step === 7"
v-if="
store.step === 1 || store.step === 3 || store.step === 7
"
>
<div class="col-12">
<ViewStep1
@ -712,63 +728,63 @@ onMounted(async () => {
</div>
</div>
</div>
</div>
<div class="q-pt-sm q-gutter-sm" align="right">
<q-btn
v-if="
store.step >= store.currentStep &&
store.statusUpload === false &&
store.step !== 3 &&
store.step !== 4 &&
store.step !== 5 &&
store.step !== 7 &&
store.step !== 8 &&
store.step !== 9
"
unelevated
:label="
store.step === 2 || store.step === 6
? 'บันทึกข้อมูล'
: 'ดำเนินการต่อ'
"
color="public"
@click="onCilckNextStep()"
/>
</div>
<div class="q-pt-sm q-gutter-sm" align="right">
<q-btn
v-if="
store.step >= store.currentStep &&
store.statusUpload === false &&
store.step !== 3 &&
store.step !== 4 &&
store.step !== 5 &&
store.step !== 7 &&
store.step !== 8 &&
store.step !== 9
"
unelevated
:label="
store.step === 2 || store.step === 6
? 'บันทึกข้อมูล'
: 'ดำเนินการต่อ'
"
color="public"
@click="onCilckNextStep()"
/>
<q-btn
v-else-if="
store.step >= store.currentStep &&
(store.step == 3 || store.step == 7)
"
unelevated
label="ยื่นเอกสาร"
color="public"
@click="onCilckNextStep()"
/>
<q-btn
v-else-if="
store.step >= store.currentStep &&
(store.step == 3 || store.step == 7)
"
unelevated
label="ยื่นเอกสาร"
color="public"
@click="onCilckNextStep()"
/>
<q-btn
v-if="
store.step >= store.currentStep &&
store.step == 2 &&
store.statusUpload
"
unelevated
label="ดำเนินการต่อ"
color="public"
@click="onCilckNextStep()"
/>
<q-btn
v-if="
store.step >= store.currentStep &&
store.step == 6 &&
store.statusUpload
"
unelevated
label="ดำเนินการต่อ"
color="public"
@click="onCilckNextStep()"
/>
</div>
<q-btn
v-if="
store.step >= store.currentStep &&
store.step == 2 &&
store.statusUpload
"
unelevated
label="ดำเนินการต่อ"
color="public"
@click="onCilckNextStep()"
/>
<q-btn
v-if="
store.step >= store.currentStep &&
store.step == 6 &&
store.statusUpload
"
unelevated
label="ดำเนินการต่อ"
color="public"
@click="onCilckNextStep()"
/>
</div>
</div>
</q-card>
</div>

View file

@ -228,12 +228,12 @@ function onSubmit(data: any) {
:readonly="isReadOnly"
ref="titleRef"
:rules="[
(val) => !!val || 'กรุณากรอกอุทธรณ์/ร้องทุกข์',
(val) => !!val || 'กรุณากรอกเรื่องอุทธรณ์/ร้องทุกข์',
]"
v-model="formData.title"
dense
outlined
label="อุทธรณ์/ร้องทุกข์"
label="เรื่องอุทธรณ์/ร้องทุกข์"
hide-bottom-space
/>
</div>

View file

@ -13,7 +13,14 @@ const router = useRouter();
const $q = useQuasar();
const mixin = useCounterMixin();
const { date2Thai } = mixin;
const {
date2Thai,
dialogRemove,
showLoader,
hideLoader,
messageError,
success,
} = mixin;
const fullname = ref<string>("");
const notiList = ref<any>([]);
@ -26,31 +33,53 @@ const link = ref<string>("");
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/
onMounted(async () => {
await fetchlistNotification(1);
await fetchlistNotification(1, "NOMAL");
if (keycloak.tokenParsed != null) {
fullname.value = keycloak.tokenParsed.name;
}
});
const fetchlistNotification = async (index: number) => {
const fetchlistNotification = async (index: number, type: string) => {
await http
.get(config.API.msgNotificate + `?page=${index}&pageSize=${20}`)
.then((res: any) => {
const data = res.data.result.data;
totalInbox.value = res.data.result.total;
let list: any[] = [];
data.map((e: any) => {
list.push({
id: e.id,
sender:
e.createdFullName == "" || e.createdFullName == null
? "เจ้าหน้าที่"[0]
: e.createdFullName[0],
body: e.body ?? "",
timereceive: date2Thai(e.createdAt),
if (type === "DEL") {
totalInbox.value = res.data.result.total;
console.log(notiList.value.length);
if (notiList.value.length === 14) {
notiList.value = [];
data.map((e: any) => {
list.push({
id: e.id,
sender:
e.createdFullName == "" || e.createdFullName == null
? "เจ้าหน้าที่"[0]
: e.createdFullName[0],
body: e.body ?? "",
timereceive: date2Thai(e.createdAt),
});
});
notiList.value.push(...list);
}
} else {
data.map((e: any) => {
list.push({
id: e.id,
sender:
e.createdFullName == "" || e.createdFullName == null
? "เจ้าหน้าที่"[0]
: e.createdFullName[0],
body: e.body ?? "",
timereceive: date2Thai(e.createdAt),
});
});
});
notiList.value.push(...list);
notiList.value.push(...list);
totalInbox.value = res.data.result.total;
}
})
.catch((err) => {
console.log(err);
@ -73,11 +102,32 @@ const doLogout = () => {
});
};
const clickDelete = async (id: string, index: number) => {
dialogRemove($q, async () => {
showLoader();
await http
.delete(config.API.msgId(id))
.then(() => {
notiList.value.splice(index, 1);
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
fetchlistNotification(1, "DEL");
hideLoader();
});
});
};
const totalInbox = ref<number>(0);
const page = ref<number>(1);
function onLoad(index: any, done: any) {
page.value = index + 1;
if (notiList.value.length < totalInbox.value) {
setTimeout(() => {
fetchlistNotification(index + 1);
fetchlistNotification(page.value, "NOMAL");
done();
}, 2000);
}
@ -159,24 +209,24 @@ function onLoad(index: any, done: any) {
floating
>{{ totalInbox }}</q-badge
>
<q-menu v-model="notiTrigger" max-width="480px" :offset="[0, 10]">
<q-menu
v-model="notiTrigger"
:offset="[0, 10]"
style="max-width: 480px"
>
<div class="q-px-md q-py-sm row col-12 items-center">
<div class="text-subtitle1 text-weight-medium">การแจงเตอน</div>
<q-space />
<q-btn
<!-- <q-btn
label="ล้างข้อมูล"
color="pink"
dense
class="text-caption"
flat
/>
/> -->
</div>
<q-infinite-scroll
@load="onLoad"
:offset="250"
style="min-width: 300px"
>
<q-infinite-scroll @load="onLoad" :offset="250">
<div
v-for="(item, index) in notiList"
:key="index"
@ -213,66 +263,21 @@ function onLoad(index: any, done: any) {
dense
icon="mdi-close"
class="mybtn q-mx-xs"
v-close-popup
@click="clickDelete(item.id, index)"
></q-btn>
</div>
</q-item>
</div>
<template v-slot:loading v-if="notiList.length < totalInbox">
<template
v-slot:loading
v-if="notiList.length < totalInbox || notiList.length !== 19"
>
<div class="row justify-center q-my-md">
<q-spinner-dots color="primary" size="40px" />
</div>
</template>
</q-infinite-scroll>
<!-- <q-list
style="min-width: 300px"
v-for="(n, index) in notiList"
:key="index"
>
<q-item v-ripple class="mytry q-py-sm" dense>
<q-item-section avatar top style="min-width: 40px">
<q-avatar
rounded
color="primary"
size="25px"
text-color="white"
>
<span class="text-weight-medium text-uppercase">{{
n.sender[0]
}}</span>
</q-avatar>
</q-item-section>
<q-item-section>
<q-item-label caption class="text-black">{{
n.body
}}</q-item-label>
<q-item-label
caption
class="row items-center text-grey-7"
style="font-size: 12px"
>{{ n.timereceive }}</q-item-label
>
</q-item-section>
<div>
<q-btn
size="sm"
unelevated
dense
icon="mdi-close"
class="mybtn q-mx-xs"
v-close-popup
></q-btn>
</div>
</q-item>
<q-separator
class="q-my-xs"
color="grey-2"
v-if="index + 1 < notiList.length"
:key="index"
/>
</q-list> -->
</q-menu>
</q-btn>