0
0
Fork 0

Merge pull request '#7825: Fill the bank field when a new entity is created' (!798) from 7825-FixCreatebankEntity into dev

Reviewed-on: verdnatura/salix-front#798
Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
Jon Elias 2024-10-15 11:42:38 +00:00
commit 4fb3e0dadf
2 changed files with 13 additions and 3 deletions

View File

@ -31,8 +31,8 @@ const countriesFilter = {
const countriesOptions = ref([]);
const onDataSaved = (formData, requestResponse) => {
emit('onDataSaved', formData, requestResponse);
const onDataSaved = (...args) => {
emit('onDataSaved', ...args);
};
onMounted(async () => {

View File

@ -29,6 +29,7 @@ const postcodesOptions = ref([]);
const user = useState().getUser();
const defaultPayMethod = ref();
const bankEntitiesRef = ref();
const columns = computed(() => [
{
align: 'left',
@ -118,6 +119,12 @@ onBeforeMount(async () => {
).data?.payMethodFk;
});
async function handleNewBankEntity(data, resp) {
await bankEntitiesRef.value.fetch();
data.bankEntityFk = resp.id;
bankEntitiesOptions.value.push(resp);
}
function handleLocation(data, location) {
const { town, code, provinceFk, countryFk } = location ?? {};
data.postcode = code;
@ -177,6 +184,7 @@ async function autofillBic(worker) {
auto-load
/>
<FetchData
ref="bankEntitiesRef"
url="BankEntities"
@on-fetch="(data) => (bankEntitiesOptions = data)"
auto-load
@ -344,7 +352,9 @@ async function autofillBic(worker) {
>
<template #form>
<CreateBankEntityForm
@on-data-saved="(data) => bankEntitiesOptions.push(data)"
@on-data-saved="
(_, resp) => handleNewBankEntity(data, resp)
"
/>
</template>
<template #option="scope">