From 7bc71cf93f0bec7a83cdbf3b2cb0a1b512d49a7a Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 18 Nov 2024 13:15:01 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20code=20?= =?UTF-8?q?=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=87?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=8A=20=3D=3D>=20=E0=B8=88=E0=B8=B1?= =?UTF-8?q?=E0=B8=94=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=84=E0=B8=B3=E0=B8=82?= =?UTF-8?q?=E0=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../07_insignia/components/2_Manage/Tab1.vue | 130 +++++++++--------- .../07_insignia/interface/index/Main.ts | 40 ++++++ .../07_insignia/interface/response/Main.ts | 65 +++++++++ src/modules/07_insignia/store.ts | 82 ++++++----- .../07_insignia/views/02_ManageMain.vue | 3 +- 5 files changed, 222 insertions(+), 98 deletions(-) diff --git a/src/modules/07_insignia/components/2_Manage/Tab1.vue b/src/modules/07_insignia/components/2_Manage/Tab1.vue index 890263059..91ea55927 100644 --- a/src/modules/07_insignia/components/2_Manage/Tab1.vue +++ b/src/modules/07_insignia/components/2_Manage/Tab1.vue @@ -3,7 +3,6 @@ import { onMounted, ref, computed, reactive, watch } from "vue"; import { useQuasar, QForm } from "quasar"; import { useInsigniaDataStore } from "@/modules/07_insignia/store"; -import { useroleUserDataStore } from "@/stores/roleUser"; import { useCounterMixin } from "@/stores/mixin"; import { checkPermission } from "@/utils/permissions"; import http from "@/plugins/http"; @@ -11,8 +10,17 @@ import config from "@/app.config"; /** import Type*/ import type { QTableProps } from "quasar"; -import type { OptionData } from "@/modules/07_insignia/interface/index/Main"; +import type { + OptionData, + Pagination, + DataProfileOtherSystem, + DataManageList, +} from "@/modules/07_insignia/interface/index/Main"; import type { CheckboxData } from "@/modules/07_insignia/interface/request/Main"; +import type { + ResponseProfile, + ResponseInsigniaType, +} from "@/modules/07_insignia/interface/response/Main"; /** import components*/ import DialogPopupReason from "@/components/Dialogs/PopupReason.vue"; @@ -25,7 +33,6 @@ import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue"; const myForm = ref(); const $q = useQuasar(); const DataStore = useInsigniaDataStore(); -const roleDataStore = useroleUserDataStore(); const mixin = useCounterMixin(); const { dialogConfirm, @@ -249,8 +256,8 @@ const columns2 = ref([ }, ]); -const rows2 = ref([]); //รายชื่อข้าราชการตามหน่วยงานที่จะเพิ่ม -const person = ref([]); +const rows2 = ref([]); //รายชื่อข้าราชการตามหน่วยงานที่จะเพิ่ม +const person = ref(); /** เช็คสถานนะแสดงปุ่มเพิ่ม*/ const checkStatus = computed(() => { @@ -277,11 +284,9 @@ function changtypeOc() { /** function เพิ่มรายชื่อ*/ async function clickmodalAdd() { - await clearForm(); - let ocId = DataStore.typeOc ? DataStore.typeOc : DataStore.agency; - // showLoader(); + clearForm(); await fecthInsignia(); - await fecthlistperson(ocId); + await fecthlistperson(); } function onCloseModalAdd() { @@ -296,7 +301,7 @@ const formFilter = reactive({ searchField: "citizenId", searchKeyword: "", }); -const filterOption = ref([ +const filterOption = ref([ { id: "citizenId", name: "เลขประจำตัวประชาชน", @@ -311,14 +316,14 @@ const filterOption = ref([ * function เรียกรายชื่อข้าราชการตามหน่วยงานที่จะเพิ่ม * @param id หน่วยงาน */ -async function fecthlistperson(id: string = "") { +async function fecthlistperson() { showLoader(); http .get(config.API.registryNewOtherSystem(""), { params: formFilter }) .then((res) => { maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize); total.value = res.data.result.total; - let data = res.data.result.data.map((e: any) => ({ + let data = res.data.result.data.map((e: ResponseProfile) => ({ id: e.id, rootId: e.rootId, citizenId: e.citizenId, @@ -340,19 +345,11 @@ async function fecthlistperson(id: string = "") { } /** update ค่า เเถวข้อมูล */ -function updatePageSize(newPagination: any) { +function updatePageSize(newPagination: Pagination) { formFilter.page = 1; formFilter.pageSize = newPagination.rowsPerPage; } -/** เช็คเเถวข้อมูลว่ามีการเปลี่ยนแปลงไหม */ -watch( - () => formFilter.pageSize, - () => { - fecthlistperson(); - } -); - /** function ยืนยันการเพิ่มรายชื่อ*/ async function clickAdd() { dataPerson.id @@ -408,7 +405,7 @@ async function addlistperson(id: string) { * function openPopup แก้ไขเครื่องราชฯ * @param props รายละเอียด */ -async function clickmodalEdit(props: any) { +async function clickmodalEdit(props: DataManageList) { insignia.value = props.insigniaSend; person.value = props; modalEdit.value = true; @@ -433,7 +430,7 @@ async function downloadFile(response: any, filename: string) { /** function เรียก file รายชื่อข้าราชการสามัญฯ*/ async function downloadFileexcel() { const findInsigniaId = DataStore.dataInsigniaType.find( - (e: any) => e.name == DataStore.typeinsignia + (e: ResponseInsigniaType) => e.name == DataStore.typeinsignia ); showLoader(); await http @@ -442,7 +439,12 @@ async function downloadFileexcel() { { profileType: DataStore.employeeClass == "all" ? null : DataStore.employeeClass, - InsigniaId: DataStore.typeinsignia == "all" ? null : findInsigniaId.id, + InsigniaId: + DataStore.typeinsignia == "all" + ? null + : findInsigniaId + ? findInsigniaId.id + : "", }, { responseType: "blob" } ) @@ -460,47 +462,39 @@ async function downloadFileexcel() { }); } -/*** function ยืนยันการแก้ไขเครื่องราช*/ +/** function ยืนยันการแก้ไขเครื่องราช แก้ไขเครื่องราช API*/ async function clickSave() { dialogConfirm( $q, async () => { - await listEdit(person.value.id); + showLoader(); + let data = { + insigniaId: insignia.value, + }; + await http + .put(config.API.insigniaEdit(person.value ? person.value.id : ""), data) + .then(async () => { + await props?.fecthInsigniaByOc?.( + props.roundId, + organization.value, + "officer", + props.tab + ); + success($q, "แก้ไขเครื่องราชฯ ที่ยื่นขอสำเร็จ"); + modalEdit.value = false; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); }, "ยืนยันการแก้ไขเครื่องราชฯ ที่ยื่นขอ", "ต้องการยืนยันการแก้ไขเครื่องราชฯ ที่ยื่นขอนี้หรือไม่ ?" ); } -/** - * function แก้ไขเครื่องราช API - * @param profileId - */ -async function listEdit(profileId: string) { - showLoader(); - let data: any = { - insigniaId: insignia.value, - }; - await http - .put(config.API.insigniaEdit(profileId), data) - .then(async () => { - await props?.fecthInsigniaByOc?.( - props.roundId, - organization.value, - "officer", - props.tab - ); - success($q, "แก้ไขเครื่องราชฯ ที่ยื่นขอสำเร็จ"); - modalEdit.value = false; - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); -} - /** * function openPopup ไม่ยืนขอ * @param id profileId @@ -650,7 +644,7 @@ async function fecthInsignia() { await http .get(config.API.insigniaOrg) .then((res) => { - const listtype = res.data.result.map((e: any) => ({ + const listtype = res.data.result.map((e: ResponseInsigniaType) => ({ id: e.id, name: e.name + `(${e.shortName})`, })); @@ -787,6 +781,22 @@ function clearInsigniaFilters(name: string) { } } +watch( + () => DataStore.typeOc, + async () => { + filterOrganizationOP.value = await DataStore.optionsTypeOc; + organization.value = await DataStore.typeOc; + } +); + +/** เช็คเเถวข้อมูลว่ามีการเปลี่ยนแปลงไหม */ +watch( + () => formFilter.pageSize, + () => { + fecthlistperson(); + } +); + /** Hook*/ onMounted(async () => { filterOrganizationOP.value = await DataStore.optionsTypeOc; @@ -804,14 +814,6 @@ onMounted(async () => { } } }); - -watch( - () => DataStore.typeOc, - async () => { - filterOrganizationOP.value = await DataStore.optionsTypeOc; - organization.value = await DataStore.typeOc; - } -);