From 31bae5775093e7b7c527c0f8723e00819ac5a008 Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Thu, 15 Feb 2024 10:54:00 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A8=E0=B8=B6?= =?UTF-8?q?=E0=B8=81=E0=B8=A9=E0=B8=B2=20=E0=B8=81=E0=B8=A3=E0=B8=AD?= =?UTF-8?q?=E0=B8=81=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B8=84=E0=B8=A3=E0=B8=9A?= =?UTF-8?q?=20=E0=B8=AA=E0=B9=88=E0=B8=87null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_registry/components/Education.vue | 55 +++++++++++-------- .../interface/request/Education.ts | 8 +-- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/modules/04_registry/components/Education.vue b/src/modules/04_registry/components/Education.vue index 0c3419413..e18914d9f 100644 --- a/src/modules/04_registry/components/Education.vue +++ b/src/modules/04_registry/components/Education.vue @@ -26,14 +26,14 @@
{{ props.row.isDate == "true" - ? date2Thai(props.row.startDate2) + ? (props.row.startDate2 ? date2Thai(props.row.startDate2):'-') : col.value + 543 }}
{{ props.row.isDate == "true" - ? date2Thai(props.row.endDate2) + ? (props.row.endDate2 ? date2Thai(props.row.endDate2):'-') : col.value + 543 }}
@@ -735,10 +735,10 @@ const other = ref(); const fundName = ref(); const isDate = ref("true"); const finishDate = ref(null); -const startDate = ref(new Date().getFullYear()); -const startDate2 = ref(new Date()); -const endDate = ref(new Date().getFullYear()); -const endDate2 = ref(new Date()); +const startDate = ref(new Date().getFullYear()); +const startDate2 = ref(null); +const endDate = ref(new Date().getFullYear()); +const endDate2 = ref(null); const minDate = ref(); const myForm = ref(); //form data input const edit = ref(false); //เช็คการกดปุ่มแก้ไขใน dialog @@ -1218,6 +1218,7 @@ const fetchData = async () => { .get(config.API.profileEduId(profileId.value)) .then((res) => { let data = res.data.result; + rows.value = []; data.map((e: ResponseObject) => { rows.value.push({ @@ -1237,14 +1238,18 @@ const fetchData = async () => { fundName: e.fundName, isDate: e.isDate == null ? null : e.isDate.toString(), finishDate: e.finishDate ? new Date(e.finishDate) : null, - startDate: new Date(e.startDate).getFullYear(), - endDate: new Date(e.endDate).getFullYear(), - startDate2: new Date(e.startDate), - endDate2: new Date(e.endDate), + startDate:e.startDate ? new Date(e.startDate).getFullYear():null, + endDate:e.endDate ? new Date(e.endDate).getFullYear():null, + startDate2:e.startDate ? new Date(e.startDate):null, + endDate2:e.endDate ? new Date(e.endDate):null, createdFullName: e.createdFullName, createdAt: new Date(e.createdAt), }); - }); + } + + ); + console.log(data) + console.log(rows.value) }) .catch((e) => { messageError($q, e); @@ -1297,10 +1302,10 @@ const getData = () => { startDate.value = row.startDate; endDate.value = row.endDate; startDate2.value = row.startDate2; - inputStartDate.value = (Number(row.startDate) + 543).toLocaleString(); - inputEndDate.value = (Number(row.endDate) + 543).toLocaleString(); - inputStartDate2.value = convertDateDisplay(row.startDate2); - inputEndDate2.value = convertDateDisplay(row.endDate2); + inputStartDate.value = row.startDate ? (Number(row.startDate) + 543).toLocaleString():''; + inputEndDate.value = row.endDate ? (Number(row.endDate) + 543).toLocaleString():''; + inputStartDate2.value = row.startDate2 ? convertDateDisplay(row.startDate2 as Date):''; + inputEndDate2.value = row.endDate2 ? convertDateDisplay(row.endDate2 as Date):''; finishDateInput.value = row.finishDate ? convertDateDisplay(row.finishDate) : "-"; @@ -1412,11 +1417,11 @@ const saveData = async () => { : null, startDate: isDate.value == "true" - ? dateToISO(startDate2.value as Date) + ? (startDate2.value ? dateToISO(startDate2.value as Date):null) : new Date(`${startDate.value}-01-01`), endDate: isDate.value == "true" - ? dateToISO(endDate2.value as Date) + ? (endDate2.value ? dateToISO(endDate2.value as Date):null) : new Date(`${endDate.value}-01-01`), }) .then((res) => { @@ -1564,10 +1569,10 @@ const selectData = async (_props: DataProps) => { startDate2.value = _props.row.startDate2; endDate2.value = _props.row.endDate2; id.value = _props.row.id; - inputStartDate.value = (Number(_props.row.startDate) + 543).toLocaleString(); - inputEndDate.value = (Number(_props.row.endDate) + 543).toLocaleString(); - inputStartDate2.value = convertDateDisplay(_props.row.startDate2); - inputEndDate2.value = convertDateDisplay(_props.row.endDate2); + inputStartDate.value = _props.row.startDate ? (Number(_props.row.startDate) + 543).toLocaleString():''; + inputEndDate.value = _props.row.endDate ? (Number(_props.row.endDate) + 543).toLocaleString():''; + inputStartDate2.value = _props.row.startDate2 ? convertDateDisplay(_props.row.startDate2 as Date):''; + inputEndDate2.value = _props.row.endDate2 ? convertDateDisplay(_props.row.endDate2 as Date):''; finishDateInput.value = _props.row.finishDate ? convertDateDisplay(_props.row.finishDate) : "-"; @@ -1719,9 +1724,11 @@ watch( dayChecked2.value = false; startDate2.value = dateVal.value; } else { - dayChecked.value = true; + dayChecked2.value = true; inputStartDate2.value = ""; } + } else{ + startDate2.value = null } } ); @@ -1734,9 +1741,11 @@ watch( dayEndChecked2.value = false; endDate2.value = dateVal.value; } else { - dayEndChecked.value = true; + dayEndChecked2.value = true; inputEndDate2.value = ""; } + }else{ + endDate2.value = null } } ); diff --git a/src/modules/04_registry/interface/request/Education.ts b/src/modules/04_registry/interface/request/Education.ts index 21916014d..44afa2890 100644 --- a/src/modules/04_registry/interface/request/Education.ts +++ b/src/modules/04_registry/interface/request/Education.ts @@ -21,10 +21,10 @@ interface RequestItemsObject { fundName: string; isDate: string | null; finishDate: Date | null; - startDate: number; - endDate: number; - startDate2: Date; - endDate2: Date; + startDate: number|null; + endDate: number|null; + startDate2: Date|null; + endDate2: Date|null; createdFullName: string; createdAt: Date; }