salix-front/src/components/CreateBankEntityForm.vue

100 lines
2.7 KiB
Vue
Raw Normal View History

2023-12-12 14:58:44 +00:00
<script setup>
2023-12-13 15:09:23 +00:00
import { reactive, ref } from 'vue';
2023-12-12 14:58:44 +00:00
import { useI18n } from 'vue-i18n';
2023-12-13 15:09:23 +00:00
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import FetchData from 'components/FetchData.vue';
import VnRow from 'components/ui/VnRow.vue';
import FormModelPopup from './FormModelPopup.vue';
2023-12-13 15:09:23 +00:00
const emit = defineEmits(['onDataSaved']);
2023-12-13 15:09:23 +00:00
2023-12-12 14:58:44 +00:00
const { t } = useI18n();
const bankEntityFormData = reactive({
2023-12-12 14:58:44 +00:00
name: null,
bic: null,
countryFk: null,
id: null,
});
2023-12-13 15:09:23 +00:00
const countriesFilter = {
fields: ['id', 'country', 'code'],
};
const countriesOptions = ref([]);
const onDataSaved = (data) => {
emit('onDataSaved', data);
};
2023-12-12 14:58:44 +00:00
</script>
<template>
2023-12-13 15:09:23 +00:00
<FetchData
url="Countries"
:filter="countriesFilter"
auto-load
2024-01-02 11:47:38 +00:00
@on-fetch="(data) => (countriesOptions = data)"
2023-12-13 15:09:23 +00:00
/>
<FormModelPopup
2023-12-13 15:09:23 +00:00
url-create="bankEntities"
model="bankEntity"
:title="t('title')"
:subtitle="t('subtitle')"
:form-initial-data="bankEntityFormData"
@on-data-saved="onDataSaved($event)"
2023-12-13 15:09:23 +00:00
>
<template #form-inputs="{ data, validate }">
2023-12-13 15:09:23 +00:00
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<QInput
:label="t('name')"
v-model="data.name"
:rules="validate('bankEntity.name')"
/>
</div>
<div class="col">
<QInput
:label="t('swift')"
v-model="data.bic"
:rules="validate('bankEntity.bic')"
/>
</div>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnSelectFilter
:label="t('country')"
v-model="data.countryFk"
2023-12-13 15:09:23 +00:00
:options="countriesOptions"
option-value="id"
option-label="country"
hide-selected
:rules="validate('bankEntity.countryFk')"
/>
</div>
<div class="col">
<QInput :label="t('id')" v-model="data.id" />
2023-12-13 15:09:23 +00:00
</div>
</VnRow>
</template>
</FormModelPopup>
2023-12-12 14:58:44 +00:00
</template>
<i18n>
en:
2023-12-12 17:00:56 +00:00
title: New bank entity
subtitle: Please, ensure you put the correct data!
2023-12-13 15:09:23 +00:00
name: Name *
swift: Swift *
country: Country
id: Entity code
2023-12-12 14:58:44 +00:00
es:
2023-12-12 17:00:56 +00:00
title: Nueva entidad bancaria
subtitle: ¡Por favor, asegúrate de poner los datos correctos!
2023-12-13 15:09:23 +00:00
name: Nombre *
swift: Swift *
country: País
id: Código de la entidad
2023-12-12 14:58:44 +00:00
</i18n>