API สรุปผล รอ pathName

This commit is contained in:
setthawutttty 2023-12-20 17:04:32 +07:00
parent 5bb31541c9
commit 84a45e3f59
4 changed files with 94 additions and 61 deletions

View file

@ -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<string>(route.params.id as string);
const type = ref<string>("");
const rows = ref<DataListRow[]>([]);
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'
);
}
}
});

View file

@ -28,7 +28,7 @@ const investigateDis = useInvestigateDisStore();
const isReadonly = ref<boolean>(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<FormData>({
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 () => {});
<div class="col-1 self-center text-center">
<q-btn
v-if="formData.file && isReadonly"
v-if="formData.file"
size="14px"
flat
round
@ -586,11 +587,11 @@ onMounted(async () => {});
</div>
</div>
<div
v-if="formData.disciplineComplaint_Appeal_Docs.length > 0"
v-if="formData.disciplineDisciplinary_DocResults.length > 0"
class="col-xs-12 q-pa-sm row"
>
<q-list
v-for="data in formData.disciplineComplaint_Appeal_Docs"
v-for="data in formData.disciplineDisciplinary_DocResults"
:key="data.id"
class="full-width"
bordered

View file

@ -4,7 +4,7 @@ interface FormData {
titleType: string;
oc: string;
file: any
disciplineComplaint_Appeal_Docs: any
disciplineDisciplinary_DocResults: any
year: number | null;
}