ปลด validate วันที่มีผล ถ้าไม่มีค่า เเสดง ว่าง

This commit is contained in:
setthawutttty 2024-03-06 15:01:14 +07:00
parent e9fd48f7f3
commit 36d1473c11
3 changed files with 14 additions and 66 deletions

View file

@ -19,7 +19,7 @@ import Header from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
const isReadonly = ref<boolean>(false) const isReadonly = ref<boolean>(false);
const $q = useQuasar(); const $q = useQuasar();
const { const {
date2Thai, date2Thai,
@ -64,17 +64,11 @@ const formData = reactive<FormData>({
const salaryTypeRef = ref<Object | null>(null); const salaryTypeRef = ref<Object | null>(null);
const posTypeRef = ref<Object | null>(null); const posTypeRef = ref<Object | null>(null);
const posLevelRef = ref<Object | null>(null); const posLevelRef = ref<Object | null>(null);
const dateRef = ref<any>(null);
const startDateRef = ref<any>();
const endDateRef = ref<any>();
const ObjectRef: ObjectSalaryRef = { const ObjectRef: ObjectSalaryRef = {
salaryType: salaryTypeRef, salaryType: salaryTypeRef,
posTypId: posTypeRef, posTypId: posTypeRef,
posLevelId: posLevelRef, posLevelId: posLevelRef,
date: dateRef,
startDate: startDateRef,
endDate: endDateRef,
}; };
const salaryTypeOption = ref<DataOption[]>([ const salaryTypeOption = ref<DataOption[]>([
@ -145,7 +139,7 @@ async function fetchSalaryDetail(id: string) {
formData.endDate = data.endDate; formData.endDate = data.endDate;
formData.details = data.details; formData.details = data.details;
formData.isSpecial = data.isSpecial; formData.isSpecial = data.isSpecial;
isReadonly.value = data.isActive isReadonly.value = data.isActive;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -208,7 +202,7 @@ function clearFormData() {
formData.details = ""; formData.details = "";
documentFile.value = null; documentFile.value = null;
itemsDocument.value = []; itemsDocument.value = [];
isReadonly.value = false isReadonly.value = false;
} }
function onClickSubmit() { function onClickSubmit() {
@ -256,37 +250,10 @@ function checkEndDate() {
} }
} }
// watch(
// () => formData.date,
// () => {
// if (formData.date) {
// dateRef.value.resetValidation();
// }
// }
// );
// watch(
// () => formData.startDate,
// () => {
// if (formData.startDate) {
// startDateRef.value.resetValidation();
// }
// }
// );
// watch(
// () => formData.endDate,
// () => {
// if (formData.endDate) {
// endDateRef.value.resetValidation();
// }
// }
// );
</script> </script>
<template> <template>
<q-dialog v-model="modal" persistent> <q-dialog v-model="modal" persistent>
<q-card class="col-12" style="width: 80%"> <q-card class="col-12" style="width: 80%">
<form @submit.prevent.stop="onClickSubmit"> <form @submit.prevent.stop="onClickSubmit">
<Header :tittle="title" :close="closeDialog" /> <Header :tittle="title" :close="closeDialog" />
@ -396,7 +363,6 @@ function checkEndDate() {
<template #trigger> <template #trigger>
<q-input <q-input
:readonly="isReadonly" :readonly="isReadonly"
ref="dateRef"
outlined outlined
dense dense
hide-bottom-space hide-bottom-space
@ -406,10 +372,6 @@ function checkEndDate() {
: null : null
" "
label="ให้ไว้ ณ วันที่" label="ให้ไว้ ณ วันที่"
:rules="[
(val) =>
!!val || `${'กรุณาเลือกวันที่ ให้ไว ณ วันที่'}`,
]"
> >
<template v-slot:prepend> <template v-slot:prepend>
<q-icon <q-icon
@ -445,7 +407,6 @@ function checkEndDate() {
<template #trigger> <template #trigger>
<q-input <q-input
:readonly="isReadonly" :readonly="isReadonly"
ref="startDateRef"
outlined outlined
dense dense
hide-bottom-space hide-bottom-space
@ -455,10 +416,6 @@ function checkEndDate() {
: null : null
" "
label="วันที่มีผลบังคับใช้" label="วันที่มีผลบังคับใช้"
:rules="[
(val) =>
!!val || `${'กรุณาเลือกวันที่มีผลบังคับใช้'}`,
]"
> >
<template v-slot:prepend> <template v-slot:prepend>
<q-icon <q-icon
@ -494,20 +451,14 @@ function checkEndDate() {
<template #trigger> <template #trigger>
<q-input <q-input
:readonly="isReadonly" :readonly="isReadonly"
ref="endDateRef"
outlined outlined
dense dense
hide-bottom-space
:model-value=" :model-value="
formData.endDate != null formData.endDate != null
? date2Thai(formData.endDate) ? date2Thai(formData.endDate)
: null : null
" "
label="วันที่สิ้นสุดบังคับใช้" label="วันที่สิ้นสุดบังคับใช้"
:rules="[
(val) =>
!!val || `${'กรุณาเลือกวันที่สิ้นสุดบังคับใช้'}`,
]"
> >
<template v-slot:prepend> <template v-slot:prepend>
<q-icon <q-icon

View file

@ -26,9 +26,6 @@ interface ObjectSalaryRef {
salaryType: object | null; salaryType: object | null;
posTypId: object | null; posTypId: object | null;
posLevelId: object | null; posLevelId: object | null;
date: object | null;
startDate: object | null;
endDate: object | null;
[key: string]: any; [key: string]: any;
} }

View file

@ -313,7 +313,7 @@ async function filterFn(page: number) {
}} }}
</div> </div>
<div v-else-if="col.name === 'startDate'"> <div v-else-if="col.name === 'startDate'">
{{ col.value ? date2Thai(col.value) : "-" }} {{ col.value ? date2Thai(col.value) : "" }}
</div> </div>
<div v-else-if="col.name === 'posLevel'"> <div v-else-if="col.name === 'posLevel'">
{{ props.row.isSpecial ? `${col.value} (ฉ)` : `${col.value}` }} {{ props.row.isSpecial ? `${col.value} (ฉ)` : `${col.value}` }}