117 lines
3.2 KiB
Vue
117 lines
3.2 KiB
Vue
<script setup>
|
|
import { reactive, ref, onMounted, nextTick } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import VnInput from 'src/components/common/VnInput.vue';
|
|
|
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
import FetchData from 'components/FetchData.vue';
|
|
import VnRow from 'components/ui/VnRow.vue';
|
|
import FormModelPopup from './FormModelPopup.vue';
|
|
|
|
const props = defineProps({
|
|
showEntityField: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
});
|
|
|
|
const emit = defineEmits(['onDataSaved']);
|
|
const { t } = useI18n();
|
|
const bicInputRef = ref(null);
|
|
const bankEntityFormData = reactive({
|
|
name: null,
|
|
bic: null,
|
|
countryFk: null,
|
|
id: null,
|
|
});
|
|
|
|
const countriesFilter = {
|
|
fields: ['id', 'country', 'code'],
|
|
};
|
|
|
|
const countriesOptions = ref([]);
|
|
|
|
const onDataSaved = (formData, requestResponse) => {
|
|
emit('onDataSaved', formData, requestResponse);
|
|
};
|
|
|
|
onMounted(async () => {
|
|
await nextTick();
|
|
bicInputRef.value.focus();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<FetchData
|
|
url="Countries"
|
|
:filter="countriesFilter"
|
|
auto-load
|
|
@on-fetch="(data) => (countriesOptions = data)"
|
|
/>
|
|
<FormModelPopup
|
|
url-create="bankEntities"
|
|
model="bankEntity"
|
|
:title="t('title')"
|
|
:subtitle="t('subtitle')"
|
|
:form-initial-data="bankEntityFormData"
|
|
@on-data-saved="onDataSaved"
|
|
>
|
|
<template #form-inputs="{ data, validate }">
|
|
<VnRow class="row q-gutter-md q-mb-md">
|
|
<VnInput
|
|
:label="t('name')"
|
|
v-model="data.name"
|
|
:required="true"
|
|
:rules="validate('bankEntity.name')"
|
|
/>
|
|
<VnInput
|
|
ref="bicInputRef"
|
|
:label="t('swift')"
|
|
v-model="data.bic"
|
|
:required="true"
|
|
:rules="validate('bankEntity.bic')"
|
|
/>
|
|
</VnRow>
|
|
<VnRow class="row q-gutter-md q-mb-md">
|
|
<div class="col">
|
|
<VnSelect
|
|
:label="t('country')"
|
|
v-model="data.countryFk"
|
|
:options="countriesOptions"
|
|
option-value="id"
|
|
option-label="country"
|
|
hide-selected
|
|
:required="true"
|
|
:rules="validate('bankEntity.countryFk')"
|
|
/>
|
|
</div>
|
|
<div v-if="showEntityField" class="col">
|
|
<VnInput
|
|
:label="t('id')"
|
|
v-model="data.id"
|
|
:required="true"
|
|
:rules="validate('city.name')"
|
|
/>
|
|
</div>
|
|
</VnRow>
|
|
</template>
|
|
</FormModelPopup>
|
|
</template>
|
|
|
|
<i18n>
|
|
en:
|
|
title: New bank entity
|
|
subtitle: Please, ensure you put the correct data!
|
|
name: Name
|
|
swift: Swift
|
|
country: Country
|
|
id: Entity code
|
|
es:
|
|
title: Nueva entidad bancaria
|
|
subtitle: ¡Por favor, asegúrate de poner los datos correctos!
|
|
name: Nombre
|
|
swift: Swift
|
|
country: País
|
|
id: Código de la entidad
|
|
</i18n>
|