diff --git a/src/modules/04_registry/components/Assessment.vue b/src/modules/04_registry/components/Assessment.vue index 83b48252b..01b003642 100644 --- a/src/modules/04_registry/components/Assessment.vue +++ b/src/modules/04_registry/components/Assessment.vue @@ -64,7 +64,19 @@
+ (""); const name = ref(); @@ -588,6 +608,23 @@ const visibleColumnsHistory = ref([ "createdAt", ]); +const inputDate = ref(""); +const dayChecked = ref(false); +watch( + () => inputDate.value, + (value: string) => { + if (value.length === 10) { + const dateVal = convertDate(value); + if (dateVal.isValid) { + dayChecked.value = false; + date.value = new Date(dateVal.value); + } else { + dayChecked.value = true; + inputDate.value = ""; + } + } + } +); watch(visibleColumns, async (count: String[], prevCount: String[]) => { await changeProfileColumns("assessment", count); }); @@ -733,6 +770,7 @@ const saveData = async () => { .then((res) => { success($q, "บันทึกข้อมูลสำเร็จ"); modal.value = false; + inputDate.value = ""; }) .catch((e) => { messageError($q, e); @@ -845,6 +883,7 @@ const selectData = async (props: DataProps) => { pointSum.value = props.row.pointSum; date.value = props.row.date; id.value = props.row.id; + inputDate.value = convertDateDisplay(props.row.date); await checkRowPage(); }; @@ -852,6 +891,7 @@ const selectData = async (props: DataProps) => { * กดปุ่มเพิ่มบน table */ const addData = () => { + inputDate.value = ""; modalEdit.value = false; modal.value = true; edit.value = true; diff --git a/src/modules/04_registry/components/Coin.vue b/src/modules/04_registry/components/Coin.vue index 4f78aa308..8c9607cd7 100644 --- a/src/modules/04_registry/components/Coin.vue +++ b/src/modules/04_registry/components/Coin.vue @@ -32,6 +32,12 @@ : col.value + 543 }}
+
+ {{ date2Thai(props.row.refCommandDate) }} +
{{ col.value }}
@@ -90,8 +96,30 @@ />
+ + @@ -134,7 +161,7 @@
+ (""); const issuer = ref(); @@ -376,7 +422,7 @@ const detail = ref(); const issueDate = ref(new Date().getFullYear()); const issueDate2 = ref(new Date()); const refCommandNo = ref(); -const refCommandDate = ref(new Date()); +const refCommandDate = ref(new Date()); const myForm = ref(); //form data input const edit = ref(false); //เช็คการกดปุ่มแก้ไขใน dialog const modal = ref(false); //modal add detail @@ -556,6 +602,55 @@ watch(visibleColumns, async (count: String[], prevCount: String[]) => { await changeProfileColumns("coined", count); }); +const inputDateRef = ref(""); +const inputYear = ref(""); +const inputDate = ref(""); +const dayCheckedRef = ref(false); +const dayChecked = ref(false); +const yearChecked = ref(false); + +watch( + () => inputDate.value, + (value: string) => { + if (value.length === 10) { + const dateVal = convertDate(value); + if (dateVal.isValid) { + dayChecked.value = false; + issueDate2.value = new Date(dateVal.value); + } else { + dayChecked.value = true; + inputDate.value = ""; + } + } + } +); + +watch( + () => inputYear.value, + (value: string) => { + if (value.length === 4) { + yearChecked.value = false; + issueDate.value = parseInt(value) - 543; + } + } +); + +watch( + () => inputDateRef.value, + (value: string) => { + if (value.length === 10) { + const dateVal = convertDate(value); + if (dateVal.isValid) { + dayCheckedRef.value = false; + refCommandDate.value = new Date(dateVal.value); + } else { + dayCheckedRef.value = true; + inputDateRef.value = ""; + } + } + } +); + onMounted(async () => { await fetchData(); }); @@ -669,6 +764,7 @@ const clickSave = async () => { if (modalEdit.value) { await editData(); } else { + if (inputDate.value === "") dayChecked.value = true; await saveData(); } } @@ -693,13 +789,14 @@ const saveData = async () => { : new Date(`${issueDate.value}-01-01`), refCommandNo: refCommandNo.value, refCommandDate: - refCommandDate.value == null - ? null - : dateToISO(refCommandDate.value as Date), + refCommandDate.value == null ? null : dateToISO(refCommandDate.value), }) .then((res) => { success($q, "บันทึกข้อมูลสำเร็จ"); modal.value = false; + inputYear.value = ""; + inputDateRef.value = ""; + inputDate.value = ""; }) .catch((e) => { messageError($q, e); @@ -727,9 +824,7 @@ const editData = async () => { : new Date(`${issueDate.value}-01-01`), refCommandNo: refCommandNo.value, refCommandDate: - refCommandDate.value == null - ? null - : dateToISO(refCommandDate.value as Date), + refCommandDate.value == null ? null : dateToISO(refCommandDate.value), }) .then((res) => { success($q, "บันทึกข้อมูลสำเร็จ"); @@ -816,6 +911,11 @@ const selectData = async (props: DataProps) => { refCommandDate.value = props.row.refCommandDate == "-" ? null : props.row.refCommandDate; id.value = props.row.id; + inputYear.value = props.row.issueDate + 543; + inputDate.value = convertDateDisplay(props.row.issueDate2); + inputDateRef.value = convertDateDisplay(props.row.refCommandDate); + console.log(refCommandDate.value); + await checkRowPage(); }; @@ -824,6 +924,9 @@ const selectData = async (props: DataProps) => { */ const addData = () => { modalEdit.value = false; + inputDate.value = ""; + inputYear.value = ""; + inputDateRef.value = ""; modal.value = true; edit.value = true; issuer.value = ""; diff --git a/src/modules/04_registry/components/Discipline.vue b/src/modules/04_registry/components/Discipline.vue index 657ec504b..5efecb683 100644 --- a/src/modules/04_registry/components/Discipline.vue +++ b/src/modules/04_registry/components/Discipline.vue @@ -60,7 +60,19 @@
+
+ (""); const level = ref(); @@ -372,7 +401,7 @@ const OpsFilter = ref({ const detail = ref(); const unStigma = ref(); const refCommandNo = ref(); -const refCommandDate = ref(new Date()); +const refCommandDate = ref(null); const date = ref(new Date()); const myForm = ref(); //form data input const edit = ref(false); //เช็คการกดปุ่มแก้ไขใน dialog @@ -573,8 +602,54 @@ const visibleColumnsHistory = ref([ "createdAt", ]); +const inputDate = ref(""); +const dayChecked = ref(false); + +const inputRefCommandDate = ref(""); +const dayCheckedRef = ref(false); + +watch( + () => inputRefCommandDate.value, + (value: string) => { + console.log(value); + if (value.length === 10) { + const dateVal = convertDate(value); + + if (dateVal.isValid) { + dayCheckedRef.value = false; + if (!!dateVal.value) { + refCommandDate.value = new Date(dateVal.value); + } else { + refCommandDate.value = null; + } + } else { + dayCheckedRef.value = true; + inputRefCommandDate.value = ""; + } + } else { + refCommandDate.value = null; + } + } +); + +watch( + () => inputDate.value, + (value: string) => { + if (value.length === 10) { + const dateVal = convertDate(value); + if (dateVal.isValid) { + dayChecked.value = false; + date.value = new Date(dateVal.value); + } else { + dayChecked.value = true; + inputDate.value = ""; + } + } + } +); + watch(visibleColumns, async (count: String[], prevCount: String[]) => { - await changeProfileColumns("discipline", count); + changeProfileColumns("discipline", count); }); onMounted(async () => { @@ -727,6 +802,8 @@ const saveData = async () => { }) .then((res) => { success($q, "บันทึกข้อมูลสำเร็จ"); + inputDate.value = ""; + inputRefCommandDate.value = ""; modal.value = false; }) .catch((e) => { @@ -837,13 +914,19 @@ const selectData = async (props: DataProps) => { refCommandDate.value = props.row.refCommandDate; date.value = props.row.date; id.value = props.row.id; - await checkRowPage(); + inputDate.value = convertDateDisplay(props.row.date); + inputRefCommandDate.value = props.row.refCommandDate + ? convertDateDisplay(props.row.refCommandDate) + : ""; + checkRowPage(); }; /** * กดปุ่มเพิ่มบน table */ const addData = () => { + inputDate.value = ""; + inputRefCommandDate.value = ""; modalEdit.value = false; modal.value = true; edit.value = true; diff --git a/src/modules/04_registry/components/Salary.vue b/src/modules/04_registry/components/Salary.vue index 879654e69..5aee28128 100644 --- a/src/modules/04_registry/components/Salary.vue +++ b/src/modules/04_registry/components/Salary.vue @@ -116,7 +116,21 @@
+ (""); @@ -1220,7 +1236,23 @@ const visibleColumnsHistory = ref([ "createdFullName", "createdAt", ]); - +const inputDate = ref(""); +const dayChecked = ref(false); +watch( + () => inputDate.value, + (value: string) => { + if (value.length === 10) { + const dateVal = convertDate(value); + if (dateVal.isValid) { + dayChecked.value = false; + formDataSalary.date = new Date(dateVal.value); + } else { + dayChecked.value = true; + inputDate.value = ""; + } + } + } +); /****************************************** FormDataNew **********************************************/ const formDataSalary = reactive({ date: new Date(), @@ -1674,7 +1706,7 @@ const selectData = async (props: DataProps) => { rawItem.value = props.row; rowIndex.value = props.rowIndex; id.value = props.row.id; - + inputDate.value = formDataSalary.date; // console.log(props.row); // date.value = props.row.date; @@ -1698,7 +1730,7 @@ const selectData = async (props: DataProps) => { // orgName.value = props.row.orgName; // agencyName.value = props.row.agencyName; // cLevel.value = props.row.cLevel; - + inputDate.value = convertDateDisplay(props.row.date); formDataSalary.date = props.row.date; formDataSalary.posNo = props.row.posNo ?? "-"; formDataSalary.templatePos = "";