Refactoring code module 11_discipline
This commit is contained in:
parent
202fbf27b6
commit
9653ae78cb
58 changed files with 1021 additions and 1305 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import Form from "@/modules/11_discipline/components/2_InvestigateFacts/Form.vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch, type PropType } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import moment from "moment";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import type { CalendarOptions } from "@fullcalendar/core";
|
||||
import type { DataDateMonthObject } from "@/modules/09_leave/interface/response/leave";
|
||||
import type { ExtendHistoryObject } from "@/modules/11_discipline/interface/response/Main";
|
||||
|
||||
import FullCalendar from "@fullcalendar/vue3";
|
||||
import dayGridPlugin from "@fullcalendar/daygrid";
|
||||
import timeGridPlugin from "@fullcalendar/timegrid";
|
||||
import interactionPlugin from "@fullcalendar/interaction";
|
||||
import allLocales from "@fullcalendar/core/locales-all";
|
||||
import listPlugin from "@fullcalendar/list";
|
||||
import moment from "moment";
|
||||
|
||||
import type { CalendarOptions } from "@fullcalendar/core";
|
||||
import type { DataDateMonthObject } from "@/modules/09_leave/interface/response/leave";
|
||||
import type { ExtendHistoryObject } from "@/modules/11_discipline/interface/response/Main";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง
|
||||
const { monthYear2Thai, showLoader, hideLoader, messageError, dateToISO } =
|
||||
|
|
@ -36,7 +37,7 @@ const props = defineProps({
|
|||
default: false,
|
||||
},
|
||||
close: {
|
||||
type: Boolean,
|
||||
type: Function,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
|
@ -163,7 +164,7 @@ watch(
|
|||
unelevated
|
||||
round
|
||||
dense
|
||||
@click="props.close"
|
||||
@click="props.close?.()"
|
||||
style="color: #ff8080; background-color: #ffdede"
|
||||
/>
|
||||
</q-toolbar>
|
||||
|
|
|
|||
|
|
@ -1,24 +1,25 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from "vue";
|
||||
import FullCalendar from "@fullcalendar/vue3";
|
||||
import dayGridPlugin from "@fullcalendar/daygrid";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import type { DataDateMonthObject } from "@/modules/09_leave/interface/response/leave";
|
||||
|
||||
import type { CalendarOptions } from "@fullcalendar/core";
|
||||
|
||||
import timeGridPlugin from "@fullcalendar/timegrid";
|
||||
import interactionPlugin from "@fullcalendar/interaction";
|
||||
import allLocales from "@fullcalendar/core/locales-all";
|
||||
import listPlugin from "@fullcalendar/list";
|
||||
import { useQuasar } from "quasar";
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
|
||||
import type { DataDateMonthObject } from "@/modules/09_leave/interface/response/leave";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import FullCalendar from "@fullcalendar/vue3";
|
||||
import dayGridPlugin from "@fullcalendar/daygrid";
|
||||
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง
|
||||
const { monthYear2Thai, showLoader, hideLoader, messageError } = mixin;
|
||||
|
||||
const $q = useQuasar();
|
||||
/**
|
||||
* Option ของปฏิทิน
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, watch } from "vue";
|
||||
import FormComplaints from "@/modules/11_discipline/components/1_Complaint/Form.vue"; //เรื่องร้องเรียน
|
||||
import FormInvestigatefacts from "@/modules/11_discipline/components/2_InvestigateFacts/Form.vue"; //สืบสวนข้อเท็จจริง
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useInvestigateFactStore } from "@/modules/11_discipline/store/InvestigateFactStore";
|
||||
import { useDisciplineMainStore } from "@/modules/11_discipline/store/main";
|
||||
import { useQuasar } from "quasar";
|
||||
import PopupSendToNext from "@/modules/11_discipline/components/PopupSendToNext.vue";
|
||||
|
||||
import type { ArrayPersonAdd } from "../../interface/response/investigate";
|
||||
import type { FormData } from "@/modules/11_discipline/interface/request/investigateFact";
|
||||
import type {
|
||||
FormData as FormDataComplaint,
|
||||
|
|
@ -15,9 +17,9 @@ import type {
|
|||
ArrayFileList,
|
||||
} from "@/modules/11_discipline/interface/request/complaint";
|
||||
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
import type { ArrayPersonAdd } from "../../interface/response/investigate";
|
||||
import PopupSendToNext from "@/modules/11_discipline/components/PopupSendToNext.vue";
|
||||
import FormComplaints from "@/modules/11_discipline/components/1_Complaint/Form.vue"; //เรื่องร้องเรียน
|
||||
import FormInvestigatefacts from "@/modules/11_discipline/components/2_InvestigateFacts/Form.vue"; //สืบสวนข้อเท็จจริง
|
||||
|
||||
const mainStore = useDisciplineMainStore();
|
||||
|
||||
|
|
@ -110,6 +112,7 @@ const dataComplaints = reactive<FormDataComplaint>({
|
|||
disciplineComplaintDocs: [fileListObjComplaint],
|
||||
});
|
||||
|
||||
/** ดึงข้อมูลร้องเรียน */
|
||||
async function getDataComplaint() {
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -148,6 +151,7 @@ async function getDataComplaint() {
|
|||
});
|
||||
}
|
||||
|
||||
/** ดึงข้อมูลรายละเอียด */
|
||||
function getData() {
|
||||
showLoader();
|
||||
http
|
||||
|
|
@ -228,6 +232,7 @@ function sentInvestigate() {
|
|||
}
|
||||
}
|
||||
|
||||
/** ส่งไปสอบสวน */
|
||||
function sentConfirmNoPerson() {
|
||||
showLoader();
|
||||
http
|
||||
|
|
@ -246,6 +251,7 @@ function sentConfirmNoPerson() {
|
|||
});
|
||||
}
|
||||
|
||||
/** ปิด popup */
|
||||
function closePopup() {
|
||||
modalPopup.value = false;
|
||||
}
|
||||
|
|
@ -320,14 +326,6 @@ function emitPerson(data: FormData[]) {
|
|||
});
|
||||
}
|
||||
|
||||
/** โหลดข้อมูลเมื่อเข้าหน้านี้ */
|
||||
onMounted(() => {
|
||||
getData();
|
||||
if (store.tabMenu == "complaints") {
|
||||
getDataComplaint();
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => store.tabMenu,
|
||||
() => {
|
||||
|
|
@ -338,6 +336,14 @@ watch(
|
|||
}
|
||||
}
|
||||
);
|
||||
|
||||
/** โหลดข้อมูลเมื่อเข้าหน้านี้ */
|
||||
onMounted(() => {
|
||||
getData();
|
||||
if (store.tabMenu == "complaints") {
|
||||
getDataComplaint();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
|
|
@ -1,33 +1,32 @@
|
|||
<script setup lang="ts">
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { onMounted, ref, watch, reactive, computed } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRoute } from "vue-router";
|
||||
import { onMounted, ref, watch, reactive, computed } from "vue";
|
||||
import moment from "moment";
|
||||
import PopupSendToNext from "@/modules/11_discipline/components/PopupSendToNext.vue";
|
||||
import DialogDirector from "@/modules/11_discipline/components/DialogDirector.vue";
|
||||
import DialogAddPersonal from "@/components/Dialogs/AddPersonal.vue";
|
||||
import Table from "@/modules/11_discipline/components/DirectorTable.vue";
|
||||
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useInvestigateDisStore } from "@/modules/11_discipline/store/InvestigateDisStore";
|
||||
import { useInvestigateFactStore } from "@/modules/11_discipline/store/InvestigateFactStore";
|
||||
import { useDisciplineMainStore } from "@/modules/11_discipline/store/main";
|
||||
|
||||
import type { FormData } from "@/modules/11_discipline/interface/request/investigateFact";
|
||||
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
|
||||
|
||||
import CalandarDialog from "@/modules/11_discipline/components/2_InvestigateFacts/CalandarDialog.vue";
|
||||
import DialogDuty from "@/modules/11_discipline/components/DialogDuty.vue";
|
||||
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
||||
|
||||
import type { FormData } from "@/modules/11_discipline/interface/request/investigateFact";
|
||||
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
|
||||
import Table from "@/modules/11_discipline/components/DirectorTable.vue";
|
||||
import DialogDirector from "@/modules/11_discipline/components/DialogDirector.vue";
|
||||
import PopupSendToNext from "@/modules/11_discipline/components/PopupSendToNext.vue";
|
||||
import DialogAddPersonal from "@/components/Dialogs/AddPersonal.vue";
|
||||
|
||||
const modalPersonal = ref<boolean>(false);
|
||||
const personId = ref<string>("");
|
||||
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const checkRoutePermisson = ref<boolean>(
|
||||
route.name == "disciplineInvestigatefactsDetail"
|
||||
);
|
||||
|
|
@ -150,6 +149,8 @@ const initialPagination = ref<any>({
|
|||
rowsPerPage: 0,
|
||||
});
|
||||
|
||||
const organization = ref<OptionData>();
|
||||
|
||||
const calendarModal = ref<boolean>(false);
|
||||
const calendarModalclose = () => (calendarModal.value = !calendarModal.value);
|
||||
|
||||
|
|
@ -185,7 +186,6 @@ function onSubmit() {
|
|||
});
|
||||
}
|
||||
|
||||
const organization = ref<OptionData>();
|
||||
/**
|
||||
* ฟังชั้นคำนวณเวลาวันที่สิ้นสุดจาก วันที่สิ้นสุดการสืบสวน
|
||||
* @param val จำนวนวันที่ต้องการขยาย
|
||||
|
|
@ -198,6 +198,7 @@ async function calEndDate(val: string) {
|
|||
);
|
||||
}
|
||||
|
||||
/** reset วันที่สืบสวน */
|
||||
function resetExtend() {
|
||||
formData.investigationDateEnd = props.data.investigationDateEnd;
|
||||
formData.investigationDaysExtend = 0;
|
||||
|
|
@ -213,6 +214,391 @@ function clickClose() {
|
|||
modal.value = false;
|
||||
}
|
||||
|
||||
function uploadFileRelevant() {
|
||||
const Data = new FormData();
|
||||
Data.append("file", formData.evidenceFiles);
|
||||
showLoader();
|
||||
http
|
||||
.put(config.API.investigateRelevantUploadFile(formData.id), Data)
|
||||
.then((res) => {
|
||||
countNum.value = 2;
|
||||
props.getData();
|
||||
success($q, "อัปโหลดไฟล์สำเร็จ");
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
formData.evidenceFiles = null;
|
||||
});
|
||||
}
|
||||
|
||||
/** อัปโหลดไฟล์ */
|
||||
function uploadFile() {
|
||||
const Data = new FormData();
|
||||
Data.append("file", formData.documentFile);
|
||||
showLoader();
|
||||
http
|
||||
.put(config.API.investigateUploadFile(formData.id), Data)
|
||||
.then((res) => {
|
||||
success($q, "อัปโหลดไฟล์สำเร็จ");
|
||||
countNum.value = 3;
|
||||
props.getData();
|
||||
// router.push(`/discipline/complaints`);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
formData.documentFile = null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบไฟล์
|
||||
* @param id id file
|
||||
*/
|
||||
function deleteFileRelevant(id: string) {
|
||||
dialogRemove($q, () => confirmDeleteRelevant(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* ยืนยัน ลบ ไฟล์
|
||||
* @param id id file
|
||||
*/
|
||||
function confirmDeleteRelevant(id: string) {
|
||||
showLoader();
|
||||
http
|
||||
.delete(config.API.investigateRelevantFileDelete(formData.id, id))
|
||||
.then((res) => {
|
||||
success($q, `ลบไฟล์สำเร็จ`);
|
||||
props.getData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {});
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบไฟล์
|
||||
* @param id id file
|
||||
*/
|
||||
function deleteFile(id: string) {
|
||||
dialogRemove($q, () => confirmDelete(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* ยืนยัน ลบ ไฟล์
|
||||
* @param id id file
|
||||
*/
|
||||
function confirmDelete(id: string) {
|
||||
showLoader();
|
||||
http
|
||||
.delete(config.API.investigateFileDelete(formData.id, id))
|
||||
.then((res) => {
|
||||
success($q, `ลบไฟล์สำเร็จ`);
|
||||
props.getData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {});
|
||||
}
|
||||
|
||||
async function addPerson(data: any) {
|
||||
await mainStore.fetchData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังชั่น รับค่าจาก คอมโพเเนน
|
||||
* @param returnData ค่าที่ได้คืนมา
|
||||
*/
|
||||
function handleSave(returnData: any) {
|
||||
addPerson(returnData);
|
||||
changeFormData();
|
||||
toggleModal();
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล active */
|
||||
async function getActive() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
getOc(res.data.result.activeId);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** ดึงข้อมูลหน่วยงาน */
|
||||
async function getOc(activeId: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgByIdSystem(activeId, route.meta.Key as string))
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result.map((item: any) => ({
|
||||
organizationId: item.orgTreeId,
|
||||
organizationName: item.orgName,
|
||||
}));
|
||||
|
||||
investigateFactStore.ocListFn(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
async function updatePagingProp(rowPerpage: number, pageCurrent: number) {
|
||||
rowsPerPage.value = rowPerpage;
|
||||
page.value = pageCurrent;
|
||||
await getList();
|
||||
}
|
||||
|
||||
/** ดึงข้อมูลรายละเอียดสืบสวน */
|
||||
async function getList() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.directorList(
|
||||
page.value,
|
||||
rowsPerPage.value,
|
||||
filterKeyword.value
|
||||
)
|
||||
)
|
||||
//
|
||||
.then((res) => {
|
||||
maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value);
|
||||
const data = res.data.result.data;
|
||||
investigateDis.fecthDirector(data);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* เก็บข้อมูล กรรม ลง ตัวแปร
|
||||
* @param data ข้อมูลกรรมการ
|
||||
*/
|
||||
function returnDirector(data: any) {
|
||||
const dataList = data.map((item: any) => item.id);
|
||||
formData.directors = dataList;
|
||||
|
||||
rows.value = data;
|
||||
changeFormData();
|
||||
clickClose();
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบรายชื่อบุคคล
|
||||
* @param id บุคคล
|
||||
*/
|
||||
function deletePerson(id: string) {
|
||||
changeFormData();
|
||||
const dataRow = mainStore.rowsAdd;
|
||||
const updatedRows = dataRow.filter((item: any) => item.personId !== id);
|
||||
mainStore.rowsAdd = updatedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบ รายชื่อ กรรมการ
|
||||
* @param id กรรมการ
|
||||
*/
|
||||
function deleteDirector(id: string) {
|
||||
changeFormData();
|
||||
const dataRow = rows.value;
|
||||
const updatedRows = dataRow.filter((item: any) => item.id !== id);
|
||||
rows.value = updatedRows;
|
||||
|
||||
const dataList = updatedRows.map((item: any) => item.id);
|
||||
formData.directors = dataList;
|
||||
}
|
||||
|
||||
/** ฟังก์ชั่นเช็คการแก้ไขฟอร์มแล้วไม่ได้กดบันทึก */
|
||||
function changeFormData() {
|
||||
isSave.value = true;
|
||||
|
||||
if (organization.value) {
|
||||
formData.organizationId = organization.value.id;
|
||||
formData.organization = organization.value.name;
|
||||
}
|
||||
}
|
||||
|
||||
/** เช็ควันที่สิ้นสุดต้องมากกว่า หรือเท่ากับวันเริ่ม */
|
||||
function changeFormDataDate() {
|
||||
isSave.value = true;
|
||||
const startDate = new Date(formData.investigationDateStart as Date);
|
||||
const endDate = new Date(formData.investigationDateEnd as Date);
|
||||
|
||||
if (startDate > endDate) {
|
||||
formData.investigationDateEnd = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** เปิด ปฏิทิน */
|
||||
function calendarOpen() {
|
||||
calendarModal.value = true;
|
||||
}
|
||||
|
||||
/** เปลี่ยนสี เมื่อ readonly
|
||||
* @param val true/false
|
||||
*/
|
||||
function inputEdit(val: boolean) {
|
||||
return {
|
||||
"full-width cursor-pointer ": val,
|
||||
"full-width cursor-pointer inputgreen": !val,
|
||||
};
|
||||
}
|
||||
|
||||
/** เปลี่ยนสี เมื่อ readonly
|
||||
* @param val true/false
|
||||
*/
|
||||
function inputEditExtend(val: boolean) {
|
||||
if (formData.investigationExtendHistory.length > 0) {
|
||||
return {
|
||||
"full-width cursor-pointer ": val,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
"full-width cursor-pointer ": val,
|
||||
"full-width cursor-pointer inputgreen": !val,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/** เปิด dialog ส่งรายชื่อไปออกคำสั่งยุติเรื่อง*/
|
||||
function openModal() {
|
||||
modalPopup.value = true;
|
||||
}
|
||||
|
||||
/** ปิด dialog ส่งรายชื่อไปออกคำสั่งยุติเรื่อง*/
|
||||
function closePopup() {
|
||||
modalPopup.value = false;
|
||||
}
|
||||
|
||||
/** ดึงข้อมูลรายละเอียด */
|
||||
function fetchData() {
|
||||
setTimeout(() => {
|
||||
props.getData();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
/** ส่งรายชื่อไปออกคำสั่งยุติเรื่อง */
|
||||
function emitPerson(data: FormData[]) {
|
||||
const dataMapId = data.map((item: FormData) => item.id);
|
||||
showLoader();
|
||||
http
|
||||
.post(config.API.investigateReport(), {
|
||||
Id: dataMapId,
|
||||
})
|
||||
.then((res) => {
|
||||
getActive();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** เปิด dialog กรรมการ */
|
||||
function openEditDirector(data: any) {
|
||||
editDirectorId.value = data.directorId;
|
||||
modalEditDirector.value = true;
|
||||
dutyVal.value = data.duty;
|
||||
commandNoVal.value = data.commandNo;
|
||||
}
|
||||
|
||||
/** ปิด dialog กรรมการ */
|
||||
function closeEditDirector() {
|
||||
modalEditDirector.value = false;
|
||||
}
|
||||
|
||||
/** บันทึก กรรมการ */
|
||||
async function saveDuty(id: string, duty: string, resolution: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.investigateEditDuty(formData.id, id), {
|
||||
duty: duty,
|
||||
commandNo: resolution,
|
||||
})
|
||||
.then((res: any) => {
|
||||
success($q, "บันทึกสำเร็จ");
|
||||
closeEditDirector();
|
||||
props.getData?.();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** ดูข้อมูลในทะเบียนประวัติ */
|
||||
function onclickViewinfo(id: string) {
|
||||
modalPersonal.value = true;
|
||||
personId.value = id;
|
||||
}
|
||||
|
||||
/** อัพเดต ปิด/เปิดเมนู ทะเบียนประวัติ */
|
||||
function updatemodalPersonal(modal: boolean) {
|
||||
modalPersonal.value = modal;
|
||||
}
|
||||
|
||||
/**
|
||||
* function ค้นหาข้อมูลใน option
|
||||
* @param val คำค้นหา
|
||||
* @param update function
|
||||
*/
|
||||
function filterOptionFn(val: string, update: Function) {
|
||||
update(() => {
|
||||
option.value = investigateFactStore.organizationIdOp.filter(
|
||||
(e: any) => e.name.search(val) !== -1
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function ค้นหาข้อมูลใน option
|
||||
* @param val คำค้นหา
|
||||
* @param update function
|
||||
*/
|
||||
function filterOptionFnStatusResult(val: string, update: Function) {
|
||||
update(() => {
|
||||
optionStatusResult.value = mainStore.statusResultOptions.filter(
|
||||
(e: any) => e.name.search(val) !== -1
|
||||
);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* function ค้นหาข้อมูลใน option
|
||||
* @param val คำค้นหา
|
||||
* @param update function
|
||||
*/
|
||||
function filterOptionFnCauseText(val: string, update: Function) {
|
||||
update(() => {
|
||||
optionCauseText.value = mainStore.causeTextOptions.filter(
|
||||
(e: any) => e.name.search(val) !== -1
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* เช็คข้อมูลจาก props
|
||||
* เมื่อมีข้อมูล
|
||||
|
|
@ -322,348 +708,6 @@ watch(props.data, async () => {
|
|||
}
|
||||
});
|
||||
|
||||
function uploadFileRelevant() {
|
||||
const Data = new FormData();
|
||||
Data.append("file", formData.evidenceFiles);
|
||||
showLoader();
|
||||
http
|
||||
.put(config.API.investigateRelevantUploadFile(formData.id), Data)
|
||||
.then((res) => {
|
||||
countNum.value = 2;
|
||||
props.getData();
|
||||
success($q, "อัปโหลดไฟล์สำเร็จ");
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
formData.evidenceFiles = null;
|
||||
});
|
||||
}
|
||||
|
||||
/** อัปโหลดไฟล์ */
|
||||
function uploadFile() {
|
||||
const Data = new FormData();
|
||||
Data.append("file", formData.documentFile);
|
||||
showLoader();
|
||||
http
|
||||
.put(config.API.investigateUploadFile(formData.id), Data)
|
||||
.then((res) => {
|
||||
success($q, "อัปโหลดไฟล์สำเร็จ");
|
||||
countNum.value = 3;
|
||||
props.getData();
|
||||
// router.push(`/discipline/complaints`);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
formData.documentFile = null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* เปิดลิงก์ไฟล์
|
||||
* @param link รับมาเป็น https ลิงก์
|
||||
*/
|
||||
function downloadFile(link: string) {
|
||||
window.open(link, "_blank");
|
||||
}
|
||||
|
||||
/**
|
||||
* เปิดลิงก์ไฟล์
|
||||
* @param link รับมาเป็น https ลิงก์
|
||||
*/
|
||||
function downloadFileRelevant(link: string) {
|
||||
window.open(link, "_blank");
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบไฟล์
|
||||
* @param id id file
|
||||
*/
|
||||
function deleteFileRelevant(id: string) {
|
||||
dialogRemove($q, () => confirmDeleteRelevant(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* ยืนยัน ลบ ไฟล์
|
||||
* @param id id file
|
||||
*/
|
||||
function confirmDeleteRelevant(id: string) {
|
||||
showLoader();
|
||||
http
|
||||
.delete(config.API.investigateRelevantFileDelete(formData.id, id))
|
||||
.then((res) => {
|
||||
success($q, `ลบไฟล์สำเร็จ`);
|
||||
props.getData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {});
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบไฟล์
|
||||
* @param id id file
|
||||
*/
|
||||
function deleteFile(id: string) {
|
||||
dialogRemove($q, () => confirmDelete(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* ยืนยัน ลบ ไฟล์
|
||||
* @param id id file
|
||||
*/
|
||||
function confirmDelete(id: string) {
|
||||
showLoader();
|
||||
http
|
||||
.delete(config.API.investigateFileDelete(formData.id, id))
|
||||
.then((res) => {
|
||||
success($q, `ลบไฟล์สำเร็จ`);
|
||||
props.getData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {});
|
||||
}
|
||||
async function addPerson(data: any) {
|
||||
await mainStore.fetchData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังชั่น รับค่าจาก คอมโพเเนน
|
||||
* @param returnData ค่าที่ได้คืนมา
|
||||
*/
|
||||
function handleSave(returnData: any) {
|
||||
addPerson(returnData);
|
||||
changeFormData();
|
||||
toggleModal();
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล active */
|
||||
async function getActive() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
getOc(res.data.result.activeId);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
async function getOc(activeId: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgByIdSystem(activeId, route.meta.Key as string))
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result.map((item: any) => ({
|
||||
organizationId: item.orgTreeId,
|
||||
organizationName: item.orgName,
|
||||
}));
|
||||
|
||||
investigateFactStore.ocListFn(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
|
||||
// http.get(config.API.typeOc()).then((res) => {
|
||||
// const data = res.data.result;
|
||||
// investigateFactStore.ocListFn(data);
|
||||
// });
|
||||
}
|
||||
|
||||
async function updatePagingProp(rowPerpage: number, pageCurrent: number) {
|
||||
rowsPerPage.value = rowPerpage;
|
||||
page.value = pageCurrent;
|
||||
await getList();
|
||||
}
|
||||
|
||||
async function getList() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.directorList(
|
||||
page.value,
|
||||
rowsPerPage.value,
|
||||
filterKeyword.value
|
||||
)
|
||||
)
|
||||
//
|
||||
.then((res) => {
|
||||
maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value);
|
||||
const data = res.data.result.data;
|
||||
investigateDis.fecthDirector(data);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function returnDirector(data: any) {
|
||||
const dataList = data.map((item: any) => item.id);
|
||||
formData.directors = dataList;
|
||||
|
||||
rows.value = data;
|
||||
changeFormData();
|
||||
clickClose();
|
||||
}
|
||||
|
||||
function deletePerson(id: string) {
|
||||
changeFormData();
|
||||
const dataRow = mainStore.rowsAdd;
|
||||
const updatedRows = dataRow.filter((item: any) => item.personId !== id);
|
||||
mainStore.rowsAdd = updatedRows;
|
||||
}
|
||||
|
||||
function deleteDirector(id: string) {
|
||||
changeFormData();
|
||||
const dataRow = rows.value;
|
||||
const updatedRows = dataRow.filter((item: any) => item.id !== id);
|
||||
rows.value = updatedRows;
|
||||
|
||||
const dataList = updatedRows.map((item: any) => item.id);
|
||||
formData.directors = dataList;
|
||||
}
|
||||
|
||||
/** ฟังก์ชั่นเช็คการแก้ไขฟอร์มแล้วไม่ได้กดบันทึก */
|
||||
function changeFormData() {
|
||||
isSave.value = true;
|
||||
|
||||
if (organization.value) {
|
||||
formData.organizationId = organization.value.id;
|
||||
formData.organization = organization.value.name;
|
||||
}
|
||||
}
|
||||
|
||||
/** เช็ควันที่สิ้นสุดต้องมากกว่า หรือเท่ากับวันเริ่ม */
|
||||
function changeFormDataDate() {
|
||||
isSave.value = true;
|
||||
const startDate = new Date(formData.investigationDateStart as Date);
|
||||
const endDate = new Date(formData.investigationDateEnd as Date);
|
||||
|
||||
if (startDate > endDate) {
|
||||
formData.investigationDateEnd = null;
|
||||
}
|
||||
}
|
||||
|
||||
function calendarOpen() {
|
||||
calendarModal.value = true;
|
||||
}
|
||||
|
||||
/** เปลี่ยนสี เมื่อ readonly
|
||||
* @param val true/false
|
||||
*/
|
||||
function inputEdit(val: boolean) {
|
||||
return {
|
||||
"full-width cursor-pointer ": val,
|
||||
"full-width cursor-pointer inputgreen": !val,
|
||||
};
|
||||
}
|
||||
|
||||
/** เปลี่ยนสี เมื่อ readonly
|
||||
* @param val true/false
|
||||
*/
|
||||
function inputEditExtend(val: boolean) {
|
||||
if (formData.investigationExtendHistory.length > 0) {
|
||||
return {
|
||||
"full-width cursor-pointer ": val,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
"full-width cursor-pointer ": val,
|
||||
"full-width cursor-pointer inputgreen": !val,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function openModal() {
|
||||
modalPopup.value = true;
|
||||
}
|
||||
function closePopup() {
|
||||
modalPopup.value = false;
|
||||
}
|
||||
|
||||
function fetchData() {
|
||||
setTimeout(() => {
|
||||
props.getData();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function emitPerson(data: FormData[]) {
|
||||
const dataMapId = data.map((item: FormData) => item.id);
|
||||
showLoader();
|
||||
http
|
||||
.post(config.API.investigateReport(), {
|
||||
Id: dataMapId,
|
||||
})
|
||||
.then((res) => {
|
||||
getActive();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function openEditDirector(data: any) {
|
||||
editDirectorId.value = data.directorId;
|
||||
modalEditDirector.value = true;
|
||||
dutyVal.value = data.duty;
|
||||
commandNoVal.value = data.commandNo;
|
||||
}
|
||||
|
||||
function closeEditDirector() {
|
||||
modalEditDirector.value = false;
|
||||
}
|
||||
|
||||
async function saveDuty(id: string, duty: string, resolution: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.investigateEditDuty(formData.id, id), {
|
||||
duty: duty,
|
||||
commandNo: resolution,
|
||||
})
|
||||
.then((res: any) => {
|
||||
success($q, "บันทึกสำเร็จ");
|
||||
closeEditDirector();
|
||||
props.getData?.();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function onclickViewinfo(id: string) {
|
||||
modalPersonal.value = true;
|
||||
personId.value = id;
|
||||
}
|
||||
|
||||
function updatemodalPersonal(modal: boolean) {
|
||||
modalPersonal.value = modal;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formData.investigationDetail,
|
||||
(newValue, oldValue) => {
|
||||
|
|
@ -690,44 +734,6 @@ watch(
|
|||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* function ค้นหาข้อมูลใน option
|
||||
* @param val คำค้นหา
|
||||
* @param update function
|
||||
*/
|
||||
function filterOptionFn(val: string, update: Function) {
|
||||
update(() => {
|
||||
option.value = investigateFactStore.organizationIdOp.filter(
|
||||
(e: any) => e.name.search(val) !== -1
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function ค้นหาข้อมูลใน option
|
||||
* @param val คำค้นหา
|
||||
* @param update function
|
||||
*/
|
||||
function filterOptionFnStatusResult(val: string, update: Function) {
|
||||
update(() => {
|
||||
optionStatusResult.value = mainStore.statusResultOptions.filter(
|
||||
(e: any) => e.name.search(val) !== -1
|
||||
);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* function ค้นหาข้อมูลใน option
|
||||
* @param val คำค้นหา
|
||||
* @param update function
|
||||
*/
|
||||
function filterOptionFnCauseText(val: string, update: Function) {
|
||||
update(() => {
|
||||
optionCauseText.value = mainStore.causeTextOptions.filter(
|
||||
(e: any) => e.name.search(val) !== -1
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
mainStore.rowsAdd = [];
|
||||
getActive();
|
||||
|
|
|
|||
|
|
@ -1,32 +1,24 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, useAttrs, onMounted, watch } from "vue";
|
||||
|
||||
import router from "@/router";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { ref, useAttrs, onMounted, watch } from "vue";
|
||||
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
|
||||
import router from "@/router";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useInvestigateFactStore } from "@/modules/11_discipline/store/InvestigateFactStore";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
|
||||
const dataInvestigate = useInvestigateFactStore();
|
||||
const mixin = useCounterMixin();
|
||||
const { messageError, showLoader, hideLoader } = mixin;
|
||||
const option = ref<any[]>(dataInvestigate.statusOptions);
|
||||
const $q = useQuasar(); //ใช้ noti quasar
|
||||
const mixin = useCounterMixin();
|
||||
const dataInvestigate = useInvestigateFactStore();
|
||||
const { messageError, showLoader, hideLoader } = mixin;
|
||||
|
||||
const option = ref<any[]>(dataInvestigate.statusOptions);
|
||||
|
||||
/** ค้นหาข้อมูลในตาราง */
|
||||
const filterKeyword = ref<string>("");
|
||||
const filterRef = ref<HTMLInputElement | null>(null);
|
||||
function resetFilter() {
|
||||
filterKeyword.value = "";
|
||||
if (filterRef.value) {
|
||||
filterRef.value.focus();
|
||||
getList();
|
||||
}
|
||||
}
|
||||
const statusFilter = ref<string>("NEW");
|
||||
const currentPage = ref<number>(1);
|
||||
const maxPage = ref<number>(1);
|
||||
|
|
@ -43,23 +35,18 @@ const pagination = ref({
|
|||
rowsPerPage: rowsPerPage.value,
|
||||
});
|
||||
|
||||
watch(
|
||||
() => currentPage.value,
|
||||
() => {
|
||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
||||
const attrs = ref<any>(useAttrs());
|
||||
|
||||
/** ล้างค่า Input */
|
||||
function resetFilter() {
|
||||
filterKeyword.value = "";
|
||||
if (filterRef.value) {
|
||||
filterRef.value.focus();
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => pagination.value.rowsPerPage,
|
||||
() => {
|
||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
||||
currentPage.value = 1;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** ดึงข้อมูลบสวน */
|
||||
async function getList() {
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -86,8 +73,6 @@ async function getList() {
|
|||
});
|
||||
}
|
||||
|
||||
const attrs = ref<any>(useAttrs());
|
||||
|
||||
/**
|
||||
* ไปหน้าแก้ไข
|
||||
* @param id ไอดีเฉพาะ รายบุคคล
|
||||
|
|
@ -105,10 +90,6 @@ async function detailPage(id: string) {
|
|||
router.push(`/discipline-detail/investigatefacts/${id}`);
|
||||
}
|
||||
|
||||
function filterFn() {
|
||||
getList();
|
||||
}
|
||||
|
||||
/**
|
||||
* function ค้นหาข้อมูลใน option
|
||||
* @param val คำค้นหา
|
||||
|
|
@ -123,6 +104,23 @@ function filterOptionFn(val: string, update: Function) {
|
|||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
() => currentPage.value,
|
||||
() => {
|
||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => pagination.value.rowsPerPage,
|
||||
() => {
|
||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
||||
currentPage.value = 1;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
/**เมื่อเริ่มโหลดหน้า
|
||||
* ส่งข้อมูลจำลองไปยัง store
|
||||
*/
|
||||
|
|
@ -180,7 +178,7 @@ onMounted(async () => {
|
|||
ref="filterRef"
|
||||
outlined
|
||||
placeholder="ค้นหา"
|
||||
@keydown.enter.prevent="filterFn"
|
||||
@keydown.enter.prevent="getList()"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="filterKeyword == ''" name="search" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue