ลาไปศึกษา
This commit is contained in:
parent
ddbcb40488
commit
2ebfacdbc1
4 changed files with 524 additions and 33 deletions
|
|
@ -29,6 +29,7 @@ const formData = reactive<any>({
|
|||
dateAt: "",
|
||||
admitted: "",
|
||||
atPlace: "",
|
||||
info:''
|
||||
});
|
||||
|
||||
const dateLeaveStartRef = ref<object | null>(null);
|
||||
|
|
|
|||
|
|
@ -1,44 +1,516 @@
|
|||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
|
||||
const edit = ref<boolean>(false);
|
||||
import { reactive, ref,computed } from "vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import type { FormRef09 } from "@/modules/05_leave/interface/request/AddAbsence";
|
||||
import { useQuasar } from "quasar";
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const { date2Thai, dialogConfirm } = mixin;
|
||||
const edit = ref<boolean>(true);
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Array,
|
||||
default: null,
|
||||
},
|
||||
onSubmit: {
|
||||
type: Function,
|
||||
default: () => "",
|
||||
},
|
||||
});
|
||||
const files = ref<any>(null);
|
||||
const formData = reactive<any>({
|
||||
writeat: "",
|
||||
dateLeaveStart: null,
|
||||
dateLeaveEnd: null,
|
||||
birthday: new Date(),
|
||||
dateGovernment: new Date(),
|
||||
saraly: 10000,
|
||||
tel: "",
|
||||
addressLeave: "test",
|
||||
capital: "",
|
||||
country: "",
|
||||
nameEducation: "",
|
||||
degree: "",
|
||||
study: "",
|
||||
file: "",
|
||||
info: "",
|
||||
});
|
||||
|
||||
const dateLeaveStartRef = ref<object | null>(null);
|
||||
const dateLeaveEndRef = ref<object | null>(null);
|
||||
const birthdayRef = ref<object | null>(null);
|
||||
const dateGovernmentRef = ref<object | null>(null);
|
||||
const saralyRef = ref<object | null>(null);
|
||||
const telRef = ref<object | null>(null);
|
||||
const addressLeaveRef = ref<object | null>(null);
|
||||
const capitalRef = ref<object | null>(null);
|
||||
const countryRef = ref<object | null>(null);
|
||||
const nameEducationRef = ref<object | null>(null);
|
||||
const degreeRef = ref<object | null>(null);
|
||||
const studyRef = ref<object | null>(null);
|
||||
const fileRef = ref<object | null>(null);
|
||||
const writeatRef = ref<object | null>(null);
|
||||
|
||||
const formRef: FormRef09 = {
|
||||
dateLeaveStart: dateLeaveStartRef,
|
||||
dateLeaveEnd: dateLeaveEndRef,
|
||||
birthday: birthdayRef,
|
||||
dateGovernment: dateGovernmentRef,
|
||||
saraly: saralyRef,
|
||||
tel: telRef,
|
||||
addressLeave: addressLeaveRef,
|
||||
capital: capitalRef,
|
||||
country: countryRef,
|
||||
nameEducation: nameEducationRef,
|
||||
degree: degreeRef,
|
||||
study: studyRef,
|
||||
file: fileRef,
|
||||
writeat: writeatRef,
|
||||
};
|
||||
|
||||
function onValidate() {
|
||||
const hasError = [];
|
||||
|
||||
for (const key in formRef) {
|
||||
if (Object.prototype.hasOwnProperty.call(formRef, key)) {
|
||||
const property = formRef[key];
|
||||
if (property.value && typeof property.value.validate === "function") {
|
||||
const isValid = property.value.validate();
|
||||
hasError.push(isValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError.every((result) => result === true)) {
|
||||
onSubmit();
|
||||
}
|
||||
}
|
||||
function onSubmit() {
|
||||
dialogConfirm(
|
||||
$q,
|
||||
async () => {
|
||||
console.log(formData);
|
||||
props.onSubmit();
|
||||
},
|
||||
"ยืนยันการบันทึกข้อมูล",
|
||||
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
||||
);
|
||||
}
|
||||
function calculateDuration(startDate: string | null, endDate: string | null) {
|
||||
if (startDate && endDate) {
|
||||
const start = new Date(startDate);
|
||||
const end = new Date(endDate);
|
||||
|
||||
const duration = end.getTime() - start.getTime(); // ระยะเวลาในมิลลิวินาที
|
||||
|
||||
const days = Math.floor(duration / (1000 * 60 * 60 * 24));
|
||||
const months = Math.floor(duration / (1000 * 60 * 60 * 24 * 30.44));
|
||||
const years = Math.floor(duration / (1000 * 60 * 60 * 24 * 30.44 * 12));
|
||||
|
||||
// return `${days} วัน, ${months} เดือน, ${years} ปี`;
|
||||
return `${years} ปี, ${months} เดือน, ${days} วัน`;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
const formattedSalary = computed(() => {
|
||||
return formData.saraly !== null
|
||||
? formData.saraly.toLocaleString("th-TH")
|
||||
: "";
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-icon name="mdi-numeric-3-circle" size="20px" color="primary" />
|
||||
<div class="q-pl-sm text-weight-bold text-dark">กรอกข้อมูล</div>
|
||||
<div>
|
||||
ลาไปศึกษา
|
||||
<ul>
|
||||
<li>ลาตั้งแต่วันที่</li>
|
||||
<li>ลาถึงวันที่</li>
|
||||
<li>มีกำหนด กี่ปี กี่เดือน กี่วัน (คำนวนจากทาง frontend Auto)</li>
|
||||
<li>วันเดือนปีเกิด (Auto)</li>
|
||||
<li>วันที่เข้ารับราชการ (Auto)</li>
|
||||
<li>เงินเดือนปัจจุบัน (Auto)</li>
|
||||
<li>
|
||||
เงินเดือนปัจจุบัน (เขียนเป็นคำอ่าน) ใช้ฟังก์ชั่นแปลงเลขเป็นข้อความ
|
||||
</li>
|
||||
<li>ศึกษาวิชา</li>
|
||||
<li>ขั้นปริญญา</li>
|
||||
<li>ชื่อสถานศึกษา</li>
|
||||
<li>ประเทศ</li>
|
||||
<li>ด้วยทุน</li>
|
||||
<li>ที่อยู่ที่ติดต่อได้ระหว่างลา</li>
|
||||
<li>หมายเลขโทรศัพท์</li>
|
||||
<li>รายละเอียด (ไม่บังคับกรอก)</li>
|
||||
<li>เอกสารประกอบ</li>
|
||||
</ul>
|
||||
<form @submit.prevent="onValidate">
|
||||
<q-card bordered class="q-pa-md bg-grey-1">
|
||||
<div class="row q-pa-sm q-col-gutter-sm">
|
||||
<q-input
|
||||
ref="writeatRef"
|
||||
class="col-12 col-sm-12"
|
||||
dense
|
||||
outlined
|
||||
bg-color="white"
|
||||
hide-bottom-space
|
||||
v-model="formData.writeat"
|
||||
label="เขียนที่"
|
||||
:rules="[(val) => !!val || `${'เขียนที่'}`]"
|
||||
/>
|
||||
<div class="full-width">
|
||||
<div class="q-col-gutter-sm row">
|
||||
<datepicker
|
||||
class="col-12 col-md-4 col-sm-6"
|
||||
menu-class-name="modalfix"
|
||||
v-model="formData.dateGovernment"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
borderless
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
readonly
|
||||
>
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
outlined
|
||||
readonly
|
||||
bg-color="white"
|
||||
dense
|
||||
ref="dateGovernmentRef"
|
||||
hide-bottom-space
|
||||
class="full-width datepicker"
|
||||
:model-value="
|
||||
formData.dateGovernment != null
|
||||
? date2Thai(formData.dateGovernment)
|
||||
: null
|
||||
"
|
||||
:label="`${'วันที่เข้ารับราชการ'}`"
|
||||
:rules="[
|
||||
(val) => !!val || `${'กรุณาเลือกวันที่เข้ารับราชการ'}`,
|
||||
]"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
<datepicker
|
||||
class="col-12 col-md-4 col-sm-6"
|
||||
menu-class-name="modalfix"
|
||||
v-model="formData.birthday"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
borderless
|
||||
readonly
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
>
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
outlined
|
||||
dense
|
||||
readonly
|
||||
ref="birthdayRef"
|
||||
bg-color="white"
|
||||
hide-bottom-space
|
||||
class="full-width datepicker"
|
||||
:model-value="
|
||||
formData.birthday != null
|
||||
? date2Thai(formData.birthday)
|
||||
: null
|
||||
"
|
||||
:label="`${'วันเดือนปีเกิด'}`"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกลาถึงวันที่'}`]"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
*หมายเหตุ ที่อยู่ที่ติดต่อได้ระหว่างลา
|
||||
(อาจดึงมาจากที่อยู่ปัจจุบันโดยอัตโนมัติ แต่ให้ผู้ใช้งานแก้ไขได้)
|
||||
</p>
|
||||
</div>
|
||||
<datepicker
|
||||
class="col-12 col-md-4 col-sm-6"
|
||||
menu-class-name="modalfix"
|
||||
v-model="formData.dateLeaveStart"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
borderless
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
>
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
outlined
|
||||
bg-color="white"
|
||||
dense
|
||||
lazy-rules
|
||||
ref="dateLeaveStartRef"
|
||||
hide-bottom-space
|
||||
class="full-width datepicker"
|
||||
:model-value="
|
||||
formData.dateLeaveStart != null
|
||||
? date2Thai(formData.dateLeaveStart)
|
||||
: null
|
||||
"
|
||||
:label="`${'ลาตั้งแต่วันที่'}`"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกลาตั้งแต่วันที่'}`]"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
|
||||
<datepicker
|
||||
class="col-12 col-md-4 col-sm-6"
|
||||
menu-class-name="modalfix"
|
||||
v-model="formData.dateLeaveEnd"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
borderless
|
||||
:readonly="!formData.dateLeaveStart"
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
:min-date="formData.dateLeaveStart ? new Date(formData.dateLeaveStart.getTime() + 24 * 60 * 60 * 1000) : null"
|
||||
>
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
outlined
|
||||
dense
|
||||
:readonly="!formData.dateLeaveStart"
|
||||
lazy-rules
|
||||
ref="dateLeaveEndRef"
|
||||
bg-color="white"
|
||||
hide-bottom-space
|
||||
class="full-width datepicker"
|
||||
:model-value="
|
||||
formData.dateLeaveEnd != null
|
||||
? date2Thai(formData.dateLeaveEnd)
|
||||
: null
|
||||
"
|
||||
:label="`${'ลาถึงวันที่'}`"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกลาถึงวันที่'}`]"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
<div class="col-12 col-md-4 col-sm-6">
|
||||
<p
|
||||
v-if="formData.dateLeaveStart && formData.dateLeaveEnd"
|
||||
class="text-weight-bold text-subtitle1 q-mb-none"
|
||||
style="padding-top: 7px; color: #26a69a"
|
||||
>
|
||||
ระยะเวลา
|
||||
{{
|
||||
calculateDuration(formData.dateLeaveStart, formData.dateLeaveEnd)
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="full-width">
|
||||
<div class="q-col-gutter-sm row">
|
||||
<q-input
|
||||
ref="saralyRef"
|
||||
class="col-12 col-sm-6 col-md-4"
|
||||
dense
|
||||
bg-color="white"
|
||||
outlined
|
||||
v-model="formattedSalary"
|
||||
label="เงินเดือนปัจจุบัน"
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเงินเดือนปัจจุบัน'}`]"
|
||||
/>
|
||||
<q-input
|
||||
ref="saralyRef"
|
||||
class="col-12 col-sm-6 col-md-4"
|
||||
dense
|
||||
readonly
|
||||
outlined
|
||||
bg-color="white"
|
||||
v-model="formData.saraly"
|
||||
label="เงินเดือนปัจจุบัน(คำอ่าน)"
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกเงินเดือนปัจจุบัน'}`]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="full-width">
|
||||
<div class="q-col-gutter-sm row">
|
||||
<q-input
|
||||
ref="nameEducationRef"
|
||||
class="col-12 col-sm-6 col-md-4"
|
||||
dense
|
||||
bg-color="white"
|
||||
outlined
|
||||
v-model="formData.nameEducation"
|
||||
label="ชื่อสถานศึกษา"
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกชื่อสถานศึกษา'}`]"
|
||||
/>
|
||||
<q-input
|
||||
ref="degreeRef"
|
||||
class="col-12 col-sm-6 col-md-4"
|
||||
dense
|
||||
bg-color="white"
|
||||
outlined
|
||||
v-model="formData.degree"
|
||||
label="ชั้นปริญญา"
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกชั้นปริญญา'}`]"
|
||||
/>
|
||||
<q-input
|
||||
ref="studyRef"
|
||||
class="col-12 col-sm-6 col-md-4"
|
||||
dense
|
||||
bg-color="white"
|
||||
outlined
|
||||
v-model="formData.study"
|
||||
label="ศึกษาวิชา"
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกศึกษาวิชา'}`]"
|
||||
/>
|
||||
<q-input
|
||||
ref="countryRef"
|
||||
class="col-12 col-sm-6 col-md-4"
|
||||
dense
|
||||
bg-color="white"
|
||||
outlined
|
||||
v-model="formData.country"
|
||||
label="ประเทศ"
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกประเทศ'}`]"
|
||||
/>
|
||||
<q-input
|
||||
ref="capitalRef"
|
||||
class="col-12 col-sm-6 col-md-4"
|
||||
dense
|
||||
bg-color="white"
|
||||
outlined
|
||||
v-model="formData.capital"
|
||||
label="ด้วยทุน"
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกด้วยทุน'}`]"
|
||||
/>
|
||||
<q-input
|
||||
class="col-12 col-sm-6 col-md-4"
|
||||
dense
|
||||
outlined
|
||||
bg-color="white"
|
||||
ref="telRef"
|
||||
v-model="formData.tel"
|
||||
mask="(###)-###-####"
|
||||
unmasked-value
|
||||
hide-bottom-space
|
||||
label="หมายเลขโทรศัพท์ที่ติดต่อได้"
|
||||
:rules="[
|
||||
(val) => !!val || `${'กรุณากรอกหมายเลขโทรศัพท์ที่ติดต่อได้'}`,
|
||||
]"
|
||||
/>
|
||||
<q-input
|
||||
ref="addressLeaveRef"
|
||||
class="col-12"
|
||||
dense
|
||||
bg-color="white"
|
||||
outlined
|
||||
v-model="formData.addressLeave"
|
||||
label="ที่อยู่ที่ติดต่อได้ระหว่างลา"
|
||||
hide-bottom-space
|
||||
:rules="[
|
||||
(val) => !!val || `${'กรุณากรอก ที่อยู่ที่ติดต่อได้ระหว่างลา'}`,
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<q-input
|
||||
class="col-12 q-mt-sm"
|
||||
dense
|
||||
bg-color="white"
|
||||
outlined
|
||||
v-model="formData.info"
|
||||
label="รายละเอียด"
|
||||
/>
|
||||
<div class="col-12 col-sm-6">
|
||||
<q-file
|
||||
ref="fileRef"
|
||||
v-model="formData.file"
|
||||
dense
|
||||
label="เอกสารประกอบ"
|
||||
outlined
|
||||
bg-color="white"
|
||||
multiple
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกไฟล์'}`]"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="attach_file" color="primary" />
|
||||
</template>
|
||||
</q-file>
|
||||
</div>
|
||||
|
||||
<div class="col-12 row" v-if="!edit">
|
||||
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
|
||||
<div class="q-pl-sm text-weight-bold text-dark">
|
||||
เอกสารเพิ่มเติม
|
||||
</div>
|
||||
</div>
|
||||
<q-card bordered flat class="full-width">
|
||||
<q-list separator>
|
||||
<q-item v-for="file in files" :key="file.key" class="q-my-xs">
|
||||
<q-item-section>
|
||||
<q-item-label class="full-width ellipsis">
|
||||
{{ file.fileName }}
|
||||
</q-item-label>
|
||||
|
||||
<q-item-label caption> </q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-card>
|
||||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
<q-separator class="q-mt-sm" />
|
||||
<div class="row col-12 q-pt-md">
|
||||
<q-space />
|
||||
<q-btn
|
||||
id="onSubmit"
|
||||
type="submit"
|
||||
unelevated
|
||||
dense
|
||||
class="q-px-md items-center btnBlue"
|
||||
label="บันทึก"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -46,9 +46,27 @@ interface FormRef08 {
|
|||
atPlace:object|null
|
||||
[key: string]: any;
|
||||
}
|
||||
interface FormRef09 {
|
||||
dateLeaveStart:object|null
|
||||
dateLeaveEnd:object|null
|
||||
birthday:object|null
|
||||
dateGovernment:object|null
|
||||
saraly:object|null
|
||||
tel:object|null
|
||||
addressLeave:object|null
|
||||
capital:object|null
|
||||
country:object|null
|
||||
nameEducation:object|null
|
||||
degree:object|null
|
||||
study:object|null
|
||||
file:object|null
|
||||
writeat:object|null
|
||||
[key: string]: any;
|
||||
}
|
||||
export type {
|
||||
FormData,
|
||||
FormRef06,
|
||||
FormRef07,
|
||||
FormRef08,
|
||||
FormRef09
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ const route = useRoute();
|
|||
const myform = ref<QForm | null>(null);
|
||||
const $q = useQuasar();
|
||||
|
||||
const model = ref("6");
|
||||
const model = ref("");
|
||||
const modelSpecific = ref("");
|
||||
|
||||
const clickBack = () => {
|
||||
|
|
@ -149,8 +149,8 @@ const onSubmit = async () => {
|
|||
/>
|
||||
<Form8 :on-submit="onSubmit" v-if="model === '6'" style="width: 100%;"/>
|
||||
<Form9
|
||||
:on-submit="onSubmit"
|
||||
v-if="model === '7' && modelSpecific === '0'"
|
||||
:on-submit="onSubmit"
|
||||
v-if="model === '7' && modelSpecific === '0'" style="width: 100%"
|
||||
/>
|
||||
<Form10
|
||||
:on-submit="onSubmit"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue