feat: use clientFK in dialog
This commit is contained in:
parent
cad6b077f0
commit
3b3332f15c
|
@ -1,15 +1,15 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export async function getAddresses(clientId, _filter = {}) {
|
||||
export async function getAddresses(clientId, _filter = {}) {
|
||||
if (!clientId) return;
|
||||
const filter = {
|
||||
..._filter,
|
||||
fields: ['nickname', 'street', 'city', 'id'],
|
||||
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
||||
where: { isActive: true },
|
||||
order: 'nickname ASC',
|
||||
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
return await axios.get(`Clients/${clientId}/addresses`, {
|
||||
params,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { computed, ref, onBeforeMount } from 'vue';
|
||||
import { computed, ref, onBeforeMount, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
@ -425,6 +425,23 @@ function setReference(data) {
|
|||
|
||||
dialogData.value.value.description = newDescription;
|
||||
}
|
||||
|
||||
const formInitialData = ref({});
|
||||
watch(
|
||||
() => route.query.table,
|
||||
(newValue) => {
|
||||
if (newValue) {
|
||||
const clientId = +JSON.parse(newValue)?.clientFk;
|
||||
if (!clientFk) return;
|
||||
formInitialData.value = {
|
||||
clientId,
|
||||
};
|
||||
if (tableRef.value) tableRef.value.create.formInitialData = { clientId };
|
||||
onClientSelected({ clientId });
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -462,11 +479,10 @@ function setReference(data) {
|
|||
urlCreate: 'Tickets/new',
|
||||
title: t('ticketList.createTicket'),
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: { clientId: null },
|
||||
formInitialData,
|
||||
}"
|
||||
default-mode="table"
|
||||
:columns="columns"
|
||||
:user-params="userParams"
|
||||
:right-search="false"
|
||||
redirect="ticket"
|
||||
v-model:selected="selectedRows"
|
||||
|
|
Loading…
Reference in New Issue