ปรับ Code เคื่องราช
This commit is contained in:
parent
51d072ccc0
commit
240862be2c
13 changed files with 548 additions and 885 deletions
|
|
@ -1,106 +1,4 @@
|
|||
<template>
|
||||
<div class="col-xs-12 col-sm-12 col-md-11">
|
||||
<div class="toptitle col-12 row items-center">
|
||||
<q-btn icon="mdi-arrow-left" unelevated round dense flat color="primary" class="q-mr-sm" @click="clickBack" />
|
||||
{{
|
||||
edit
|
||||
? "รอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์"
|
||||
: "เพิ่มรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์"
|
||||
}}
|
||||
</div>
|
||||
<q-form ref="myForm">
|
||||
<div class="col-12">
|
||||
<q-card bordered>
|
||||
<div class="col-12 row q-col-gutter-md q-pa-md">
|
||||
<div class="col-xs-12 col-sm-12 row">
|
||||
<q-separator />
|
||||
<div class="col-12 row q-pa-sm q-col-gutter-sm">
|
||||
<q-select class="col-10" dense outlined v-model="roundInsig" :options="options" option-value="value"
|
||||
option-label="label" label="รอบการเสนอขอพระราชทานเครื่องราชฯ" @update:model-value="updateDateRange"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกรอบที่'}`]" />
|
||||
<datepicker menu-class-name="modalfix" v-model="yearly" class="col-2" :locale="'th'" autoApply year-picker
|
||||
:enableTimePicker="false" @update:modelValue="updateYear">
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
parseInt(value + 543)
|
||||
}}</template>
|
||||
<template #trigger>
|
||||
<q-input dense lazy-rules outlined :model-value="yearly + 543"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกปีที่เสนอ'}`]" :label="`${'ปีที่เสนอ'}`">
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)">
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
<datepicker menu-class-name="modalfix" v-model="dateStart" :locale="'th'" autoApply
|
||||
class="col-xs-12 col-sm-5" borderless :enableTimePicker="false" week-start="0">
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input outlined dense class="full-width datepicker" :model-value="dateStart != null ? date2Thai(dateStart) : null
|
||||
" :label="`${'วันเริ่มต้น'}`" :rules="[(val) => !!val || `${'กรุณาเลือกวันเริ่มต้น'}`]">
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)">
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
<datepicker menu-class-name="modalfix" v-model="dateEnd" class="col-xs-12 col-sm-5" :locale="'th'"
|
||||
autoApply borderless :enableTimePicker="false" week-start="0">
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input outlined dense class="col-xs-12 col-sm-4"
|
||||
:model-value="dateEnd != null ? date2Thai(dateEnd) : null" :label="`${'วันสิ้นสุด'}`" :rules="[
|
||||
(val) => !!val || `${'กรุณาเลือกวันที่วันสิ้นสุด'}`,
|
||||
]">
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)">
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
|
||||
<q-input class="col-xs-12 col-sm-2" dense outlined v-model="datelast"
|
||||
label="จำนวนวันแจ้งเตือนก่อนวันสิ้นสุด" />
|
||||
<q-file class="col-xs-12 col-sm-10" outlined dense v-model="files" @added="fileUploadDoc"
|
||||
label="อัปโหลดเอกสารประกอบ" hide-bottom-space lazy-rules>
|
||||
<!-- :rules="[
|
||||
(val) => val || 'กรุณาเลือกไฟล์หนังสือถึงหน่วยงานที่รับโอน',
|
||||
]" -->
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="attach_file" />
|
||||
</template>
|
||||
</q-file>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<q-separator />
|
||||
<q-separator />
|
||||
<div class="row col-12 q-pa-sm">
|
||||
<q-space />
|
||||
<q-btn unelevated dense class="q-px-md items-center" color="light-blue-10" label="บันทึก"
|
||||
@click="checkSave" />
|
||||
</div>
|
||||
</q-card>
|
||||
</div>
|
||||
</q-form>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import type { QTableProps } from "quasar";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useQuasar, QForm } from "quasar";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
|
@ -111,12 +9,12 @@ import config from "@/app.config";
|
|||
const mixin = useCounterMixin();
|
||||
const {
|
||||
date2Thai,
|
||||
success,
|
||||
dateToISO,
|
||||
messageError,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
dialogConfirm,
|
||||
success,
|
||||
} = mixin;
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
|
@ -138,18 +36,14 @@ const options = ref([
|
|||
onMounted(async () => {
|
||||
await fetchData();
|
||||
});
|
||||
|
||||
const fetchData = async () => {
|
||||
if (route.params.id) {
|
||||
edit.value = true;
|
||||
showLoader();
|
||||
// console.log(id.value);
|
||||
|
||||
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 =
|
||||
options.value.filter((r: any) => r.value == data.period_round)
|
||||
|
|
@ -171,8 +65,6 @@ const fetchData = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
const routeName = router.currentRoute.value.name;
|
||||
|
||||
const fileUploadDoc = async (files: any) => {
|
||||
files.forEach((file: any) => {
|
||||
fileDocDataUpload.value.push(file);
|
||||
|
|
@ -185,7 +77,9 @@ const updateYear = async (e: number) => {
|
|||
|
||||
const editData = async (id: string) => {
|
||||
const formData = new FormData();
|
||||
const name = `รอบการเสนอขอพระราชทานเครื่องราชรอบที่ ${roundInsig.value.value} ปี ${yearly.value + 543}`;
|
||||
const name = `รอบการเสนอขอพระราชทานเครื่องราชรอบที่ ${
|
||||
roundInsig.value.value
|
||||
} ปี ${yearly.value + 543}`;
|
||||
formData.append("name", name);
|
||||
formData.append("year", yearly.value.toString());
|
||||
formData.append("amount", datelast.value.toString());
|
||||
|
|
@ -196,15 +90,12 @@ const editData = async (id: string) => {
|
|||
if (dateEnd.value !== null) {
|
||||
formData.append("endDate", dateToISO(dateEnd.value));
|
||||
}
|
||||
// files.value.forEach((file: any) => {
|
||||
// formData.append("file", file);
|
||||
// });
|
||||
formData.append("file", files.value);
|
||||
console.log(formData);
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.editRoundInsignia(id), formData)
|
||||
.then(async () => { })
|
||||
.then(async () => {})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
|
|
@ -231,19 +122,7 @@ const SaveData = async () => {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
// const sendData = () => {
|
||||
// const valueData: any = {
|
||||
// Name: roundInsig.value,
|
||||
// year: year.value,
|
||||
// Amount: datelast.value,
|
||||
// dateStart: dateStart.value !== null ? dateToISO(dateStart.value) : null,
|
||||
// dateEnd: dateEnd.value !== null ? dateToISO(dateEnd.value) : null,
|
||||
// };
|
||||
// return valueData;
|
||||
// };
|
||||
const updateDateRange = () => {
|
||||
// console.log("test")
|
||||
if (roundInsig.value.value == 1) {
|
||||
dateStart.value = new Date(new Date().getFullYear(), 9, 1);
|
||||
dateEnd.value = new Date(new Date().getFullYear() + 1, 3, 29);
|
||||
|
|
@ -257,8 +136,9 @@ const updateDateRange = () => {
|
|||
|
||||
const addData = async () => {
|
||||
const formData = new FormData();
|
||||
const name = `รอบการเสนอขอพระราชทานเครื่องราชรอบที่ ${roundInsig.value.value
|
||||
} ปี ${yearly.value + 543} `;
|
||||
const name = `รอบการเสนอขอพระราชทานเครื่องราชรอบที่ ${
|
||||
roundInsig.value.value
|
||||
} ปี ${yearly.value + 543} `;
|
||||
console.log(name);
|
||||
formData.append("name", name);
|
||||
formData.append("year", yearly.value.toString());
|
||||
|
|
@ -270,17 +150,14 @@ const addData = async () => {
|
|||
if (dateEnd.value !== null) {
|
||||
formData.append("endDate", dateToISO(dateEnd.value));
|
||||
}
|
||||
console.log(files.value);
|
||||
// files.value.forEach((file: any) => {
|
||||
// formData.append("file", file);
|
||||
// });
|
||||
formData.append("file", files.value);
|
||||
console.log(files.value);
|
||||
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.listRoundInsignia(), formData)
|
||||
.then(async (res) => { })
|
||||
.then(() => {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
|
|
@ -293,3 +170,197 @@ const clickBack = () => {
|
|||
router.push({ name: "insigniaProposals" });
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<div class="col-xs-12 col-sm-12 col-md-11">
|
||||
<div class="toptitle col-12 row items-center">
|
||||
<q-btn
|
||||
icon="mdi-arrow-left"
|
||||
unelevated
|
||||
round
|
||||
dense
|
||||
flat
|
||||
color="primary"
|
||||
class="q-mr-sm"
|
||||
@click="clickBack"
|
||||
/>
|
||||
{{
|
||||
edit
|
||||
? "รอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์"
|
||||
: "เพิ่มรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์"
|
||||
}}
|
||||
</div>
|
||||
<q-form ref="myForm">
|
||||
<div class="col-12">
|
||||
<q-card bordered>
|
||||
<div class="col-12 row q-col-gutter-md q-pa-md">
|
||||
<div class="col-xs-12 col-sm-12 row">
|
||||
<q-separator />
|
||||
<div class="col-12 row q-pa-sm q-col-gutter-sm">
|
||||
<q-select
|
||||
class="col-10"
|
||||
dense
|
||||
outlined
|
||||
v-model="roundInsig"
|
||||
:options="options"
|
||||
option-value="value"
|
||||
option-label="label"
|
||||
label="รอบการเสนอขอพระราชทานเครื่องราชฯ"
|
||||
@update:model-value="updateDateRange"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกรอบที่'}`]"
|
||||
/>
|
||||
<datepicker
|
||||
menu-class-name="modalfix"
|
||||
v-model="yearly"
|
||||
class="col-2"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
year-picker
|
||||
:enableTimePicker="false"
|
||||
@update:modelValue="updateYear"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
parseInt(value + 543)
|
||||
}}</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
dense
|
||||
lazy-rules
|
||||
outlined
|
||||
:model-value="yearly + 543"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกปีที่เสนอ'}`]"
|
||||
:label="`${'ปีที่เสนอ'}`"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
<datepicker
|
||||
menu-class-name="modalfix"
|
||||
v-model="dateStart"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
class="col-xs-12 col-sm-5"
|
||||
borderless
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
>
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
outlined
|
||||
dense
|
||||
class="full-width datepicker"
|
||||
:model-value="
|
||||
dateStart != null ? date2Thai(dateStart) : null
|
||||
"
|
||||
:label="`${'วันเริ่มต้น'}`"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกวันเริ่มต้น'}`]"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
<datepicker
|
||||
menu-class-name="modalfix"
|
||||
v-model="dateEnd"
|
||||
class="col-xs-12 col-sm-5"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
borderless
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
>
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
outlined
|
||||
dense
|
||||
class="col-xs-12 col-sm-4"
|
||||
:model-value="dateEnd != null ? date2Thai(dateEnd) : null"
|
||||
:label="`${'วันสิ้นสุด'}`"
|
||||
:rules="[
|
||||
(val) => !!val || `${'กรุณาเลือกวันที่วันสิ้นสุด'}`,
|
||||
]"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
|
||||
<q-input
|
||||
class="col-xs-12 col-sm-2"
|
||||
dense
|
||||
outlined
|
||||
v-model="datelast"
|
||||
label="จำนวนวันแจ้งเตือนก่อนวันสิ้นสุด"
|
||||
/>
|
||||
<q-file
|
||||
class="col-xs-12 col-sm-10"
|
||||
outlined
|
||||
dense
|
||||
v-model="files"
|
||||
@added="fileUploadDoc"
|
||||
label="อัปโหลดเอกสารประกอบ"
|
||||
hide-bottom-space
|
||||
lazy-rules
|
||||
>
|
||||
<!-- :rules="[
|
||||
(val) => val || 'กรุณาเลือกไฟล์หนังสือถึงหน่วยงานที่รับโอน',
|
||||
]" -->
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="attach_file" />
|
||||
</template>
|
||||
</q-file>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<q-separator />
|
||||
<q-separator />
|
||||
<div class="row col-12 q-pa-sm">
|
||||
<q-space />
|
||||
<q-btn
|
||||
unelevated
|
||||
dense
|
||||
class="q-px-md items-center"
|
||||
color="light-blue-10"
|
||||
label="บันทึก"
|
||||
@click="checkSave"
|
||||
/>
|
||||
</div>
|
||||
</q-card>
|
||||
</div>
|
||||
</q-form>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ import router from "@/router";
|
|||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import type { FormProprsalsRound } from " @/modules/07_insignia/interface/request/Main.ts";
|
||||
import { useRoute } from "vue-router";
|
||||
import config from "@/app.config";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
|
||||
const mixin = useCounterMixin();
|
||||
|
|
@ -15,22 +13,12 @@ const {
|
|||
date2Thai,
|
||||
success,
|
||||
messageError,
|
||||
statusLeave,
|
||||
dialogMessage,
|
||||
dateToISO,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
dialogConfirm,
|
||||
dialogRemove,
|
||||
} = mixin;
|
||||
const route = useRoute();
|
||||
const $q = useQuasar(); //ใช้ noti quasar
|
||||
const modal = ref<boolean>(false);
|
||||
const pagination = ref({
|
||||
sortBy: "desc",
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
|
||||
const visibleColumns = ref<string[]>([
|
||||
"round",
|
||||
|
|
@ -194,34 +182,22 @@ const clickEdit = (col: any) => {
|
|||
router.push(`/insignia/round-add/${col.id}`);
|
||||
};
|
||||
|
||||
// หัวตาราง2
|
||||
const clickDelete = (id: string) => {
|
||||
$q.dialog({
|
||||
title: "ยืนยันการลบข้อมูล",
|
||||
message: "ต้องการลบข้อมูลนี้ใช่หรือไม่?",
|
||||
cancel: {
|
||||
flat: true,
|
||||
color: "negative",
|
||||
},
|
||||
persistent: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.RoundInsignia(id))
|
||||
.then((res) => {
|
||||
success($q, "ลบข้อมูลการเสนอขอสำเร็จ");
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
})
|
||||
.onCancel(() => {})
|
||||
.onDismiss(() => {});
|
||||
dialogRemove($q, async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.RoundInsignia(id))
|
||||
.then(() => {
|
||||
success($q, "ลบข้อมูลการเสนอขอสำเร็จ");
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const clickAdd = () => {
|
||||
|
|
@ -247,12 +223,10 @@ const getRequest = async (id: string) => {
|
|||
showLoader();
|
||||
await http
|
||||
.get(config.API.requestInsignia(id))
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
.then(() => {
|
||||
success($q, "ยืนยันสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(async () => {
|
||||
|
|
@ -268,16 +242,14 @@ const resetFilter = () => {
|
|||
filterRef.value.focus();
|
||||
};
|
||||
|
||||
const filterKeyword2 = ref<string>("");
|
||||
const filterRef2 = ref<any>(null);
|
||||
const resetFilter2 = () => {
|
||||
filterKeyword2.value = "";
|
||||
filterRef2.value.focus();
|
||||
};
|
||||
|
||||
const attrs = ref<any>(useAttrs());
|
||||
|
||||
const paging = ref<boolean>(true);
|
||||
const pagination = ref({
|
||||
sortBy: "desc",
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
const paginationLabel = (start: string, end: string, total: string) => {
|
||||
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
|
||||
else return start + "-" + end + " ใน " + total;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue