placement ==> ปรับ API

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-29 11:17:29 +07:00
parent ac53080cec
commit b808db1c73
5 changed files with 29 additions and 16 deletions

View file

@ -4,6 +4,7 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useRouter, useRoute } from "vue-router";
import { checkPermissionGet } from "@/utils/permissions";
/** importType*/
import type { PersonalImformation } from "@/components/information/interface/response/Information";
@ -101,8 +102,8 @@ async function fetchInformation(id: string) {
`${empType.value == "employee" ? `-${empType.value}` : ""}`
)
)
.then((res) => {
const data = res.data.result;
.then(async (res) => {
const data = await res.data.result;
imformation.prefix = data.prefix ? data.prefix : "-";
imformation.citizenId = data.citizenId ? data.citizenId : "-";
imformation.firstName = data.firstName ? data.firstName : "-";
@ -115,7 +116,7 @@ async function fetchInformation(id: string) {
avatar.position = data.position ? data.position : "-";
if (data.avatarName) {
fetchProfile(data.id as string, data.avatarName);
await fetchProfile(data.id as string, data.avatarName);
} else {
avatar.avatar = "";
}
@ -136,13 +137,13 @@ async function fetchProfileGov(id: string) {
showLoader();
await http
.get(
config.API.profileNewGovernmentById(
config.API.profileNewGovernmentCard(
id,
`${empType.value == "employee" ? `-${empType.value}` : ""}`
)
)
.then((res) => {
const data = res.data.result;
.then(async (res) => {
const data = await res.data.result;
goverment.oc = data.org !== "" ? data.org : "-";
goverment.posNo = data.posMasterNo !== "" ? data.posMasterNo : "-";
goverment.position = data.position !== "" ? data.position : "-";
@ -183,8 +184,10 @@ watch(
? "employee"
: "officer";
fetchInformation(props.id);
fetchProfileGov(props.id);
await Promise.all([
fetchInformation(props.id),
fetchProfileGov(props.id),
]);
}
}
}
@ -197,14 +200,10 @@ watch(modal, (newValue) => {
});
async function fetchProfile(id: string, avatarName: string) {
showLoader();
await http
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName))
.then(async (res) => {
avatar.avatar = await res.data.downloadUrl;
})
.finally(() => {
hideLoader();
});
}
</script>
@ -259,6 +258,11 @@ async function fetchProfile(id: string, avatarName: string) {
</div>
<div class="q-mt-md">
<q-btn
v-if="
empType === 'employee'
? checkPermissionGet('SYS_REGISTRY_EMP')
: checkPermissionGet('SYS_REGISTRY_OFFICER')
"
class="bg-white"
outline
rounded