fix: service & product card image

This commit is contained in:
puriphatt 2024-07-01 11:04:24 +00:00
parent b07d1b9085
commit 2d0def98a3
3 changed files with 185 additions and 176 deletions

View file

@ -39,14 +39,13 @@ withDefaults(
</script> </script>
<template> <template>
<AppBox <div
no-padding
bordered bordered
:class="{ 'is-add-product': isAddProduct }" :class="{ 'is-add-product': isAddProduct }"
style="box-shadow: var(--shadow-3); min-height: 300px" class="column bordered rounded q-pa-sm no-wrap"
style="box-shadow: var(--shadow-3); height: 20rem"
@click="$emit('select', data)" @click="$emit('select', data)"
> >
<div class="q-pa-sm">
<div class="row flex justify-between text-bold"> <div class="row flex justify-between text-bold">
<div class="col-9" :class="{ inactive: isDisabled }"> <div class="col-9" :class="{ inactive: isDisabled }">
{{ title ?? 'title' }} {{ title ?? 'title' }}
@ -142,7 +141,7 @@ withDefaults(
</q-avatar> </q-avatar>
</div> </div>
<div :class="{ inactive: isDisabled }"> <div :class="{ inactive: isDisabled }" class="column col">
<div class="app-text-muted">{{ data?.code ?? 'code' }}</div> <div class="app-text-muted">{{ data?.code ?? 'code' }}</div>
<div class="flex justify-start text-bold"> <div class="flex justify-start text-bold">
<div <div
@ -192,30 +191,35 @@ withDefaults(
</div> </div>
<div <div
class="flex justify-center rounded items-center q-my-md q-py-lg" class="col rounded q-my-md items-center justify-center flex"
:class="[ :class="[
data?.type === 'product' ? 'card__green' : 'card__orange', data?.type === 'product' ? 'card__green' : 'card__orange',
$q.dark.isActive ? 'dark' : '', $q.dark.isActive ? 'dark' : '',
]" ]"
style="overflow: hidden"
> >
<q-img <q-img
loading="lazy" loading="lazy"
:src="`${baseUrl}/${data?.type === 'service' ? 'service' : 'product'}/${data?.id}/image`" :src="`${baseUrl}/${data?.type === 'service' ? 'service' : 'product'}/${data?.id}/image`"
style="height: 86px; max-width: 100px"
> >
<template #error> <template #error>
<div
class="full-width items-center justify-center flex"
style="background-color: transparent"
>
<q-img <q-img
style="background: none; height: 86px; max-width: 100px"
:src=" :src="
data?.type === 'product' data?.type === 'product'
? '/shop-image.png' ? '/shop-image.png'
: '/service-image.png' : '/service-image.png'
" "
width="100%" width="5rem"
/> />
</div>
</template> </template>
</q-img> </q-img>
</div> </div>
<div class="row justify-between items-center q-mb-xs"> <div class="row justify-between items-center q-mb-xs">
<div class="q-pr-md" v-if="data?.type === 'service'"> <div class="q-pr-md" v-if="data?.type === 'service'">
<q-icon <q-icon
@ -237,7 +241,6 @@ withDefaults(
</div> </div>
</div> </div>
</div> </div>
</AppBox>
</template> </template>
<style scoped> <style scoped>

View file

@ -11,6 +11,7 @@ withDefaults(
isService?: boolean; isService?: boolean;
labelStatusToggle?: string; labelStatusToggle?: string;
hideToggle?: boolean; hideToggle?: boolean;
readonly?: boolean;
}>(), }>(),
{ {
hideToggle: true, hideToggle: true,
@ -48,7 +49,7 @@ defineEmits<{
/> />
</div> </div>
<div <div
v-if="urlProfile && !profileSubmit" v-if="urlProfile && !profileSubmit && !readonly"
class="col-12 row q-mt-md q-col-gutter-x-md" class="col-12 row q-mt-md q-col-gutter-x-md"
> >
<div class="col-6"> <div class="col-6">
@ -78,7 +79,7 @@ defineEmits<{
</div> </div>
<q-btn <q-btn
id="btn-profile-edit" id="btn-profile-edit"
v-else-if="urlProfile && profileSubmit" v-else-if="urlProfile && profileSubmit && !readonly"
dense dense
unelevated unelevated
outlined outlined
@ -91,7 +92,7 @@ defineEmits<{
<q-btn <q-btn
id="btn-profile-upload" id="btn-profile-upload"
v-else v-if="!urlProfile && !readonly"
dense dense
unelevated unelevated
outlined outlined

View file

@ -634,6 +634,9 @@ async function assignFormDataProductService(id: string) {
if (res) { if (res) {
statusToggle.value = res.status === 'INACTIVE' ? false : true; statusToggle.value = res.status === 'INACTIVE' ? false : true;
profileUrl.value = res.imageUrl;
profileSubmit.value = true;
currentService.value = JSON.parse(JSON.stringify(res)); currentService.value = JSON.parse(JSON.stringify(res));
prevService.value = { prevService.value = {
@ -732,7 +735,7 @@ function clearFormProduct() {
code: '', code: '',
image: undefined, image: undefined,
}; };
imageProduct.value = undefined;
dialogProduct.value = false; dialogProduct.value = false;
dialogProductEdit.value = false; dialogProductEdit.value = false;
profileUrl.value = ''; profileUrl.value = '';
@ -758,6 +761,7 @@ function clearFormService() {
dialogServiceEdit.value = false; dialogServiceEdit.value = false;
profileUrl.value = ''; profileUrl.value = '';
profileSubmit.value = false; profileSubmit.value = false;
imageProduct.value = undefined;
} }
function assignFormDataProductServiceCreate() { function assignFormDataProductServiceCreate() {
@ -2172,6 +2176,7 @@ watch(inputSearchProductAndService, async () => {
<template #prepend> <template #prepend>
<ProfileUpload <ProfileUpload
isService isService
:readonly="!infoServiceEdit"
v-model:url-profile="profileUrl" v-model:url-profile="profileUrl"
v-model:status-toggle="statusToggle" v-model:status-toggle="statusToggle"
v-model:profile-submit="profileSubmit" v-model:profile-submit="profileSubmit"