From d90e023042d6202e9c16d4d674b29bf728db33b4 Mon Sep 17 00:00:00 2001
From: AnandaTon <125332905+anandaAiemvong@users.noreply.github.com>
Date: Tue, 8 Aug 2023 14:58:39 +0700
Subject: [PATCH] =?UTF-8?q?Api=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81?=
=?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7=E0=B9=88?=
=?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/07_insignia/api.insignia.ts | 1 -
.../components/1_Proposals/addProposals.vue | 140 ++++++++++++------
.../components/1_Proposals/listProposals.vue | 30 +++-
src/modules/07_insignia/router.ts | 10 ++
4 files changed, 129 insertions(+), 52 deletions(-)
diff --git a/src/api/07_insignia/api.insignia.ts b/src/api/07_insignia/api.insignia.ts
index f17086d3f..3d233fec5 100644
--- a/src/api/07_insignia/api.insignia.ts
+++ b/src/api/07_insignia/api.insignia.ts
@@ -8,5 +8,4 @@ export default {
listRoundInsignia: (type: string) => `${insignia}/period/${type}`,
editRoundInsignia: (id: string) => `${insignia}/period/${id}`,
RoundInsignia: (id: string) => `${insignia}/period/${id}`,
- docRoundInsignia: (id: string) => `${insignia}/period/${id}`,
};
diff --git a/src/modules/07_insignia/components/1_Proposals/addProposals.vue b/src/modules/07_insignia/components/1_Proposals/addProposals.vue
index ba6c3ec5c..8d90236b4 100644
--- a/src/modules/07_insignia/components/1_Proposals/addProposals.vue
+++ b/src/modules/07_insignia/components/1_Proposals/addProposals.vue
@@ -9,9 +9,13 @@
flat
color="primary"
class="q-mr-sm"
- @click="router.go(-1)"
+ @click="clickBack"
/>
-
เพิ่มรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์
+ {{
+ edit
+ ? "รอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์"
+ : "เพิ่มรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์"
+ }}
@@ -27,13 +31,40 @@
v-model="roundInsig"
label="รอบการเสนอขอพระราชทานเครื่องราชฯ"
/>
-
+ :locale="'th'"
+ autoApply
+ year-picker
+ :enableTimePicker="false"
+ @update:modelValue="updateYear"
+ >
+
{{ year + 543 }}
+
{{
+ parseInt(value + 543)
+ }}
+
+
+
+
+
+
+
+
+
("");
+const id = ref(route.params.id as string);
const myForm = ref(null); //form data input
const edit = ref(false);
-const dateStart = ref(new Date());
-const dateEnd = ref(new Date());
-const files = ref([]);
+const dateStart = ref(new Date());
+const dateEnd = ref(new Date());
+const yearly = ref(new Date().getFullYear());
+const files = ref([]);
const fileDocDataUpload = ref([]);
const roundInsig = ref("");
-const yearOffer = ref(0);
-const datelast = ref(0);
+const datelast = ref(1);
onMounted(async () => {
await fetchData();
});
const fetchData = async () => {
- showLoader();
- await http
- .get(config.API.getRoundInsignia("insignia"))
- .then((res) => {
- const data = res.data.result.periods;
- const files = res.data.result.files;
+ if (route.params.id) {
+ edit.value = true;
+ showLoader();
+ console.log(id.value);
- id.value = data.id;
- roundInsig.value = data.period_name;
- yearOffer.value = data.year;
- datelast.value = data.amount;
- dateStart.value = data.startDate;
- dateEnd.value = data.endDate;
-
- files.value = files;
- })
- .catch((e) => {
- messageError($q, e);
- })
- .finally(() => {
- hideLoader();
- });
+ await http
+ .get(config.API.getRoundInsignia(id.value))
+ .then((res) => {
+ const data = res.data.result;
+ // const files = res.data.result.files;
+ id.value = data.period_id;
+ roundInsig.value = data.period_name;
+ yearly.value = data.period_year;
+ datelast.value = data.period_amount;
+ dateStart.value = new Date(data.period_start);
+ dateEnd.value = new Date(data.period_end);
+ files.value = data.period_doc;
+ })
+ .catch((e) => {
+ messageError($q, e);
+ })
+ .finally(() => {
+ hideLoader();
+ });
+ }
};
const routeName = router.currentRoute.value.name;
@@ -218,6 +253,10 @@ const fileUploadDoc = async (files: any) => {
});
};
+const updateYear = async (e: number) => {
+ yearly.value = e;
+};
+
const uploadDocData = async () => {
const formData = new FormData();
if (fileDocDataUpload.value.length > 0) {
@@ -226,7 +265,7 @@ const uploadDocData = async () => {
});
showLoader();
await http
- .put(config.API.docRoundInsignia(id.value), formData)
+ .put(config.API.RoundInsignia(id.value), formData)
.then((res) => {})
.catch((e) => {
messageError($q, e);
@@ -243,6 +282,18 @@ const uploadDocData = async () => {
};
const editData = async (id: string) => {
+ const formData = new FormData();
+ formData.append("Name", roundInsig.value);
+ formData.append("year", parseInt(yearly.value).toString());
+ formData.append("amount", datelast.value.toString());
+ if (dateStart.value !== null) {
+ formData.append("startDate", dateToISO(dateStart.value));
+ }
+ if (dateEnd.value !== null) {
+ formData.append("endDate", dateToISO(dateEnd.value));
+ }
+ formData.append("file", files.value.toString());
+ console.log(formData);
showLoader();
await http
.put(config.API.editRoundInsignia(id))
@@ -255,6 +306,7 @@ const editData = async (id: string) => {
.finally(async () => {
hideLoader();
});
+ console.log(formData);
};
const checkSave = async () => {
@@ -284,15 +336,17 @@ const checkSave = async () => {
const addData = async () => {
const formData = new FormData();
- formData.append("Name", roundInsig.value);
- formData.append("year", parseInt(yearOffer.value).toString());
- formData.append("Amount", files.datelast);
+ formData.append("name", roundInsig.value);
+ formData.append("year", parseInt(yearly.value).toString());
+ formData.append("amount", datelast.value.toString());
if (dateStart.value !== null) {
- formData.append("StartDate", dateToISO(dateStart.value));
+ formData.append("startDate", dateToISO(dateStart.value));
}
if (dateEnd.value !== null) {
- formData.append("EndDate", dateToISO(dateEnd.value));
+ formData.append("endDate", dateToISO(dateEnd.value));
}
+ formData.append("file", files.value.toString());
+ console.log(formData);
showLoader();
await http
diff --git a/src/modules/07_insignia/components/1_Proposals/listProposals.vue b/src/modules/07_insignia/components/1_Proposals/listProposals.vue
index 6cdff4beb..d40c5ec29 100644
--- a/src/modules/07_insignia/components/1_Proposals/listProposals.vue
+++ b/src/modules/07_insignia/components/1_Proposals/listProposals.vue
@@ -84,30 +84,36 @@
-
+
{{ props.row.round }}
-
+
{{ props.row.year }}
-
+
{{ props.row.startDate }}
-
+
{{ props.row.endDate }}
-
+
@@ -116,12 +122,14 @@
name="mdi-timer-sand"
color="orange"
class="text-h5"
+ @click="clickEdit(props.row)"
/>
@@ -313,7 +321,7 @@ const rows = ref([
year: "2566",
startDate: "2566",
endDate: "31 พ.ค. 2566",
- status: "ยังไม่ได้เสนอ",
+ status: "ไม่ใช้งาน",
statusRoyal: "ยังไม่ได้เสนอ",
},
{
@@ -343,9 +351,11 @@ const fetchData = async () => {
id: e.period_id,
round: e.period_name,
year: e.period_year,
+ amount: e.period_amount,
startDate:
- e.startDate == null ? null : date2Thai(new Date(e.startDate)),
- endDate: e.endDate == null ? null : date2Thai(new Date(e.endDate)),
+ e.period_start == null ? null : date2Thai(new Date(e.period_start)),
+ endDate:
+ e.period_end == null ? null : date2Thai(new Date(e.period_end)),
status: e.period_status,
});
});
@@ -358,6 +368,10 @@ const fetchData = async () => {
});
};
+const clickEdit = (col: any) => {
+ router.push(`/insignia/round-add/${col.id}`);
+};
+
// หัวตาราง2
const clickDelete = (id: string) => {
$q.dialog({
diff --git a/src/modules/07_insignia/router.ts b/src/modules/07_insignia/router.ts
index 5eb982863..423cca427 100644
--- a/src/modules/07_insignia/router.ts
+++ b/src/modules/07_insignia/router.ts
@@ -45,6 +45,16 @@ export default [
Role: "insignia",
},
},
+ {
+ path: "/insignia/round-add/:id",
+ name: "roundAddEdit",
+ component: roundAdd,
+ meta: {
+ Auth: true,
+ Key: [8.1],
+ Role: "insignia",
+ },
+ },
{
path: "/insignia/round-add",
name: "roundAdd",