Merge branch 'develop' into warunee-dev

This commit is contained in:
Warunee Tamkoo 2024-01-05 17:55:34 +07:00
commit bb1903ab25
9 changed files with 234 additions and 14 deletions

View file

@ -97,7 +97,7 @@ const formData = reactive<FremData>({
leaveTotal: 0, //(Auto)
leavebirthDate: new Date(), //(Auto)
leavegovernmentDate: new Date(), //(Auto)
leaveSalary: 0, //(Auto)
leaveSalary: "", //(Auto)
leaveSalaryText: "", //()
leaveTypeDay: "", //
wifeDayName: "", //()
@ -196,7 +196,9 @@ async function fetchDetailLeave(paramsId: string) {
data.leaveBirthDate && date2Thai(data.leaveBirthDate);
formData.leavegovernmentDate =
data.leaveGovernmentDate && date2Thai(data.leaveGovernmentDate);
formData.leaveSalary = data.leaveSalary ? data.leaveSalary : "-";
formData.leaveSalary = data.leaveSalary
? formattedNumber(data.leaveSalary)
: "-";
formData.leaveSalaryText = data.leaveSalaryText
? data.leaveSalaryText
: "-";
@ -307,7 +309,7 @@ async function fectOptionType() {
.then((res) => {
console.log(res);
leaveType.value = res.data.result;
checkLeaveType(formData.leaveTypeId, formData.leaveTypeName);
checkLeaveType(formData.leaveTypeId, formData);
})
.catch((err) => {
messageError($q, err);
@ -319,7 +321,7 @@ const checkForm = ref<string>("");
* Function เชคประเภทการลา
* @param type บค
*/
function checkLeaveType(leaveTypeId: string, leaveTypeName: string) {
function checkLeaveType(leaveTypeId: string, formData: FremData) {
if (leaveType.value) {
const filtertype: LeaveType | undefined = leaveType.value.find(
(e: any) => e.id === leaveTypeId
@ -331,13 +333,13 @@ function checkLeaveType(leaveTypeId: string, leaveTypeName: string) {
checkForm.value = "FormChildbirth";
} else if (type === "LV-005") {
checkForm.value = "FormHoliday";
} else if (type === "LV-006") {
} else if (type === "LV-006" && formData.ordainDayLocationName !== "-") {
checkForm.value = "FormUpasom";
} else if (type === "LV-006" && leaveTypeName === "พิธีฮัจญ์ฯ") {
} else if (type === "LV-006") {
checkForm.value = "FormHajj";
} else if (type === "LV-007") {
checkForm.value = "FormCheckSelect";
} else if (type === "LV-008" && leaveTypeName === "ลาไปศีกษา") {
} else if (type === "LV-008" && formData.studyDayTrainingSubject === "-") {
checkForm.value = "FormStudy";
} else if (type === "LV-008") {
checkForm.value = "FormLeaveToTraining";
@ -481,6 +483,10 @@ async function onClickDownloadFile(id: string, fileName: string, type: string) {
hideLoader();
});
}
function formattedNumber(x: number) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">

View file

@ -1,10 +1,43 @@
<script setup lang="ts">
/** importStore */
import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin();
const { calculateDurationYmd } = mixin;
const props = defineProps({
data: {
type: Object,
required: true,
},
});
function convertDateToEng(dataThia: string) {
const thaiDateParts: string[] = dataThia.split(" ");
const thaiMonthAbbreviation: string = thaiDateParts[1];
const thaiMonths: { [key: string]: string } = {
"ม.ค.": "Jan",
"ก.พ.": "Feb",
"มี.ค.": "Mar",
"เม.ย.": "Apr",
"พ.ค.": "May",
"มิ.ย.": "Jun",
"ก.ค.": "Jul",
"ส.ค.": "Aug",
"ก.ย.": "Sep",
"ต.ค.": "Oct",
"พ.ย.": "Nov",
"ธ.ค.": "Dec",
};
const englishMonth: string = thaiMonths[thaiMonthAbbreviation];
if (englishMonth) {
const englishDateString: string = `${englishMonth} ${thaiDateParts[0]} ${thaiDateParts[2]}`;
const dateObject: Date = new Date(englishDateString);
return dateObject.toString();
}
}
</script>
<template>
<q-card-section>
@ -23,7 +56,14 @@ const props = defineProps({
</div>
<div class="row">
<div class="col text-grey-8">จำนวนวนทลา</div>
<div class="col">{{ props.data.leaveTotal }}</div>
<div class="col">
{{
calculateDurationYmd(
convertDateToEng(props.data.leaveDateStart),
convertDateToEng(props.data.leaveDateEnd)
)
}}
</div>
</div>
<div class="row">
<div class="col text-grey-8">นเดอนปเก</div>

View file

@ -26,7 +26,7 @@ const props = defineProps({
<div class="col">{{ props.data.leaveDetail }}</div>
</div>
<div class="row">
<div class="col text-grey-8">เอกสารแน</div>
<div class="col text-grey-8">เอกสารประกอ</div>
<div class="col" v-if="props.data.leaveDocument">
<q-btn
:href="props.data.leaveDocument"
@ -41,6 +41,22 @@ const props = defineProps({
</div>
<div class="col" v-else>-</div>
</div>
<div class="row">
<div class="col text-grey-8">เอกสารแบบฟอร</div>
<div class="col" v-if="props.data.leaveDraftDocument">
<q-btn
:href="props.data.leaveDraftDocument"
target="_blank"
outline
color="blue"
label="ดาวน์โหลด"
size="12px"
>
<q-tooltip>ดาวนโหลดไฟล</q-tooltip></q-btn
>
</div>
<div class="col" v-else>-</div>
</div>
</div>
</q-card-section>
</template>

View file

@ -1,10 +1,43 @@
<script setup lang="ts">
/** importStore */
import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin();
const { calculateDurationYmd } = mixin;
const props = defineProps({
data: {
type: Object,
required: true,
},
});
function convertDateToEng(dataThia: string) {
const thaiDateParts: string[] = dataThia.split(" ");
const thaiMonthAbbreviation: string = thaiDateParts[1];
const thaiMonths: { [key: string]: string } = {
"ม.ค.": "Jan",
"ก.พ.": "Feb",
"มี.ค.": "Mar",
"เม.ย.": "Apr",
"พ.ค.": "May",
"มิ.ย.": "Jun",
"ก.ค.": "Jul",
"ส.ค.": "Aug",
"ก.ย.": "Sep",
"ต.ค.": "Oct",
"พ.ย.": "Nov",
"ธ.ค.": "Dec",
};
const englishMonth: string = thaiMonths[thaiMonthAbbreviation];
if (englishMonth) {
const englishDateString: string = `${englishMonth} ${thaiDateParts[0]} ${thaiDateParts[2]}`;
const dateObject: Date = new Date(englishDateString);
return dateObject.toString();
}
}
</script>
<template>
<q-card-section>
@ -23,7 +56,14 @@ const props = defineProps({
</div>
<div class="row">
<div class="col text-grey-8">จำนวนวนทลา</div>
<div class="col">{{ props.data.leaveTotal }}</div>
<div class="col">
{{
calculateDurationYmd(
convertDateToEng(props.data.leaveDateStart),
convertDateToEng(props.data.leaveDateEnd)
)
}}
</div>
</div>
<div class="row">
<div class="col text-grey-8">นเดอนปเก</div>

View file

@ -1,10 +1,43 @@
<script setup lang="ts">
/** importStore */
import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin();
const { calculateDurationYmd } = mixin;
const props = defineProps({
data: {
type: Object,
required: true,
},
});
function convertDateToEng(dataThia: string) {
const thaiDateParts: string[] = dataThia.split(" ");
const thaiMonthAbbreviation: string = thaiDateParts[1];
const thaiMonths: { [key: string]: string } = {
"ม.ค.": "Jan",
"ก.พ.": "Feb",
"มี.ค.": "Mar",
"เม.ย.": "Apr",
"พ.ค.": "May",
"มิ.ย.": "Jun",
"ก.ค.": "Jul",
"ส.ค.": "Aug",
"ก.ย.": "Sep",
"ต.ค.": "Oct",
"พ.ย.": "Nov",
"ธ.ค.": "Dec",
};
const englishMonth: string = thaiMonths[thaiMonthAbbreviation];
if (englishMonth) {
const englishDateString: string = `${englishMonth} ${thaiDateParts[0]} ${thaiDateParts[2]}`;
const dateObject: Date = new Date(englishDateString);
return dateObject.toString();
}
}
</script>
<template>
@ -24,7 +57,14 @@ const props = defineProps({
</div>
<div class="row">
<div class="col text-grey-8">จำนวนวนทลา</div>
<div class="col">{{ props.data.leaveTotal }}</div>
<div class="col">
{{
calculateDurationYmd(
convertDateToEng(props.data.leaveDateStart),
convertDateToEng(props.data.leaveDateEnd)
)
}}
</div>
</div>
<div class="row">
<div class="col text-grey-8">นเดอนปเก</div>

View file

@ -26,7 +26,7 @@ const props = defineProps({
<div class="col">{{ props.data.leaveDetail }}</div>
</div>
<div class="row">
<div class="col text-grey-8">เอกสารแน</div>
<div class="col text-grey-8">เอกสารประกอ</div>
<div class="col" v-if="props.data.leaveDocument">
<q-btn
:href="props.data.leaveDocument"
@ -41,6 +41,22 @@ const props = defineProps({
</div>
<div class="col" v-else>-</div>
</div>
<div class="row">
<div class="col text-grey-8">เอกสารแบบฟอร</div>
<div class="col" v-if="props.data.leaveDraftDocument">
<q-btn
:href="props.data.leaveDraftDocument"
target="_blank"
outline
color="blue"
label="ดาวน์โหลด"
size="12px"
>
<q-tooltip>ดาวนโหลดไฟล</q-tooltip></q-btn
>
</div>
<div class="col" v-else>-</div>
</div>
</div>
</q-card-section>
</template>

View file

@ -51,7 +51,7 @@ interface FremData {
leaveTotal: number; //จำนวนวันที่ลา(Auto)
leavebirthDate: Date | null; //วันเดือนปีเกิด(Auto)
leavegovernmentDate: Date | null; //วันที่เข้ารับราชการ(Auto)
leaveSalary: Number; //เงินเดือนปัจจุบัน(Auto)
leaveSalary: string; //เงินเดือนปัจจุบัน(Auto)
leaveSalaryText: String; //เงินเดือนปัจจุบัน(เขียนเป็นคำอ่าน)
leaveTypeDay: string; //ประเภทการลาในวันนั้นเช่น
wifeDayName: String; //ชื่อภรรยา(ลาไปช่วยเหลือภริยาที่คลอดบุตร)

View file

@ -284,7 +284,7 @@ function formattedNumber(x: number) {
borderless
:model-value="date2Thai(education.finishDate)"
readonly
label="วันทราสำเร็จการศึกษา"
label="วันที่สำเร็จการศึกษา"
>
<template v-slot:prepend>
<q-icon class="size-icon" name="o_calendar_today" />

View file

@ -858,6 +858,67 @@ export const useCounterMixin = defineStore("mixin", () => {
}
};
/**
*
* @param startDate format MM-DD-YYYY"
* @param endDate format MM-DD-YYYY"
* @returns 1 10 5
*/
function calculateDurationYmd(startDate: any, endDate: any) {
if (startDate && endDate) {
const start = new Date(startDate);
const end = new Date(endDate);
//Get the Timestamp
const date1_time_stamp = start.getTime();
const date2_time_stamp = end.getTime();
let calc;
//Check which timestamp is greater
if (date1_time_stamp > date2_time_stamp) {
calc = new Date(date1_time_stamp - date2_time_stamp);
} else {
calc = new Date(date2_time_stamp - date1_time_stamp);
}
//retrieve the date, month and year
const calcFormatTmp =
calc.getDate() + "-" + (calc.getMonth() + 1) + "-" + calc.getFullYear();
//Convert to an array and store
const calcFormat = calcFormatTmp.split("-");
//Subtract each member of our array from the default date
const days_passed = Number(Math.abs(Number(calcFormat[0])) - 1);
const months_passed = Number(Math.abs(Number(calcFormat[1])) - 1);
const years_passed = Number(Math.abs(Number(calcFormat[2])) - 1970);
//Set up custom text
const yrsTxt = "ปี";
const mnthsTxt = "เดือน";
const daysTxt = "วัน";
//display result with custom text
const result =
(years_passed > 0 && (months_passed > 0 || days_passed > 0)
? years_passed + " " + yrsTxt + ", "
: "") +
(years_passed > 0 && months_passed == 0 && days_passed == 0
? years_passed + " " + yrsTxt + " "
: "") +
(months_passed > 0 && days_passed > 0
? months_passed + " " + mnthsTxt + ", "
: "") +
(months_passed > 0 && days_passed == 0
? months_passed + " " + mnthsTxt + " "
: "") +
(days_passed > 0 ? days_passed + " " + daysTxt : "");
return result.trim();
}
return "";
}
return {
calAge,
date2Thai,
@ -886,6 +947,7 @@ export const useCounterMixin = defineStore("mixin", () => {
typeChangeName,
statusLeave,
modalWarning,
calculateDurationYmd,
// common dialog
dialogConfirm,
dialogRemove,