Merge branch 'develop' into devTee
This commit is contained in:
commit
d2eca5cbe1
11 changed files with 266 additions and 84 deletions
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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; //ชื่อภรรยา(ลาไปช่วยเหลือภริยาที่คลอดบุตร)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,30 @@ onMounted(async () => {
|
|||
hideLoader();
|
||||
}
|
||||
});
|
||||
|
||||
// เช็คว่าต้องมีแนบท้ายไหม code ที่เพิ่มคืออันที่ไม่มีแนบท้าย
|
||||
const attachmentStatus = computed(() => {
|
||||
return code.value != "c-pm-10" &&
|
||||
code.value != "c-pm-11" &&
|
||||
code.value != "c-pm-12" &&
|
||||
code.value != "c-pm-16" &&
|
||||
code.value != "c-pm-18" &&
|
||||
code.value != "c-pm-19" &&
|
||||
code.value != "c-pm-20" &&
|
||||
code.value != "c-pm-21" &&
|
||||
code.value != "c-pm-23" &&
|
||||
code.value != "c-pm-25" &&
|
||||
code.value != "c-pm-26" &&
|
||||
code.value != "c-pm-27" &&
|
||||
code.value != "c-pm-28" &&
|
||||
code.value != "c-pm-29" &&
|
||||
code.value != "c-pm-30" &&
|
||||
code.value != "c-pm-31" &&
|
||||
code.value != "c-pm-32"
|
||||
? true
|
||||
: false;
|
||||
});
|
||||
|
||||
// เรียกข้อมูลคำสั่ง
|
||||
const getCommandDetail = async () => {
|
||||
await http
|
||||
|
|
@ -68,17 +92,7 @@ const getCommandDetail = async () => {
|
|||
|
||||
fetchReportCover("pdf", orderId.value);
|
||||
|
||||
if (
|
||||
code.value != "c-pm-10" &&
|
||||
code.value != "c-pm-11" &&
|
||||
code.value != "c-pm-12" &&
|
||||
code.value != "c-pm-16" &&
|
||||
code.value != "c-pm-18" &&
|
||||
code.value != "c-pm-19" &&
|
||||
code.value != "c-pm-20" &&
|
||||
code.value != "c-pm-21" &&
|
||||
code.value != "c-pm-23"
|
||||
) {
|
||||
if (attachmentStatus.value) {
|
||||
fetchReportAttachment("pdf", orderId.value);
|
||||
}
|
||||
})
|
||||
|
|
@ -265,17 +279,7 @@ const saveUpload = () => {
|
|||
dialogConfirm($q, async () => {
|
||||
showLoader();
|
||||
await postfileOrder();
|
||||
if (
|
||||
code.value != "c-pm-10" &&
|
||||
code.value != "c-pm-11" &&
|
||||
code.value != "c-pm-12" &&
|
||||
code.value != "c-pm-16" &&
|
||||
code.value != "c-pm-18" &&
|
||||
code.value != "c-pm-19" &&
|
||||
code.value != "c-pm-20" &&
|
||||
code.value != "c-pm-21" &&
|
||||
code.value != "c-pm-23"
|
||||
) {
|
||||
if (attachmentStatus.value) {
|
||||
await postfileTailer();
|
||||
}
|
||||
await fetchAttachment(orderId.value);
|
||||
|
|
@ -300,17 +304,7 @@ const saveDetail = () => {
|
|||
await fetchReportCover("pdf", orderId.value); // ดึงรายงานคำสั่งใหม่
|
||||
|
||||
// เช็คประเภทคำสั่งถ้าไม่ใช่ type เหล่านี้จะมีแนบท้าย
|
||||
if (
|
||||
code.value != "c-pm-10" &&
|
||||
code.value != "c-pm-11" &&
|
||||
code.value != "c-pm-12" &&
|
||||
code.value != "c-pm-16" &&
|
||||
code.value != "c-pm-18" &&
|
||||
code.value != "c-pm-19" &&
|
||||
code.value != "c-pm-20" &&
|
||||
code.value != "c-pm-21" &&
|
||||
code.value != "c-pm-23"
|
||||
) {
|
||||
if (attachmentStatus.value) {
|
||||
// ดึงรายงานในส่วนของแนบท้ายมาใหม่
|
||||
await fetchReportAttachment("pdf", orderId.value);
|
||||
|
||||
|
|
@ -399,15 +393,7 @@ const clickExecute = async (id: string) => {
|
|||
};
|
||||
const validateFormUpload = () => {
|
||||
if (
|
||||
code.value != "c-pm-10" &&
|
||||
code.value != "c-pm-11" &&
|
||||
code.value != "c-pm-12" &&
|
||||
code.value != "c-pm-16" &&
|
||||
code.value != "c-pm-18" &&
|
||||
code.value != "c-pm-19" &&
|
||||
code.value != "c-pm-20" &&
|
||||
code.value != "c-pm-21" &&
|
||||
code.value != "c-pm-23" &&
|
||||
attachmentStatus.value &&
|
||||
fileOrder.value !== null &&
|
||||
fileTailer.value !== null
|
||||
) {
|
||||
|
|
@ -499,17 +485,7 @@ const viewFileUpload = async (url: string) => {
|
|||
</q-btn>
|
||||
</div>
|
||||
<div
|
||||
v-if="
|
||||
code != 'c-pm-10' &&
|
||||
code != 'c-pm-11' &&
|
||||
code != 'c-pm-12' &&
|
||||
code != 'c-pm-16' &&
|
||||
code != 'c-pm-18' &&
|
||||
code != 'c-pm-19' &&
|
||||
code != 'c-pm-20' &&
|
||||
code != 'c-pm-21' &&
|
||||
code != 'c-pm-23'
|
||||
"
|
||||
v-if="attachmentStatus"
|
||||
@click="setTab('second')"
|
||||
:class="getClass(tab == 'second')"
|
||||
>
|
||||
|
|
@ -678,19 +654,7 @@ const viewFileUpload = async (url: string) => {
|
|||
</template>
|
||||
</q-file>
|
||||
</div>
|
||||
<div
|
||||
v-if="
|
||||
code != 'c-pm-10' &&
|
||||
code != 'c-pm-11' &&
|
||||
code != 'c-pm-12' &&
|
||||
code != 'c-pm-16' &&
|
||||
code != 'c-pm-18' &&
|
||||
code != 'c-pm-19' &&
|
||||
code != 'c-pm-20' &&
|
||||
code != 'c-pm-21' &&
|
||||
code != 'c-pm-23'
|
||||
"
|
||||
>
|
||||
<div v-if="attachmentStatus">
|
||||
<label class="text-file">เอกสารแนบท้าย</label>
|
||||
<div v-if="TailerPDFUpload != ''" class="text-right">
|
||||
<q-btn
|
||||
|
|
|
|||
|
|
@ -129,9 +129,7 @@ const formData = reactive<any>({
|
|||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label
|
||||
>มีระยะเวลาขั้นต่ำในการดำรงตำแหน่งหรือเคย
|
||||
ดำรงตำแหน่งในสายงานที่จะคัดเลือก
|
||||
ตามคุณวุฒิของบุคคลและระดับตำแหน่งที่จะคัดเลือก</q-item-label
|
||||
>มีระยะเวลาขั้นต่ำในการดำรงตำแหน่งหรือเคยดำรงตำแหน่งในสายงานที่จะคัดเลือกตามคุณวุฒิของบุคคลและระดับตำแหน่งที่จะคัดเลือก</q-item-label
|
||||
>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
|
|
|
|||
|
|
@ -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" />
|
||||
|
|
@ -410,7 +410,7 @@ function formattedNumber(x: number) {
|
|||
|
||||
<q-card bordered style="border: 1px solid #d6dee1">
|
||||
<div class="text-weight-bold row items-center bg-grey-2">
|
||||
<span class="q-ml-lg q-my-sm">ผลงานทีเคยเสนอขอประเมิน (ถ้ามี)</span>
|
||||
<span class="q-ml-lg q-my-sm">ผลงานที่เคยเสนอขอประเมิน (ถ้ามี)</span>
|
||||
</div>
|
||||
<q-separator />
|
||||
<div class="row q-pa-sm">
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue