From 2e91482bf9a1ca151feaed66c567d681b49b7649 Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Tue, 19 Sep 2023 16:36:40 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=88=E0=B8=B1=E0=B8=94=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=9A=E0=B8=B5=E0=B8=A2=E0=B8=9A=20code=20?= =?UTF-8?q?=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../05_placement/components/Other/Detail.vue | 80 +-- .../components/Other/Dialogbody.vue | 283 ++++++++ .../05_placement/components/Other/Main.vue | 607 ++++-------------- 3 files changed, 446 insertions(+), 524 deletions(-) create mode 100644 src/modules/05_placement/components/Other/Dialogbody.vue diff --git a/src/modules/05_placement/components/Other/Detail.vue b/src/modules/05_placement/components/Other/Detail.vue index 994b4bc84..406ace50a 100644 --- a/src/modules/05_placement/components/Other/Detail.vue +++ b/src/modules/05_placement/components/Other/Detail.vue @@ -6,7 +6,7 @@ import { useCounterMixin } from "@/stores/mixin"; import type { ResponseTitle } from "@/modules/05_placement/interface/response/Receive"; import type { ResponseDataDetail } from "@/modules/05_placement/interface/response/Transfer"; -import type { QTableProps, QForm } from "quasar"; +import type { QForm } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; @@ -27,8 +27,8 @@ const { dialogConfirm, success, } = mixin; -const roleAdmin = ref(false); +const roleAdmin = ref(false); const title = ref({ fullname: "", organizationPositionOld: "", @@ -64,23 +64,14 @@ const reason = ref(""); const Otherdata = ref([]); const avatar = ref(""); -onMounted(async () => { - if (keycloak.tokenParsed != null) { - roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1"); - console.log("roleAdmin===>", roleAdmin.value); - } - await fecthOther(); -}); - +//-----(fetch data by id)-----// const fecthOther = async () => { showLoader(); await http .get(config.API.otherByid(paramsId.toString())) - // .get(config.API.transferId(paramsId.toString())) .then((res: any) => { const data = res.data.result; Otherdata.value = res.data.result; - // console.log(data); avatar.value = data.avatar ?? ""; title.value.fullname = `${data.firstname ?? "-"} ${data.lastname ?? "-"}`; title.value.organizationPositionOld = data.organizationPositionOld ?? "-"; @@ -89,12 +80,10 @@ const fecthOther = async () => { responseData.value.profileId = data.profileId; responseData.value.createdAt = data.createdAt; - responseData.value.date = - data.date !== null ? new Date(data.date) : new Date(); + responseData.value.date = data.date !== null ? new Date(data.date) : new Date(); responseData.value.id = data.id ?? ""; responseData.value.organization = data.organization ?? ""; - responseData.value.organizationPositionOld = - data.organizationPositionOld ?? ""; + responseData.value.organizationPositionOld = data.organizationPositionOld ?? ""; responseData.value.positionLevelOld = data.positionLevelOld ?? ""; responseData.value.positionNumberOld = data.positionNumberOld ?? ""; responseData.value.positionTypeOld = data.positionTypeOld ?? ""; @@ -102,18 +91,14 @@ const fecthOther = async () => { responseData.value.salary = data.salary !== null ? data.salary : 0; responseData.value.status = data.status ?? ""; responseData.value.avataPath = data.avataPath ?? ""; - responseData.value.fullname = `${data.firstname ?? "-"} ${ - data.lastName ?? "-" - }`; - + responseData.value.fullname = `${data.prefix ?? "-"}${data.firstname ?? "-"} ${data.lastname ?? "-"}`; organizationPositionOld.value = data.organizationPositionOld ?? ""; positionTypeOld.value = data.positionTypeOld ?? ""; positionLevelOld.value = data.positionLevelOld ?? ""; posNo.value = data.positionNumberOld ?? ""; salary.value = data.amountOld ?? ""; organization.value = data.organization ?? ""; - date.value = - data.positionDate !== null ? new Date(data.positionDate) : null; + date.value = data.positionDate !== null ? new Date(data.positionDate) : null; reason.value = data.reason ?? ""; }) .catch((e) => { @@ -124,6 +109,8 @@ const fecthOther = async () => { edit.value = false; }); }; + +//-----(edit)-----// const clickEdit = async () => { await myform.value.validate().then(async (success: boolean) => { if (success) { @@ -132,8 +119,8 @@ const clickEdit = async () => { } }); }; +//-----(update)-----// const saveOther = async () => { - // showLoader(); let data = { citizenId: Otherdata.value.citizenId, prefixId: Otherdata.value.prefixId, @@ -147,8 +134,6 @@ const saveOther = async () => { positionNumberOld: posNo.value, amountOld: Number(salary.value), }; - console.log(data); - await http .put(config.API.otherByid(paramsId.toString()), data) .then(() => { @@ -168,8 +153,14 @@ const getClass = (val: boolean) => { "full-width cursor-pointer": !val, }; }; +onMounted(async () => { + if (keycloak.tokenParsed != null) { + roleAdmin.value = await keycloak.tokenParsed.role.includes("placement1"); + console.log("roleAdmin===>", roleAdmin.value); + } + await fecthOther(); +}); -