refactor(01): empty value show '-'

This commit is contained in:
puriphatt 2024-08-16 17:31:40 +07:00
parent 4fedd3ad6a
commit a56ac704ee
3 changed files with 44 additions and 12 deletions

View file

@ -144,7 +144,6 @@ watch(
option-value="value" option-value="value"
input-debounce="0" input-debounce="0"
option-label="label" option-label="label"
v-model="book.bankName"
lazy-rules="ondemand" lazy-rules="ondemand"
class="col-3" class="col-3"
:dense="dense" :dense="dense"
@ -153,7 +152,12 @@ watch(
:readonly="readonly" :readonly="readonly"
:hide-dropdown-icon="readonly" :hide-dropdown-icon="readonly"
for="select-bankbook" for="select-bankbook"
:model-value="readonly ? book.bankName || '-' : book.bankName"
@update:model-value="
(v) => (typeof v === 'string' ? (book.bankName = v) : '')
"
@filter="bankBoookFilter" @filter="bankBoookFilter"
@clear="book.bankName = ''"
> >
<template v-slot:option="scope"> <template v-slot:option="scope">
<q-item <q-item
@ -175,7 +179,11 @@ watch(
</template> </template>
<template v-slot:selected-item="scope"> <template v-slot:selected-item="scope">
<q-item-section v-if="scope.opt" avatar class="q-py-sm"> <q-item-section
v-if="scope.opt && book.bankName"
avatar
class="q-py-sm"
>
<q-img <q-img
:src="`/img/bank/${scope.opt.value}.png`" :src="`/img/bank/${scope.opt.value}.png`"
class="bordered" class="bordered"
@ -198,7 +206,6 @@ watch(
class="col-3" class="col-3"
lazy-rules="ondemand" lazy-rules="ondemand"
hide-bottom-space hide-bottom-space
v-model="book.accountNumber"
:dense="dense" :dense="dense"
:readonly="readonly" :readonly="readonly"
:label="$t('accountNumber')" :label="$t('accountNumber')"
@ -208,6 +215,10 @@ watch(
(val.length >= 7 && val.length <= 13) || (val.length >= 7 && val.length <= 13) ||
$t('form.error.please', { msg: $t('accountNumber') }), $t('form.error.please', { msg: $t('accountNumber') }),
]" ]"
:model-value="readonly ? book.accountNumber || '-' : book.accountNumber"
@update:model-value="
(v) => (typeof v === 'string' ? (book.accountNumber = v) : '')
"
/> />
<q-input <q-input
outlined outlined
@ -215,10 +226,13 @@ watch(
class="col-3" class="col-3"
lazy-rules="ondemand" lazy-rules="ondemand"
hide-bottom-space hide-bottom-space
v-model="book.bankBranch"
:dense="dense" :dense="dense"
:readonly="readonly" :readonly="readonly"
:label="$t('bankBranch')" :label="$t('bankBranch')"
:model-value="readonly ? book.bankBranch || '-' : book.bankBranch"
@update:model-value="
(v) => (typeof v === 'string' ? (book.bankBranch = v) : '')
"
/> />
<q-input <q-input
outlined outlined
@ -226,10 +240,13 @@ watch(
class="col-3" class="col-3"
lazy-rules="ondemand" lazy-rules="ondemand"
hide-bottom-space hide-bottom-space
v-model="book.accountName"
:dense="dense" :dense="dense"
:readonly="readonly" :readonly="readonly"
:label="$t('accountName')" :label="$t('accountName')"
:model-value="readonly ? book.accountName || '-' : book.accountName"
@update:model-value="
(v) => (typeof v === 'string' ? (book.accountName = v) : '')
"
/> />
<q-select <q-select
outlined outlined
@ -243,7 +260,6 @@ watch(
option-value="value" option-value="value"
input-debounce="0" input-debounce="0"
option-label="label" option-label="label"
v-model="book.accountType"
lazy-rules="ondemand" lazy-rules="ondemand"
class="col-4" class="col-4"
:dense="dense" :dense="dense"
@ -252,7 +268,12 @@ watch(
:readonly="readonly" :readonly="readonly"
:hide-dropdown-icon="readonly" :hide-dropdown-icon="readonly"
for="select-bankbook" for="select-bankbook"
:model-value="readonly ? book.accountType || '-' : book.accountType"
@update:model-value="
(v) => (typeof v === 'string' ? (book.accountType = v) : '')
"
@filter="accountTypeFilter" @filter="accountTypeFilter"
@clear="book.accountType = ''"
> >
<template v-slot:no-option> <template v-slot:no-option>
<q-item> <q-item>

View file

@ -42,8 +42,9 @@ defineProps<{
? $t('formDialogInputEmailHq') ? $t('formDialogInputEmailHq')
: $t('formDialogInputEmailSubBranch') : $t('formDialogInputEmailSubBranch')
" "
v-model="email"
for="input-email" for="input-email"
:model-value="readonly ? email || '-' : email"
@update:model-value="(v) => (typeof v === 'string' ? (email = v) : '')"
> >
<template #prepend> <template #prepend>
<q-icon <q-icon
@ -67,8 +68,11 @@ defineProps<{
? $t('formDialogInputTelephoneHq') ? $t('formDialogInputTelephoneHq')
: $t('formDialogInputTelephoneSubBranch') : $t('formDialogInputTelephoneSubBranch')
" "
v-model="telephoneNo"
for="input-telephone-no" for="input-telephone-no"
:model-value="readonly ? telephoneNo || '-' : telephoneNo"
@update:model-value="
(v) => (typeof v === 'string' ? (telephoneNo = v) : '')
"
> >
<template #prepend> <template #prepend>
<q-icon <q-icon
@ -88,8 +92,9 @@ defineProps<{
hide-bottom-space hide-bottom-space
class="col-3" class="col-3"
label="Line ID" label="Line ID"
v-model="lineId"
for="input-line-id" for="input-line-id"
:model-value="readonly ? lineId || '-' : lineId"
@update:model-value="(v) => (typeof v === 'string' ? (lineId = v) : '')"
/> />
<div class="col-12 row q-col-gutter-sm"> <div class="col-12 row q-col-gutter-sm">
@ -101,8 +106,11 @@ defineProps<{
hide-bottom-space hide-bottom-space
class="col-3" class="col-3"
:label="$t('formDialogInputContactName')" :label="$t('formDialogInputContactName')"
v-model="contactName"
for="input-contact-name" for="input-contact-name"
:model-value="readonly ? contactName || '-' : contactName"
@update:model-value="
(v) => (typeof v === 'string' ? (contactName = v) : '')
"
/> />
<q-input <q-input
@ -113,8 +121,11 @@ defineProps<{
hide-bottom-space hide-bottom-space
class="col-3" class="col-3"
:label="$t('formDialogInputTelephoneContact')" :label="$t('formDialogInputTelephoneContact')"
v-model="contact"
for="input-contact" for="input-contact"
:model-value="readonly ? contact || '-' : contact"
@update:model-value="
(v) => (typeof v === 'string' ? (contact = v) : '')
"
> >
<template #prepend> <template #prepend>
<q-icon <q-icon

View file

@ -329,7 +329,7 @@ async function fetchBranchById(id: string) {
zipCode: res.zipCode, zipCode: res.zipCode,
email: res.email, email: res.email,
contactName: res.contactName, contactName: res.contactName,
contact: res.contact.length > 0 ? res.contact[0].telephoneNo : ' ', contact: res.contact.length > 0 ? res.contact[0].telephoneNo : '',
telephoneNo: res.telephoneNo, telephoneNo: res.telephoneNo,
longitude: res.longitude, longitude: res.longitude,
latitude: res.latitude, latitude: res.latitude,