fix: new service & work properties

This commit is contained in:
puriphatt 2024-06-25 09:35:06 +00:00
parent 82560b6abd
commit d67e6e13dd
7 changed files with 312 additions and 189 deletions

View file

@ -106,25 +106,7 @@ defineEmits<{
class="col-9" class="col-9"
:label="$t('serviceName')" :label="$t('serviceName')"
v-model="serviceName" v-model="serviceName"
> />
<template #prepend>
<q-btn
v-if="!readonly"
dense
unelevated
round
padding="0"
style="background-color: var(--surface-tab)"
@click="$emit('serviceProperties')"
>
<Icon
icon="basil:settings-adjust-solid"
width="24px"
style="color: var(--stone-7)"
/>
</q-btn>
</template>
</q-input>
<div v-if="readonly && serviceAttributes" class="col-12 q-gutter-x-md"> <div v-if="readonly && serviceAttributes" class="col-12 q-gutter-x-md">
<span <span
v-for="(p, index) in serviceAttributes.additional" v-for="(p, index) in serviceAttributes.additional"

View file

@ -0,0 +1,63 @@
<script setup lang="ts">
import useOptionStore from 'src/stores/options';
import { Attributes } from 'src/stores/product-service/types';
import { Icon } from '@iconify/vue';
const optionStore = useOptionStore();
defineProps<{
readonly?: boolean;
}>();
const serviceAttributes = defineModel<Attributes>('serviceAttributes', {
required: true,
});
defineEmits<{
(e: 'serviceProperties'): void;
}>();
</script>
<template>
<div class="col-3 app-text-muted">
{{ $t(`formDialogTitleInformation`) }}
<div>
<q-btn
:disable="readonly"
dense
unelevated
outline
class="q-mt-sm q-px-sm"
color="primary"
@click="$emit('serviceProperties')"
>
<Icon
icon="basil:settings-adjust-solid"
width="24px"
class="q-mr-sm"
style="color: var(--brand-1)"
/>
{{ $t('properties') }}
</q-btn>
</div>
</div>
<div class="col-9 row">
<div
v-if="serviceAttributes.additional.length > 0"
class="col q-gutter-sm row items-center"
>
<div
v-for="(p, index) in serviceAttributes.additional"
:key="index"
class="bordered q-px-sm surface-3"
style="border-radius: 6px"
>
{{ optionStore.mapOption(p.fieldName ?? '') }}
</div>
</div>
<div v-else class="col flex items-center app-text-muted">
{{ $t('noProperties') }}
</div>
</div>
</template>

View file

@ -50,7 +50,7 @@ function confirmDelete(items: unknown[], index: number) {
<template> <template>
<div class="column col-12 full-height"> <div class="column col-12 full-height">
<div class="col-1 app-text-muted row items-start"> <div class="app-text-muted row items-start">
{{ $t(`workInformation`) }} {{ $t(`workInformation`) }}
<q-btn <q-btn
v-if="!readonly" v-if="!readonly"

View file

@ -21,7 +21,7 @@ defineProps<{
}>(); }>();
const workName = defineModel<string>('workName'); const workName = defineModel<string>('workName');
const attributes = defineModel<Attributes>('attributes'); const attributes = defineModel<Attributes>('attributes', { required: true });
const productItems = defineModel<(ProductList & { nameEn: string })[]>( const productItems = defineModel<(ProductList & { nameEn: string })[]>(
'productItems', 'productItems',
{ {
@ -85,22 +85,6 @@ defineEmits<{
:style="`background-color:${readonly ? 'var(--surface-2)' : 'var(--surface-1); z-index: 2'}`" :style="`background-color:${readonly ? 'var(--surface-2)' : 'var(--surface-1); z-index: 2'}`"
@click="() => (readonly ? '' : fetchListOfWork())" @click="() => (readonly ? '' : fetchListOfWork())"
> >
<q-btn
v-if="!readonly"
dense
unelevated
round
padding="0"
class="q-mr-sm"
style="background-color: var(--surface-tab)"
@click.stop="$emit('workProperties')"
>
<Icon
icon="basil:settings-adjust-solid"
width="24px"
style="color: var(--stone-7)"
/>
</q-btn>
<span class="text-body2" style="color: var(--foreground)"> <span class="text-body2" style="color: var(--foreground)">
{{ $t('workNo') }} {{ index + 1 }} : {{ $t('workNo') }} {{ index + 1 }} :
<span class="app-text-muted-2"> <span class="app-text-muted-2">
@ -168,143 +152,186 @@ defineEmits<{
<q-tooltip>{{ $t('delete') }}</q-tooltip> <q-tooltip>{{ $t('delete') }}</q-tooltip>
</q-btn> </q-btn>
</div> </div>
<div
v-if="readonly && attributes"
class="row q-pb-md q-px-md q-gutter-x-md"
>
<span
v-for="(p, index) in attributes.additional"
:key="index"
class="bordered q-px-sm surface-tab"
style="border-radius: 6px"
>
{{ optionStore.mapOption(p.fieldName ?? '') }}
</span>
</div>
</div> </div>
</template> </template>
<div class="surface-2"> <div class="surface-2">
<div <!-- properties -->
class="q-py-xs text-weight-medium row justify-between items-center q-px-md" <div class="bordered-t">
style="background-color: hsla(var(--info-bg) / 0.1)" <div
> class="q-py-xs text-weight-medium row justify-between items-center q-px-md"
<span>{{ $t('productInWork') }} {{ workIndex + 1 }}</span> style="background-color: hsla(var(--info-bg) / 0.1)"
<q-btn >
v-if="!readonly" <span>{{ $t('propertiesInWork') }} {{ workIndex + 1 }}</span>
id="btn-add-work-product" <q-btn
flat v-if="!readonly"
dense id="btn-add-work-product"
icon="mdi-plus" flat
:label="$t('serviceAddProduct')" dense
padding="0" padding="0"
style="color: hsl(var(--info-bg))" style="color: hsl(var(--info-bg))"
@click.stop="$emit('addProduct')" @click.stop="$emit('workProperties')"
/> >
<Icon
icon="basil:settings-adjust-solid"
width="24px"
class="q-mr-sm"
style="color: hsl(var(--info-bg))"
/>
{{ $t('properties') }}
</q-btn>
</div>
<div class="q-py-md q-px-lg full-width">
<div
v-if="attributes.additional.length > 0"
class="row items-center full-width surface-1 q-py-md q-px-sm q-gutter-sm"
>
<div
v-for="(p, index) in attributes.additional"
:key="index"
class="bordered q-px-sm surface-3"
style="border-radius: 6px"
>
{{ optionStore.mapOption(p.fieldName ?? '') }}
</div>
</div>
<div v-else class="app-text-muted">
{{ $t('noProperties') }}
</div>
</div>
</div> </div>
<div class="q-py-md q-px-lg full-width q-gutter-y-sm"> <!-- product -->
<div class="bordered-t">
<div <div
v-for="(product, index) in productItems" class="q-py-xs text-weight-medium row justify-between items-center q-px-md"
:key="product.id" style="background-color: hsla(var(--info-bg) / 0.1)"
class="full-width row items-center justify-between" >
<span>{{ $t('productInWork') }} {{ workIndex + 1 }}</span>
<q-btn
v-if="!readonly"
id="btn-add-work-product"
flat
dense
icon="mdi-plus"
:label="$t('serviceAddProduct')"
padding="0"
style="color: hsl(var(--info-bg))"
@click.stop="$emit('addProduct')"
/>
</div>
<div
v-if="productItems.length > 0"
class="q-py-md q-px-lg full-width q-gutter-y-sm"
> >
<div <div
class="row col items-center justify-between full-width surface-1 q-py-md q-px-sm" v-for="(product, index) in productItems"
:key="product.id"
class="full-width row items-center justify-between"
> >
<div class="row items-center col-9 no-wrap" v-if="productItems"> <div
<q-btn class="row col items-center justify-between full-width surface-1 q-py-md q-px-sm"
v-if="!readonly" >
id="btn-product-up" <div class="row items-center col-9 no-wrap" v-if="productItems">
icon="mdi-arrow-up" <q-btn
dense v-if="!readonly"
flat id="btn-product-up"
round icon="mdi-arrow-up"
:disable="index === 0" dense
style="color: hsl(var(--text-mute-2))" flat
@click.stop="$emit('moveProductUp', productItems, index)" round
/> :disable="index === 0"
<q-btn style="color: hsl(var(--text-mute-2))"
v-if="!readonly" @click.stop="$emit('moveProductUp', productItems, index)"
id="btn-product-down" />
icon="mdi-arrow-down" <q-btn
dense v-if="!readonly"
flat id="btn-product-down"
round icon="mdi-arrow-down"
class="q-mx-sm" dense
:disable="index === productItems.length - 1" flat
style="color: hsl(var(--text-mute-2))" round
@click.stop="$emit('moveProductDown', productItems, index)" class="q-mx-sm"
/> :disable="index === productItems.length - 1"
style="color: hsl(var(--text-mute-2))"
@click.stop="$emit('moveProductDown', productItems, index)"
/>
<q-avatar <q-avatar
size="md" size="md"
class="q-mx-lg" class="q-mx-lg"
style="background-color: var(--surface-tab)" style="background-color: var(--surface-tab)"
> >
{{ index + 1 }} {{ index + 1 }}
</q-avatar> </q-avatar>
<div class="row no-wrap"> <div class="row no-wrap">
<div class="bordered q-mx-md col-3 image-box"> <div class="bordered q-mx-md col-3 image-box">
<q-img <q-img
src="blank-image.png" src="blank-image.png"
style="object-fit: cover; width: 100%; height: 100%" style="object-fit: cover; width: 100%; height: 100%"
></q-img> ></q-img>
</div> </div>
<div class="column col justify-between"> <div class="column col justify-between">
<span <span
class="text-weight-bold ellipsis-2-lines" class="text-weight-bold ellipsis-2-lines"
:style="`max-width: ${$q.screen.gt.sm ? '25vw' : '20vw'}`" :style="`max-width: ${$q.screen.gt.sm ? '25vw' : '20vw'}`"
> >
{{
$i18n.locale === 'en-US' ? product.nameEn : product.name
}}
<q-tooltip>
{{ {{
$i18n.locale === 'en-US' $i18n.locale === 'en-US'
? product.nameEn ? product.nameEn
: product.name : product.name
}} }}
</q-tooltip> <q-tooltip>
</span> {{
<div $i18n.locale === 'en-US'
class="bordered q-px-sm" ? product.nameEn
style="border-radius: 6px; max-width: 60px" : product.name
> }}
{{ product.code }} </q-tooltip>
</span>
<div
class="bordered q-px-sm"
style="border-radius: 6px; max-width: 60px"
>
{{ product.code }}
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="row justify-end text-right col-3 q-pr-sm">
<span
class="col-12 text-weight-bold text-h6"
style="color: var(--teal-9)"
>
฿ {{ formatNumberDecimal(product.price, 2) }}
</span>
<span class="col-9 text-caption app-text-muted-2">
{{ $t('processTime') }}
</span>
<span class="col-3 text-caption app-text-muted-2">
{{ product.process }} {{ $t('day') }}
</span>
</div>
</div> </div>
<div class="row justify-end text-right col-3 q-pr-sm"> <q-btn
<span v-if="!readonly"
class="col-12 text-weight-bold text-h6" id="btn-delete-work-product"
style="color: var(--teal-9)" icon="mdi-trash-can-outline"
> dense
฿ {{ formatNumberDecimal(product.price, 2) }} flat
</span> round
<span class="col-9 text-caption app-text-muted-2"> color="negative"
{{ $t('processTime') }} class="q-mx-sm"
</span> @click.stop="$emit('deleteProduct', productItems, index)"
<span class="col-3 text-caption app-text-muted-2"> />
{{ product.process }} {{ $t('day') }}
</span>
</div>
</div> </div>
</div>
<q-btn <div v-else class="app-text-muted q-py-md q-px-lg">
v-if="!readonly" {{ $t('noProduct') }}
id="btn-delete-work-product"
icon="mdi-trash-can-outline"
dense
flat
round
color="negative"
class="q-mx-sm"
@click.stop="$emit('deleteProduct', productItems, index)"
/>
</div> </div>
</div> </div>
</div> </div>

View file

@ -49,6 +49,10 @@ export default {
addWork: 'Add work', addWork: 'Add work',
properties: 'Properties', properties: 'Properties',
noProperties: 'No Properties',
serviceProperties: 'Service Properties',
workProperties: 'Work Properties',
propertiesInWork: 'Properties in work',
text: 'Text', text: 'Text',
number: 'Number', number: 'Number',
date: 'Date', date: 'Date',
@ -61,4 +65,6 @@ export default {
telMaxLength: 'Max Length', telMaxLength: 'Max Length',
addSelection: 'Add Selection', addSelection: 'Add Selection',
selectAll: 'Select All', selectAll: 'Select All',
noProduct: 'No Product',
}; };

View file

@ -49,6 +49,10 @@ export default {
addWork: 'เพิ่มงานใหม่', addWork: 'เพิ่มงานใหม่',
properties: 'คุณสมบัติ', properties: 'คุณสมบัติ',
noProperties: 'ยังไม่มีคุณสมบัติ',
serviceProperties: 'คุณสมบัติของบริการ',
workProperties: 'คุณสมบัติของงาน',
propertiesInWork: 'คุณสมบัติภายในงาน',
text: 'ข้อความ', text: 'ข้อความ',
number: 'ตัวเลข', number: 'ตัวเลข',
date: 'วันที่', date: 'วันที่',
@ -61,4 +65,6 @@ export default {
telMaxLength: 'จำนวนหลัก', telMaxLength: 'จำนวนหลัก',
addSelection: 'เพิ่มตัวเลือก', addSelection: 'เพิ่มตัวเลือก',
selectAll: 'เลือกทั้งหมด', selectAll: 'เลือกทั้งหมด',
noProduct: 'ยังไม่มีสินค้า',
}; };

View file

@ -18,6 +18,7 @@ import FormServiceWork from 'src/components/04_product-service/FormServiceWork.v
import ServiceProperties from 'src/components/04_product-service/ServiceProperties.vue'; import ServiceProperties from 'src/components/04_product-service/ServiceProperties.vue';
import WorkNameManagement from 'src/components/04_product-service/WorkNameManagement.vue'; import WorkNameManagement from 'src/components/04_product-service/WorkNameManagement.vue';
import useOptionStore from 'src/stores/options'; import useOptionStore from 'src/stores/options';
import FormServiceProperties from 'src/components/04_product-service/FormServiceProperties.vue';
import { Status } from 'src/stores/types'; import { Status } from 'src/stores/types';
import NoData from 'components/NoData.vue'; import NoData from 'components/NoData.vue';
@ -1789,6 +1790,7 @@ watch(currentStatus, async () => {
<!-- add service --> <!-- add service -->
<FormDialog <FormDialog
no-address no-address
no-app-box
height="95vh" height="95vh"
:title="$t('addService')" :title="$t('addService')"
v-model:modal="dialogService" v-model:modal="dialogService"
@ -1816,25 +1818,42 @@ watch(currentStatus, async () => {
/> />
</template> </template>
<template #information> <div v-if="currentServiceTab === 'serviceInformation'" class="col-10">
<BasicInformation <div class="surface-1 rounded bordered q-pa-lg full-width row">
v-if="currentServiceTab === 'serviceInformation'" <BasicInformation
dense dense
service service
@service-properties=" @service-properties="
() => { () => {
tempValueProperties = formDataProductService.attributes; tempValueProperties = formDataProductService.attributes;
openPropertiesDialog('service'); openPropertiesDialog('service');
} }
" "
v-model:service-code="formDataProductService.code" v-model:service-code="formDataProductService.code"
v-model:service-description="formDataProductService.detail" v-model:service-description="formDataProductService.detail"
v-model:service-name-th="formDataProductService.name" v-model:service-name-th="formDataProductService.name"
@input-file="inputFile.click()" @input-file="inputFile.click()"
/> />
</div>
<div class="surface-1 rounded bordered q-mt-md q-pa-lg row">
<FormServiceProperties
v-model:service-attributes="formDataProductService.attributes"
@service-properties="
() => {
tempValueProperties = formDataProductService.attributes;
openPropertiesDialog('service');
}
"
/>
</div>
</div>
<div
v-if="currentServiceTab === 'workInformation'"
class="surface-1 rounded bordered col-10 q-pa-lg"
>
<FormServiceWork <FormServiceWork
v-model:work-items="workItems" v-model:work-items="workItems"
v-if="currentServiceTab === 'workInformation'"
dense dense
@addProduct=" @addProduct="
async (index) => { async (index) => {
@ -1856,7 +1875,7 @@ watch(currentStatus, async () => {
} }
" "
/> />
</template> </div>
</FormDialog> </FormDialog>
<!-- service properties --> <!-- service properties -->
@ -1914,6 +1933,7 @@ watch(currentStatus, async () => {
<!-- edit service --> <!-- edit service -->
<FormDialog <FormDialog
no-address no-address
no-app-box
:edit="!(formDataProductService.status === 'INACTIVE')" :edit="!(formDataProductService.status === 'INACTIVE')"
height="95vh" height="95vh"
:isEdit="infoServiceEdit" :isEdit="infoServiceEdit"
@ -1956,24 +1976,43 @@ watch(currentStatus, async () => {
/> />
</template> </template>
<template #information> <div v-if="currentServiceTab === 'serviceInformation'" class="col-10">
<BasicInformation <div class="surface-1 rounded bordered q-pa-lg full-width row">
:readonly="!infoServiceEdit" <BasicInformation
v-if="currentServiceTab === 'serviceInformation'" :readonly="!infoServiceEdit"
dense v-if="currentServiceTab === 'serviceInformation'"
service dense
@service-properties=" service
() => { @service-properties="
tempValueProperties = formDataProductService.attributes; () => {
openPropertiesDialog('service'); tempValueProperties = formDataProductService.attributes;
} openPropertiesDialog('service');
" }
v-model:service-attributes="formDataProductService.attributes" "
v-model:service-code="formDataProductService.code" v-model:service-code="formDataProductService.code"
v-model:service-description="formDataProductService.detail" v-model:service-description="formDataProductService.detail"
v-model:service-name-th="formDataProductService.name" v-model:service-name-th="formDataProductService.name"
@input-file="inputFile.click()" @input-file="inputFile.click()"
/> />
</div>
<div class="surface-1 rounded bordered q-mt-md q-pa-lg row">
<FormServiceProperties
:readonly="!infoServiceEdit"
v-model:service-attributes="formDataProductService.attributes"
@service-properties="
() => {
tempValueProperties = formDataProductService.attributes;
openPropertiesDialog('service');
}
"
/>
</div>
</div>
<div
v-if="currentServiceTab === 'workInformation'"
class="surface-1 rounded bordered col-10 q-pa-lg"
>
<FormServiceWork <FormServiceWork
:readonly="!infoServiceEdit" :readonly="!infoServiceEdit"
v-model:work-items="workItems" v-model:work-items="workItems"
@ -1995,7 +2034,7 @@ watch(currentStatus, async () => {
} }
" "
/> />
</template> </div>
</FormDialog> </FormDialog>
</template> </template>