jws-frontend/src/components/04_product-service/ProductCardComponent.vue

153 lines
3.8 KiB
Vue
Raw Normal View History

2024-06-10 16:42:59 +07:00
<script setup lang="ts">
import { dateFormat } from 'src/utils/datetime';
2024-08-09 15:06:41 +07:00
import { Status } from 'stores/types';
2024-08-27 11:46:26 +07:00
import KebabAction from '../shared/KebabAction.vue';
2024-06-10 16:42:59 +07:00
withDefaults(
defineProps<{
title?: string;
subtitle?: string;
color?: string;
2024-06-11 15:05:16 +07:00
status?: Status;
2024-06-10 16:42:59 +07:00
date?: Date;
2024-06-14 16:36:28 +07:00
isType?: boolean;
2024-06-19 18:00:38 +07:00
id?: string;
isDisabled?: boolean;
noAction?: boolean;
countType?: number;
countProduct?: number;
countService?: number;
action?: boolean;
2024-06-10 16:42:59 +07:00
}>(),
{
2024-06-10 17:42:37 +07:00
color: 'var(--brand-1)',
2024-06-10 16:42:59 +07:00
},
);
</script>
<template>
2024-06-11 12:00:53 +07:00
<div
2024-07-31 14:37:19 +07:00
:id="`enter-${title}`"
class="full-width rounded q-pa-sm"
2024-06-19 18:00:38 +07:00
@click="
() => {
$emit('onClick');
2024-06-19 18:00:38 +07:00
}
"
:class="{
'hover-card': !isDisabled,
}"
:style="`border: 1px solid hsla(var(--gray-7-hsl) / ${isDisabled ? 0.1 : 0.3})`"
2024-06-11 12:00:53 +07:00
>
2024-06-14 16:36:28 +07:00
<div
class="relative-position rounded q-pb-lg"
2024-07-04 15:45:09 +07:00
:style="`background-color:hsla(${color}/.2)`"
2024-06-14 16:36:28 +07:00
>
<div class="row justify-between items-center">
<q-avatar
2024-06-14 16:36:28 +07:00
round
icon="mdi-folder"
size="48px"
2024-06-14 16:36:28 +07:00
class="q-my-md q-ml-md"
:class="{ 'disabled-card': isDisabled }"
:style="`color:hsl(${color});background-color:var(--surface-1) `"
2024-06-14 16:36:28 +07:00
/>
2024-08-27 11:46:26 +07:00
<KebabAction
:id-name="id"
:status="status"
class="absolute-top-right"
v-if="action"
2024-08-27 11:46:26 +07:00
@view="$emit('viewCard')"
@edit="$emit('updateCard')"
@delete="$emit('deleteCard')"
@change-status="$emit('toggleStatus', id)"
/>
2024-06-14 16:36:28 +07:00
</div>
2024-06-10 16:42:59 +07:00
<div class="q-px-md" :class="{ 'disabled-card': isDisabled }">
2024-06-14 16:36:28 +07:00
<div class="text-subtitle1 text-bold">{{ title }}</div>
<div class="text-subtitle3 app-text-muted">{{ subtitle }}</div>
<div class="row q-gutter-md q-mt-sm">
<div
v-if="!isType"
class="col-3 bordered row justify-between q-px-sm rounded no-wrap"
style="border-radius: 5px"
2024-06-10 16:42:59 +07:00
>
2024-06-14 16:36:28 +07:00
<div><q-icon name="mdi-folder-table" /></div>
<div>{{ countType }}</div>
2024-06-14 16:36:28 +07:00
</div>
<div
class="col-3 bordered row justify-between q-px-sm rounded no-wrap"
style="border-radius: 5px"
2024-06-10 16:42:59 +07:00
>
2024-06-14 16:36:28 +07:00
<div><q-icon name="mdi-server-network" /></div>
<div>{{ countService }}</div>
2024-06-14 16:36:28 +07:00
</div>
<div
class="col-3 bordered row justify-between q-px-sm rounded no-wrap"
style="border-radius: 5px"
>
<div><q-icon name="mdi-shopping" /></div>
<div>{{ countProduct }}</div>
2024-06-14 16:36:28 +07:00
</div>
2024-06-10 16:42:59 +07:00
</div>
</div>
</div>
<div
class="q-pt-lg q-pb-sm row justify-between"
:class="{ 'disabled-card': isDisabled }"
>
2024-06-14 16:36:28 +07:00
<div class="flex items-center">
<q-icon
size="xs"
name="mdi-calendar-month"
class="q-mr-sm rounded q-pa-xs"
style="color: var(--stone-6); background-color: var(--surface-3)"
/>
{{ dateFormat(date) }}
</div>
<q-btn
2024-06-19 18:00:38 +07:00
@click.stop="
() => {
$emit('viewCard');
2024-06-19 18:00:38 +07:00
}
"
2024-06-14 16:36:28 +07:00
unelevated
2024-08-26 16:24:08 +07:00
class="q-px-sm text-capitalize"
:label="$t('general.detail')"
style="
background-color: hsla(var(--blue-5-hsl) / 0.1);
color: var(--blue-5);
"
2024-06-14 16:36:28 +07:00
>
<q-icon
size="xs"
name="mdi-chevron-right"
class="rounded"
style="color: var(--blue-5)"
/>
</q-btn>
</div>
2024-06-10 16:42:59 +07:00
</div>
</template>
<style scoped>
.sub-card {
background-color: var(--surface-0);
border-radius: 0 0 var(--radius-2) var(--radius-2);
font-size: 16px;
}
2024-06-11 12:00:53 +07:00
.hover-card:hover {
cursor: pointer;
opacity: 0.8;
box-shadow: var(--shadow-3);
}
2024-06-19 18:00:38 +07:00
.disabled-card {
opacity: 0.4;
cursor: pointer;
2024-06-19 18:00:38 +07:00
}
2024-06-10 16:42:59 +07:00
</style>