refactor(04): action and display control in component

This commit is contained in:
puriphatt 2024-08-20 10:43:23 +07:00
parent 4899688740
commit 73bbc07e82
8 changed files with 111 additions and 32 deletions

View file

@ -21,11 +21,12 @@ defineEmits<{
<div class="column full-width full-height"> <div class="column full-width full-height">
<div <div
class="text-weight-bold text-body1 flex items-center justify-between q-px-md q-py-sm" class="text-weight-bold text-body1 flex items-center justify-between q-px-md q-py-sm"
style="background: hsla(var(--info-bg) / 0.1)" style="background: hsla(var(--info-bg) / 0.1); min-height: 50px"
> >
{{ $t(`serviceProperties`) }} {{ $t(`serviceProperties`) }}
<q-btn <q-btn
v-if="!readonly"
:disable="readonly" :disable="readonly"
dense dense
flat flat

View file

@ -16,6 +16,12 @@ defineProps<{
outlined?: boolean; outlined?: boolean;
readonly?: boolean; readonly?: boolean;
separator?: boolean; separator?: boolean;
priceDisplay?: {
price: boolean;
agentPrice: boolean;
serviceCharge: boolean;
};
}>(); }>();
defineEmits<{ defineEmits<{
@ -78,6 +84,7 @@ function confirmDelete(items: unknown[], index: number) {
:length="workItems.length" :length="workItems.length"
:workIndex="index" :workIndex="index"
:readonly="readonly" :readonly="readonly"
:priceDisplay="priceDisplay"
v-model:work-name="workItems[index].name" v-model:work-name="workItems[index].name"
v-model:product-items="work.product" v-model:product-items="work.product"
v-model:attributes="work.attributes" v-model:attributes="work.attributes"

View file

@ -3,13 +3,27 @@ const serviceCharge = defineModel<number>('serviceCharge');
const agentPrice = defineModel<number>('agentPrice'); const agentPrice = defineModel<number>('agentPrice');
const price = defineModel<number>('price'); const price = defineModel<number>('price');
defineProps<{ withDefaults(
dense?: boolean; defineProps<{
outlined?: boolean; dense?: boolean;
readonly?: boolean; outlined?: boolean;
separator?: boolean; readonly?: boolean;
isType?: boolean; separator?: boolean;
}>(); isType?: boolean;
priceDisplay?: {
price: boolean;
agentPrice: boolean;
serviceCharge: boolean;
};
}>(),
{
priceDisplay: () => ({
price: true,
agentPrice: true,
serviceCharge: true,
}),
},
);
</script> </script>
<template> <template>
@ -27,6 +41,7 @@ defineProps<{
</div> </div>
<div class="col-12 row q-col-gutter-sm"> <div class="col-12 row q-col-gutter-sm">
<q-input <q-input
v-if="priceDisplay?.price"
lazy-rules="ondemand" lazy-rules="ondemand"
:dense="dense" :dense="dense"
outlined outlined
@ -40,6 +55,7 @@ defineProps<{
/> />
<q-input <q-input
v-if="priceDisplay?.agentPrice"
lazy-rules="ondemand" lazy-rules="ondemand"
:dense="dense" :dense="dense"
outlined outlined
@ -53,6 +69,7 @@ defineProps<{
/> />
<q-input <q-input
v-if="priceDisplay?.serviceCharge"
lazy-rules="ondemand" lazy-rules="ondemand"
:dense="dense" :dense="dense"
outlined outlined

View file

@ -15,6 +15,7 @@ withDefaults(
countType?: number; countType?: number;
countProduct?: number; countProduct?: number;
countService?: number; countService?: number;
action?: boolean;
}>(), }>(),
{ {
color: 'var(--brand-1)', color: 'var(--brand-1)',
@ -51,6 +52,7 @@ withDefaults(
/> />
<q-btn <q-btn
v-if="action"
flat flat
round round
padding="sm" padding="sm"

View file

@ -28,15 +28,21 @@ withDefaults(
typeProduct?: string; typeProduct?: string;
isAddProduct?: boolean; isAddProduct?: boolean;
isSelected?: boolean; action?: boolean;
index?: number; index?: number;
isDisabled?: boolean; isDisabled?: boolean;
noTimeImg?: boolean; noTimeImg?: boolean;
priceDisplay?: {
price: boolean;
agentPrice: boolean;
serviceCharge: boolean;
};
}>(), }>(),
{ {
isSelected: false, action: false,
}, },
); );
</script> </script>
@ -57,7 +63,7 @@ withDefaults(
</q-tooltip> </q-tooltip>
</div> </div>
<div <div
v-if="isSelected === false" v-if="action"
class="col-1 relative-position" class="col-1 relative-position"
style="left: 10px; bottom: 10px" style="left: 10px; bottom: 10px"
> >
@ -141,7 +147,7 @@ withDefaults(
</q-avatar> </q-avatar>
</div> </div>
<div :class="{ inactive: isDisabled }" class="column col"> <div :class="{ inactive: isDisabled }" class="column col full-width">
<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
@ -155,14 +161,16 @@ withDefaults(
</div> </div>
</div> </div>
<div v-if="data?.type === 'product'" class="flex"> <div v-if="data?.type === 'product'" class="flex full-width">
<div <div
class="row full-width text-right" class="row full-width text-right"
style="font-size: 10px; color: hsl(var(--stone-4-hsl))" style="font-size: 10px; color: hsl(var(--stone-4-hsl))"
> >
<div class="col-4">ราคาขาย</div> <div class="col" v-if="priceDisplay?.price">ราคาขาย</div>
<div class="col-4">ราคาตวแทน</div> <div class="col" v-if="priceDisplay?.agentPrice">ราคาตัวแทน</div>
<div class="col-4">ราคาคาดำเนนการ</div> <div class="col" v-if="priceDisplay?.serviceCharge">
ราคาดำเนนการ
</div>
</div> </div>
<div <div
@ -170,20 +178,23 @@ withDefaults(
style="margin-top: -5px" style="margin-top: -5px"
> >
<div <div
class="col-4 text-weight-bold" class="col text-weight-bold"
style="font-size: 14px; color: hsl(var(--orange-5-hsl))" style="font-size: 14px; color: hsl(var(--orange-5-hsl))"
v-if="priceDisplay?.price"
> >
฿{{ formatNumberDecimal(data?.price, 2) }} ฿{{ formatNumberDecimal(data?.price, 2) }}
</div> </div>
<div <div
class="col-4 text-weight-bold" class="col text-weight-bold"
style="font-size: 14px; color: hsl(var(--purple-9-hsl))" style="font-size: 14px; color: hsl(var(--purple-9-hsl))"
v-if="priceDisplay?.agentPrice"
> >
฿{{ formatNumberDecimal(data?.agentPrice, 2) }} ฿{{ formatNumberDecimal(data?.agentPrice, 2) }}
</div> </div>
<div <div
class="col-4" class="col"
style="font-size: 12px; color: hsl(var(--pink-7-hsl))" style="font-size: 12px; color: hsl(var(--pink-7-hsl))"
v-if="priceDisplay?.serviceCharge"
> >
฿{{ formatNumberDecimal(data?.serviceCharge, 2) }} ฿{{ formatNumberDecimal(data?.serviceCharge, 2) }}
</div> </div>

View file

@ -15,12 +15,27 @@ const optionStore = useOptionStore();
const { fetchListOfWork } = productServiceStore; const { fetchListOfWork } = productServiceStore;
const { workNameItems } = storeToRefs(productServiceStore); const { workNameItems } = storeToRefs(productServiceStore);
defineProps<{ withDefaults(
workIndex: number; defineProps<{
length: number; workIndex: number;
index: number; length: number;
readonly?: boolean; index: number;
}>(); readonly?: boolean;
priceDisplay?: {
price: boolean;
agentPrice: boolean;
serviceCharge: boolean;
};
}>(),
{
priceDisplay: () => ({
price: true,
agentPrice: true,
serviceCharge: true,
}),
},
);
const workName = defineModel<string>('workName'); const workName = defineModel<string>('workName');
const attributes = defineModel<Attributes>('attributes', { required: true }); const attributes = defineModel<Attributes>('attributes', { required: true });
@ -327,30 +342,51 @@ defineEmits<{
class="col-12 q-col-gutter-md row" class="col-12 q-col-gutter-md row"
style="color: var(--teal-9)" style="color: var(--teal-9)"
> >
<span class="col ellipsis price-orange text-weight-bold"> <span
v-if="priceDisplay?.price"
class="col ellipsis price-orange text-weight-bold"
>
<div class="text-caption app-text-muted-2"> <div class="text-caption app-text-muted-2">
{{ $t('salePrice') }} {{ $t('salePrice') }}
</div> </div>
฿{{ formatNumberDecimal(product.price, 2) }} ฿{{ formatNumberDecimal(product.price, 2) }}
<q-tooltip> <q-tooltip
anchor="bottom right"
self="center right"
:delay="300"
>
฿{{ formatNumberDecimal(product.price, 2) }} ฿{{ formatNumberDecimal(product.price, 2) }}
</q-tooltip> </q-tooltip>
</span> </span>
<span class="col ellipsis price-purple text-weight-bold"> <span
v-if="priceDisplay?.agentPrice"
class="col ellipsis price-purple text-weight-bold"
>
<div class="text-caption app-text-muted-2"> <div class="text-caption app-text-muted-2">
{{ $t('agentPrice') }} {{ $t('agentPrice') }}
</div> </div>
฿{{ formatNumberDecimal(product.agentPrice, 2) }} ฿{{ formatNumberDecimal(product.agentPrice, 2) }}
<q-tooltip> <q-tooltip
anchor="bottom right"
self="center right"
:delay="300"
>
฿{{ formatNumberDecimal(product.agentPrice, 2) }} ฿{{ formatNumberDecimal(product.agentPrice, 2) }}
</q-tooltip> </q-tooltip>
</span> </span>
<span class="col ellipsis price-pink column"> <span
v-if="priceDisplay?.serviceCharge"
class="col ellipsis price-pink column"
>
<div class="text-caption app-text-muted-2"> <div class="text-caption app-text-muted-2">
{{ $t('processingPrice') }} {{ $t('processingPrice') }}
</div> </div>
฿{{ formatNumberDecimal(product.serviceCharge, 2) }} ฿{{ formatNumberDecimal(product.serviceCharge, 2) }}
<q-tooltip> <q-tooltip
anchor="bottom right"
self="center right"
:delay="300"
>
฿{{ formatNumberDecimal(product.serviceCharge, 2) }} ฿{{ formatNumberDecimal(product.serviceCharge, 2) }}
</q-tooltip> </q-tooltip>
</span> </span>

View file

@ -176,7 +176,10 @@ const showOverlay = ref(false);
<!-- icon --> <!-- icon -->
<div class="row items-center q-pr-lg" style="z-index: 1"> <div class="row items-center q-pr-lg" style="z-index: 1">
<span v-if="toggleTitle" class="q-mr-md app-text-muted-2"> <span
v-if="useToggle && toggleTitle"
class="q-mr-md app-text-muted-2"
>
{{ toggleTitle }} {{ toggleTitle }}
</span> </span>

View file

@ -15,6 +15,7 @@ withDefaults(
nodeKey?: string; nodeKey?: string;
labelKey?: string; labelKey?: string;
childrenKey: string; childrenKey: string;
action?: boolean;
}>(), }>(),
{ {
color: 'transparent', color: 'transparent',
@ -123,6 +124,7 @@ defineEmits<{
/> />
<q-btn <q-btn
v-if="action"
icon="mdi-dots-vertical" icon="mdi-dots-vertical"
:id="`btn-tree-dots-${node.name}`" :id="`btn-tree-dots-${node.name}`"
size="sm" size="sm"