From e18386db65c467780158cd18ec17f361298e989e Mon Sep 17 00:00:00 2001 From: waruneeta Date: Fri, 24 Nov 2023 13:15:43 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B9=89=E0=B8=B2=E0=B9=80=E0=B8=A3=E0=B8=B7=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B9=89=E0=B8=AD=E0=B8=87=E0=B9=80?= =?UTF-8?q?=E0=B8=A3=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B8=82=E0=B8=AD=E0=B8=87?= =?UTF-8?q?=E0=B8=A7=E0=B8=B4=E0=B8=99=E0=B8=B1=E0=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Dialogs/AddPersonal.vue | 67 +----- .../components/1_Complaint/EditPage.vue | 51 ++-- .../components/1_Complaint/Form.vue | 51 ++-- .../components/1_Complaint/MainPage.vue | 17 +- .../components/1_Complaint/TableComplaint.vue | 32 +-- .../interface/response/complaint.ts | 84 ++++--- .../11_discipline/store/ComplaintsStore.ts | 224 ++++++++++-------- 7 files changed, 221 insertions(+), 305 deletions(-) diff --git a/src/components/Dialogs/AddPersonal.vue b/src/components/Dialogs/AddPersonal.vue index c304b724c..efc590ed2 100644 --- a/src/components/Dialogs/AddPersonal.vue +++ b/src/components/Dialogs/AddPersonal.vue @@ -12,48 +12,6 @@ const $q = useQuasar(); const mixin = useCounterMixin(); const { dialogConfirm, dialogMessageNotify, showLoader, hideLoader } = mixin; -const data = [ - { - id: "001", - idcard: "0000000000001", - prefix: "นาง", - firstName: "ศิรินภา", - lastName: "คงน้อย", - posNo: "สกก.1", - position: "ตำเเหน่ง1", - positionLevel: "level1", - salary: "100", - organization: "สำนักงาน 1", - name: "นางศิรินภา คงน้อย", - }, - { - id: "002", - idcard: "0000000000002", - prefix: "นาย", - firstName: "แก้ว", - lastName: "คำ", - posNo: "สกก.1", - position: "ตำแหน่ง2", - positionLevel: "level2", - salary: "100", - organization: "สำนักงาน 2", - name: "นางแก้ว คำ", - }, - { - id: "003", - idcard: "0000000000003", - prefix: "นาย", - firstName: "ภัทรานุย", - lastName: "คงนอย", - posNo: "สกก.1", - position: "ตำแหน่ง2", - positionLevel: "level3", - salary: "100", - organization: "สำนักงาน 3", - name: "นางภัทรานุย คงนอย", - }, -]; - interface typeOp { id: string; name: string; @@ -219,7 +177,8 @@ async function close() { /** เปิด dialog ยืนยัน */ function savePost() { if (selected.value.length != 0) { - dialogConfirm($q, () => saveData()); + // dialogConfirm($q, () => saveData()); + saveData(); } else { dialogMessageNotify($q, "กรุณาเลือกอย่างน้อย 1 รายการ"); } @@ -262,7 +221,6 @@ async function searchInput() { })); rows.value = list; - console.log(list); }) .catch((err) => { console.log(err); @@ -284,26 +242,6 @@ function updateInput() { function updateSelect() { search.value = ""; } - -// watch( -// () => props.modal, -// () => { -// if (props.modal === true) { -// console.log(props.checkId); -// const dataProps = props.checkId.map((item: any) => item.idcard); -// const dataMapId = data.filter( -// (item: any) => !dataProps.includes(item.idcard) -// ); -// rows.value = dataMapId; -// } -// } -// ); - -/** เรียกข้อมูลเมื่อเริ่มโหลด หน้า dialog mock */ -onMounted(() => { - // dataObject.value = data; - // rows.value = data; -}); diff --git a/src/modules/11_discipline/components/1_Complaint/Form.vue b/src/modules/11_discipline/components/1_Complaint/Form.vue index 0ea6a356f..f11fe4355 100644 --- a/src/modules/11_discipline/components/1_Complaint/Form.vue +++ b/src/modules/11_discipline/components/1_Complaint/Form.vue @@ -72,8 +72,6 @@ const props = defineProps({ }, }); - - const fileListOj = reactive({ id: "", pathName: "", @@ -96,12 +94,11 @@ const formData = reactive({ appellant: "", documentFile: null, status: "", - result: '', + result: "", persons: [], disciplineComplaintDocs: fileList.value ?? null, }); - /** maping ref เข้าตัวแปรเพื่อเตรียมตรวจสอบ */ const objectComplaintsRef: MyObjectComplaintsRef = { respondentType: respondentTypeRef, @@ -142,6 +139,15 @@ const complaintFromtoptions = ref([ /** หัวตาราง */ const columns = ref([ + { + name: "info", + align: "left", + label: "", + sortable: false, + field: "info", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, { name: "no", align: "left", @@ -218,6 +224,7 @@ const columns = ref([ /** หัวข้อที่เเสดงในตาราง */ const visibleColumns = ref([ + "info", "no", "idcard", "name", @@ -235,32 +242,12 @@ const visibleColumns = ref([ async function selectComplainant(val: string) { formData.organizationId = ""; formData.consideredAgency = ""; - if (val === "0") { - await fetchListname(); // ถ้าเลือกบุกคลจะเรียก function fetchListname เรียกรายชื่อจากทะเบียน - } else if (val === "1") { + + if (val === "1") { await fetchOffice(); // ถ้าเลือกหน่วยงานจะเรียก function fetchOffice เรียกโครงสร้างสำนักงาน } } -/** เรียกรายชื่อ */ -async function fetchListname() { - const listName = [ - { - id: "1", - name: "นายเอ", - }, - { - id: "2", - name: "นายบี", - }, - { - id: "3", - name: "นายชี", - }, - ]; - selectComplainantTpye(listName); -} - /** เรียกโครงสร้างสำนักงาน */ async function fetchOffice() {} @@ -600,7 +587,15 @@ onMounted(() => {
{{ props.rowIndex + 1 }}
-
+
+ ดูข้อมูลในทะเบียนประวัติ + + {{ col.value }} +
+
{{ col.value }}
@@ -638,7 +633,7 @@ onMounted(() => { v-model="formData.description" :rules="[(val) => !!val || 'กรุณาการข้อมูล']" lazy-rules - label="รายละเอียดที่เกี่นวข้องกับเรื่องที่ต้องการจะข้อเรียน" + label="รายละเอียดเรื่องร้องเรียน" type="textarea" rows="5" /> diff --git a/src/modules/11_discipline/components/1_Complaint/MainPage.vue b/src/modules/11_discipline/components/1_Complaint/MainPage.vue index e8e23f606..9c87d2eb4 100644 --- a/src/modules/11_discipline/components/1_Complaint/MainPage.vue +++ b/src/modules/11_discipline/components/1_Complaint/MainPage.vue @@ -3,8 +3,6 @@ import { ref, onMounted, watch } from "vue"; import { useRouter } from "vue-router"; import { useQuasar } from "quasar"; import { useCounterMixin } from "@/stores/mixin"; -// import type -import type { DataList } from "@/modules/11_discipline/interface/response/complaint"; // importStroe import { useComplainstDataStore } from "@/modules/11_discipline/store/ComplaintsStore"; // impoet Components @@ -29,10 +27,10 @@ const maxPage = ref(1); const page = ref(1); const rowsPerPage = ref(10); -async function updatePagingProp(rowPerpage:number,pageCurrent:number) { - rowsPerPage.value = rowPerpage - page.value = pageCurrent - await getList() +async function updatePagingProp(rowPerpage: number, pageCurrent: number) { + rowsPerPage.value = rowPerpage; + page.value = pageCurrent; + await getList(); } async function getList() { @@ -44,11 +42,10 @@ async function getList() { rowsPerPage.value, filterKeyword.value ) - ) - // + // .then((res) => { - maxPage.value = Math.ceil(res.data.result.total/ rowsPerPage.value); + maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value); const data = res.data.result.data; fetchComplainst(data); }) @@ -62,7 +59,7 @@ async function getList() { /** ไปยังหน้าเพิ่มข้อมูล */ function redirectToPageadd() { - complainstStore.fetchComplainstAdd([]) + complainstStore.fetchComplainstAdd([]); router.push(`/discipline/complaints/add`); } diff --git a/src/modules/11_discipline/components/1_Complaint/TableComplaint.vue b/src/modules/11_discipline/components/1_Complaint/TableComplaint.vue index bf454a350..2f721d1f5 100644 --- a/src/modules/11_discipline/components/1_Complaint/TableComplaint.vue +++ b/src/modules/11_discipline/components/1_Complaint/TableComplaint.vue @@ -45,27 +45,27 @@ const columns = ref([ { name: "title", align: "left", - label: "เรื่อง", + label: "เรื่องร้องเรียน", sortable: true, field: "title", headerStyle: "font-size: 14px", style: "font-size: 14px", }, { - name: "description", + name: "dateReceived", align: "left", - label: "รายละเอียด", + label: "วันที่รับเรื่อง", sortable: true, - field: "description", + field: "dateReceived", headerStyle: "font-size: 14px", style: "font-size: 14px", }, { - name: "appellant", + name: "respondentType", align: "left", label: "ผู้ถูกร้องเรียน", sortable: true, - field: "appellant", + field: "respondentType", headerStyle: "font-size: 14px", style: "font-size: 14px", }, @@ -78,15 +78,6 @@ const columns = ref([ headerStyle: "font-size: 14px", style: "font-size: 14px", }, - { - name: "createdAt", - align: "left", - label: "วันที่สร้างเรื่องร้องเรียน", - sortable: true, - field: "createdAt", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, { name: "levelConsideration", align: "left", @@ -108,7 +99,7 @@ const columns = ref([ { name: "status", align: "left", - label: "สถานะเรื่องร้องเรียน", + label: "สถานะ", sortable: true, field: "status", headerStyle: "font-size: 14px", @@ -120,8 +111,8 @@ const columns = ref([ const visibleColumns = ref([ "no", "title", - "description", - "appellant", + "dateReceived", + "respondentType", "offenseDetails", "createdAt", "levelConsideration", @@ -216,11 +207,6 @@ watch(
{{ props.rowIndex + 1 }}
-
-
- {{ props.row.description }} -
-
{{ col.value }}
diff --git a/src/modules/11_discipline/interface/response/complaint.ts b/src/modules/11_discipline/interface/response/complaint.ts index 16f25dbb0..01cce00c8 100644 --- a/src/modules/11_discipline/interface/response/complaint.ts +++ b/src/modules/11_discipline/interface/response/complaint.ts @@ -1,55 +1,51 @@ interface DataListRow { - id:string - title: string - description: string - appellant: string - offenseDetails: string - createdAt: string - levelConsideration: string - dateConsideration: string - status: string + id: string; + personId: string; + title: string; + dateReceived: Date | "-"; + respondentType: string; + offenseDetails: string; + createdAt: string; + levelConsideration: string; + dateConsideration: string; + status: string; } interface DataAdd { - id:string - idcard:string - name:string - positionNo:string - position:string - positionLevel:string - salary:string - organization:string + id: string; + idcard: string; + name: string; + positionNo: string; + position: string; + positionLevel: string; + salary: string; + organization: string; } interface DataAddResponse { - id:string - idcard:string - name:string - positionNo:string - position:string - positionLevel:string - salary:string - organization:string + id: string; + idcard: string; + name: string; + positionNo: string; + position: string; + positionLevel: string; + salary: string; + organization: string; } interface DataList { - id:string - title: string - description: string - appellant: string - offenseDetails: string - createdAt: Date - levelConsideration: string - dateConsideration: Date - status: string + id: string; + personId: string; + title: string; + dateReceived: Date | "-"; + respondentType: string; + offenseDetails: string; + createdAt: Date; + levelConsideration: string; + dateConsideration: Date; + status: string; } -interface ocListType{ - organizationId:string - organizationName:string +interface ocListType { + organizationId: string; + organizationName: string; } -export type { - DataList, - DataListRow, - DataAdd, - DataAddResponse, - ocListType -} \ No newline at end of file +export type { DataList, DataListRow, DataAdd, DataAddResponse, ocListType }; diff --git a/src/modules/11_discipline/store/ComplaintsStore.ts b/src/modules/11_discipline/store/ComplaintsStore.ts index b7ccca28b..ff13a70ac 100644 --- a/src/modules/11_discipline/store/ComplaintsStore.ts +++ b/src/modules/11_discipline/store/ComplaintsStore.ts @@ -3,140 +3,158 @@ import { ref } from "vue"; import { useCounterMixin } from "@/stores/mixin"; import type { DataOption } from "@/modules/11_discipline/interface/index/Main"; -import type { DataList, DataListRow, DataAdd, ArrayPerson,ocListType } from "@/modules/11_discipline/interface/response/complaint" +import type { + DataList, + DataListRow, + DataAdd, + ArrayPerson, + ocListType, +} from "@/modules/11_discipline/interface/response/complaint"; import type { QTableProps } from "quasar"; -const mixin = useCounterMixin() -const { date2Thai } = mixin +const mixin = useCounterMixin(); +const { date2Thai } = mixin; -// id -// cardId -// prefix -// firstName -// lastName -// position -// level -// oc -export const useComplainstDataStore = defineStore("DisciplineComplainst", () => { - const rows = ref([]) - const rowsAdd = ref([]) +export const useComplainstDataStore = defineStore( + "DisciplineComplainst", + () => { + const rows = ref([]); + const rowsAdd = ref([]); const visibleColumns = ref([]); const columns = ref([]); function fetchComplainstAdd(data: ArrayPerson[]) { - rowsAdd.value = data + rowsAdd.value = data; } function addCommas(salaryString: string): string { - const salaryNumber = parseFloat(salaryString.replace(/,/g, '')); - return salaryNumber.toLocaleString(); + const salaryNumber = parseFloat(salaryString.replace(/,/g, "")); + return salaryNumber.toLocaleString(); } function fetchComplainst(data: DataList[]) { - let datalist: DataListRow[] = data.map((e: DataList) => ({ - id: e.id, - title: e.title, - description: e.description, - appellant: e.appellant, - offenseDetails: offenseDetailsTran(e.offenseDetails), - createdAt: date2Thai(e.createdAt)!, - levelConsideration: levelConsiderationTran(e.levelConsideration), - dateConsideration: date2Thai(e.dateConsideration)!, - status: statusTothai(e.status), - })); - rows.value = datalist; - } - + let datalist: DataListRow[] = data.map((e: DataList) => ({ + id: e.id, + personId: e.personId, + title: e.title, + dateReceived: e.dateReceived ? e.dateReceived : "-", + respondentType: convertComplaintType(e.respondentType), + offenseDetails: offenseDetailsTran(e.offenseDetails), + createdAt: date2Thai(e.createdAt)!, + levelConsideration: levelConsiderationTran(e.levelConsideration), + dateConsideration: date2Thai(e.dateConsideration)!, + status: statusTothai(e.status), + })); + rows.value = datalist; + } + // filter options const complainantoptionsMain = ref([ - { id: "PERSON", name: "บุคคล" }, - { id: "ORGANIZATION", name: "หน่วยงาน" }, - { id: "BANGKOK", name: "กรุงเทพมหานคร" }, + { id: "PERSON", name: "บุคคล" }, + { id: "ORGANIZATION", name: "หน่วยงาน" }, + { id: "BANGKOK", name: "กรุงเทพมหานคร" }, ]); - const complainantoptions = ref(complainantoptionsMain.value) + + function convertComplaintType(val: string) { + const result = complainantoptionsMain.value.find( + (x: any) => x.id == val + )?.name; + return result ? result : "-"; + } + + const complainantoptions = ref(complainantoptionsMain.value); const consideredAgencytoptions = ref([]); const organizationIdOp = ref([]); const statusTothai = (val: string) => { - switch (val) { - case 'NEW': return "ใหม่"; - case 'STOP': return "ยุติเรื่อง"; - case 'SEND_INVESTIGATE': return "มีมูลส่งไปสืบสวนแล้ว"; - default: return "-"; - } + switch (val) { + case "NEW": + return "ใหม่"; + case "STOP": + return "ยุติเรื่อง"; + case "SEND_INVESTIGATE": + return "มีมูลส่งไปสืบสวนแล้ว"; + default: + return "-"; + } }; - function offenseDetailsTran(val: string){ - switch (val) { - case 'NOT_SPECIFIED': return "ยังไม่ระบุ"; - case 'NOT_DEADLY': return "ร้ายแรง"; - case 'DEADLY': return "ไม่ร้ายแรง"; - default: return "-"; - } + function offenseDetailsTran(val: string) { + switch (val) { + case "NOT_SPECIFIED": + return "ยังไม่ระบุ"; + case "NOT_DEADLY": + return "ร้ายแรง"; + case "DEADLY": + return "ไม่ร้ายแรง"; + default: + return "-"; + } } - function levelConsiderationTran(val: string){ - switch (val) { - case 'NORMAL': return "ปกติ"; - case 'URGENT': return "ด่วน"; - case 'VERT_URGENT': return "ด่วนมาก"; - default: return "-"; - } + function levelConsiderationTran(val: string) { + switch (val) { + case "NORMAL": + return "ปกติ"; + case "URGENT": + return "ด่วน"; + case "VERT_URGENT": + return "ด่วนมาก"; + default: + return "-"; + } } - const agencytoptions = ref(consideredAgencytoptions.value) - const optionListNameMain = ref([]) - const optionListName = ref([]) + const agencytoptions = ref(consideredAgencytoptions.value); + const optionListNameMain = ref([]); + const optionListName = ref([]); function selectComplainantTpye(list: any) { - optionListNameMain.value = list - optionListName.value = list + optionListNameMain.value = list; + optionListName.value = list; } + function filterSelector(val: string, update: Function, type: string) { - update(() => { - const needle = val.toLowerCase(); + update(() => { + const needle = val.toLowerCase(); - if (type === "filtercomplainantType") { - complainantoptions.value = complainantoptionsMain.value.filter( - (v: any) => v.name.toLowerCase().indexOf(needle) > -1 - ); - - } else if (type === "filteragencytoptions") { - agencytoptions.value = consideredAgencytoptions.value.filter( - (v: any) => v.name.toLowerCase().indexOf(needle) > -1 - ); - } else if (type === "filtercomplainantOP") { - optionListName.value = optionListNameMain.value.filter( - (v: any) => v.name.toLowerCase().indexOf(needle) > -1 - ); - } - - }); + if (type === "filtercomplainantType") { + complainantoptions.value = complainantoptionsMain.value.filter( + (v: any) => v.name.toLowerCase().indexOf(needle) > -1 + ); + } else if (type === "filteragencytoptions") { + agencytoptions.value = consideredAgencytoptions.value.filter( + (v: any) => v.name.toLowerCase().indexOf(needle) > -1 + ); + } else if (type === "filtercomplainantOP") { + optionListName.value = optionListNameMain.value.filter( + (v: any) => v.name.toLowerCase().indexOf(needle) > -1 + ); + } + }); } - function ocListFn(data:ocListType[]){ - let dataList:DataOption[] = data.map((item:ocListType)=>({ - id:item.organizationId, - name:item.organizationName - })) - consideredAgencytoptions.value = dataList - organizationIdOp.value = dataList - + function ocListFn(data: ocListType[]) { + let dataList: DataOption[] = data.map((item: ocListType) => ({ + id: item.organizationId, + name: item.organizationName, + })); + consideredAgencytoptions.value = dataList; + organizationIdOp.value = dataList; } return { - rows, - rowsAdd, - visibleColumns, - columns, - fetchComplainst, - selectComplainantTpye, - filterSelector, - complainantoptions, - consideredAgencytoptions, - optionListName, - fetchComplainstAdd, - organizationIdOp, - ocListFn - - - } -}) \ No newline at end of file + rows, + rowsAdd, + visibleColumns, + columns, + fetchComplainst, + selectComplainantTpye, + filterSelector, + complainantoptions, + consideredAgencytoptions, + optionListName, + fetchComplainstAdd, + organizationIdOp, + ocListFn, + }; + } +);