fix: customer => branch card customer & table

This commit is contained in:
puriphatt 2024-12-10 15:01:14 +07:00
parent 65d39a7e69
commit 1df80aeb02
2 changed files with 56 additions and 14 deletions

View file

@ -10,6 +10,7 @@ defineProps<{
telephone: string; telephone: string;
businessTypePure: string; businessTypePure: string;
totalEmployee: number; totalEmployee: number;
code: string;
}; };
metadata?: unknown; metadata?: unknown;
badgeField?: string[]; badgeField?: string[];
@ -48,7 +49,7 @@ defineProps<{
</div> </div>
<div class="branch-card__name"> <div class="branch-card__name">
<b>{{ data.branchName }}</b> <b>{{ data.branchName }}</b>
<small class="branch-card__code">{{ data.branchName }}</small> <small class="branch-card__code">{{ data.code }}</small>
</div> </div>
<div class="branch-card__action"> <div class="branch-card__action">
@ -75,18 +76,25 @@ defineProps<{
" "
/> />
<div <div
v-for="key in fieldSelected?.sort() || [ v-for="key in fieldSelected || [
'customerBranchFormTab',
'branchName',
'address', 'address',
'telephone', 'telephone',
'businessTypePure', 'businessTypePure',
'totalEmployee', 'totalEmployee',
]" ]"
:key="key"
class="branch-card__data" class="branch-card__data"
> >
<div>{{ $t(key) }}</div> <div>
<div>{{ data[key as keyof typeof data] }}</div> {{
fieldSelected
? $t(key)
: key !== 'address' && key !== 'telephone'
? $t(`customer.table.${key}`)
: $t(`general.${key}`)
}}
</div>
<div>{{ data[key as keyof typeof data] || '-' }}</div>
</div> </div>
</div> </div>
</template> </template>
@ -174,7 +182,7 @@ defineProps<{
} }
&.branch-card__pers { &.branch-card__pers {
--_branch-card-bg: var(--pink-6-hsl); --_branch-card-bg: var(--teal-10-hsl);
} }
&.branch-card__corp { &.branch-card__corp {

View file

@ -167,6 +167,28 @@ const branchFieldSelected = ref<
)[] )[]
>(fieldDisplay.value); >(fieldDisplay.value);
function getCustomerName(
record: CustomerBranch,
opts?: {
locale?: string;
},
) {
const customer = record;
return (
{
['CORP']: {
['eng']: customer.registerNameEN,
['tha']: customer.registerName,
}[opts?.locale || 'eng'],
['PERS']: {
['eng']: `${useOptionStore().mapOption(customer?.namePrefix)} ${customer?.firstNameEN} ${customer?.lastNameEN}`,
['tha']: `${useOptionStore().mapOption(customer?.namePrefix)} ${customer?.firstName} ${customer?.lastName}`,
}[opts?.locale || 'eng'],
}[customer.customer.customerType] || '-'
);
}
async function deleteBranchById(id: string) { async function deleteBranchById(id: string) {
return await new Promise((resolve) => { return await new Promise((resolve) => {
dialog({ dialog({
@ -229,8 +251,6 @@ async function fetchEmployee(opts: { branchId: string; pageSize?: number }) {
visa: true, visa: true,
}); });
console.log(res);
if (res) { if (res) {
listEmployee.value = res.data.result; listEmployee.value = res.data.result;
} }
@ -407,7 +427,6 @@ watch(
<NoData v-if="totalBranch === 0" :not-found="!!inputSearch" /> <NoData v-if="totalBranch === 0" :not-found="!!inputSearch" />
<div style="width: 100%" v-else> <div style="width: 100%" v-else>
{{ console.log(branch) }}
<q-table <q-table
v-if="branch" v-if="branch"
flat flat
@ -454,7 +473,13 @@ watch(
> >
<div <div
class="branch-card__icon" class="branch-card__icon"
:class="{ 'branch-card__dark': $q.dark.isActive }" :class="{
dark: $q.dark.isActive,
'branch-card__pers':
props.row.customer.customerType === 'PERS',
'branch-card__corp':
props.row.customer.customerType === 'CORP',
}"
> >
<q-icon <q-icon
size="md" size="md"
@ -617,7 +642,10 @@ watch(
:badgeField="['status']" :badgeField="['status']"
:data="{ :data="{
customerBranchFormTab: props.row.branchNo, customerBranchFormTab: props.row.branchNo,
branchName: props.row.name, code: props.row.code,
branchName: getCustomerName(props.row, {
locale: $i18n.locale,
}),
address: address:
$i18n.locale === 'eng' $i18n.locale === 'eng'
? `${props.row.addressEN || ''} ${props.row.subDistrict?.nameEN || ''} ${props.row.district?.nameEN || ''} ${props.row.province?.nameEN || ''}` ? `${props.row.addressEN || ''} ${props.row.subDistrict?.nameEN || ''} ${props.row.district?.nameEN || ''} ${props.row.province?.nameEN || ''}`
@ -950,8 +978,14 @@ watch(
position: relative; position: relative;
transform: rotate(45deg); transform: rotate(45deg);
&.branch-card__dark { &.branch-card__pers {
--_branch-card-bg: var(--pink-5-hsl); --_branch-card-bg: var(--teal-10-hsl);
}
&.branch-card__corp {
--_branch-card-bg: var(--violet-11-hsl);
&.dark {
--_branch-card-bg: var(--violet-10-hsl);
}
} }
&::after { &::after {