release 1.1

This commit is contained in:
2026-02-22 09:40:08 +03:00
parent ea28427c3d
commit e269425fe0
10 changed files with 1173 additions and 410 deletions
+389 -23
View File
@@ -197,6 +197,19 @@
const inProgress = preSingingData.inProgress || [];
const complete = preSingingData.complete || [];
const daysRemainingControl = preSingingData.daysRemainingControl || 30;
const deliveryType = preSingingData.deliveryType || ["sms"];
const multipleSending = preSingingData.multipleSending || false;
// Массив получателей (только если multipleSending = true)
let recipients = [];
// Маппинг типов доставки на отображаемые названия
const deliveryTypeLabels = {
'sms': 'СМС-сообщение',
'max': 'МАХ-сообщение',
'mila': 'Mila-сообщение',
'goskey': 'Goskey-сообщение'
};
// Определяем тип документов
const hasIds = documents.some(doc => doc.title.includes('ИДС'));
@@ -309,7 +322,7 @@
const dialog = document.createElement('div');
dialog.className = 'el-dialog';
dialog.style.cssText = 'margin-top: 15vh; width: 700px; z-index: 2002; position: relative; margin: 15vh auto 50px; background: #fff; border-radius: 4px; box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);';
dialog.style.cssText = 'margin-top: 15vh; width: 750px; z-index: 2002; position: relative; margin: 15vh auto 50px; background: #fff; border-radius: 4px; box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);';
// Создаем заголовок
const dialogHeader = document.createElement('div');
@@ -335,7 +348,7 @@
// Создаем тело диалога
const dialogBody = document.createElement('div');
dialogBody.className = 'el-dialog__body';
dialogBody.style.cssText = 'padding: 15px; color: #606266; font-size: 14px;';
dialogBody.style.cssText = 'padding: 15px; padding-bottom: 0; color: #606266; font-size: 14px;';
// Создаем контент
const dialogContent = document.createElement('div');
@@ -492,12 +505,275 @@
documentsSection.appendChild(documentsList);
dialogContent.appendChild(documentsSection);
// ========== НАЧАЛО: Блок дополнительных получателей (только при multipleSending=true) ==========
if (multipleSending) {
// Функция рендеринга блока получателей (будет вызываться при изменениях)
function renderRecipientsBlock() {
// Удаляем старый контейнер, если он есть
const oldContainer = dialogContent.querySelector('.recipients-container');
if (oldContainer) {
oldContainer.remove();
}
// Если получателей нет - не отображаем блок
if (recipients.length === 0) {
return;
}
const recipientsContainer = document.createElement('div');
recipientsContainer.className = 'recipients-container';
recipientsContainer.style.cssText = 'margin-top: 15px; margin-bottom: 0px;';
// Заголовок с количеством получателей
const recipientsHeader = document.createElement('div');
recipientsHeader.style.cssText = 'display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;';
const recipientsTitle = document.createElement('h4');
recipientsTitle.style.cssText = 'margin: 0; color: #303133; font-size: 14px; font-weight: 500;';
recipientsTitle.textContent = 'Дополнительные получатели:';
const recipientsCount = document.createElement('span');
recipientsCount.className = 'el-tag el-tag--info el-tag--mini';
recipientsCount.style.cssText = 'margin-left: 6px;';
recipientsCount.textContent = recipients.length;
const titleWrapper = document.createElement('div');
titleWrapper.style.cssText = 'display: flex; align-items: center;';
titleWrapper.appendChild(recipientsTitle);
titleWrapper.appendChild(recipientsCount);
recipientsHeader.appendChild(titleWrapper);
// Компактный список получателей
const recipientsList = document.createElement('div');
recipientsList.className = 'recipients-list';
recipientsList.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px;';
recipients.forEach((recipient, index) => {
const recipientTag = document.createElement('span');
recipientTag.className = 'el-tag el-tag--info el-tag--small';
recipientTag.style.cssText = 'display: inline-flex; align-items: center; height: 24px; line-height: 22px; padding: 0 8px; margin-right: 4px; margin-bottom: 4px;';
const nameSpan = document.createElement('span');
nameSpan.textContent = `${recipient.surname} ${recipient.name.charAt(0)}. ${recipient.secondName ? recipient.secondName.charAt(0) + '.' : ''}`;
const closeIcon = document.createElement('i');
closeIcon.className = 'el-icon-close';
closeIcon.style.cssText = 'margin-left: 4px; cursor: pointer; font-size: 12px;';
closeIcon.addEventListener('click', (e) => {
e.stopPropagation();
if (window.confirm(`Удалить получателя ${recipient.surname} ${recipient.name}?`)) {
recipients.splice(index, 1);
renderRecipientsBlock(); // Перерисовываем блок
}
});
recipientTag.appendChild(nameSpan);
recipientTag.appendChild(closeIcon);
recipientsList.appendChild(recipientTag);
});
recipientsContainer.appendChild(recipientsHeader);
recipientsContainer.appendChild(recipientsList);
// Вставляем после списка документов
dialogContent.insertBefore(recipientsContainer, documentsSection.nextSibling);
}
// Кнопка добавления получателя
const addButtonContainer = document.createElement('div');
addButtonContainer.style.cssText = 'margin: 10px 0;';
const addRecipientBtn = document.createElement('button');
addRecipientBtn.type = 'button';
addRecipientBtn.className = 'el-button m-button el-button--success el-button--small is-plain button-with-icon';
if (!canSend) {
addRecipientBtn.classList.add('is-disabled');
addRecipientBtn.disabled = true;
}
addRecipientBtn.innerHTML = '<i class="m-icon fa-plus button-icon fad fa-fw" style="font-size: 17px;"></i> Добавить получателя';
addButtonContainer.appendChild(addRecipientBtn);
dialogContent.appendChild(addButtonContainer);
// Контейнер для аккордеона (поиск получателей)
const searchAccordion = document.createElement('div');
searchAccordion.className = 'search-accordion';
searchAccordion.style.cssText = 'margin-top: 10px; display: none;';
const searchCard = document.createElement('div');
searchCard.className = 'el-card';
searchCard.style.cssText = 'border: 1px solid #EBEEF5; border-radius: 4px;';
const searchBody = document.createElement('div');
searchBody.className = 'el-card__body';
searchBody.style.cssText = 'padding: 12px;';
// Поле ввода номера телефона и кнопка поиска
const searchRow = document.createElement('div');
searchRow.style.cssText = 'display: flex; gap: 8px; margin-bottom: 10px;';
const phoneInput = document.createElement('input');
phoneInput.type = 'text';
phoneInput.placeholder = 'Введите номер телефона';
phoneInput.className = 'el-input__inner';
phoneInput.style.cssText = 'flex: 1; height: 28px; line-height: 28px; border: 1px solid #DCDFE6; border-radius: 4px; padding: 0 8px; font-size: 12px;';
const searchBtn = document.createElement('button');
searchBtn.type = 'button';
searchBtn.className = 'el-button m-button el-button--primary el-button--small is-plain button-with-icon';
searchBtn.innerHTML = '<i class="m-icon fa-search button-icon fad fa-fw" style="font-size: 17px;"></i> Найти';
searchBtn.style.cssText = 'height: 28px;';
searchRow.appendChild(phoneInput);
searchRow.appendChild(searchBtn);
// Контейнер для результатов поиска
const searchResults = document.createElement('div');
searchResults.className = 'search-results';
searchResults.style.cssText = 'max-height: 150px; overflow-y: auto; font-size: 12px;';
// Кнопка отмены
const cancelSearchBtn = document.createElement('button');
cancelSearchBtn.type = 'button';
cancelSearchBtn.className = 'el-button m-button el-button--small is-plain button-with-icon cancel-button';
const cancelSearchIcon = document.createElement('i');
cancelSearchIcon.className = 'm-icon fa-times button-icon fad';
cancelSearchIcon.style.cssText = 'font-size: 14px; margin-right: 6px;';
const cancelSearchText = document.createElement('span');
cancelSearchText.textContent = 'Отмена';
cancelSearchBtn.appendChild(cancelSearchIcon);
cancelSearchBtn.appendChild(cancelSearchText);
searchBody.appendChild(searchRow);
searchBody.appendChild(searchResults);
searchBody.appendChild(cancelSearchBtn);
searchCard.appendChild(searchBody);
searchAccordion.appendChild(searchCard);
dialogContent.appendChild(searchAccordion);
// Функция поиска получателей по номеру телефона
async function searchRecipients(phone) {
if (!phone || phone.trim() === '') {
showMessage('Введите номер телефона', 'info');
return;
}
// Показываем загрузку
searchResults.innerHTML = '<div style="text-align: center; padding: 15px;"><i class="el-icon-loading" style="font-size: 18px;"></i><p style="margin: 5px 0 0; color: #909399;">Поиск...</p></div>';
try {
const result = await sendMessageToContent('searchRecipients', {
phone: phone.trim()
});
searchResults.innerHTML = '';
if (result && result.success && result.data && result.data.length > 0) {
result.data.forEach(person => {
const personItem = document.createElement('div');
personItem.style.cssText = 'display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid #F0F0F0;';
const personInfo = document.createElement('div');
personInfo.style.cssText = 'flex: 1;';
const fullName = document.createElement('span');
fullName.style.cssText = 'font-size: 12px; color: #606266;';
fullName.textContent = `${person.surname} ${person.name} ${person.secondName || ''}`.trim();
const birthdate = document.createElement('span');
birthdate.style.cssText = 'font-size: 11px; color: #909399; margin-left: 6px;';
birthdate.textContent = person.birthDate ? `(${person.birthDate})` : '';
personInfo.appendChild(fullName);
personInfo.appendChild(birthdate);
const addBtn = document.createElement('button');
addBtn.type = 'button';
addBtn.className = 'el-button el-button--primary el-button--mini';
addBtn.innerHTML = 'Добавить';
addBtn.style.cssText = 'height: 24px; padding: 0 8px;';
// Проверяем, не добавлен ли уже этот получатель
const alreadyAdded = recipients.some(r => r.id === person.id);
if (alreadyAdded) {
addBtn.disabled = true;
addBtn.classList.add('is-disabled');
addBtn.innerHTML = 'Добавлен';
}
addBtn.addEventListener('click', () => {
if (!alreadyAdded) {
recipients.push(person);
renderRecipientsBlock(); // Обновляем отображение блока получателей
// Закрываем аккордеон
searchAccordion.style.display = 'none';
// Очищаем поле ввода и результаты
phoneInput.value = '';
searchResults.innerHTML = '';
}
});
personItem.appendChild(personInfo);
personItem.appendChild(addBtn);
searchResults.appendChild(personItem);
});
} else {
searchResults.innerHTML = '<div style="text-align: center; padding: 15px; color: #909399;">Ничего не найдено</div>';
}
} catch (error) {
console.error('Ошибка поиска получателей:', error);
searchResults.innerHTML = '<div class="el-alert el-alert--error" style="margin: 5px 0;"><div class="el-alert__content"><span class="el-alert__title">Ошибка поиска</span><p class="el-alert__description">' + error.message + '</p></div></div>';
}
}
// Обработчик кнопки добавления получателя
addRecipientBtn.addEventListener('click', () => {
if (searchAccordion.style.display === 'none' || searchAccordion.style.display === '') {
searchAccordion.style.display = 'block';
phoneInput.value = '';
searchResults.innerHTML = '';
phoneInput.focus();
} else {
searchAccordion.style.display = 'none';
}
});
// Обработчик кнопки поиска
searchBtn.addEventListener('click', () => {
searchRecipients(phoneInput.value);
});
// Поиск при нажатии Enter
phoneInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
searchRecipients(phoneInput.value);
}
});
// Обработчик кнопки отмены
cancelSearchBtn.addEventListener('click', () => {
searchAccordion.style.display = 'none';
phoneInput.value = '';
searchResults.innerHTML = '';
});
// Инициализация - рендерим блок (если есть получатели)
renderRecipientsBlock();
}
// ========== КОНЕЦ: Блок дополнительных получателей ==========
dialogBody.appendChild(dialogContent);
// Создаем футер
const dialogFooter = document.createElement('div');
dialogFooter.className = 'el-dialog__footer';
dialogFooter.style.cssText = 'display: flex; justify-content: space-between; align-items: center;';
dialogFooter.style.cssText = 'display: flex; justify-content: space-between; align-items: flex-start; padding: 15px; padding-top: 10px;';
// Левая часть футера (информация о сроке действия разрешения на подпись)
const footerLeft = document.createElement('div');
@@ -506,7 +782,7 @@
if (signature.expiration && signature.type) {
// Тип разрешения
const typeContainer = document.createElement('div');
typeContainer.style.cssText = 'margin-bottom: 5px; margin-top: 0px;';
typeContainer.style.cssText = 'margin-bottom: 5px; margin-top: 10px;';
const typeText = document.createElement('span');
typeText.style.cssText = 'font-size: 12px; font-weight: 500; color: #606266;';
@@ -534,8 +810,8 @@
expirationContainer.appendChild(expirationLabel);
expirationContainer.appendChild(expirationDate);
// Остаточный срок (показываем справа от даты если меньше 30 дней)
if (daysRemaining >= 0 && daysRemaining < 30) {
// Остаточный срок (показываем справа от даты если недостаточно дней)
if (daysRemaining >= 0 && daysRemaining < daysRemainingControl) {
const warningIcon = document.createElement('i');
warningIcon.className = 'el-icon-warning';
warningIcon.style.cssText = 'font-size: 14px; color: #e6a23c; margin-left: 4px; margin-right: 4px;';
@@ -570,10 +846,88 @@
}
}
// Правая часть футера (кнопки)
// Правая часть футера (выбор способа доставки и кнопки)
const footerRight = document.createElement('div');
footerRight.className = 'dialog-footer';
footerRight.style.cssText = 'display: flex; align-items: center; padding-top: 10px;';
footerRight.style.cssText = 'display: flex; flex-direction: column; align-items: flex-end;';
const deliveryBlock = document.createElement('div');
deliveryBlock.style.cssText = 'margin-bottom: 10px; width: 210px;';
const selectWrapper = document.createElement('div');
selectWrapper.style.cssText = `
position: relative;
border: 1px solid #dcdfe6;
border-radius: 4px;
background: ${canSend ? 'white' : '#f5f7fa'};
transition: all 0.2s;
width: 100%;
opacity: ${canSend ? '1' : '0.6'};
pointer-events: ${canSend ? 'auto' : 'none'};
`;
// Создаем select элемент
const deliverySelect = document.createElement('select');
deliverySelect.style.cssText = `
width: 100%;
height: 25px;
padding: 3px 24px 3px 8px;
border: none;
background: none;
font-size: 12px;
color: ${canSend ? '#606266' : '#c0c4cc'};
outline: none;
cursor: ${canSend ? 'pointer' : 'not-allowed'};
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
`;
const option = document.createElement('option');
option.value = null;
option.textContent = "Способ отправки";
option.selected = true;
option.disabled = true;
deliverySelect.appendChild(option);
// Добавляем опции выбора на основе доступных типов доставки
deliveryType.forEach(type => {
const option = document.createElement('option');
option.value = type;
option.textContent = deliveryTypeLabels[type] || type;
deliverySelect.appendChild(option);
});
// Сохраняем выбранное значение
let selectedDeliveryType = null;
// Обработчик изменения выбора
deliverySelect.addEventListener('change', (e) => {
selectedDeliveryType = e.target.value;
updateSendButtonState();
});
const selectArrow = document.createElement('span');
selectArrow.style.cssText = `
position: absolute;
right: 8px;
top: 50%;
transform: translateY(-50%);
pointer-events: none;
color: ${canSend ? '#c0c4cc' : '#dcdfe6'};
font-size: 12px;
`;
selectArrow.textContent = '▼';
selectWrapper.appendChild(deliverySelect);
selectWrapper.appendChild(selectArrow);
deliveryBlock.appendChild(selectWrapper);
// Блок кнопок
const buttonsBlock = document.createElement('div');
buttonsBlock.className = 'dialog-footer';
buttonsBlock.style.cssText = 'display: flex; align-items: center; gap: 5px;';
// Кнопка "Отмена" - стиль как у кнопки на главной странице
const cancelBtn = document.createElement('button');
@@ -594,10 +948,19 @@
const sendBtn = document.createElement('button');
sendBtn.type = 'button';
if (canSend) {
sendBtn.className = 'el-button m-button el-button--small is-plain send-button button-with-icon';
} else {
sendBtn.className = 'el-button m-button el-button--small is-plain send-button button-with-icon is-disabled';
// Функция обновления состояния кнопки отправки
function updateSendButtonState() {
const canSendWithDelivery = canSend && selectedDeliveryType !== null;
if (canSendWithDelivery) {
sendBtn.className = 'el-button m-button el-button--small is-plain send-button button-with-icon';
sendBtn.disabled = false;
sendBtn.classList.remove('is-disabled');
} else {
sendBtn.className = 'el-button m-button el-button--small is-plain send-button button-with-icon is-disabled';
sendBtn.disabled = true;
sendBtn.classList.add('is-disabled');
}
}
const sendIcon = document.createElement('i');
@@ -610,10 +973,14 @@
sendBtn.appendChild(sendIcon);
sendBtn.appendChild(sendText);
sendBtn.disabled = !canSend;
// Устанавливаем начальное состояние кнопки
updateSendButtonState();
footerRight.appendChild(cancelBtn);
footerRight.appendChild(sendBtn);
buttonsBlock.appendChild(cancelBtn);
buttonsBlock.appendChild(sendBtn);
footerRight.appendChild(deliveryBlock);
footerRight.appendChild(buttonsBlock);
dialogFooter.appendChild(footerLeft);
dialogFooter.appendChild(footerRight);
@@ -630,16 +997,18 @@
// Обработчик отправки
async function handleSend() {
if (!canSend) return;
if (!canSend || selectedDeliveryType === null) return;
closeModal();
// Отправляем документы на подписание
// Отправляем документы на подписание с выбранным типом доставки
try {
const docNumbers = documents.map(doc => parseInt(doc.number, 10));
const result = await sendMessageToContent('sendDocuments', {
docNumbers: docNumbers
docNumbers: docNumbers,
deliveryType: selectedDeliveryType,
recipients: recipients
});
if (result && result.response) {
@@ -664,9 +1033,7 @@
cancelBtn.addEventListener('click', closeModal);
backdrop.addEventListener('click', closeModal);
if (canSend) {
sendBtn.addEventListener('click', handleSend);
}
sendBtn.addEventListener('click', handleSend);
// Закрытие по ESC
const escHandler = (e) => {
@@ -724,7 +1091,6 @@
}
}
// Функция добавления кнопки
function addSendBtn() {
const sendBtn = document.createElement('button');