updated req edit profile

This commit is contained in:
Warunee Tamkoo 2024-10-25 15:49:07 +07:00
parent 7ba8a0feea
commit c8d1ca89ca
2 changed files with 52 additions and 70 deletions

View file

@ -18,7 +18,6 @@ const router = useRouter();
const route = useRoute(); const route = useRoute();
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin(); const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
const urlImg = ref<string>("");
const requestId = ref<string>(route.params.id.toString()); const requestId = ref<string>(route.params.id.toString());
const dataRequest = ref<any>({ const dataRequest = ref<any>({
@ -49,9 +48,7 @@ async function fetchData() {
status: data.status, status: data.status,
remark: data.remark, remark: data.remark,
}; };
if (dataRequest.value.topic == "ขอแก้ไขรูปภาพประจำตัว") { onDownloadFile(requestId.value); //
onDownloadFile(requestId.value);
}
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -61,12 +58,14 @@ async function fetchData() {
}); });
} }
const checkFile = ref<null | false | "img" | "doc">(null); // null , false , "img" , "doc"
const urlDownload = ref<string>(""); // url
/** /**
* function หาชอไฟล * function หาชอไฟล
* @param id รายการยนคำรองขอแกไขขอม * @param id รายการยนคำรองขอแกไขขอม
*/ */
function onDownloadFile(id: string) { function onDownloadFile(id: string) {
showLoader();
http http
.get( .get(
config.API.file( config.API.file(
@ -75,16 +74,15 @@ function onDownloadFile(id: string) {
id id
) )
) )
.then((res) => { .then(async (res) => {
if (res.data.length !== 0) { if (res.data.length !== 0) {
downloadUrl(id, res.data[0].fileName); await downloadUrl(id, res.data[0].fileName);
} else { } else {
hideLoader(); checkFile.value = false;
} }
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
hideLoader();
}); });
} }
@ -104,10 +102,11 @@ function downloadUrl(id: string, fileName: string) {
) )
) )
.then((res) => { .then((res) => {
urlDownload.value = res.data.downloadUrl;
if (dataRequest.value.topic == "ขอแก้ไขรูปภาพประจำตัว") { if (dataRequest.value.topic == "ขอแก้ไขรูปภาพประจำตัว") {
urlImg.value = res.data.downloadUrl; checkFile.value = "img";
} else { } else {
window.open(res.data.downloadUrl, "_blank"); checkFile.value = "doc";
} }
}) })
.catch((e) => { .catch((e) => {
@ -218,54 +217,37 @@ onMounted(async () => {
type="textarea" type="textarea"
/> />
</div> </div>
<div class="text-weight-bold text-dark col-12">
{{ <div v-if="checkFile != null && checkFile != false">
dataRequest.topic == "ขอแก้ไขรูปภาพประจำตัว" <div class="text-weight-bold text-dark col-12">
? "รูปภาพประจำตัว" {{
: "เอกสารหลักฐาน" checkFile == "img" ? "รูปภาพประจำตัว" : "เอกสารหลักฐาน"
}} }}
</div> </div>
<div class="col-12"> <div class="col-12">
<!-- เอกสารหลกฐาน --> <!-- เอกสารหลกฐาน -->
<q-btn <q-btn
v-if="dataRequest.topic !== 'ขอแก้ไขรูปภาพประจำตัว'" v-if="checkFile == 'doc'"
icon="mdi-download" icon="mdi-download"
dense dense
flat flat
label="ดาวน์โหลดเอกสารหลักฐาน" label="ดาวน์โหลดเอกสารหลักฐาน"
color="blue" color="blue"
@click.stop.pervent="onDownloadFile(requestId)" :href="urlDownload"
/> target="_blank"
<div v-else> />
<span v-if="urlImg == ''" <div
><div v-else-if="checkFile == 'img'"
style=" class="q-pa-md q-gutter-sm"
height: 200px;
max-width: 200px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
"
class="text-grey-5"
>
<q-spinner color="primary" size="3em" :thickness="10" />
</div>
</span>
<q-img
v-else
:src="urlImg"
:ratio="1"
spinner-color="primary"
spinner-size="82px"
fit="cover"
style="
height: 200px;
max-width: 200px;
border-radius: 20px;
"
> >
</q-img> <q-avatar size="120px" color="grey-4">
<img
:src="urlDownload"
class="bg-grey-3"
style="object-fit: cover"
/>
</q-avatar>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -81,15 +81,15 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
}, },
{ // {
name: "document", // name: "document",
align: "center", // align: "center",
label: "หลักฐานอ้างอิง", // label: "",
sortable: false, // sortable: false,
field: "document", // field: "document",
headerStyle: "font-size: 14px", // headerStyle: "font-size: 14px",
style: "font-size: 14px", // style: "font-size: 14px",
}, // },
{ {
name: "status", name: "status",
align: "left", align: "left",
@ -115,7 +115,7 @@ const visibleColumns = ref<string[]>([
"no", "no",
"topic", "topic",
"detail", "detail",
"document", // "document",
"status", "status",
"remark", "remark",
]); ]);
@ -405,7 +405,7 @@ onMounted(() => {
<div v-if="col.name == 'no'"> <div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }} {{ props.rowIndex + 1 }}
</div> </div>
<div v-else-if="col.name === 'document'"> <!-- <div v-else-if="col.name === 'document'">
<q-btn <q-btn
icon="mdi-download" icon="mdi-download"
round round
@ -417,7 +417,7 @@ onMounted(() => {
> >
<q-tooltip>หลกฐานอางอ</q-tooltip> <q-tooltip>หลกฐานอางอ</q-tooltip>
</q-btn> </q-btn>
</div> </div> -->
<div v-else class="table_ellipsis2"> <div v-else class="table_ellipsis2">
{{ col.value ? col.value : "-" }} {{ col.value ? col.value : "-" }}
</div> </div>