ตรวจสอบ กรอกเวลาไม่ครบ 10 หลัก
This commit is contained in:
parent
bdeda2d089
commit
75d871fc64
5 changed files with 56 additions and 9 deletions
|
|
@ -380,6 +380,7 @@ import { onMounted, ref, watch } from "vue";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useProfileDataStore } from "@/modules/04_registry/store";
|
import { useProfileDataStore } from "@/modules/04_registry/store";
|
||||||
|
import { validateTime } from "@/modules/04_registry/stores/time";
|
||||||
|
|
||||||
import ProfileTable from "@/modules/04_registry/components/Table.vue";
|
import ProfileTable from "@/modules/04_registry/components/Table.vue";
|
||||||
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
|
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
|
||||||
|
|
@ -770,10 +771,10 @@ const clickAdd = async () => {
|
||||||
* กดบันทึกใน dialog
|
* กดบันทึกใน dialog
|
||||||
*/
|
*/
|
||||||
const clickSave = async () => {
|
const clickSave = async () => {
|
||||||
if (inputDateRef.value.length != 0 && inputDateRef.value.length != 10) {
|
dayChecked.value = validateTime(inputDate.value);
|
||||||
dayCheckedRef.value = true;
|
dayCheckedRef.value = validateTime(inputDateRef.value);
|
||||||
return "";
|
if (dayCheckedRef.value || dayChecked.value) return;
|
||||||
}
|
|
||||||
myForm.value.validate().then(async (result: boolean) => {
|
myForm.value.validate().then(async (result: boolean) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
if (modalEdit.value) {
|
if (modalEdit.value) {
|
||||||
|
|
@ -904,6 +905,8 @@ const clickClose = async () => {
|
||||||
modal.value = false;
|
modal.value = false;
|
||||||
next.value = false;
|
next.value = false;
|
||||||
previous.value = false;
|
previous.value = false;
|
||||||
|
dayChecked.value = false;
|
||||||
|
dayCheckedRef.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@
|
||||||
mask="##/##/####"
|
mask="##/##/####"
|
||||||
dense
|
dense
|
||||||
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่'}`]"
|
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่'}`]"
|
||||||
|
:error="dayChecked"
|
||||||
|
error-message="กรุณากรอกวันที่"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<datepicker
|
<datepicker
|
||||||
|
|
@ -178,7 +180,7 @@ import { onMounted, ref, watch } from "vue";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import { useProfileDataStore } from "@/modules/04_registry/store";
|
import { useProfileDataStore } from "@/modules/04_registry/store";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { validateTime } from "@/modules/04_registry/stores/time";
|
||||||
import ProfileTable from "@/modules/04_registry/components/Table.vue";
|
import ProfileTable from "@/modules/04_registry/components/Table.vue";
|
||||||
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
|
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
|
||||||
import DialogFooter from "@/modules/04_registry/components/DialogFooter.vue";
|
import DialogFooter from "@/modules/04_registry/components/DialogFooter.vue";
|
||||||
|
|
@ -436,6 +438,9 @@ const clickAdd = async () => {
|
||||||
* กดบันทึกใน dialog
|
* กดบันทึกใน dialog
|
||||||
*/
|
*/
|
||||||
const clickSave = async () => {
|
const clickSave = async () => {
|
||||||
|
dayChecked.value = validateTime(inputDate.value);
|
||||||
|
if (dayChecked.value) return;
|
||||||
|
|
||||||
myForm.value.validate().then(async (result: boolean) => {
|
myForm.value.validate().then(async (result: boolean) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
if (modalEdit.value) {
|
if (modalEdit.value) {
|
||||||
|
|
@ -546,6 +551,7 @@ const clickClose = async () => {
|
||||||
modal.value = false;
|
modal.value = false;
|
||||||
next.value = false;
|
next.value = false;
|
||||||
previous.value = false;
|
previous.value = false;
|
||||||
|
dayChecked.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,8 @@
|
||||||
mask="##/##/####"
|
mask="##/##/####"
|
||||||
dense
|
dense
|
||||||
:rules="[(val) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี'}`]"
|
:rules="[(val) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี'}`]"
|
||||||
|
:error="dayChecked"
|
||||||
|
error-message="กรุณากรอก วัน/เดือน/ปี"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<datepicker
|
<datepicker
|
||||||
|
|
@ -181,6 +183,8 @@
|
||||||
:label="`${'เอกสารอ้างอิง (ลงวันที่)'}`"
|
:label="`${'เอกสารอ้างอิง (ลงวันที่)'}`"
|
||||||
mask="##/##/####"
|
mask="##/##/####"
|
||||||
dense
|
dense
|
||||||
|
:error="dayCheckedRefCommandDate"
|
||||||
|
error-message="กรุณากรอกเอกสารอ้างอิง (ลงวันที่) หรือเว้นว่าง"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<datepicker
|
<datepicker
|
||||||
|
|
@ -290,7 +294,7 @@ import { onMounted, ref, watch } from "vue";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import { useProfileDataStore } from "@/modules/04_registry/store";
|
import { useProfileDataStore } from "@/modules/04_registry/store";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { validateTime } from "@/modules/04_registry/stores/time";
|
||||||
import ProfileTable from "@/modules/04_registry/components/Table.vue";
|
import ProfileTable from "@/modules/04_registry/components/Table.vue";
|
||||||
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
|
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
|
||||||
import DialogFooter from "@/modules/04_registry/components/DialogFooter.vue";
|
import DialogFooter from "@/modules/04_registry/components/DialogFooter.vue";
|
||||||
|
|
@ -385,13 +389,14 @@ watch(
|
||||||
if (value.length === 10) {
|
if (value.length === 10) {
|
||||||
const dateVal = convertDate(value);
|
const dateVal = convertDate(value);
|
||||||
if (dateVal.isValid) {
|
if (dateVal.isValid) {
|
||||||
dayChecked.value = false;
|
dayCheckedRefCommandDate.value = false;
|
||||||
refCommandDate.value = new Date(dateVal.value);
|
refCommandDate.value = new Date(dateVal.value);
|
||||||
} else {
|
} else {
|
||||||
dayChecked.value = true;
|
dayCheckedRefCommandDate.value = true;
|
||||||
inputDateRefCommandDate.value = "";
|
inputDateRefCommandDate.value = "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
dayCheckedRefCommandDate.value = false;
|
||||||
refCommandDate.value = null;
|
refCommandDate.value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -660,6 +665,14 @@ const clickAdd = async () => {
|
||||||
* กดบันทึกใน dialog
|
* กดบันทึกใน dialog
|
||||||
*/
|
*/
|
||||||
const clickSave = async () => {
|
const clickSave = async () => {
|
||||||
|
dayChecked.value = validateTime(inputDate.value);
|
||||||
|
dayCheckedRefCommandDate.value = validateTime(inputDateRefCommandDate.value);
|
||||||
|
console.log(dayChecked.value);
|
||||||
|
|
||||||
|
console.log(dayCheckedRefCommandDate.value);
|
||||||
|
|
||||||
|
if (dayChecked.value || dayCheckedRefCommandDate.value) return;
|
||||||
|
|
||||||
myForm.value.validate().then(async (result: boolean) => {
|
myForm.value.validate().then(async (result: boolean) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
if (modalEdit.value) {
|
if (modalEdit.value) {
|
||||||
|
|
@ -782,6 +795,8 @@ const clickClose = async () => {
|
||||||
modal.value = false;
|
modal.value = false;
|
||||||
next.value = false;
|
next.value = false;
|
||||||
previous.value = false;
|
previous.value = false;
|
||||||
|
dayChecked.value = false;
|
||||||
|
dayCheckedRefCommandDate.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,8 @@
|
||||||
:label="`${'เอกสารอ้างอิง (ลงวันที่)'}`"
|
:label="`${'เอกสารอ้างอิง (ลงวันที่)'}`"
|
||||||
mask="##/##/####"
|
mask="##/##/####"
|
||||||
dense
|
dense
|
||||||
|
:error="dayCheckedRefCommandDate"
|
||||||
|
error-message="กรุณากรอกเอกสารอ้างอิง (ลงวันที่) หรือเว้นว่าง"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<datepicker
|
<datepicker
|
||||||
|
|
@ -350,7 +352,7 @@ import { useRoute } from "vue-router";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { useProfileDataStore } from "@/modules/04_registry/store";
|
import { useProfileDataStore } from "@/modules/04_registry/store";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { validateTime } from "@/modules/04_registry/stores/time";
|
||||||
import ProfileTable from "@/modules/04_registry/components/Table.vue";
|
import ProfileTable from "@/modules/04_registry/components/Table.vue";
|
||||||
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
|
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
|
||||||
import DialogFooter from "@/modules/04_registry/components/DialogFooter.vue";
|
import DialogFooter from "@/modules/04_registry/components/DialogFooter.vue";
|
||||||
|
|
@ -424,6 +426,7 @@ const inputRefCommandDate = ref<string>("");
|
||||||
|
|
||||||
const dayCheckedStart = ref<boolean>(false);
|
const dayCheckedStart = ref<boolean>(false);
|
||||||
const dayCheckedEnd = ref<boolean>(false);
|
const dayCheckedEnd = ref<boolean>(false);
|
||||||
|
const dayCheckedRefCommandDate = ref<boolean>(false);
|
||||||
/** ตรวจเวลา */
|
/** ตรวจเวลา */
|
||||||
watch(
|
watch(
|
||||||
() => inputDateStart.value,
|
() => inputDateStart.value,
|
||||||
|
|
@ -446,11 +449,14 @@ watch(
|
||||||
if (value.length === 10) {
|
if (value.length === 10) {
|
||||||
const dateVal = convertDate(value);
|
const dateVal = convertDate(value);
|
||||||
if (dateVal.isValid) {
|
if (dateVal.isValid) {
|
||||||
|
dayCheckedRefCommandDate.value = false;
|
||||||
refCommandDate.value = new Date(dateVal.value);
|
refCommandDate.value = new Date(dateVal.value);
|
||||||
} else {
|
} else {
|
||||||
|
dayCheckedRefCommandDate.value = true;
|
||||||
inputRefCommandDate.value = "";
|
inputRefCommandDate.value = "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
dayCheckedRefCommandDate.value = false;
|
||||||
refCommandDate.value = null;
|
refCommandDate.value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -765,6 +771,16 @@ const clickAdd = async () => {
|
||||||
* กดบันทึกใน dialog
|
* กดบันทึกใน dialog
|
||||||
*/
|
*/
|
||||||
const clickSave = async () => {
|
const clickSave = async () => {
|
||||||
|
dayCheckedStart.value = validateTime(inputDateStart.value);
|
||||||
|
dayCheckedEnd.value = validateTime(inputDateEnd.value);
|
||||||
|
dayCheckedRefCommandDate.value = validateTime(inputRefCommandDate.value);
|
||||||
|
|
||||||
|
if (
|
||||||
|
dayCheckedStart.value ||
|
||||||
|
dayCheckedEnd.value ||
|
||||||
|
dayCheckedRefCommandDate.value
|
||||||
|
)
|
||||||
|
return;
|
||||||
myForm.value.validate().then(async (result: boolean) => {
|
myForm.value.validate().then(async (result: boolean) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
if (modalEdit.value) {
|
if (modalEdit.value) {
|
||||||
|
|
@ -889,6 +905,9 @@ const clickClose = async () => {
|
||||||
modal.value = false;
|
modal.value = false;
|
||||||
next.value = false;
|
next.value = false;
|
||||||
previous.value = false;
|
previous.value = false;
|
||||||
|
dayCheckedStart.value = false;
|
||||||
|
dayCheckedEnd.value = false;
|
||||||
|
dayCheckedRefCommandDate.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
4
src/modules/04_registry/stores/time.ts
Normal file
4
src/modules/04_registry/stores/time.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
export function validateTime(input: string) {
|
||||||
|
if (input.length != 0 && input.length != 10) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue