feat: новая функция

This commit is contained in:
2025-10-16 18:44:30 +03:00
parent e0300480e1
commit 927d174f66
33 changed files with 1494 additions and 700 deletions

View File

@@ -16,72 +16,16 @@
<span>Контакты</span>
<span v-if="newContacts.length" class="badge">+{{ newContacts.length }}</span>
</div>
<ContactTable v-if="canViewContacts" :contacts="contacts" :new-contacts="newContacts" :new-messages="newMessages" @markNewAsRead="markMessagesAsRead"
:markMessagesAsReadForUser="markMessagesAsReadForUser" :markContactAsRead="markContactAsRead" @close="goBack" />
<!-- Таблица-заглушка для обычных пользователей -->
<div v-else class="contact-table-placeholder">
<div class="contact-table-header">
<h2>Контакты</h2>
<button class="close-btn" @click="goBack">×</button>
</div>
<!-- Форма фильтров (неактивная) -->
<div class="filters-form-placeholder">
<div class="form-row">
<div class="form-item">
<label>Поиск</label>
<input type="text" disabled placeholder="Поиск по имени, email, telegram, кошельку" />
</div>
<div class="form-item">
<label>Тип контакта</label>
<select disabled>
<option>Все</option>
</select>
</div>
<div class="form-item">
<label>Дата от</label>
<input type="date" disabled />
</div>
<div class="form-item">
<label>Дата до</label>
<input type="date" disabled />
</div>
<button class="btn-disabled" disabled>Сбросить фильтры</button>
</div>
</div>
<!-- Таблица с замаскированными данными -->
<table class="contact-table-masked">
<thead>
<tr>
<th>Имя</th>
<th>Email</th>
<th>Telegram</th>
<th>Кошелек</th>
<th>Дата создания</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
<tr v-for="i in 3" :key="i">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
<button class="details-btn-disabled" disabled>Подробнее</button>
</td>
</tr>
</tbody>
</table>
<div class="access-notice">
<i class="fas fa-info-circle"></i>
Полные данные контактов доступны только администраторам
</div>
</div>
<!-- Таблица контактов для всех пользователей -->
<ContactTable
:contacts="contacts"
:new-contacts="newContacts"
:new-messages="newMessages"
@markNewAsRead="markMessagesAsRead"
:markMessagesAsReadForUser="markMessagesAsReadForUser"
:markContactAsRead="markContactAsRead"
@close="goBack"
/>
</BaseLayout>
</template>
@@ -150,137 +94,4 @@ function goBack() {
margin-left: 7px;
}
/* Стили для таблицы-заглушки */
.contact-table-placeholder {
background: #fff;
border-radius: 16px;
box-shadow: 0 4px 32px rgba(0,0,0,0.12);
padding: 32px 24px 24px 24px;
width: 100%;
margin-top: 40px;
position: relative;
overflow-x: auto;
}
.contact-table-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
}
.contact-table-header h2 {
margin: 0;
color: #333;
}
.close-btn {
position: absolute;
top: 18px;
right: 18px;
background: none;
border: none;
font-size: 2rem;
cursor: pointer;
color: #bbb;
transition: color 0.2s;
}
.close-btn:hover {
color: #333;
}
.filters-form-placeholder {
margin-bottom: 24px;
padding: 16px;
background: #f8f9fa;
border-radius: 8px;
}
.form-row {
display: flex;
flex-wrap: wrap;
gap: 16px;
align-items: end;
}
.form-item {
display: flex;
flex-direction: column;
min-width: 150px;
}
.form-item label {
font-size: 0.9rem;
color: #666;
margin-bottom: 4px;
}
.form-item input,
.form-item select {
padding: 8px 12px;
border: 1px solid #dee2e6;
border-radius: 4px;
font-size: 0.9rem;
background: #f8f9fa;
color: #6c757d;
cursor: not-allowed;
}
.btn-disabled {
padding: 8px 16px;
border: 1px solid #dee2e6;
border-radius: 4px;
background: #f8f9fa;
color: #6c757d;
cursor: not-allowed;
height: fit-content;
}
.contact-table-masked {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
}
.contact-table-masked th,
.contact-table-masked td {
padding: 12px 8px;
text-align: left;
border-bottom: 1px solid #e9ecef;
}
.contact-table-masked th {
background: #f8f9fa;
font-weight: 600;
color: #495057;
}
.contact-table-masked td {
color: #adb5bd;
font-family: monospace;
}
.details-btn-disabled {
padding: 6px 12px;
border: 1px solid #dee2e6;
border-radius: 4px;
background: #f8f9fa;
color: #6c757d;
font-size: 0.8rem;
cursor: not-allowed;
}
.access-notice {
margin-top: 20px;
padding: 12px 16px;
background: #e3f2fd;
border: 1px solid #bbdefb;
border-radius: 8px;
color: #1976d2;
display: flex;
align-items: center;
gap: 8px;
font-size: 0.9rem;
}
</style>

View File

@@ -53,6 +53,13 @@
Подробнее
</button>
</div>
<!-- Блок Акселератор -->
<div class="crm-accelerator-block">
<h2>Акселератор</h2>
<button class="details-btn" @click="goToAcceleratorRegistration">
Подробнее
</button>
</div>
</div>
</BaseLayout>
</template>
@@ -242,6 +249,10 @@ function goToManagement() {
function goToWeb3App() {
router.push({ name: 'vds-mock' });
}
function goToAcceleratorRegistration() {
router.push({ name: 'accelerator-registration' });
}
</script>
<style scoped>
@@ -402,4 +413,23 @@ strong {
.crm-web3-block .details-btn {
margin-top: 0;
}
.crm-accelerator-block {
margin: 32px 0 24px 0;
padding: 24px;
background: #f8fafc;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
display: flex;
align-items: center;
justify-content: space-between;
}
.crm-accelerator-block h2 {
margin: 0;
font-size: 1.4rem;
font-weight: 600;
}
.crm-accelerator-block .details-btn {
margin-top: 0;
}
</style>

View File

@@ -51,6 +51,7 @@ import { useRouter, useRoute } from 'vue-router';
import BaseLayout from '../components/BaseLayout.vue';
import adminChatService from '../services/adminChatService.js';
import { usePermissions } from '@/composables/usePermissions';
import { getPrivateMessages } from '../services/messagesService';
const router = useRouter();
const route = useRoute();
@@ -65,15 +66,41 @@ let ws = null;
async function fetchPersonalMessages() {
try {
isLoading.value = true;
console.log('[PersonalMessagesView] Загружаем личные сообщения...');
const response = await adminChatService.getAdminContacts();
console.log('[PersonalMessagesView] API ответ:', response);
personalMessages.value = response?.contacts || [];
console.log('[PersonalMessagesView] Загружено бесед:', personalMessages.value.length);
console.log('[PersonalMessagesView] Беседы:', personalMessages.value);
newMessagesCount.value = personalMessages.value.length; // Simplified for now
console.log('[PersonalMessagesView] Загружаем приватные сообщения...');
// Загружаем приватные сообщения через новый API с пагинацией
const response = await getPrivateMessages({ limit: 100, offset: 0 });
console.log('[PersonalMessagesView] Загружено приватных сообщений:', response.messages?.length || 0);
const privateMessages = response.success && response.messages ? response.messages : [];
// Группируем сообщения по отправителям для отображения списка бесед
const messageGroups = {};
privateMessages.forEach(msg => {
const senderId = msg.sender_id || 'unknown';
if (!messageGroups[senderId]) {
messageGroups[senderId] = {
id: senderId,
name: `Админ ${senderId}`,
last_message: msg.content,
last_message_at: msg.created_at,
messages: []
};
}
messageGroups[senderId].messages.push(msg);
// Обновляем последнее сообщение
if (new Date(msg.created_at) > new Date(messageGroups[senderId].last_message_at)) {
messageGroups[senderId].last_message = msg.content;
messageGroups[senderId].last_message_at = msg.created_at;
}
});
personalMessages.value = Object.values(messageGroups);
newMessagesCount.value = personalMessages.value.length;
console.log('[PersonalMessagesView] Сформировано бесед:', personalMessages.value.length);
} catch (error) {
console.error('[PersonalMessagesView] Ошибка загрузки личных сообщений:', error);
console.error('[PersonalMessagesView] Ошибка загрузки приватных сообщений:', error);
personalMessages.value = [];
} finally {
isLoading.value = false;

View File

@@ -0,0 +1,368 @@
<!--
Copyright (c) 2024-2025 Тарабанов Александр Викторович
All rights reserved.
This software is proprietary and confidential.
Unauthorized copying, modification, or distribution is prohibited.
For licensing inquiries: info@hb3-accelerator.com
Website: https://hb3-accelerator.com
GitHub: https://github.com/HB3-ACCELERATOR
-->
<template>
<BaseLayout
:is-authenticated="isAuthenticated"
:identities="identities"
:token-balances="tokenBalances"
:is-loading-tokens="isLoadingTokens"
@auth-action-completed="$emit('auth-action-completed')"
>
<div class="accelerator-registration-container">
<div class="page-header">
<h1>Программы акселератора HB3</h1>
<p class="page-description">
Выберите подходящую программу для развития вашего бизнеса
</p>
</div>
<div class="program-selection">
<div class="form-section">
<h2>Выберите вид деятельности</h2>
<div class="form-group">
<label for="activityType">Вид деятельности *</label>
<select
id="activityType"
v-model="selectedActivity"
@change="onActivityChange"
class="form-select"
>
<option value="">Выберите вид деятельности</option>
<option value="fintech">Финансовые технологии (FinTech)</option>
<option value="blockchain">Блокчейн и Web3</option>
<option value="ai">Искусственный интеллект</option>
<option value="ecommerce">Электронная коммерция</option>
<option value="healthtech">Медицинские технологии</option>
<option value="edtech">Образовательные технологии</option>
<option value="realestate">Недвижимость и PropTech</option>
<option value="logistics">Логистика и транспорт</option>
<option value="greentech">Зеленые технологии</option>
<option value="agritech">Агротехнологии</option>
<option value="other">Другое</option>
</select>
</div>
<!-- Кнопка подключиться появляется при выборе деятельности -->
<div v-if="selectedActivity" class="connect-section">
<div class="selected-activity-info">
<h3>{{ getActivityInfo(selectedActivity).title }}</h3>
<p>{{ getActivityInfo(selectedActivity).description }}</p>
</div>
<button
@click="goToProgramDescription"
class="btn btn-primary btn-connect"
>
Подключиться
</button>
</div>
</div>
<!-- Кнопка назад -->
<div class="form-actions">
<button
@click="goBack"
class="btn btn-secondary"
>
Назад к CRM
</button>
</div>
</div>
</div>
</BaseLayout>
</template>
<script setup>
import { ref, defineProps, defineEmits } from 'vue';
import { useRouter } from 'vue-router';
import BaseLayout from '../../components/BaseLayout.vue';
// Определяем props
const props = defineProps({
isAuthenticated: Boolean,
identities: Array,
tokenBalances: Object,
isLoadingTokens: Boolean
});
// Определяем emits
const emit = defineEmits(['auth-action-completed']);
const router = useRouter();
const selectedActivity = ref('');
// Информация о видах деятельности
const activityInfo = {
fintech: {
title: 'Финансовые технологии (FinTech)',
description: 'Развитие инновационных решений в сфере финансовых услуг, платежных систем и банкинга.'
},
blockchain: {
title: 'Блокчейн и Web3',
description: 'Создание децентрализованных приложений, смарт-контрактов и Web3 решений.'
},
ai: {
title: 'Искусственный интеллект',
description: 'Разработка AI-решений, машинного обучения и автоматизации бизнес-процессов.'
},
ecommerce: {
title: 'Электронная коммерция',
description: 'Создание и развитие онлайн-магазинов, маркетплейсов и платформ для продаж.'
},
healthtech: {
title: 'Медицинские технологии',
description: 'Инновационные решения в сфере здравоохранения, телемедицины и биотехнологий.'
},
edtech: {
title: 'Образовательные технологии',
description: 'Разработка платформ для онлайн-обучения, образовательных приложений и EdTech решений.'
},
realestate: {
title: 'Недвижимость и PropTech',
description: 'Инновации в сфере недвижимости, платформы для аренды и продажи недвижимости.'
},
logistics: {
title: 'Логистика и транспорт',
description: 'Оптимизация цепей поставок, транспортных маршрутов и логистических процессов.'
},
greentech: {
title: 'Зеленые технологии',
description: 'Решения для экологии, возобновляемой энергетики и устойчивого развития.'
},
agritech: {
title: 'Агротехнологии',
description: 'Инновации в сельском хозяйстве, точное земледелие и агротехнические решения.'
},
other: {
title: 'Другое',
description: 'Инновационные проекты в других сферах деятельности.'
}
};
// Обработка изменения выбранной деятельности
const onActivityChange = () => {
console.log('Выбрана деятельность:', selectedActivity.value);
};
// Получение информации о выбранной деятельности
const getActivityInfo = (activity) => {
return activityInfo[activity] || { title: 'Неизвестная деятельность', description: '' };
};
// Переход к описанию программы
const goToProgramDescription = () => {
router.push({
name: 'accelerator-program-description',
params: { activity: selectedActivity.value }
});
};
// Навигация назад
const goBack = () => {
router.push({ name: 'crm' });
};
</script>
<style scoped>
.accelerator-registration-container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: var(--color-white);
border-radius: var(--radius-lg);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.page-header {
text-align: center;
margin-bottom: 40px;
padding-bottom: 20px;
border-bottom: 2px solid var(--color-light);
}
.page-header h1 {
color: var(--color-dark);
margin-bottom: 10px;
font-size: 2rem;
font-weight: 600;
}
.page-description {
color: var(--color-text-secondary);
font-size: 1.1rem;
margin: 0;
}
.program-selection {
display: flex;
flex-direction: column;
gap: 30px;
}
.form-section {
background: #f8fafc;
padding: 24px;
border-radius: 10px;
border: 1px solid #e2e8f0;
}
.form-section h2 {
color: var(--color-dark);
margin: 0 0 20px 0;
font-size: 1.3rem;
font-weight: 600;
}
.form-group {
margin-bottom: 20px;
}
.form-group:last-child {
margin-bottom: 0;
}
.form-group label {
display: block;
margin-bottom: 6px;
color: var(--color-dark);
font-weight: 500;
font-size: 0.9rem;
}
.form-select {
width: 100%;
padding: 12px 16px;
border: 2px solid #e2e8f0;
border-radius: 8px;
font-size: 1rem;
transition: border-color 0.2s, box-shadow 0.2s;
background-color: white;
cursor: pointer;
}
.form-select:focus {
outline: none;
border-color: var(--color-primary);
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.connect-section {
margin-top: 30px;
padding: 20px;
background: white;
border-radius: 8px;
border: 2px solid var(--color-primary);
text-align: center;
}
.selected-activity-info h3 {
color: var(--color-dark);
margin: 0 0 10px 0;
font-size: 1.2rem;
font-weight: 600;
}
.selected-activity-info p {
color: var(--color-text-secondary);
margin: 0 0 20px 0;
font-size: 1rem;
line-height: 1.5;
}
.btn-connect {
padding: 15px 30px;
font-size: 1.1rem;
font-weight: 600;
min-width: 200px;
}
.form-actions {
display: flex;
gap: 15px;
justify-content: flex-start;
padding-top: 20px;
border-top: 1px solid #e2e8f0;
}
.btn {
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
text-decoration: none;
display: inline-block;
text-align: center;
}
.btn-primary {
background: var(--color-primary);
color: white;
}
.btn-primary:hover:not(:disabled) {
background: var(--color-primary-dark);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.btn-primary:disabled {
background: #94a3b8;
cursor: not-allowed;
transform: none;
}
.btn-secondary {
background: #6c757d;
color: white;
}
.btn-secondary:hover {
background: #5a6268;
transform: translateY(-1px);
}
/* Адаптивность */
@media (max-width: 768px) {
.accelerator-registration-container {
margin: 10px;
padding: 15px;
}
.form-actions {
flex-direction: column;
}
.btn {
width: 100%;
}
.btn-connect {
width: 100%;
min-width: auto;
}
.page-header h1 {
font-size: 1.5rem;
}
.page-description {
font-size: 1rem;
}
.connect-section {
padding: 15px;
}
}
</style>

View File

@@ -160,6 +160,7 @@ import Message from '../../components/Message.vue';
import ChatInterface from '../../components/ChatInterface.vue';
import contactsService from '../../services/contactsService.js';
import messagesService from '../../services/messagesService.js';
import { getPublicMessages, getConversationByUserId } from '../../services/messagesService.js';
import { useAuthContext } from '@/composables/useAuth';
import { usePermissions } from '@/composables/usePermissions';
import { useContactsAndMessagesWebSocket } from '@/composables/useContactsWebSocket';
@@ -401,11 +402,15 @@ async function loadMessages() {
console.log('[ContactDetailsView] 📥 loadMessages START for:', contact.value.id);
isLoadingMessages.value = true;
try {
// Загружаем ВСЕ публичные сообщения этого пользователя (как на главной странице)
const loadedMessages = await messagesService.getMessagesByUserId(contact.value.id);
console.log('[ContactDetailsView] 📩 Loaded messages:', loadedMessages.length, 'for', contact.value.id);
// Загружаем только публичные сообщения этого пользователя с пагинацией
const response = await getPublicMessages(contact.value.id, { limit: 50, offset: 0 });
console.log('[ContactDetailsView] 📩 Loaded messages:', response.messages?.length || 0, 'for', contact.value.id);
messages.value = loadedMessages;
if (response.success && response.messages) {
messages.value = response.messages;
} else {
messages.value = [];
}
if (messages.value.length > 0) {
lastMessageDate.value = messages.value[messages.value.length - 1].created_at;
@@ -417,7 +422,7 @@ async function loadMessages() {
// Гости не имеют conversations
if (!String(contact.value.id).startsWith('guest_')) {
try {
const conv = await messagesService.getConversationByUserId(contact.value.id);
const conv = await getConversationByUserId(contact.value.id);
conversationId.value = conv?.id || null;
} catch (convError) {
console.warn('[ContactDetailsView] Не удалось загрузить conversationId:', convError.message);