refactor: product create

This commit is contained in:
puriphatt 2024-08-09 10:56:27 +00:00
parent 676c2c5ebf
commit 5e4cfb747d
8 changed files with 325 additions and 217 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 KiB

View file

@ -23,7 +23,6 @@ defineProps<{
dense?: boolean; dense?: boolean;
outlined?: boolean; outlined?: boolean;
readonly?: boolean; readonly?: boolean;
separator?: boolean;
isType?: boolean; isType?: boolean;
}>(); }>();
@ -51,11 +50,20 @@ const branchFilter = selectFilterOptionRefMod(
</script> </script>
<template> <template>
<div class="col-3 app-text-muted"> <div class="row col-12">
{{ $t(`formDialogTitleInformation`) }} <div class="col-12 q-pb-sm text-weight-bold text-body1 row items-center">
<q-icon
flat
size="xs"
class="q-pa-sm rounded q-mr-sm"
color="info"
name="mdi-office-building-outline"
style="background-color: var(--surface-3)"
/>
{{ $t(`formDialogTitleInformation`) }}
</div> </div>
<div class="col-9 row q-col-gutter-md"> <div class="col-12 row q-col-gutter-sm">
<q-select <q-select
outlined outlined
clearable clearable
@ -141,7 +149,19 @@ const branchFilter = selectFilterOptionRefMod(
:label="$t('productName')" :label="$t('productName')"
v-model="name" v-model="name"
/> />
<q-input
lazy-rules="ondemand"
for="input-process"
:dense="dense"
outlined
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-3"
:label="$t('productProcessingTime')"
v-model="process"
type="number"
/>
<q-input <q-input
lazy-rules="ondemand" lazy-rules="ondemand"
for="input-detail" for="input-detail"
@ -154,7 +174,6 @@ const branchFilter = selectFilterOptionRefMod(
class="col-12" class="col-12"
:label="$t('serviceDetail')" :label="$t('serviceDetail')"
v-model="detail" v-model="detail"
autogrow
/> />
<div class="col-12"> <div class="col-12">
@ -186,27 +205,21 @@ const branchFilter = selectFilterOptionRefMod(
/> />
</q-field> </q-field>
</div> </div>
<!-- <q-input
<q-input
lazy-rules="ondemand" lazy-rules="ondemand"
for="input-process" for="input-detail"
:dense="dense" :dense="dense"
outlined outlined
:readonly="readonly" :readonly="readonly"
:borderless="readonly" :borderless="readonly"
hide-bottom-space hide-bottom-space
class="col-4" type="textarea"
:label="$t('productProcessingTime')" class="col-12"
v-model="process" :label="$t('formDialogInputRemark')"
type="number" v-model="detail"
/> /> -->
</div>
</div> </div>
<q-separator
v-if="separator"
class="col-12 q-mb-md"
style="padding-block: 0.5px; margin-top: 32px"
/>
</template> </template>
<style scoped> <style scoped>

View file

@ -13,8 +13,19 @@ defineProps<{
</script> </script>
<template> <template>
<div class="col-3 app-text-muted"> {{ $t('priceInformation') }}</div> <div class="row col-12">
<div class="col-9 row q-col-gutter-md"> <div class="col-12 q-pb-sm text-weight-bold text-body1 row items-center">
<q-icon
flat
size="xs"
class="q-pa-sm rounded q-mr-sm"
color="info"
name="mdi-cash"
style="background-color: var(--surface-3)"
/>
{{ $t('priceInformation') }}
</div>
<div class="col-12 row q-col-gutter-sm">
<q-input <q-input
lazy-rules="ondemand" lazy-rules="ondemand"
:dense="dense" :dense="dense"
@ -54,6 +65,7 @@ defineProps<{
v-model="serviceCharge" v-model="serviceCharge"
/> />
</div> </div>
</div>
</template> </template>
<style scoped></style> <style scoped></style>

View file

@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import ToggleButton from './button/ToggleButton.vue';
defineProps<{ defineProps<{
icon?: string; icon?: string;
@ -12,6 +13,8 @@ defineProps<{
toggleTitle?: string; toggleTitle?: string;
hideFade?: boolean; hideFade?: boolean;
hideActive?: boolean;
noImageAction?: boolean;
active?: boolean; active?: boolean;
readonly?: boolean; readonly?: boolean;
useToggle?: boolean; useToggle?: boolean;
@ -73,11 +76,12 @@ const showOverlay = ref(false);
<q-avatar <q-avatar
size="6rem" size="6rem"
font-size="3rem" font-size="3rem"
class="cursor-pointer relative-position" class="relative-position"
style="z-index: 1" style="z-index: 1"
:style="{ :style="{
background: `${bgColor || 'var(--brand-1)'}`, background: `${bgColor || 'var(--brand-1)'}`,
color: `${color || 'white'}`, color: `${color || 'white'}`,
cursor: `${noImageAction ? 'default' : 'pointer'}`,
}" }"
@mouseover="showOverlay = true" @mouseover="showOverlay = true"
@mouseleave="showOverlay = false" @mouseleave="showOverlay = false"
@ -98,6 +102,7 @@ const showOverlay = ref(false);
</q-img> </q-img>
<q-icon id="profile-view" v-else :name="icon || 'mdi-account'" /> <q-icon id="profile-view" v-else :name="icon || 'mdi-account'" />
<q-badge <q-badge
v-if="!hideActive"
class="absolute-bottom-right" class="absolute-bottom-right"
style=" style="
border-radius: 10px; border-radius: 10px;

View file

@ -196,4 +196,7 @@ export default {
passportExpire: 'Passport Expiration Date', passportExpire: 'Passport Expiration Date',
pleaseInformation: 'Please enter information', pleaseInformation: 'Please enter information',
// product
formDialogTitleUseStatus: 'Status',
}; };

View file

@ -196,4 +196,7 @@ export default {
passportExpire: 'วันหมดอายุของเอกสาร(visa ,passport)', passportExpire: 'วันหมดอายุของเอกสาร(visa ,passport)',
pleaseInformation: 'โปรดกรอกข้อมูล', pleaseInformation: 'โปรดกรอกข้อมูล',
// product
formDialogTitleUseStatus: 'สถานะการใช้งาน',
}; };

View file

@ -217,6 +217,7 @@ const dialogProductServiceType = ref(false);
const dialogTotalProduct = ref(false); const dialogTotalProduct = ref(false);
const productMode = ref<'group' | 'type' | 'service' | 'product'>('group'); const productMode = ref<'group' | 'type' | 'service' | 'product'>('group');
const productTab = ref(1);
const productGroup = ref<ProductGroup[]>(); const productGroup = ref<ProductGroup[]>();
const productType = ref<ProductGroup[]>(); const productType = ref<ProductGroup[]>();
const product = ref<(ProductList & { type: 'product' })[]>(); const product = ref<(ProductList & { type: 'product' })[]>();
@ -1414,6 +1415,7 @@ watch(
icon="mdi-folder-multiple-plus" icon="mdi-folder-multiple-plus"
@click=" @click="
async () => { async () => {
productTab = 1;
clearFormProduct(); clearFormProduct();
await fetchListOfOptionBranch(); await fetchListOfOptionBranch();
dialogProduct = true; dialogProduct = true;
@ -2089,6 +2091,13 @@ watch(
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr <q-tr
:style="
props.rowIndex % 2 !== 0
? $q.dark.isActive
? 'background: hsl(var(--gray-11-hsl)/0.2)'
: `background: #f9fafc`
: ''
"
:id="`enter-${props.row.name}`" :id="`enter-${props.row.name}`"
class="cursor-pointer" class="cursor-pointer"
:class="{ :class="{
@ -2342,6 +2351,7 @@ watch(
<q-item-section class="q-py-sm"> <q-item-section class="q-py-sm">
<div class="q-pa-sm surface-2 rounded"> <div class="q-pa-sm surface-2 rounded">
<q-toggle <q-toggle
color="positive"
:id="`view-detail-btn-${props.row.name}-status`" :id="`view-detail-btn-${props.row.name}-status`"
dense dense
size="sm" size="sm"
@ -3162,6 +3172,7 @@ watch(
<q-item-section class="q-py-sm"> <q-item-section class="q-py-sm">
<div class="q-pa-sm surface-2 rounded"> <div class="q-pa-sm surface-2 rounded">
<q-toggle <q-toggle
color="positive"
:id="`view-detail-btn-${props.row.name}-status`" :id="`view-detail-btn-${props.row.name}-status`"
dense dense
size="sm" size="sm"
@ -3334,9 +3345,13 @@ watch(
> >
<div class="q-mx-lg q-mt-lg"> <div class="q-mx-lg q-mt-lg">
<ProfileBanner <ProfileBanner
readonly
noImageAction
active active
hideFade hideFade
hideActive
useToggle useToggle
:toggleTitle="$t('formDialogTitleUseStatus')"
:icon="productMode === 'group' ? 'mdi-folder' : 'mdi-folder-table'" :icon="productMode === 'group' ? 'mdi-folder' : 'mdi-folder-table'"
:title="formDataGroup.name" :title="formDataGroup.name"
:caption="formDataGroup.code" :caption="formDataGroup.code"
@ -3363,7 +3378,6 @@ watch(
: '--violet-11' : '--violet-11'
}-hsl)/0.1)`" }-hsl)/0.1)`"
v-model:toggle-status="currentStatusGroupType" v-model:toggle-status="currentStatusGroupType"
@view="imageDialog = true"
@update:toggle-status=" @update:toggle-status="
() => { () => {
currentStatusGroupType = currentStatusGroupType =
@ -3466,6 +3480,7 @@ watch(
<InfoForm> <InfoForm>
<div class="q-mx-lg q-mt-lg"> <div class="q-mx-lg q-mt-lg">
<ProfileBanner <ProfileBanner
noImageAction
:active="currentStatusGroupType !== 'INACTIVE'" :active="currentStatusGroupType !== 'INACTIVE'"
hideFade hideFade
useToggle useToggle
@ -3497,7 +3512,6 @@ watch(
bgColor: 'var(--surface-1)', bgColor: 'var(--surface-1)',
}, },
]" ]"
@view="imageDialog = true"
@update:toggle-status=" @update:toggle-status="
async (v) => { async (v) => {
await triggerChangeStatus(currentIdGroupType, v, productMode); await triggerChangeStatus(currentIdGroupType, v, productMode);
@ -3693,9 +3707,8 @@ watch(
</FormDialog> </FormDialog>
<!-- Add Product --> <!-- Add Product -->
<FormDialog <DialogForm
v-model:modal="dialogProduct" v-model:modal="dialogProduct"
noAddress
:title="$t('buttonAddProduct')" :title="$t('buttonAddProduct')"
:submit=" :submit="
() => { () => {
@ -3709,8 +3722,7 @@ watch(
} }
" "
> >
<template #prepend> <!-- <ProfileUpload
<ProfileUpload
prefix-id="form-dialog-product" prefix-id="form-dialog-product"
isProduct isProduct
v-model:url-profile="profileUrl" v-model:url-profile="profileUrl"
@ -3718,11 +3730,64 @@ watch(
v-model:profile-submit="profileSubmit" v-model:profile-submit="profileSubmit"
@input-file="inputFile.click()" @input-file="inputFile.click()"
@cancel-file="inputFile.value = ''" @cancel-file="inputFile.value = ''"
/> -->
<div class="q-mx-lg q-mt-lg">
<ProfileBanner
hideFade
useToggle
hideActive
:toggleTitle="$t('formDialogTitleUseStatus')"
img="/images/product-avatar.png"
fallbackCover="/images/product-banner.png"
bgColor="#ebf1ee"
:menu="[
{
icon: 'mdi-office-building-outline',
color: 'hsl(var(--info-bg))',
bgColor: 'var(--surface-1)',
},
]"
/> />
</template> </div>
<template #information> <div
class="col surface-1 q-ma-lg rounded bordered scroll row relative-position"
id="group-form"
>
<div
class="col"
style="height: 100%; max-height: 100; overflow-y: auto"
v-if="$q.screen.gt.sm"
>
<div class="q-py-md q-pl-md q-pr-sm">
<q-item
v-for="v in 2"
:key="v"
dense
clickable
class="no-padding items-center rounded full-width"
:class="{ 'q-mt-xs': v > 1 }"
active-class="product-form-active"
:active="productTab === v"
@click="productTab = v"
>
<span class="full-width q-py-sm" style="padding-inline: 20px">
{{
v === 0
? $t('formDialogTitleInformation')
: $t('priceInformation')
}}
</span>
</q-item>
</div>
</div>
<div
class="col-12 col-md-10 q-py-md q-pr-md q-pl-sm"
id="customer-form-content"
style="height: 100%; max-height: 100%; overflow-y: auto"
>
<BasicInfoProduct <BasicInfoProduct
v-if="productTab === 1"
v-model:options-branch="branchOption" v-model:options-branch="branchOption"
v-model:registered-branch-id="formDataProduct.registeredBranchId" v-model:registered-branch-id="formDataProduct.registeredBranchId"
v-model:detail="formDataProduct.detail" v-model:detail="formDataProduct.detail"
@ -3733,16 +3798,16 @@ watch(
dense dense
separator separator
/> />
</template>
<template #person>
<PriceDataComponent <PriceDataComponent
v-if="productTab === 2"
v-model:price="formDataProduct.price" v-model:price="formDataProduct.price"
v-model:agent-price="formDataProduct.agentPrice" v-model:agent-price="formDataProduct.agentPrice"
v-model:service-charge="formDataProduct.serviceCharge" v-model:service-charge="formDataProduct.serviceCharge"
dense dense
/> />
</template> </div>
</FormDialog> </div>
</DialogForm>
<!-- edit product --> <!-- edit product -->
<FormDialog <FormDialog
@ -4184,6 +4249,7 @@ watch(
<q-item clickable v-ripple> <q-item clickable v-ripple>
<q-item-section avatar> <q-item-section avatar>
<q-toggle <q-toggle
color="positive"
dense dense
:id="`view-detail-btn-${currentNode.name}-status`" :id="`view-detail-btn-${currentNode.name}-status`"
size="sm" size="sm"
@ -4354,4 +4420,10 @@ watch(
* :deep(.q-icon.mdi-play) { * :deep(.q-icon.mdi-play) {
display: none; display: none;
} }
.product-form-active {
background-color: hsla(var(--info-bg) / 0.2);
color: hsl(var(--info-bg));
font-weight: 600;
}
</style> </style>