${singing.documents.map(d => `№${d.number} ${d.title}`).join(', ')}
+
+ `;
+
+ document.body.appendChild(modalWrapper);
+
+ // Получаем элементы
+ const checkboxes = modalWrapper.querySelectorAll('.recipient-checkbox');
+ const confirmBtn = modalWrapper.querySelector('.confirm-btn');
+ const deliverySelect = modalWrapper.querySelector('.delivery-select');
+ let selectedDeliveryType = deliverySelect.value || null;
+
+ // Функция обновления состояния кнопки
+ function updateConfirmButton() {
+ const anyChecked = Array.from(checkboxes).some(cb => cb.checked);
+ const hasDeliveryType = selectedDeliveryType && selectedDeliveryType !== '';
+
+ if (anyChecked && hasDeliveryType) {
+ confirmBtn.style.opacity = '1';
+ confirmBtn.style.pointerEvents = 'auto';
+ } else {
+ confirmBtn.style.opacity = '0.5';
+ confirmBtn.style.pointerEvents = 'none';
+ }
+ }
+
+ // Обработчик изменения выбора в select
+ deliverySelect.addEventListener('change', (e) => {
+ selectedDeliveryType = e.target.value;
+ updateConfirmButton();
+ });
+
+ // Обработчики для чекбоксов
+ if (checkboxes.length > 0) {
+ checkboxes.forEach(cb => {
+ cb.addEventListener('change', updateConfirmButton);
+ });
+ }
+
+ // Функции закрытия
+ const closeModal = () => {
+ modalWrapper.remove();
+ resolve({ confirmed: false, recipients: [], deliveryType: null });
+ };
+
+ // Обработчик кнопки подтверждения
+ confirmBtn.addEventListener('click', () => {
+ const selectedRecipients = Array.from(checkboxes)
+ .filter(cb => cb.checked)
+ .map(cb => cb.value);
+
+ if (selectedRecipients.length === 0 || !selectedDeliveryType) {
+ return;
+ }
+
+ modalWrapper.remove();
+ resolve({
+ confirmed: true,
+ recipients: selectedRecipients,
+ deliveryType: selectedDeliveryType
+ });
+ });
+
+ // Обработчики закрытия
+ modalWrapper.querySelector('.el-dialog__headerbtn').addEventListener('click', closeModal);
+ modalWrapper.querySelector('.cancel-btn').addEventListener('click', closeModal);
+ modalWrapper.addEventListener('click', (e) => {
+ if (e.target === modalWrapper) closeModal();
+ });
+
+ // Закрытие по ESC
+ const escHandler = (e) => {
+ if (e.key === 'Escape') {
+ closeModal();
+ document.removeEventListener('keydown', escHandler);
+ }
+ };
+ document.addEventListener('keydown', escHandler);
+
+ // Инициализация состояния кнопки
+ updateConfirmButton();
+ });
+ }
+
+ // Функция создания модального окна подтверждения отзыва
+ function createRevokeConfirmModal(singing) {
+ return new Promise((resolve) => {
+ const modalWrapper = document.createElement('div');
+ modalWrapper.className = 'el-dialog__wrapper';
+ modalWrapper.style.cssText = 'z-index: 2001; position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow: auto;';
+
+ modalWrapper.innerHTML = `
+
+ `;
document.body.appendChild(modalWrapper);
@@ -438,43 +670,9 @@
});
}
- // Функция повторной отправки документов
- async function resendDocuments(singing, modalToClose) {
- try {
- // Сразу закрываем окно со списком документов
- if (modalToClose && modalToClose.parentNode) {
- modalToClose.remove();
- }
-
- // Показываем подтверждение
- const confirmed = await createResendConfirmModal(singing);
- if (!confirmed) return;
-
- showMessage('Повторная отправка документов...', 'info');
-
- // Отправляем запрос на повторную отправку
- const response = await sendMessageToContent('resendDocuments', {
- id: singing.id,
- trackingId: singing.trackingId,
- idPatientMis: singing.idPatientMis
- });
-
- if (response.success) {
- showMessage('Документы успешно отправлены повторно', 'success');
- console.log('Документы успешно отправлены повторно');
- // Обновляем список документов
- await prepareDocuments();
- } else {
- showMessage('Ошибка повторной отправки документов: ' + (response.message || 'Неизвестная ошибка'), 'error');
- }
- } catch (error) {
- console.error('Ошибка повторной отправки документов:', error);
- showMessage('Ошибка повторной отправки документов', 'error');
- }
- }
-
// Функция создания таблицы документов
function createDocumentsTable(data) {
+
// Создаем модальное окно
const modalWrapper = document.createElement('div');
modalWrapper.className = 'el-dialog__wrapper';
@@ -509,9 +707,10 @@
} else {
const tableRows = data.map((singing, index) => {
// Определяем последний статус
- const lastStatus = singing.statuses.reduce((max, status) =>
+ const commonStatuses = singing.statuses.filter(s => s.idPatientMis === null);
+ const lastStatus = commonStatuses.reduce((max, status) =>
status.id > max.id ? status : max
- , singing.statuses[0]);
+ , commonStatuses[0] || singing.statuses[0]);
const statusClass = getStatusClass(lastStatus.category);
const statusIcon = getStatusIcon(lastStatus.category);
@@ -519,6 +718,14 @@
lastStatus.category === 'processing' ? '#409EFF' :
lastStatus.category === 'error' ? '#F56C6C' : '#909399';
+ // Маппинг типов доставки на отображаемые названия
+ const deliveryTypeLabels = {
+ 'sms': 'СМС-сообщение',
+ 'max': 'МАХ-сообщение',
+ 'mila': 'Mila-сообщение',
+ 'goskey': 'Goskey-сообщение'
+ };
+
// Формируем ячейку с документами
const documentsHtml = singing.documents.map(doc => `
@@ -550,47 +757,47 @@
${documentsHtml}
-
-
+
+
${lastStatus.description}
- ${formatDate(lastStatus.created_at)}
+ ${formatDate(lastStatus.created_at)} ✉️ ${deliveryTypeLabels[singing.deliveryType]}
-
- ${singing.storagePath ? `
-
- ` : ''}
+
+ ${singing.storagePath && singing.storagePath.length > 0
+ ? singing.storagePath.map((path, index) => `
+
+ `).join('')
+ : ''}
${singing.statuses.length > 1 ? `
` : ''}
${lastStatus.category === 'processing' ? `
-
-
-
-
+
+
` : ''}
@@ -707,7 +914,8 @@
const response = await sendMessageToContent('prepareDocuments', {});
if (response.success) {
- createDocumentsTable(response.data);
+ deliveryTypeSettings = response.data.deliveryType;
+ createDocumentsTable(response.data.singings);
} else {
showMessage('Ошибка загрузки документов: ' + (response.message || 'Неизвестная ошибка'), 'error');
}
diff --git a/metaData.js b/metaData.js
index c4ea1d6..4612941 100644
--- a/metaData.js
+++ b/metaData.js
@@ -37,7 +37,7 @@
patientPhone = window.gon.specific.client.phone;
const patientPhoneNormalized = `+7${patientPhone.replace(/[^\d]/g, '').slice(1, 12)}`;
- metaData.patients = [{
+ metaData.patient = {
idPatientMis: window.gon.specific.client.id,
familyName: window.gon.specific.client.surname,
givenName: window.gon.specific.client.name,
@@ -55,10 +55,10 @@
documentName: 'СНИЛС',
idDocumentType: 223
}]
- }]
+ }
if (window.gon.specific.client.email) {
- metaData.patients[0].telecom.push({
+ metaData.patient.telecom.push({
system: 'Email',
value: window.gon.specific.client.email
});
@@ -73,11 +73,6 @@
data: doc.data
}));
- metaData.userData = {
- id: window.gon.application.current_user.id,
- login: window.gon.application.current_user.username,
- };
-
// Отправляем только один раз
window.postMessage(
{
diff --git a/popup.html b/popup.html
index 1c0c1b5..bf506af 100644
--- a/popup.html
+++ b/popup.html
@@ -612,7 +612,6 @@
word-wrap: break-word;
overflow-wrap: break-word;
hyphens: auto;
- cursor: help;
position: relative;
max-width: 120px;
}
diff --git a/popup.js b/popup.js
index e9911a7..cb6bb0d 100644
--- a/popup.js
+++ b/popup.js
@@ -68,9 +68,9 @@
function getStatusIcon(category) {
switch (category) {
- case 'completed': return '✓';
- case 'processing': return '⋯';
- case 'error': return '✗';
+ case 'completed': return '✅';
+ case 'processing': return '⌛';
+ case 'error': return '❌';
default: return '?';
}
}
@@ -312,6 +312,7 @@
}
}
+ // Рендер таблицы
// Рендер таблицы
function renderTable(data) {
if (!data || data.length === 0) {
@@ -323,56 +324,78 @@
emptyState.classList.add('hidden');
const rows = data.map(item => {
- const lastStatus = item.statuses?.reduce((max, s) => s.id > max.id ? s : max, item.statuses[0]);
- const statusClass = getStatusClass(lastStatus?.category);
- const statusIcon = getStatusIcon(lastStatus?.category);
+ // Берем только общие статусы (где idPatientMis === null)
+ const commonStatuses = item.statuses?.filter(s => s.idPatientMis === null) || [];
+
+ // Берем последний общий статус
+ const lastStatus = commonStatuses.length > 0
+ ? commonStatuses.reduce((max, s) => s.id > max.id ? s : max, commonStatuses[0])
+ : null;
+
+ // Если нет общих статусов, используем первый статус из списка как fallback
+ const displayStatus = lastStatus || (item.statuses && item.statuses[0]) || null;
+
+ const statusClass = getStatusClass(displayStatus?.category);
+ const statusIcon = getStatusIcon(displayStatus?.category);
+
+ // Маппинг типов доставки на отображаемые названия
+ const deliveryTypeLabels = {
+ 'sms': 'СМС',
+ 'max': 'МАХ',
+ 'mila': 'Mila',
+ 'goskey': 'Goskey'
+ };
const documentsHtml = item.documents?.map(doc => {
- const isClickable = lastStatus?.category !== 'error';
+ // Документы можно просматривать только если статус не error
+ const isClickable = displayStatus?.category !== 'error' && doc.storagePath;
const baseClass = isClickable ? 'doc-item clickable-doc' : 'doc-item';
return `
-
- №${doc.number} ${doc.title?.replace(/\s+/g, ' ')}
- ${isClickable ? '📄' : ''}
-
- `;
+
+ №${doc.number} ${doc.title?.replace(/\s+/g, ' ')}
+ ${isClickable ? '📄' : ''}
+
+ `;
}).join('');
- const hasMainDocument = item.storagePath && !item.storagePath.includes('null');
+ const hasMainDocument = item.storagePath.length > 0;
return `
-
- |
- ${item.patientName || 'Неизвестно'}
- ${formatDate(item.created_at)}
-
- 👤 ${item.userName || 'Неизвестно'}
+
+ |
+ ${item.patientName || 'Неизвестно'}
+ ${formatDate(item.created_at)}
+ ✉️ ${deliveryTypeLabels[item.deliveryType] || item.deliveryType}
+
+ 👤 ${item.userName || 'Неизвестно'}
+
+ |
+
+
+ ${documentsHtml}
+
+ |
+
+
+
+ ${statusIcon}
+ ${displayStatus?.name || 'Неизвестно'}
- |
-
-
- ${documentsHtml}
-
- |
-
-
-
- ${statusIcon}
- ${lastStatus?.name || 'Неизвестно'}
-
- ${formatDate(lastStatus?.created_at || item.created_at)}
- ${hasMainDocument ? `
-
- |
-
+ `).join('')
+ : ''}
+
+ |
+
`;
}).join('');
diff --git a/search.html b/search.html
index 66c8d50..30e07d6 100644
--- a/search.html
+++ b/search.html
@@ -94,7 +94,7 @@
-
+
+
+
+
+
+
+
-
+
-
+
|