Fix deal_date (very long bug)
This commit is contained in:
parent
c3259b7e6c
commit
619687df68
@ -1040,15 +1040,15 @@ const handleCloseDealObject = (side) => {
|
|||||||
|
|
||||||
const openModalDealContract = async () => {
|
const openModalDealContract = async () => {
|
||||||
if (!deal.value.id) {
|
if (!deal.value.id) {
|
||||||
|
console.log('[DealModal] deal до saveDeal.', deal);
|
||||||
console.log('[DealModal] Сделка не сохранена, сохраняем перед открытием модального окна договора.');
|
console.log('[DealModal] Сделка не сохранена, сохраняем перед открытием модального окна договора.');
|
||||||
try {
|
try {
|
||||||
let currentDeal = deal.value
|
//const savedDeal = await saveDeal();
|
||||||
const savedDeal = await saveDeal();
|
await saveDeal();
|
||||||
if (savedDeal?.id) {
|
console.log('[DealModal] saveDeal.', deal);
|
||||||
if (!savedDeal?.id) return
|
if (deal?.value.id) {
|
||||||
deal.value = savedDeal
|
//if (!savedDeal?.id) return
|
||||||
currentDeal = savedDeal
|
//deal.value = savedDeal.value
|
||||||
const plainDeal = JSON.parse(JSON.stringify(toRaw(currentDeal)))
|
|
||||||
|
|
||||||
console.log('[DealModal] Сделка успешно сохранена, ID:', deal.value);
|
console.log('[DealModal] Сделка успешно сохранена, ID:', deal.value);
|
||||||
console.log('InnerDocAddModal:', InnerDocAddModal);
|
console.log('InnerDocAddModal:', InnerDocAddModal);
|
||||||
@ -1058,7 +1058,7 @@ const openModalDealContract = async () => {
|
|||||||
modal: true,
|
modal: true,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
deal: plainDeal,
|
deal: deal.value,
|
||||||
},
|
},
|
||||||
onClose: (options) => {
|
onClose: (options) => {
|
||||||
console.log('InnerDocAddModal закрыт, options:', options)
|
console.log('InnerDocAddModal закрыт, options:', options)
|
||||||
@ -1180,11 +1180,29 @@ const saveDeal = async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Обновляем локальное состояние сделки
|
// Обновляем локальное состояние сделки
|
||||||
// if (response.data.deal) {
|
if (response.data.deal) {
|
||||||
// deal.value = response.data.deal;
|
//deal.value = response.data.deal;
|
||||||
// }
|
const rawDeal = response.data.deal;
|
||||||
console.log('cat', response.data)
|
|
||||||
return response.data.deal;
|
// Конвертируем строки в Date, чтобы избежать падений в computed
|
||||||
|
if (rawDeal.deal_date) {
|
||||||
|
rawDeal.deal_date = dayjs(rawDeal.deal_date, [
|
||||||
|
'YYYY-MM-DD HH:mm:ss',
|
||||||
|
'DD.MM.YYYY HH:mm'
|
||||||
|
], true).toDate();
|
||||||
|
}
|
||||||
|
if (rawDeal.created_at) {
|
||||||
|
rawDeal.created_at = new Date(rawDeal.created_at);
|
||||||
|
}
|
||||||
|
if (rawDeal.updated_at) {
|
||||||
|
rawDeal.updated_at = new Date(rawDeal.updated_at);
|
||||||
|
}
|
||||||
|
|
||||||
|
deal.value = rawDeal;
|
||||||
|
}
|
||||||
|
console.log('cat deal', response.data.deal)
|
||||||
|
//return response.data.deal;
|
||||||
|
return null;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
new Error(response.data.message || 'Ошибка при сохранении сделки');
|
new Error(response.data.message || 'Ошибка при сохранении сделки');
|
||||||
|
|||||||
@ -77,6 +77,8 @@
|
|||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useConfirm } from 'primevue/useconfirm';
|
import { useConfirm } from 'primevue/useconfirm';
|
||||||
import { useToast } from 'primevue/usetoast';
|
import { useToast } from 'primevue/usetoast';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import 'dayjs/locale/ru';
|
||||||
|
|
||||||
console.log('Запуск InnerDocCard');
|
console.log('Запуск InnerDocCard');
|
||||||
|
|
||||||
@ -152,14 +154,29 @@ const handleRemoveDealDoc = (event) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// const formatDate = (dateString) => {
|
||||||
|
// return new Date(dateString).toLocaleDateString('ru-RU', {
|
||||||
|
// day: '2-digit',
|
||||||
|
// month: '2-digit',
|
||||||
|
// year: 'numeric',
|
||||||
|
// hour: '2-digit',
|
||||||
|
// minute: '2-digit'
|
||||||
|
// });
|
||||||
|
// };
|
||||||
const formatDate = (dateString) => {
|
const formatDate = (dateString) => {
|
||||||
return new Date(dateString).toLocaleDateString('ru-RU', {
|
if (!dateString) return '—';
|
||||||
day: '2-digit',
|
// Поддерживаем разные форматы
|
||||||
month: '2-digit',
|
const parsed = dayjs(dateString, [
|
||||||
year: 'numeric',
|
'YYYY-MM-DD HH:mm:ss',
|
||||||
hour: '2-digit',
|
'DD.MM.YYYY HH:mm:ss',
|
||||||
minute: '2-digit'
|
'DD.MM.YY HH:mm',
|
||||||
});
|
'DD.MM.YYYY',
|
||||||
|
'YYYY-MM-DDTHH:mm:ssZ'
|
||||||
|
], true); // strict parsing
|
||||||
|
|
||||||
|
return parsed.isValid()
|
||||||
|
? parsed.locale('ru').format('DD.MM.YYYY HH:mm')
|
||||||
|
: '—';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user