fixing response error message for response type blob

This commit is contained in:
Warunee Tamkoo 2024-06-14 10:59:54 +07:00
parent 6375b446d2
commit a27091a81a
6 changed files with 157 additions and 139 deletions

View file

@ -386,8 +386,8 @@ const downloadExam = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -407,14 +407,8 @@ const downloadPassExam = async () => {
// start download
a.click();
})
.catch((e) => {
messageError(
$q,
e,
rows.value.length == 0
? "ไม่พบข้อมูลผลการสอบ กรุณาตรวจสอบความถูกต้องอีกครั้ง!"
: ""
);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -434,14 +428,8 @@ const downloadPassResultExam = async () => {
// start download
a.click();
})
.catch((e) => {
messageError(
$q,
e,
rows.value.length == 0
? "ไม่พบข้อมูลผลการสอบ กรุณาตรวจสอบความถูกต้องอีกครั้ง!"
: ""
);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -336,8 +336,8 @@ const downloadScore = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -358,8 +358,8 @@ const downloadCertificate = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -344,8 +344,8 @@ const downloadExam = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -365,8 +365,8 @@ const downloadPassExam = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -386,8 +386,8 @@ const downloadPassResultExam = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -339,8 +339,8 @@ const downloadScore = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -363,8 +363,8 @@ const downloadCertificate = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -65,13 +65,13 @@ const adsName = reactive({
const dataLabel = {
registrationAddress: "ที่อยู่ตามทะเบียนบ้าน",
registrationProvince: "จังหวัด",
registrationDistrict: "เขต / อำเภอ",
registrationDistrict: "เขต/อำเภอ",
registrationSubDistrict: "แขวง / ตำบล",
registrationZipCode: "รหัสไปรษณีย์",
currentAddress: "ที่อยู่ปัจจุบัน",
currentProvince: "จังหวัด",
currentDistrict: "เขต / อำเภอ",
currentDistrict: "เขต/อำเภอ",
currentSubDistrict: "แขวง / ตำบล",
currentZipCode: "รหัสไปรษณีย์",
@ -81,7 +81,6 @@ const dataLabel = {
const visibleColumnsHistory = ref<String[]>([
"currentAddress",
"currentDistrict",
"currentProvince",
"currentSubDistrict",
"currentZipCode",
"registrationAddress",
@ -481,6 +480,7 @@ onMounted(async () => {
await fetchAll();
});
</script>
<template>
<div class="row q-gutter-sm items-center">
<div class="toptitle col text-right q-gutter-x-sm">
@ -507,75 +507,109 @@ onMounted(async () => {
</div>
</div>
<q-card bordered class="my-card bg-grey-1 q-pa-md">
<div :class="$q.screen.gt.xs ? 'row' : 'column'">
<!-- column 1 -->
<div class="col-md-6 col-12 row">
<div class="col-6 text-grey-6 text-weight-medium">
<div
v-for="label in Object.keys(dataLabel).slice(0, 5)"
class="q-py-xs"
>
{{ dataLabel[label as keyof typeof dataLabel] }}
</div>
</div>
<!-- data -->
<div class="col-6">
<div class="q-py-xs">
{{ addressData.registrationAddress || "-" }}
</div>
<div class="q-py-xs">
{{ adsName.regisP || "-" }}
</div>
<div class="q-py-xs">
{{ adsName.regisD || "-" }}
</div>
<div class="q-py-xs">
{{ adsName.regisSD || "-" }}
</div>
<div class="q-py-xs">
{{ addressData.registrationZipCode || "-" }}
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-12">
<q-card bordered class="bg-grey-1 q-ma-sm">
<q-card-section>
<div class="text-bold">อยตามทะเบยนบาน</div>
</q-card-section>
<q-separator />
<q-card-section>
<div :class="$q.screen.gt.xs ? '' : 'column'">
<!-- column 1 -->
<div class="col-md-6 col-12 row">
<div class="col-5 text-grey-6 text-weight-medium">อย</div>
<div class="col-7">
<div class="q-py-xs">
{{ addressData.registrationAddress || "-" }}
</div>
</div>
<!-- column 2 -->
<!-- <div
class="text-grey-6 text-weight-medium"
v-if="addressData.same === '1'"
>
อยจจนตรงกบทอยตามทะเบยนบาน
</div> -->
<div class="col-md-6 col-12 row">
<div class="col-6 text-grey-6 text-weight-medium">
<div
v-for="label in Object.keys(dataLabel).slice(5, 10)"
class="q-py-xs"
>
{{ dataLabel[label as keyof typeof dataLabel] }}
<div class="col-5 text-grey-6 text-weight-medium">แขวง/ตำบล</div>
<div class="col-7">
<div class="q-py-xs">
{{ adsName.regisSD || "-" }}
</div>
</div>
<div class="col-5 text-grey-6 text-weight-medium">เขต/อำเภอ</div>
<div class="col-7">
<div class="q-py-xs">
{{ adsName.regisD || "-" }}
</div>
</div>
<div class="col-5 text-grey-6 text-weight-medium">งหว</div>
<div class="col-7">
<div class="q-py-xs">
{{ adsName.regisP || "-" }}
</div>
</div>
<div class="col-5 text-grey-6 text-weight-medium">
รหสไปรษณ
</div>
<div class="col-7">
<div class="q-py-xs">
{{ addressData.registrationZipCode || "-" }}
</div>
</div>
</div>
</div>
</div>
<!-- data -->
<div class="col-6">
<div class="q-py-xs">
{{ addressData.currentAddress || "-" }}
</div>
<div class="q-py-xs">
{{ adsName.currentP || "-" }}
</div>
<div class="q-py-xs">
{{ adsName.currentD || "-" }}
</div>
<div class="q-py-xs">
{{ adsName.currentSD || "-" }}
</div>
<div class="q-py-xs">
{{ addressData.currentZipCode || "-" }}
</div>
</div>
</div>
</q-card-section>
</q-card>
</div>
</q-card>
<div class="col-md-6 col-12">
<q-card bordered class="bg-grey-1 q-ma-sm">
<q-card-section>
<div class="text-bold">อยจจ</div>
</q-card-section>
<q-separator />
<q-card-section>
<div :class="$q.screen.gt.xs ? '' : 'column'">
<div class="col-md-6 col-12 row">
<div class="col-5 text-grey-6 text-weight-medium">อย</div>
<div class="col-7">
<div class="q-py-xs">
{{ addressData.currentAddress || "-" }}
</div>
</div>
<div class="col-5 text-grey-6 text-weight-medium">แขวง/ตำบล</div>
<div class="col-7">
<div class="q-py-xs">
{{ adsName.currentSD || "-" }}
</div>
</div>
<div class="col-5 text-grey-6 text-weight-medium">เขต/อำเภอ</div>
<div class="col-7">
<div class="q-py-xs">
{{ adsName.currentD || "-" }}
</div>
</div>
<div class="col-5 text-grey-6 text-weight-medium">งหว</div>
<div class="col-7">
<div class="q-py-xs">
{{ adsName.currentP || "-" }}
</div>
</div>
<div class="col-5 text-grey-6 text-weight-medium">
รหสไปรษณ
</div>
<div class="col-7">
<div class="q-py-xs">
{{ addressData.currentZipCode || "-" }}
</div>
</div>
</div>
</div>
</q-card-section>
</q-card>
</div>
</div>
<!-- Edit Dialog -->
<q-dialog v-model="modal" persistent>

View file

@ -411,48 +411,44 @@ export const useCounterMixin = defineStore("mixin", () => {
},
});
} else {
console.error(e.response.data); // ***
console.error(e.response.status); // ***
if (e.response.status == 404) {
q.dialog({
component: CustomComponent,
componentProps: {
title: `พบข้อผิดพลาด`,
message: msg,
icon: "warning",
color: "red",
onlycancel: true,
},
});
} else {
q.dialog({
component: CustomComponent,
componentProps: {
title: `พบข้อผิดพลาด`,
message: `ข้อมูลผิดพลาดทำให้เกิดการไม่ตอบสนองต่อการเรียกใช้งานดูเว็บไซต์`,
icon: "warning",
color: "red",
onlycancel: true,
},
});
}
q.dialog({
component: CustomComponent,
componentProps: {
title: `พบข้อผิดพลาด`,
message: `ข้อมูลผิดพลาดทำให้เกิดการไม่ตอบสนองต่อการเรียกใช้งานดูเว็บไซต์`,
icon: "warning",
color: "red",
onlycancel: true,
},
});
}
}
} else {
console.error(e.response.data); // ***
console.error(e.response.status); // ***
console.error("err===>", e); // ***
q.dialog({
component: CustomComponent,
componentProps: {
title: `พบข้อผิดพลาด`,
message: `ข้อมูลผิดพลาดทำให้เกิดการไม่ตอบสนองต่อการเรียกใช้งานดูเว็บไซต์`,
icon: "warning",
color: "red",
onlycancel: true,
},
});
if (e.message) {
q.dialog({
component: CustomComponent,
componentProps: {
title: `พบข้อผิดพลาด`,
message: e.message,
icon: "warning",
color: "red",
onlycancel: true,
},
});
} else {
q.dialog({
component: CustomComponent,
componentProps: {
title: `พบข้อผิดพลาด`,
message: `ข้อมูลผิดพลาดทำให้เกิดการไม่ตอบสนองต่อการเรียกใช้งานดูเว็บไซต์`,
icon: "warning",
color: "red",
onlycancel: true,
},
});
}
}
};