เครื่องราชฯ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-09-19 14:58:16 +07:00
parent 8ebbef05d9
commit 1530da36cf
22 changed files with 159 additions and 777 deletions

View file

@ -15,7 +15,7 @@ const {
hideLoader,
dialogConfirm,
success,
dialogMessageNotify
dialogMessageNotify,
} = mixin;
const router = useRouter();
const route = useRoute();
@ -34,36 +34,38 @@ const options = ref([
{ label: "รอบการเสนอขอพระราชทานเครื่องราชรอบที่ 1", value: 1 },
{ label: "รอบการเสนอขอพระราชทานเครื่องราชรอบที่ 2", value: 2 },
]);
onMounted(async () => {
await fetchData();
});
const fetchData = async () => {
if (route.params.id) {
edit.value = true;
showLoader();
await http
.get(config.API.getRoundInsignia(id.value))
.then((res) => {
const data = res.data.result;
id.value = data.period_id;
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);
dateEnd.value = new Date(data.period_end);
files.value = data.period_doc;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
await fetchData();
}
});
const fetchData = async () => {
edit.value = true;
showLoader();
await http
.get(config.API.getRoundInsignia(id.value))
.then((res) => {
const data = res.data.result;
id.value = data.period_id;
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);
dateEnd.value = new Date(data.period_end);
files.value = data.period_doc;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
const fileUploadDoc = async (files: any) => {
@ -92,11 +94,12 @@ const editData = async (id: string) => {
formData.append("endDate", dateToISO(dateEnd.value));
}
formData.append("file", files.value);
console.log(formData);
showLoader();
await http
.put(config.API.editRoundInsignia(id), formData)
.then(async () => {})
.then(() => {
success($q, "แก้ไขข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
@ -104,17 +107,16 @@ const editData = async (id: string) => {
hideLoader();
clickBack();
});
console.log(formData);
};
const checkSave = () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (success) => {
if (success) {
dialogConfirm($q, () => SaveData());
}else {
dialogMessageNotify($q,"กรุณาเลือกรอบการเสนอขอพระราชทานเครื่องราชฯ")
} else {
dialogMessageNotify($q, "กรุณาเลือกรอบการเสนอขอพระราชทานเครื่องราชฯ");
}
})
});
}
};
const SaveData = async () => {
@ -130,11 +132,9 @@ const updateDateRange = () => {
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);
} 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);
}
};
@ -143,7 +143,6 @@ const addData = async () => {
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());
@ -329,7 +328,9 @@ const clickBack = () => {
outlined
v-model="datelast"
label="จำนวนวันแจ้งเตือนก่อนวันสิ้นสุด"
mask="###"
/>
<q-file
class="col-xs-12 col-sm-10"
outlined
@ -341,9 +342,6 @@ const clickBack = () => {
lazy-rules
accept=".pdf,.xlsx,.doc"
>
<!-- :rules="[
(val) => val || 'กรุณาเลือกไฟล์หนังสือถึงหน่วยงานที่รับโอน',
]" -->
<template v-slot:prepend>
<q-icon name="attach_file" />
</template>

View file

@ -25,7 +25,6 @@ const visibleColumns = ref<string[]>([
"period_year",
"period_start",
"period_end",
// "status",
"statusRoyal",
]); //
@ -61,8 +60,8 @@ const columns = ref<QTableProps["columns"]>([
field: "period_start",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
// sort: (a: string, b: string) =>
// a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "period_end",
@ -72,8 +71,8 @@ const columns = ref<QTableProps["columns"]>([
field: "period_end",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
// sort: (a: string, b: string) =>
// a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "statusRoyal",
@ -95,6 +94,7 @@ onMounted(async () => {
await fetchData();
});
// API
const fetchData = async () => {
showLoader();
await http
@ -114,7 +114,6 @@ const fetchData = async () => {
period_doc: e.period_doc,
period_status: e.period_status.result,
}));
console.log(rows.value);
})
.catch((e) => {
messageError($q, e);
@ -145,16 +144,11 @@ const clickDelete = (id: string) => {
});
});
};
//
const clickAdd = () => {
router.push({ name: "roundAdd" });
};
const clickProposals = (file: string) => {
if (file !== null) {
window.open(file);
}
};
const clickListInsignia = async (propsId: string) => {
dialogConfirm(
$q,
@ -165,6 +159,7 @@ const clickListInsignia = async (propsId: string) => {
"ต้องการยืนยันการคำนวณราชชื่อผู้ได้รับเครื่องราชนี้หรือไม่ ?"
);
};
// API
const getRequest = async (id: string) => {
showLoader();
await http
@ -179,16 +174,6 @@ const getRequest = async (id: string) => {
await fetchData();
});
};
// const downloadFile = (response: any, name: string) => {
// const link = document.createElement("a");
// var fileName = name;
// link.href = response;
// link.setAttribute("target", "_blank");
// link.setAttribute("download", fileName);
// document.body.appendChild(link);
// link.click();
// document.body.removeChild(link);
// };
//
const filterKeyword = ref<string>("");
@ -201,7 +186,7 @@ const resetFilter = () => {
const attrs = ref<any>(useAttrs());
const paging = ref<boolean>(true);
const pagination = ref({
sortBy: "desc",
// sortBy: "desc",
descending: false,
page: 1,
rowsPerPage: 10,
@ -375,7 +360,7 @@ const paginationLabel = (start: string, end: string, total: string) => {
<q-tooltip>ไดบเครองราชฯ</q-tooltip>
</q-btn>
</q-td>
<q-td auto-width>
<q-td auto-width v-if="props.row.period_doc !== null">
<q-btn
dense
type="a"
@ -387,13 +372,10 @@ const paginationLabel = (start: string, end: string, total: string) => {
icon="mdi-file-download"
:href="props.row.period_doc"
>
<!-- @click="
downloadFile(props.row.period_doc, props.row.period_name)
" -->
<q-tooltip>ดาวนโหลดเอกสารประกอบ </q-tooltip>
</q-btn>
</q-td>
<q-td auto-width v-else></q-td>
<q-td auto-width>
<q-btn
dense