รีเซ็ต date

This commit is contained in:
setthawutttty 2024-02-14 11:51:00 +07:00
parent 9814c9f01a
commit 92aaccc791
3 changed files with 43 additions and 15 deletions

View file

@ -1755,7 +1755,11 @@ watch(
(value: string) => { (value: string) => {
if (value.length === 10) { if (value.length === 10) {
const dateVal = convertDate(value); const dateVal = convertDate(value);
finishDate.value = dateVal.value; if (dateVal.isValid) {
finishDate.value = dateVal.value;
} else {
finishDateInput.value = "";
}
} }
} }

View file

@ -1457,9 +1457,13 @@ watch(
() => dateAnnounceInput.value, () => dateAnnounceInput.value,
(value: string) => { (value: string) => {
if (value.length === 10) { if (value.length === 10) {
const dateVal = convertDate(value); const dateVal = convertDate(value);
dateAnnounce.value = dateVal.value; if (dateVal.isValid) {
console.log(dateAnnounce.value); dateAnnounce.value = dateVal.value;
} else {
dateAnnounceInput.value = "";
}
} }
} }
); );
@ -1468,7 +1472,11 @@ watch(
(value: string) => { (value: string) => {
if (value.length === 10) { if (value.length === 10) {
const dateVal = convertDate(value); const dateVal = convertDate(value);
refCommandDate.value = dateVal.value; if (dateVal.isValid) {
refCommandDate.value = dateVal.value;
} else {
refCommandDateInput.value = "";
}
} }
} }
); );

View file

@ -389,7 +389,7 @@
dense dense
/> />
<datepicker <datepicker
v-else v-else
menu-class-name="modalfix" menu-class-name="modalfix"
v-model="yearly" v-model="yearly"
:locale="'th'" :locale="'th'"
@ -505,7 +505,7 @@
dense dense
/> />
<datepicker <datepicker
v-else v-else
menu-class-name="modalfix" menu-class-name="modalfix"
v-model="dateOrder" v-model="dateOrder"
:locale="'th'" :locale="'th'"
@ -657,8 +657,16 @@ const store = useProfileDataStore();
const { profileData, changeProfileColumns } = store; const { profileData, changeProfileColumns } = store;
const isDate = ref<string | null>("true"); const isDate = ref<string | null>("true");
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { date2Thai, success, dateToISO, messageError, showLoader, hideLoader,convertDate,convertDateDisplay } = const {
mixin; date2Thai,
success,
dateToISO,
messageError,
showLoader,
hideLoader,
convertDate,
convertDateDisplay,
} = mixin;
const route = useRoute(); const route = useRoute();
const id = ref<string>(""); const id = ref<string>("");
const name = ref<string>(); const name = ref<string>();
@ -668,7 +676,7 @@ const place = ref<string>();
const duration = ref<string>(); const duration = ref<string>();
const department = ref<string>(); const department = ref<string>();
const numberOrder = ref<string>(); const numberOrder = ref<string>();
const dateOrder = ref<Date | null|string>(new Date()); const dateOrder = ref<Date | null | string>(new Date());
const startDate = ref<Date | string | number>(new Date().getFullYear()); const startDate = ref<Date | string | number>(new Date().getFullYear());
const startDate2 = ref<Date | string | null>(new Date()); const startDate2 = ref<Date | string | null>(new Date());
const endDate = ref<Date | string | number>(new Date().getFullYear()); const endDate = ref<Date | string | number>(new Date().getFullYear());
@ -1064,7 +1072,7 @@ const getData = () => {
yearlyInput.value = (Number(row.yearly) + 543).toLocaleString(); yearlyInput.value = (Number(row.yearly) + 543).toLocaleString();
inputStartDate2.value = convertDateDisplay(row.startDate2); inputStartDate2.value = convertDateDisplay(row.startDate2);
inputEndDate2.value = convertDateDisplay(row.endDate2); inputEndDate2.value = convertDateDisplay(row.endDate2);
dateOrderInput.value = row.dateOrder ? convertDateDisplay(row.dateOrder):''; dateOrderInput.value = row.dateOrder ? convertDateDisplay(row.dateOrder) : "";
}; };
/** /**
@ -1102,7 +1110,7 @@ const clickAdd = async () => {
/** /**
* กดบนทกใน dialog * กดบนทกใน dialog
*/ */
const clickSave = async () => { const clickSave = async () => {
myForm.value.validate().then(async (result: boolean) => { myForm.value.validate().then(async (result: boolean) => {
if (result) { if (result) {
if (isDate.value == "false") { if (isDate.value == "false") {
@ -1283,7 +1291,7 @@ const selectData = async (props: DataProps) => {
name.value = props.row.name; name.value = props.row.name;
topic.value = props.row.topic; topic.value = props.row.topic;
yearly.value = props.row.yearly; yearly.value = props.row.yearly;
console.log(typeof yearly.value) console.log(typeof yearly.value);
place.value = props.row.place; place.value = props.row.place;
duration.value = props.row.duration; duration.value = props.row.duration;
department.value = props.row.department; department.value = props.row.department;
@ -1296,10 +1304,15 @@ const selectData = async (props: DataProps) => {
endDate2.value = props.row.endDate2; endDate2.value = props.row.endDate2;
inputStartDate.value = (Number(props.row.startDate) + 543).toLocaleString(); inputStartDate.value = (Number(props.row.startDate) + 543).toLocaleString();
inputEndDate.value = (Number(props.row.endDate) + 543).toLocaleString(); inputEndDate.value = (Number(props.row.endDate) + 543).toLocaleString();
yearlyInput.value = props.row.yearly !== 0 ? (Number(props.row.yearly) + 543).toLocaleString():''; yearlyInput.value =
props.row.yearly !== 0
? (Number(props.row.yearly) + 543).toLocaleString()
: "";
inputStartDate2.value = convertDateDisplay(props.row.startDate2); inputStartDate2.value = convertDateDisplay(props.row.startDate2);
inputEndDate2.value = convertDateDisplay(props.row.endDate2); inputEndDate2.value = convertDateDisplay(props.row.endDate2);
dateOrderInput.value = props.row.dateOrder ? convertDateDisplay(props.row.dateOrder):''; dateOrderInput.value = props.row.dateOrder
? convertDateDisplay(props.row.dateOrder)
: "";
id.value = props.row.id; id.value = props.row.id;
await checkRowPage(); await checkRowPage();
}; };
@ -1461,8 +1474,11 @@ watch(
(value: string) => { (value: string) => {
if (value.length === 10) { if (value.length === 10) {
const dateVal = convertDate(value); const dateVal = convertDate(value);
if (dateVal.isValid) {
dateOrder.value = dateVal.value; dateOrder.value = dateVal.value;
} else {
dateOrderInput.value = "";
}
} }
} }
); );