diff --git a/src/modules/11_discipline/components/7_ListSuspend/DialogSendToCommand.vue b/src/modules/11_discipline/components/7_ListSuspend/DialogSendToCommand.vue index 183063292..62d4ea0c2 100644 --- a/src/modules/11_discipline/components/7_ListSuspend/DialogSendToCommand.vue +++ b/src/modules/11_discipline/components/7_ListSuspend/DialogSendToCommand.vue @@ -4,6 +4,9 @@ import { useQuasar } from "quasar"; import { useCounterMixin } from "@/stores/mixin"; import { useCommandMainStore } from "@/modules/18_command/store/Main"; +import { useDisciplineSuspendStore } from "@/modules/11_discipline/store/SuspendStore"; +import http from "@/plugins/http"; +import config from "@/app.config"; import type { QTableProps } from "quasar"; import type { dataType } from "@/modules/11_discipline/interface/response/suspend"; @@ -15,8 +18,9 @@ import DialogCreateCommand from "@/modules/18_command/components/DialogCreateCom /** use */ const $q = useQuasar(); const storeCommand = useCommandMainStore(); -const mixin = useCounterMixin(); -const { dialogConfirm, onSearchDataTable } = mixin; +const storeSuspend = useDisciplineSuspendStore(); +const { onSearchDataTable, showLoader, hideLoader, messageError, date2Thai } = + useCounterMixin(); const modal = defineModel("modal", { required: true }); const modalCommand = ref(false); // ตัวแปร popup สร้างคำสั่ง @@ -47,6 +51,7 @@ const filterKeyword = ref(""); const props = defineProps<{ rows: dataType[]; fetchData: Function; + employeeClass: string; }>(); /** คอลัมน์ */ @@ -128,6 +133,62 @@ const visibleColumns = ref([ "status", ]); +async function fetchListData() { + showLoader(); + const paramsNew = { + keyword: filterKeyword.value.trim(), + profileType: props.employeeClass, + status: "PENDING", + }; + + await http + .get(config.API.suspendMain, { params: paramsNew }) + .then(async (res) => { + const result = await res.data.result.data; + const mapData = result.map((item: dataType) => { + return { + id: item.id, + profileId: item.profileId, + citizenId: item.citizenId, + name: `${item.prefix}${item.firstName} ${item.lastName}`, + prefix: item.prefix, + firstName: item.firstName, + profileType: item.profileType, + lastName: item.lastName, + organization: item.organization, + position: item.position, + posNo: item.posNo, + positionType: item.positionType, + positionLevel: item.positionLevel, + salary: item.salary, + status: storeSuspend.statusTothai(item.status), + statusEn: item.status, + descriptionSuspend: item.descriptionSuspend, + dateTotal: + item.startDateSuspend && item.endDateSuspend + ? `${date2Thai(item.startDateSuspend)} - ${date2Thai( + item.endDateSuspend + )}` + : "-", + startDateSuspend: item.startDateSuspend, + endDateSuspend: item.endDateSuspend, + title: item.title, + offenseDetails: item.offenseDetails, + disciplinaryFaultLevel: item.disciplinaryFaultLevel, + disciplinaryCaseFault: item.disciplinaryCaseFault, + }; + }); + rows.value = mapData; + rowsMain.value = mapData; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} + function closeModal() { modal.value = false; commandType.value = ""; @@ -149,15 +210,8 @@ function filterSelector(val: string, update: Function) { /** ฟังก์ชั่นยืนยันและส่งคนไปสร้างคำสั่ง */ function saveOrder() { - // dialogConfirm( - // $q, - // async () => { modalCommand.value = true; modal.value = false; - // }, - // "ยืนยันส่งไปออกคำสั่ง", - // "ต้องการยืนยันส่งไปออกคำสั่งใช่หรือไม่?" - // ); } function serchDataTable() { @@ -185,8 +239,7 @@ watch( () => modal.value, async () => { if (modal.value === true) { - rows.value = props.rows ? props.rows : []; - rowsMain.value = props.rows ? props.rows : []; + await fetchListData(); selected.value = []; const data = await storeCommand.getCommandTypes(); listCommand.value = data.filter( @@ -274,7 +327,7 @@ watch( keep-color color="primary" dense - :disable="commandType" + :disable="commandType ? false : true" v-model="scope.selected" /> @@ -285,7 +338,7 @@ watch( keep-color color="primary" dense - :disable="commandType" + :disable="commandType ? false : true" v-model="props.selected" /> diff --git a/src/modules/11_discipline/components/7_ListSuspend/ListsPage.vue b/src/modules/11_discipline/components/7_ListSuspend/ListsPage.vue index bb73d2036..0faea7495 100644 --- a/src/modules/11_discipline/components/7_ListSuspend/ListsPage.vue +++ b/src/modules/11_discipline/components/7_ListSuspend/ListsPage.vue @@ -31,9 +31,9 @@ const { messageError, showLoader, hideLoader, date2Thai, convertDateToAPI } = const { pagination, params, onRequest } = usePagination("", getList); const date = ref(null); -const employeeClass = ref(""); +const employeeClass = ref("OFFICER"); const employeeClassOption = ref([ - { id: "", name: "ทั้งหมด" }, + // { id: "", name: "ทั้งหมด" }, { id: "OFFICER", name: "ข้าราชการ กทม. สามัญ" }, { id: "EMPLOYEE", name: "ลูกจ้างประจำ กทม." }, ]); @@ -451,6 +451,7 @@ onMounted(async () => { v-model:modal="modal" :rows="rows2" :fetch-data="getList" + :employeeClass="employeeClass" /> diff --git a/src/modules/11_discipline/interface/response/suspend.ts b/src/modules/11_discipline/interface/response/suspend.ts index c83d3c7fd..6b383214e 100644 --- a/src/modules/11_discipline/interface/response/suspend.ts +++ b/src/modules/11_discipline/interface/response/suspend.ts @@ -45,6 +45,8 @@ interface dataType { offenseDetails: string; disciplinaryFaultLevel: string; disciplinaryCaseFault: string; + profileId?: string; + profileType: string; } interface DataDetail { diff --git a/src/modules/11_discipline/store/SuspendStore.ts b/src/modules/11_discipline/store/SuspendStore.ts index 84e6fe581..4b571d327 100644 --- a/src/modules/11_discipline/store/SuspendStore.ts +++ b/src/modules/11_discipline/store/SuspendStore.ts @@ -99,6 +99,7 @@ export const useDisciplineSuspendStore = defineStore( visibleColumns, getData, offenseDetailsOps, + statusTothai, }; } );