From 626e6023c32b3520bae157c25aefa0a57fbf25f0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 25 Jul 2023 18:04:11 +0700 Subject: [PATCH 1/8] no message --- .../components/ListRetirement/AddList.vue | 110 +++++++++++++----- .../components/ListRetirement/TableList.vue | 67 +++++++++-- src/modules/06_retirement/router.ts | 4 +- src/modules/06_retirement/views/Main.vue | 2 +- 4 files changed, 143 insertions(+), 40 deletions(-) diff --git a/src/modules/06_retirement/components/ListRetirement/AddList.vue b/src/modules/06_retirement/components/ListRetirement/AddList.vue index 01c06f54c..eb21b9163 100644 --- a/src/modules/06_retirement/components/ListRetirement/AddList.vue +++ b/src/modules/06_retirement/components/ListRetirement/AddList.vue @@ -4,24 +4,31 @@ import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import { useQuasar } from "quasar"; +import { useRoute } from "vue-router"; const $q = useQuasar(); //ใช้ noti quasar const mixin = useCounterMixin(); -const { messageError, success } = mixin; +const { messageError, success, showLoader, hideLoader } = mixin; +const route = useRoute(); +const type_params = route.params.type; const props = defineProps({ retireld: String, + listId: String, + UpdateListId: Function, }); const modal = ref(false); const retireld = ref(); +const type = ref(); +const listId = ref(props.listId); const columns = ref([ { - name: "order", + name: "index", required: true, label: "ลำดับ", - field: "order", + field: "index", align: "left", }, { @@ -108,27 +115,73 @@ const filter = ref(""); watch(modal, () => { if (modal.value === true) { retireld.value = props.retireld; - fecthlistRetire(retireld.value); + if (type_params === "officer") { + type.value = type_params; + } else type.value = "all"; + + fecthlistRetire(); } }); -const fecthlistRetire = async (retireld: any) => { - // await http - // .get(config.API.listRetire(retireld)) - // .then((res) => { - // console.log(res); - // rows.value = res.data.result.map((e: any) => ({ - // order: e.order, - // fullname: e.fullName, - // position: e.position, - // level: e.positionEmployeeLevel, - // organizationOrganization: e.organizationOrganization, - // })); - // }) - // .catch((e) => { - // messageError($q, e); - // }); +const updateListId = (val: any) => { + listId.value = val; + if (props.UpdateListId) { + props.UpdateListId(listId.value); + } }; -const clickAdd = () => { +const fecthlistRetire = async () => { + showLoader(); + await http + .get(config.API.profileOrganizRoot) + .then((res) => { + const id = res.data.result[0].id; + console.log(id); + if (id !== "") { + findlist(id); + } + }) + .catch((e) => { + messageError($q, e); + }); +}; + +const findlist = async (id: string) => { + let data = [{}]; + if (type.value === "officer") { + data = [{ criteriaType: "is_retire", criteriaValue: "false" }]; + } else if (type.value === "all") { + console.log("all"); + data = [ + { criteriaType: "is_retire", criteriaValue: "false" }, + { criteriaType: "employee_class", criteriaValue: "perm" }, + ]; + } + console.log(data); + + await http + .post(config.API.profileSearchNewOcIdType(id, type.value), { + criterias: data, + }) + .then((res) => { + console.log(res.data.result); + rows.value = res.data.result.map((e: any) => ({ + id: e.id, + fullname: e.fullname, + position: e.position, + level: e.positionEmployeeLevel, + organizationOrganization: e.oc, + })); + }) + .catch((e) => { + console.log(e); + }) + .finally(() => { + hideLoader(); + }); +}; +const clickAdd = (props: any) => { + console.log(props.row.id); + let data: any = props.row.id; + $q.dialog({ title: "ยืนยันการเพิ่มข้อมูล", message: "ต้องการเพิ่มข้อมูลนี้ใช่หรือไม่?", @@ -141,15 +194,17 @@ const clickAdd = () => { .onOk(async () => { console.log("เพิ่มข้อมูล"); await http - .put(config.API.profileRetire("123")) - .then(() => { + .put(config.API.profileRetire(data), { profileId: data }) + .then((res) => { success($q, "เพิ่มข้อมูลสำเร็จ"); + updateListId(data); }) .catch((e) => { messageError($q, e); }) .finally(() => { fecthlistRetire(); + modal.value = false; }); }) .onCancel(() => {}) @@ -236,10 +291,10 @@ const paginationLabel = (start: number, end: number, total: number) => {