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`; const reply = `${env.API_URI}/placement/noti`;
export default { export default {
msgNotificate: `${message}/my-notifications`, msgNotificate: `${message}/my-notifications`,
msgInbox: `${message}/my-inboxes`, msgInbox: `${message}/my-inboxes`,
replyMessage: (id: string) => `${reply}/${id}`, 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 flat
bordered bordered
:style="$q.screen.gt.xs ? 'max-height: 74vh' : 'height: 100px;'" :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 class="text-subtitle1 text-weight-bold text-dark">
กลองขอความ กลองขอความ
</div> </div>
@ -232,13 +232,12 @@ async function onLoad(index: number, done: any) {
<div <div
v-if="totalInbox != 0" v-if="totalInbox != 0"
ref="scrollTargetRef" ref="scrollTargetRef"
class="q-pa-md"
style="max-height: 90%; overflow: auto" style="max-height: 90%; overflow: auto"
> >
<q-infinite-scroll <q-infinite-scroll
@load="onLoad" @load="onLoad"
:offset="250" :offset="250"
class="q-pa-md" class="q-px-md"
:scroll-target="scrollTargetRef" :scroll-target="scrollTargetRef"
> >
<div <div

View file

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

View file

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

View file

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

View file

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