Refactoring code module 11_discipline
This commit is contained in:
parent
202fbf27b6
commit
9653ae78cb
58 changed files with 1021 additions and 1305 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue