salix-front/src/components/CreateBankEntityForm.vue

131 lines
3.8 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 FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
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 closeButton = ref(null);
2023-12-13 15:09:23 +00:00
const countriesOptions = ref([]);
const loading = ref(false);
const onDataSaved = (data) => {
emit('onDataSaved', data);
closeForm();
};
const closeForm = () => {
if (closeButton.value) closeButton.value.click();
};
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
/>
<FormModel
:form-initial-data="bankEntityFormData"
2023-12-13 15:09:23 +00:00
:observe-form-changes="false"
:default-actions="false"
url-create="bankEntities"
model="bankEntity"
@on-data-saved="onDataSaved($event)"
2023-12-13 15:09:23 +00:00
>
<template #form="{ data, validate }">
2024-01-02 11:47:38 +00:00
<span ref="closeButton" class="popup-form-close-button" v-close-popup>
2023-12-22 11:31:02 +00:00
<QIcon name="close" size="sm" />
</span>
2024-01-02 11:47:38 +00:00
<h1 class="popup-form-title">{{ t('title') }}</h1>
<p class="q-mb-md">{{ t('subtitle') }}</p>
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>
<div class="q-mt-lg row justify-end">
<QBtn
:label="t('globals.save')"
type="submit"
color="primary"
:disabled="loading"
:loading="loading"
/>
<QBtn
:label="t('globals.cancel')"
type="reset"
color="primary"
flat
class="q-ml-sm"
:disabled="loading"
:loading="loading"
v-close-popup
/>
</div>
</template>
</FormModel>
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>