Fix add new client in deal
This commit is contained in:
parent
d7546d79d3
commit
b1ae591b88
@ -1250,13 +1250,28 @@ const handleCloseDealRequisition = (side) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const refreshClientsList = async () => {
|
const refreshClientsList = async (data = {}) => {
|
||||||
console.log('[DealModal] refreshClientsList — обновляем clientsList');
|
console.log('[DealModal] refreshClientsList — обновляем clientsList', data);
|
||||||
try {
|
try {
|
||||||
const clientsRes = await fetchClientsListData('/clients?fields=short&no_pagination=1');
|
const clientsRes = await fetchClientsListData('/clients?fields=short&no_pagination=1');
|
||||||
if (clientsRes?.data?.data) {
|
if (clientsRes?.data?.data) {
|
||||||
console.log('[DealModal] clientsList обновлён, количество:', clientsRes.data.data.length);
|
console.log('[DealModal] clientsList обновлён, количество:', clientsRes.data.data.length);
|
||||||
clientsList.value = clientsRes.data.data;
|
clientsList.value = clientsRes.data.data;
|
||||||
|
|
||||||
|
// Автоматически выбираем нового клиента в нужной стороне
|
||||||
|
if (data.side && data.clientId) {
|
||||||
|
const newClient = clientsList.value.find(c => c.id === data.clientId);
|
||||||
|
if (newClient) {
|
||||||
|
if (data.side === 'sideOne') {
|
||||||
|
if (!deal.value.side_one_clients) deal.value.side_one_clients = [];
|
||||||
|
deal.value.side_one_clients.push(newClient);
|
||||||
|
} else {
|
||||||
|
if (!deal.value.side_two_clients) deal.value.side_two_clients = [];
|
||||||
|
deal.value.side_two_clients.push(newClient);
|
||||||
|
}
|
||||||
|
console.log('[DealModal] клиент', newClient.fio, 'добавлен в', data.side);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn('[DealModal] clientsRes:', clientsRes);
|
console.warn('[DealModal] clientsRes:', clientsRes);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -258,12 +258,12 @@ const openHistoryClient = (clientId) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onAddClientClick = () => {
|
const onAddClientClick = () => {
|
||||||
console.log('[RequisitionDetails] onAddClientClick — registruem listener deal:clientCreated');
|
const currentSide = props.side;
|
||||||
|
console.log('[RequisitionDetails] onAddClientClick side:', currentSide, '— registruem listener');
|
||||||
window.addEventListener('deal:clientCreated', function handler(e) {
|
window.addEventListener('deal:clientCreated', function handler(e) {
|
||||||
console.log('[RequisitionDetails] deal:clientCreated poluchen:', e.detail);
|
console.log('[RequisitionDetails] deal:clientCreated poluchen:', e.detail, 'side:', currentSide);
|
||||||
window.removeEventListener('deal:clientCreated', handler);
|
window.removeEventListener('deal:clientCreated', handler);
|
||||||
console.log('[RequisitionDetails] listener udalen, emit refreshClients');
|
emit('refreshClients', { side: currentSide, clientId: e.detail.id });
|
||||||
emit('refreshClients');
|
|
||||||
});
|
});
|
||||||
console.log('[RequisitionDetails] listener zaregistrirovan');
|
console.log('[RequisitionDetails] listener zaregistrirovan');
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user