diff --git a/src/api/11_discipline/api.discipline.ts b/src/api/11_discipline/api.discipline.ts index cbfec2c6a..a1ae8de58 100644 --- a/src/api/11_discipline/api.discipline.ts +++ b/src/api/11_discipline/api.discipline.ts @@ -79,7 +79,9 @@ export default { suspendReport: () => `${suspend}/report`, reportresult: (id: string) => `${disciplineMain}/result/report/${id}`, - + discardResult:(id:string,commandType:string) => `${discipline}/discard/${id}/${commandType}`, + upLoadFileResult:(id:string) => `${disciplineMain}/result/file/${id}`, + deleteFileResult:(id:string,docId:string) => `${disciplineMain}/result/file/${id}/${docId}`, appealMainList: (status: string, type: string, year: number, page: number, pageSize: number, keyword: string) => `${appeal}/admin?status=${status}&type=${type}&year=${year}&page=${page}&pageSize=${pageSize}&keyword=${keyword}`, appealAdd: () => `${appeal}`, diff --git a/src/modules/11_discipline/components/4_Result/DialogSendToCommand.vue b/src/modules/11_discipline/components/4_Result/DialogSendToCommand.vue index a8c053141..3b0e8def8 100644 --- a/src/modules/11_discipline/components/4_Result/DialogSendToCommand.vue +++ b/src/modules/11_discipline/components/4_Result/DialogSendToCommand.vue @@ -16,11 +16,13 @@ import type { DataListRow, PersonType, } from "@/modules/11_discipline/interface/request/result"; - +import { useRouter, useRoute } from "vue-router"; import DialogHeader from "@/components/DialogHeader.vue"; import http from "@/plugins/http"; import config from "@/app.config"; +const route = useRoute(); +const idPath = ref(route.params.id as string); const type = ref(""); const rows = ref([]); const $q = useQuasar(); @@ -79,23 +81,45 @@ const saveOrder = () => { //ส่งไปออกคำสั่ง const Ordersave = async () => { const id = selected.value.map((r) => r.id); - const body = { - id, - }; - showLoader(); - await http - .put(config.API.reportresult(type.value as string), body) - .then((res: any) => { - success($q, `${props.title}สำเร็จ`); - props.closeModal?.(); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - props.getData?.(); - hideLoader(); - }); + const persons = selected.value.map((r) => r.id); + + if (props.title == "ส่งไปออกคำสั่งลงโทษทางวินัย") { + const body = { + id, + }; + showLoader(); + await http + .put(config.API.reportresult(type.value as string), body) + .then((res: any) => { + success($q, `${props.title}สำเร็จ`); + props.closeModal?.(); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + props.getData?.(); + hideLoader(); + }); + } else if (props.title == "ส่งไปออกคำสั่งงดโทษ/เพิ่มโทษ") { + const body = { + persons, + }; + showLoader(); + await http + .put(config.API.discardResult(idPath.value, type.value as string), body) + .then((res: any) => { + success($q, `${props.title}สำเร็จ`); + props.closeModal?.(); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + props.getData?.(); + hideLoader(); + }); + } }; const emit = defineEmits([ @@ -151,9 +175,15 @@ watchEffect(() => { selected.value = []; type.value = ""; // console.log(props.data.status) - rows.value = props.data.persons.filter( - (item: any) => item.status !== "REPORT" - ); + if (props.title == "ส่งไปออกคำสั่งลงโทษทางวินัย") { + rows.value = props.data.persons.filter( + (item: any) => item.status !== "REPORT" + ); + } else if (props.title == "ส่งไปออกคำสั่งงดโทษ/เพิ่มโทษ") { + rows.value = props.data.persons.filter( + (item: any) => item.status == "REPORT" && item.statusDiscard == 'NEW' + ); + } } }); diff --git a/src/modules/11_discipline/components/4_Result/Form.vue b/src/modules/11_discipline/components/4_Result/Form.vue index 67b2ddf21..6897d6b08 100644 --- a/src/modules/11_discipline/components/4_Result/Form.vue +++ b/src/modules/11_discipline/components/4_Result/Form.vue @@ -28,7 +28,7 @@ const investigateDis = useInvestigateDisStore(); const isReadonly = ref(false); // อ่านได้อย่างเดียว const dataStore = useDisciplineResultStore(); const mixin = useCounterMixin(); -const { date2Thai, hideLoader, dialogConfirm, success, messageError } = mixin; +const { date2Thai, hideLoader, dialogConfirm, success, messageError,showLoader,dialogRemove } = mixin; const router = useRouter(); const route = useRoute(); @@ -69,7 +69,7 @@ const formData = reactive({ titleType: "", oc: "", file: null, - disciplineComplaint_Appeal_Docs: [], + disciplineDisciplinary_DocResults: [], year: new Date().getFullYear(), }); @@ -171,7 +171,8 @@ watch( formData.oc = props.data.resultOc; formData.disciplineType = props.data.resultDisciplineType; formData.titleType = props.data.resultTitleType; - formData.year = props.data.resultYear; + formData.disciplineDisciplinary_DocResults = props.data.disciplineDisciplinary_DocResults; + formData.year = props.data.resultYear ?? 0; mainStore.rowsAdd = props.data.persons; await fetchDatadetail(); await fetchOrganization(); @@ -203,24 +204,24 @@ function changeFormData() { function uploadFile() { /** uploadFile */ - // const Data = new FormData(); - // Data.append("file", formData.file); - // showLoader(); - // http - // .put(config.API.appealUpLoadFile(formData.id), Data) - // .then((res) => { - // console.log(res); - // success($q, "อัปโหลดไฟล์สำเร็จ"); - // props.getData(); - // // router.push(`/discipline/complaints`); - // }) - // .catch((e) => { - // messageError($q, e); - // }) - // .finally(async () => { - // hideLoader(); - // formData.file = null; - // }); + const Data = new FormData(); + Data.append("file", formData.file); + showLoader(); + http + .put(config.API.upLoadFileResult(id.value), Data) + .then((res) => { + console.log(res); + success($q, "อัปโหลดไฟล์สำเร็จ"); + props.fetchData(); + // router.push(`/discipline/complaints`); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + hideLoader(); + formData.file = null; + }); } function downloadFile(link: string) { @@ -228,26 +229,26 @@ function downloadFile(link: string) { } function deleteFile(id: string) { - // dialogRemove($q, () => confirmDelete(id)); + dialogRemove($q, () => confirmDelete(id)); } /** * ยืนยัน ลบ ไฟล์ * @param id id file */ -function confirmDelete(id: string) { - // showLoader(); - // http - // .delete(config.API.appealDeleteFile(formData.id, id)) - // .then((res) => { - // success($q, `ลบไฟล์สำเร็จ`); - // }) - // .catch((e) => { - // messageError($q, e); - // }) - // .finally(() => { - // props.getData(); - // }); +function confirmDelete(docid: string) { + showLoader(); + http + .delete(config.API.deleteFileResult(id.value, docid)) + .then((res) => { + success($q, `ลบไฟล์สำเร็จ`); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + props.fetchData(); + }); } onMounted(async () => {}); @@ -573,7 +574,7 @@ onMounted(async () => {});
{});