แก้ไขรอบการเสนอขอพระราชทานเครื่องราช, รายการลาออก

This commit is contained in:
Thanit Konmek 2023-08-23 14:57:50 +07:00
parent fde0a3fd0b
commit 39636d0e08
2 changed files with 134 additions and 22 deletions

View file

@ -10,7 +10,6 @@
color="primary"
class="q-mr-sm"
@click="clickBack"
/>
{{
edit
@ -203,8 +202,15 @@ import http from "@/plugins/http";
import config from "@/app.config";
const mixin = useCounterMixin();
const { date2Thai, success, dateToISO, messageError, showLoader, hideLoader,dialogConfirm } =
mixin;
const {
date2Thai,
success,
dateToISO,
messageError,
showLoader,
hideLoader,
dialogConfirm,
} = mixin;
const router = useRouter();
const route = useRoute();
const $q = useQuasar();
@ -219,9 +225,9 @@ const fileDocDataUpload = ref<File[]>([]);
const roundInsig = ref<any>();
const datelast = ref<number>(1);
const options = ref([
{label:"รอบที่ 1",value:1},
{label:"รอบที่ 2",value:2}
])
{ label: "รอบที่ 1", value: 1 },
{ label: "รอบที่ 2", value: 2 },
]);
onMounted(async () => {
await fetchData();
});
@ -238,7 +244,11 @@ const fetchData = async () => {
const data = res.data.result;
// const files = res.data.result.files;
id.value = data.period_id;
roundInsig.value = data.period_name;
roundInsig.value =
options.value.filter((r: any) => r.value == data.period_round)
.length > 0
? options.value.filter((r: any) => r.value == data.period_round)[0]
: null;
yearly.value = data.period_year;
datelast.value = data.period_amount;
dateStart.value = new Date(data.period_start);
@ -268,9 +278,13 @@ const updateYear = async (e: number) => {
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());
const name = `รอบการเสนอพระราชทานเครื่องราชรอบที่ ${
roundInsig.value.value
} ${yearly.value + 543} `;
formData.append("name", name);
formData.append("year", yearly.value.toString());
formData.append("amount", datelast.value.toString());
formData.append("round", roundInsig.value.value);
if (dateStart.value !== null) {
formData.append("startDate", dateToISO(dateStart.value));
}
@ -295,9 +309,9 @@ const editData = async (id: string) => {
});
console.log(formData);
};
const checkSave = () => {
dialogConfirm($q,()=> SaveData())
}
const checkSave = () => {
dialogConfirm($q, () => SaveData());
};
const SaveData = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (success) => {
@ -324,23 +338,28 @@ const SaveData = async () => {
// return valueData;
// };
const updateDateRange = () => {
// console.log("test")
// 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);
console.log(1)
console.log(1);
} else if (roundInsig.value.value == 2) {
dateStart.value = new Date(new Date().getFullYear(), 3, 29);
dateEnd.value = new Date(new Date().getFullYear(), 4, 29);
console.log(2)
console.log(2);
}
};
const addData = async () => {
const formData = new FormData();
formData.append("name", roundInsig.value);
formData.append("year", parseInt(yearly.value).toString());
const name = `รอบการเสนอพระราชทานเครื่องราชรอบที่ ${
roundInsig.value.value
} ${yearly.value + 543} `;
console.log(name);
formData.append("name", name);
formData.append("year", yearly.value.toString());
formData.append("amount", datelast.value.toString());
formData.append("round", roundInsig.value.value);
if (dateStart.value !== null) {
formData.append("startDate", dateToISO(dateStart.value));
}
@ -356,7 +375,7 @@ const addData = async () => {
showLoader();
await http
.post(config.API.listRoundInsignia("insignia"), formData)
.post(config.API.listRoundInsignia(), formData)
.then(async (res) => {})
.catch((e) => {
messageError($q, e);