diff --git a/src/components/Dialogs/AddPersonal.vue b/src/components/Dialogs/AddPersonal.vue index 2581a16c7..17ef8be76 100644 --- a/src/components/Dialogs/AddPersonal.vue +++ b/src/components/Dialogs/AddPersonal.vue @@ -1,11 +1,10 @@ @@ -635,7 +637,7 @@ onMounted(async () => { color="red" class="q-ml-sm" icon="mdi-delete-outline" - @click="deletePerson(props.row.id)" + @click="deletePerson(props.row.personId)" >ลบผู้ถูกร้องเรียน @@ -1302,11 +1304,11 @@ onMounted(async () => { @@ -1332,4 +1334,4 @@ onMounted(async () => { min-height: 25px; } -@/modules/11_discipline/store/store \ No newline at end of file +@/modules/11_discipline/store/store diff --git a/src/modules/11_discipline/components/3_InvestigateDisciplinary/EditPage.vue b/src/modules/11_discipline/components/3_InvestigateDisciplinary/EditPage.vue index 2af0d5d41..c1b962942 100644 --- a/src/modules/11_discipline/components/3_InvestigateDisciplinary/EditPage.vue +++ b/src/modules/11_discipline/components/3_InvestigateDisciplinary/EditPage.vue @@ -2,14 +2,16 @@ import { onMounted, reactive, ref, watch } from "vue"; import { useQuasar } from "quasar"; import { useRouter, useRoute } from "vue-router"; -import type { QTableProps } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; /**import component*/ import FormComplaints from "@/modules/11_discipline/components/1_Complaint/Form.vue"; //เรื่องร้องเรียน import FormInvestigatefacts from "@/modules/11_discipline/components/2_InvestigateFacts/Form.vue"; //สืบสวนข้อเท็จจริง import FormDisciplinary from "@/modules/11_discipline/components/3_InvestigateDisciplinary/Form.vue"; // สอบสวนความผิดทางวินัย -import type { PersonsArray } from "@/modules/11_discipline/interface/request/disciplinary"; +import type { + PersonsArray, + Persons, +} from "@/modules/11_discipline/interface/request/disciplinary"; import type { FormData as FormDataComplaint, ArrayPerson, @@ -22,6 +24,9 @@ import type { FormData as FormInvestigateFact } from "@/modules/11_discipline/in /**import store*/ import { useCounterMixin } from "@/stores/mixin"; import { useInvestigateDisStore } from "@/modules/11_discipline/store/InvestigateDisStore"; +import { useDisciplineMainStore } from "@/modules/11_discipline/store/main"; + +const mainStore = useDisciplineMainStore(); const $q = useQuasar(); const mixin = useCounterMixin(); @@ -86,7 +91,8 @@ async function fetchDetailInvestigate() { dataList.disciplineInvestigateRelevantDocs; dataInvestigatefacts.investigationStatusResult = dataList.investigationStatusResult; - dataInvestigatefacts.investigationExtendStatus = dataList.investigationExtendStatus; + dataInvestigatefacts.investigationExtendStatus = + dataList.investigationExtendStatus; dataInvestigatefacts.investigationDaysExtend = dataList.investigationDaysExtend; }) @@ -167,8 +173,9 @@ const onSubmit = async (id: string) => { }; /** ยืนยัน ส่งไปออกคำสั่ง */ -function sentIssue() { - console.log("sent"); +const respondentRows = ref(); +async function sentIssue() { + respondentRows.value = await store.rowSent.filter((x) => !x.report); //x.report === false modalPopup.value = true; } @@ -214,12 +221,6 @@ function cancelInvestigate() { ); } -/** ฟังชั่น ส่งไปออกคำสั่ง*/ -function confirmSentIssue() { - console.log("sent"); - modalPopup.value = true; -} - /** ฟังชั่น ยุติเรื่อง*/ function confirmEndInvestigate() { console.log("sent"); @@ -303,7 +304,6 @@ const fileListObjComplaint = reactive({ function emitPerson(data: PersonsArray[]) { console.log(data); const dataMapId = data.map((item: PersonsArray) => item.id); - console.log(dataMapId); showLoader(); http .put(config.API.disciplinarySuspend(id.value), { @@ -321,104 +321,6 @@ function emitPerson(data: PersonsArray[]) { }); } -/** หัวตาราง */ -const columns = ref([ - { - name: "info", - align: "left", - label: "", - sortable: false, - field: "info", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "no", - align: "left", - label: "ลำดับ", - sortable: false, - field: "no", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "idcard", - align: "left", - label: "เลขบัตรประชาชน", - sortable: true, - field: "idcard", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "name", - align: "left", - label: "ชื่อ - นามสกุล", - sortable: true, - field: "name", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "posNo", - align: "left", - label: "ตำแหน่งเลขที่", - sortable: true, - field: "posNo", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "position", - align: "left", - label: "ตำแหน่ง", - sortable: true, - field: "position", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "positionLevel", - align: "left", - label: "ระดับ", - sortable: true, - field: "positionLevel", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "salary", - align: "left", - label: "เงินเดือน", - sortable: true, - field: "salary", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "organization", - align: "left", - label: "หน่วยงาน", - sortable: true, - field: "organization", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, -]); - -/** หัวข้อที่เเสดงในตาราง */ -const visibleColumns = ref([ - "info", - "no", - "idcard", - "name", - "posNo", - "position", - "positionLevel", - "salary", - "organization", -]); - const dataComplaints = reactive({ id: "", respondentType: "", @@ -555,9 +457,10 @@ const dataInvestigatefacts = reactive({ :modal="modalPopup" :close="closePopup" title="ส่งไปพักราชการ" - :rows="store.rowSent" - :columns="columns" - :visibleColumns="visibleColumns" + :rows="respondentRows" + :columns="mainStore.columnsRespondent" + :visibleColumns="mainStore.visibleColumnsRespondent" + :checked-val="false" @return-person="emitPerson" /> diff --git a/src/modules/11_discipline/components/3_InvestigateDisciplinary/Form.vue b/src/modules/11_discipline/components/3_InvestigateDisciplinary/Form.vue index f0db9c131..465bb607f 100644 --- a/src/modules/11_discipline/components/3_InvestigateDisciplinary/Form.vue +++ b/src/modules/11_discipline/components/3_InvestigateDisciplinary/Form.vue @@ -10,7 +10,6 @@ import type { QTableProps } from "quasar"; import type { FormData, DisciplinaryRef, - Persons, Director, } from "@/modules/11_discipline/interface/request/disciplinary"; import type { @@ -199,6 +198,7 @@ function calEndDate(val: string) { formData.disciplinaryDateEnd = new Date( dateNew.setDate(date.getDate() + Number(val)) ); + changeFormData(); } /** @@ -210,6 +210,10 @@ function onSubmit() { dialogConfirm( $q, async () => { + if (mainStore.rowsAdd) { + formData.persons = mainStore.rowsAdd; + } + emit("submit:disciplinary", formData); }, "ยืนยันการบันทึกข้อมูล", @@ -273,6 +277,8 @@ async function fetchDatadetail() { formData.disciplinaryCauseText = props.data.disciplinaryCauseText; formData.disciplinaryResult = props.data.disciplinaryResult; + mainStore.rowsAdd = props.data.persons; + /** MAP รายชื่อกรรมการ หน้าหลัก */ const dataMap = props.data.director.map((item: any) => ({ id: item.directorId, @@ -291,36 +297,26 @@ async function fetchDatadetail() { } } -/** - * function add ผู้ถูกร้องเรียนใน table - * @param data รายชื่อ ผู้ถูกร้องเรียน - */ -async function addPerson(data: Persons[]) { - if (!data) { - return; - } - const newPerson: Persons[] = Array.from(data).map((e) => ({ - personId: e.personId, //id อ้างอิง profile - idcard: e.idcard, //รหัสบัตรประชาชน - prefix: e.prefix, //คำนำหน้า - firstName: e.firstName, //ชื่อ - lastName: e.lastName, //นามสกุล - posNo: e.posNo, //เลขที่ตำแหน่ง - position: e.position, //ตำแหน่ง - positionLevel: e.positionLevel, //ระดับ - salary: e.salary, //เงินเดือน - organization: e.organization, //สังกัด - name: `${e.prefix}${e.firstName} ${e.lastName}`, - })); - const mergedArray = [...formData.persons, ...newPerson]; - formData.persons = mergedArray; - investigateDis.rowSent = formData.persons; +async function addPerson(data: any) { + await mainStore.fetchData(data); toggleModal(); } -/** function รับข้อมูลรายชื่อผู้ถูกร้องเรียน*/ +/** + * ฟังชั่น รับค่าจาก คอมโพเเนน + * @param returnData ค่าที่ได้คืนมา + */ function handleSave(returnData: any) { addPerson(returnData); + changeFormData(); + toggleModal(); +} + +function deletePerson(id: string) { + changeFormData(); + const dataRow = mainStore.rowsAdd; + const updatedRows = dataRow.filter((item: any) => item.personId !== id); + mainStore.rowsAdd = updatedRows; } /** @@ -413,10 +409,11 @@ async function updatePaging(rpp: number, p: number) { * function return รายชื่อกรรมการที่เลือก * @param data รายชื่อกรรมการที่เลือก */ -async function returnDirector(data: any) { +function returnDirector(data: any) { const dataList = data.map((item: any) => item.id); formData.directors = dataList; rows.value = data; + changeFormData(); clickClose(); } @@ -437,12 +434,24 @@ function changeFormData() { /** Hook */ onMounted(async () => { + mainStore.rowsAdd = []; await fetchOrganization(); }); + + + แจ้งเตือน + ยังไม่ได้บันทึกข้อมูล + + + @@ -466,7 +475,8 @@ onMounted(async () => { :rules="[(val) => !!val || `${'กรุณาเลือกผู้ร้องเรียน'}`]" lazy-rules @update:model-value=" - selectComplainant(formData.respondentType) + selectComplainant(formData.respondentType); + changeFormData(); " @filter="(inputValue: any, doneFn: Function) => filterSelector(inputValue, doneFn, 'filterrespondentType' @@ -502,6 +512,7 @@ onMounted(async () => { label="เลือกสำนักงาน" :rules="[(val) => !!val || `${'กรุณาเลือกสำนักงาน'}`]" lazy-rules + @update:model-value="changeFormData()" /> @@ -570,7 +581,7 @@ onMounted(async () => { { col.label }} + @@ -630,6 +642,20 @@ onMounted(async () => { {{ col.value }} + + ลบผู้ถูกร้องเรียน + @@ -662,6 +688,7 @@ onMounted(async () => { dense class="text-weight-medium q-ml-sm" keep-color + @update:model-value="changeFormData()" /> @@ -676,6 +703,7 @@ onMounted(async () => { autoApply :enableTimePicker="false" week-start="0" + @update:model-value="changeFormData()" > {{ year + 543 @@ -761,6 +789,7 @@ onMounted(async () => { autoApply :enableTimePicker="false" week-start="0" + @update:model-value="changeFormData()" > {{ year + 543 @@ -818,6 +847,7 @@ onMounted(async () => { borderless :enableTimePicker="false" week-start="0" + @update:model-value="changeFormData()" > {{ year + 543 }} @@ -866,6 +896,7 @@ onMounted(async () => { borderless :enableTimePicker="false" week-start="0" + @update:model-value="changeFormData()" > {{ year + 543 }} @@ -913,6 +944,7 @@ onMounted(async () => { borderless :enableTimePicker="false" week-start="0" + @update:model-value="changeFormData()" > {{ year + 543 }} @@ -961,6 +993,7 @@ onMounted(async () => { borderless :enableTimePicker="false" week-start="0" + @update:model-value="changeFormData()" > {{ year + 543 }} @@ -1087,6 +1120,7 @@ onMounted(async () => { hide-bottom-space :rules="[(val) => !!val || `${'กรุณากรอกกรณีมีความผิด'}`]" lazy-rules + @update:model-value="changeFormData()" /> { label="สอบสวนที่" :rules="[(val) => !!val || `${'กรุณากรอกสอบสวนที่'}`]" lazy-rules + @update:model-value="changeFormData()" /> { lazy-rules group-label="group" group-values="options" + @update:model-value="changeFormData()" > @@ -1136,6 +1172,7 @@ onMounted(async () => { (val) => !!val || `${'กรุณากรอกอ้างอิงมาตราตามกฎหมาย'}`, ]" lazy-rules + @update:model-value="changeFormData()" /> { type="textarea" :rules="[(val:string) => !!val || `${'กรุณากรอกสรุปพยานหลักฐานสนับสนุนข้อกล่าวหา'}`]" lazy-rules + @update:model-value="changeFormData()" /> { type="textarea" :rules="[(val:string) => !!val || `${'กรุณากรอกบันทึกถ้อยคำของผู้กล่าวหา'}`]" lazy-rules + @update:model-value="changeFormData()" /> { type="textarea" :rules="[(val:string) => !!val || `${'กรุณากรอกพยานและบันทึกถ้อยคำพยาน'}`]" lazy-rules + @update:model-value="changeFormData()" /> { type="textarea" :rules="[(val:string) => !!val || `${'กรุณากรอกผลการสอบสวน'}`]" lazy-rules + @update:model-value="changeFormData()" /> @@ -1232,6 +1273,7 @@ onMounted(async () => { @filter="(inputValue: any, doneFn: Function) => investigateDis.filterFnOptionsType(inputValue, doneFn, 'offenseDetailsOps' )" + @update:model-value="changeFormData()" > @@ -1265,6 +1307,7 @@ onMounted(async () => { option-label="name" option-value="id" use-input + @update:model-value="changeFormData()" > @@ -1289,6 +1332,7 @@ onMounted(async () => { hide-bottom-space :label="`${'เหตุผล'}`" type="textarea" + @update:model-value="changeFormData()" /> @@ -1363,11 +1407,11 @@ onMounted(async () => { @@ -1387,4 +1431,4 @@ onMounted(async () => { /> -@/modules/11_discipline/store/store \ No newline at end of file +@/modules/11_discipline/store/store diff --git a/src/modules/11_discipline/components/PopupSendToNext.vue b/src/modules/11_discipline/components/PopupSendToNext.vue index b506ebb5f..89c69fbd2 100644 --- a/src/modules/11_discipline/components/PopupSendToNext.vue +++ b/src/modules/11_discipline/components/PopupSendToNext.vue @@ -40,12 +40,15 @@ const props = defineProps({ type: Array, default: [], }, + checkedVal: { + type: Boolean, + default: true, + }, }); const emit = defineEmits(["returnPerson"]); /** หัวตาราง */ - const selected = ref([]); const inspectionResults = ref(""); const filter = ref(""); @@ -57,17 +60,16 @@ const initialPagination = ref({ }); function onclickSend() { - dialogConfirm( - $q, - async () => { - // success($q, `ส่งข้อมูล${props.title}สำเร็จ`); - emit("returnPerson", selected.value); - props.close?.(); - }, - `ยืนยันการส่ง${props.title}`, - `ต้องการยืนยันการส่ง${props.title}หรือไม่` - ); - + dialogConfirm( + $q, + async () => { + // success($q, `ส่งข้อมูล${props.title}สำเร็จ`); + emit("returnPerson", selected.value); + props.close?.(); + }, + `ยืนยันการส่ง${props.title}`, + `ต้องการยืนยันการส่ง${props.title}หรือไม่` + ); } function onClickClose() { @@ -78,7 +80,7 @@ watch([() => props.modal], () => { inspectionResults.value = props.modal ? "" : ""; selected.value = props.modal ? [] : []; if (props.modal === true) { - selected.value = props.rows; + selected.value = props.checkedVal ? props.rows : []; } }); diff --git a/src/modules/11_discipline/interface/request/disciplinary.ts b/src/modules/11_discipline/interface/request/disciplinary.ts index 2f12099eb..fd22c0be4 100644 --- a/src/modules/11_discipline/interface/request/disciplinary.ts +++ b/src/modules/11_discipline/interface/request/disciplinary.ts @@ -10,6 +10,7 @@ interface Persons { salary: number; //เงินเดือน organization: string; //สังกัด name: string; + report?: boolean; } interface PersonsArray { id: string; //id อ้างอิง profile @@ -23,6 +24,7 @@ interface PersonsArray { salary: number; //เงินเดือน organization: string; //สังกัด name: string; + report?: boolean; } interface Director { directorId?: string; @@ -128,4 +130,4 @@ interface DisciplinaryRef { [key: string]: any; } -export type { FormData, DisciplinaryRef, Persons, Director,PersonsArray }; +export type { FormData, DisciplinaryRef, Persons, Director, PersonsArray }; diff --git a/src/modules/11_discipline/interface/response/investigate.ts b/src/modules/11_discipline/interface/response/investigate.ts index d9355dea9..609bd27b9 100644 --- a/src/modules/11_discipline/interface/response/investigate.ts +++ b/src/modules/11_discipline/interface/response/investigate.ts @@ -8,39 +8,40 @@ interface ListData { investigationDateEnd: Date | null; investigationStatusResult: string; status: string; - createdAt: Date|null; + createdAt: Date | null; } interface ArrayPerson { - id:string - idcard:string - name:string - prefix:string - firstName:string - lastName:string - posNo:string - position:string - positionLevel:string - salary:number|null - organization:string + personId: string; + idcard: string; + name: string; + prefix: string; + firstName: string; + lastName: string; + posNo: string; + position: string; + positionLevel: string; + salary: number | null; + organization: string; } interface ArrayPersonAdd { - personId:string - idcard:string - name:string - prefix:string - firstName:string - lastName:string - posNo:string - position:string - positionLevel:string - salary:number|null - organization:string + personId: string; //id อ้างอิง profile + idcard: string; //รหัสบัตรประชาชน + prefix: string; //คำนำหน้า + firstName: string; //ชื่อ + lastName: string; //นามสกุล + posNo: string; //เลขที่ตำแหน่ง + position: string; //ตำแหน่ง + positionLevel: string; //ระดับ + salary: number; //เงินเดือน + organization: string; //สังกัด + name: string; + report?: boolean; } -interface ocListType{ - organizationId:string - organizationName:string +interface ocListType { + organizationId: string; + organizationName: string; } -export type { ListData,ArrayPerson,ocListType,ArrayPersonAdd }; +export type { ListData, ArrayPerson, ocListType, ArrayPersonAdd }; diff --git a/src/modules/11_discipline/store/main.ts b/src/modules/11_discipline/store/main.ts index b705596c8..dd96e2cf2 100644 --- a/src/modules/11_discipline/store/main.ts +++ b/src/modules/11_discipline/store/main.ts @@ -2,7 +2,7 @@ import { defineStore } from "pinia"; import type { QTableProps } from "quasar"; import { ref } from "vue"; import type { DataOption } from "@/modules/11_discipline/interface/index/Main"; -import type { ArrayPerson, ArrayPersonAdd } from "@/modules/11_discipline/interface/response/investigate"; +import type { ArrayPersonAdd } from "@/modules/11_discipline/interface/response/investigate"; export const useDisciplineMainStore = defineStore("disciplineMainStore", () => { /** option ผู้ถูกสอบสวน*/ @@ -273,8 +273,8 @@ export const useDisciplineMainStore = defineStore("disciplineMainStore", () => { "organization", ]); - const rowsAdd = ref([]); - function fetchData(data: ArrayPerson[]) { + const rowsAdd = ref([]); + function fetchData(data: ArrayPersonAdd[]) { rowsAdd.value = data; }