fix fetch

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-24 11:39:09 +07:00
parent 1888ce2f8b
commit 6824988322
9 changed files with 111 additions and 61 deletions

View file

@ -16,7 +16,7 @@ import { useCounterMixin } from "@/stores/mixin";
* use
*/
const $q = useQuasar();
const link = ref<string>('')
const link = ref<string>("");
const store = useRequestEditStore();
const dataStore = useDataStore();
const { dialogConfirm, showLoader, hideLoader, messageError, success } =
@ -167,20 +167,16 @@ function filterOption(val: string, update: Function) {
/**
* function fetch profileId
*/
function fetchProfile() {
showLoader();
http
.get(config.API.profilePosition())
.then((res) => {
const data = res.data.result;
profileId.value = data.profileId;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
async function fetchProfile() {
try {
isReadOnly.value = dataStore.officerType === "OFFICER";
const res = await http.get(config.API.profilePosition());
return res.data.result.profileId;
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
/** popup รายละเอียดของ ขอปรับปรุงข้อมูลจากกรมการปกครอง */
@ -194,7 +190,10 @@ function onInfo(val: string) {
watch(
() => modal.value,
async () => {
modal.value && fetchProfile();
profileId.value = dataStore.profileId
? dataStore.profileId
: await fetchProfile();
link.value = await dataStore.getProFileType();
}
);