From 460f133b3ef700d10d78efd723e6adaab4949510 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 7 Jan 2025 11:07:24 +0700 Subject: [PATCH] =?UTF-8?q?API=20=E0=B8=88=E0=B8=B1=E0=B8=94=E0=B8=A5?= =?UTF-8?q?=E0=B8=B3=E0=B8=94=E0=B8=B1=E0=B8=9A=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87=E0=B8=9C=E0=B8=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/registry/api.registry.ts | 6 +- .../DialogSortEducation.vue | 74 +++++++++++++------ 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/api/registry/api.registry.ts b/src/api/registry/api.registry.ts index e72bd36d6..5cfa64f12 100644 --- a/src/api/registry/api.registry.ts +++ b/src/api/registry/api.registry.ts @@ -76,6 +76,9 @@ export default { // ประวัติการศึกษา profileNewEducation: (type: string) => `${registryNew}${type}/educations`, + profileNewEducationSort: (type: string) => + `${registryNew}${type}/educations/sort`, + profileNewEducationByProfileId: (profileId: string, type: string) => `${registryNew}${type}/educations/${profileId}`, profileNewEducationByEducationId: (educationId: string, type: string) => @@ -202,5 +205,6 @@ export default { developMentPlan: `${registryNew}/development`, - requestInformationbyType:(type:string,id:string)=>`${registryNew}/request-edit/${type}/${id}` + requestInformationbyType: (type: string, id: string) => + `${registryNew}/request-edit/${type}/${id}`, }; diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/DialogSortEducation.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/DialogSortEducation.vue index f7ebcd39d..a2f95ebca 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/DialogSortEducation.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/DialogSortEducation.vue @@ -6,6 +6,7 @@ import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import { useOrganizational } from "@/modules/02_organization/store/organizational"; +import { useRoute } from "vue-router"; /** importType*/ import type { QTableProps } from "quasar"; @@ -18,6 +19,7 @@ import DialogHeader from "@/components/DialogHeader.vue"; /** use*/ const $q = useQuasar(); +const route = useRoute(); const store = useOrganizational(); const { dialogConfirm, @@ -34,21 +36,12 @@ const modal = defineModel("modal", { required: true }); const props = defineProps({ dataSort: Array as PropType, }); +const profileId = ref(route.params.id.toString()); //id profile /** ข้อมูล Table*/ const rows = ref([]); +const selected = ref([]); const columns = ref([ - { - name: "no", - align: "left", - label: "ลำดับ", - sortable: true, - field: "no", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, { name: "educationLevel", align: "left", @@ -234,16 +227,42 @@ const columns = ref([ */ function onDrop(from: number, to: number) { rows.value.splice(to, 0, rows.value.splice(from, 1)[0]); + selected.value.push(rows.value[0]); } /** function บันทึกการจัดลำดับ*/ function onSubmit() { - dialogConfirm($q, () => {}); + dialogConfirm($q, async () => { + showLoader(); + const body = rows.value.map((e: any) => ({ + id: e.id, + isUse: selected.value.some((i: any) => i.id === e.id), + })); + + await http + .put(config.API.profileNewEducationSort("") + `/${profileId.value}`, { + data: body, + }) + .then(async () => { + await success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); + }); } watch(modal, async () => { if (modal.value && props.dataSort) { rows.value = props.dataSort; + selected.value.push(rows.value[0]); + } else { + selected.value = []; + rows.value = []; } }); @@ -277,26 +296,33 @@ watch(modal, async () => { hide-bottom hide-pagination hide-header + selection="multiple" + v-model:selected="selected" > +