refactor: add input virtual

This commit is contained in:
Net 2024-09-04 14:35:32 +07:00
parent 37ebd3d880
commit 7b3f28e67d

View file

@ -1,4 +1,6 @@
<script setup lang="ts">
import { isRoleInclude } from 'src/stores/utils';
const code = defineModel<string>('code');
const branchCount = defineModel<number>('branchCount', { default: 0 });
const codeSubBranch = defineModel<string>('codeSubBranch');
@ -7,6 +9,7 @@ const name = defineModel<string>('name');
const abbreviation = defineModel<string>('abbreviation');
const nameEN = defineModel<string>('nameEN');
const typeBranch = defineModel<string>('typeBranch');
const virtual = defineModel<boolean>('virtual');
defineProps<{
title?: string;
@ -153,6 +156,42 @@ function formatCode(input: string | undefined, type: 'code' | 'number') {
:error-message="$t('form.error.required')"
for="input-name-en"
/>
<q-select
v-if="
typeBranch !== 'headOffice' &&
isRoleInclude(['head_of_admin', 'head_of_account'])
"
outlined
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
input-debounce="0"
option-label="label"
option-value="value"
class="col-2"
dense
for="input-branch-status"
:readonly="readonly || isRoleInclude(['head_of_account'])"
:options="['Virtual', 'Branch']"
:hide-dropdown-icon="readonly"
:label="$t('general.branchStatus')"
:model-value="virtual ? 'Virtual' : 'Branch'"
@update:model-value="(v) => (virtual = v === 'Virtual')"
:rules="[(val) => val && val.length > 0]"
:error-message="$t('form.error.required')"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('general.noData') }}
</q-item-section>
</q-item>
</template>
</q-select>
</div>
</div>
</div>