Commit 3b85ee95 authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

компонент РКК документа (_RCC.js) - добавлена проверка подписи

parent 8633bf79
......@@ -228,6 +228,103 @@ const parseChildDocuments = async (childDocuments, parentDocID) => {
return result;
}
const renderKeyInfo = async (eventClick, certID, documentID) => {
const signinfo = await appAPI.testSigns(certID, documentID);
const allInfoCert = JSON.parse(signinfo.allInfoCert);
const content = $('<div>', {class: 'key-info-overlay'});
const dialog = $('<div>', {class: 'key-info-dialog'});
const table = $('<table>', {style: "font-size: small;"});
const tBody = $('<tbody>');
for (const key in allInfoCert) {
if (key != "CERT") {
const keyTd = $("<td align='right' style='margin: 2px; padding: 6px; font-weight: bold'>").text(key.replace(/KEY_/g,""));
const valueTd = $("<td style='padding: 6px'>").text(allInfoCert[key]);
tBody.append($("<tr>").append(keyTd, valueTd));
}
}
content.on('click', e => {
if($(e.target).hasClass('key-info-overlay')) content.remove();
});
content.css({
'position': 'absolute',
'left': '0',
'top': '0',
'width': '100%',
'height': '100vh',
'z-index': '1000'
});
dialog.css({
'position': 'relative',
'left': `${eventClick.clientX + eventClick.offsetX}px`,
'top': `${eventClick.clientY + eventClick.offsetY}px`,
'width': 'max-content',
'max-width': '600px',
'height': 'auto',
'border': '1px solid #C3D9FF',
'background': '#fff'
});
table.append(tBody);
dialog.append(table);
content.append(dialog);
$('body').append(content);
}
const parseSignList = (documentID, data) => {
const result = [];
data.forEach((item, i) => {
const t = [];
let keyExpiryDate = item.keyExpiryDate.split('.');
keyExpiryDate = `${keyExpiryDate[1]}-${keyExpiryDate[0]}-${keyExpiryDate[2]}`;
keyExpiryDate = new Date(keyExpiryDate) > new Date();
const button = $(`<a href="" uk-icon="icon: info"></a>`);
const span = $('<span>', {style: "display: flex; justify-content: space-between;"});
span.append(item.nameOgrInfo, button);
button.on('click', e => {
e.preventDefault();
renderKeyInfo(e, item.certID, documentID);
});
const fieldKeyExpiryDate = $('<span>');
if(keyExpiryDate) {
fieldKeyExpiryDate.text(i18n.tr('Подпись верна'));
fieldKeyExpiryDate.css('color', 'rgb(12, 213, 112)');
} else {
fieldKeyExpiryDate.text(i18n.tr('Публичный ключ устарел'));
fieldKeyExpiryDate.css('color', 'rgb(222, 225, 8)');
}
t.push(item.name);
t.push(item.date);
t.push(span);
t.push(`${item.keyReleaseDate} - ${item.keyExpiryDate}`);
t.push(fieldKeyExpiryDate);
result.push(t);
});
return result;
}
const getSignListTable = (documentID, data) => {
if(!data || !data.length) return null;
const content = $('<div>');
const headers = [i18n.tr('ФИО подписавшего'), i18n.tr('Дата подписи'), i18n.tr('Имя, организация на сертификате'), i18n.tr('Срок действия сертификата'), i18n.tr('Результат проверки')];
const rows = parseSignList(documentID, data);
const {table} = Components.createTable({headers, rows}, ['rcc-table', 'uk-table-small', 'uk-table-responsive']);
content.append(table);
return content;
}
const getDocHistoryTable = data => {
if(!data || !data.length) return null;
const content = $('<div>');
......@@ -365,6 +462,22 @@ this._RCC = class {
});
}
checkEDSSigns(){
const content = getSignListTable(this.documentID, this.signList.formPlayerSigns);
$(content).dialog({
modal: true,
width: 850,
height: 500,
resizable: true,
title: i18n.tr("Проверить ЭЦП"),
show: {effect: 'fade', duration: 500},
hide: {effect: 'fade', duration: 500},
close: function() {
$(this).remove();
}
});
}
async render() {
const rccContainer = $('<div>', {class: 'rcc_container'});
const rccData = $('<div>', {class: 'rcc_data'});
......@@ -411,10 +524,20 @@ this._RCC = class {
// подписи
const signListContent = getSignListContent(this.signList.signs);
if(signListContent) accordionItems.push({
title: i18n.tr("Лист подписей"),
content: signListContent
});
if(signListContent) {
accordionItems.push({
title: i18n.tr("Лист подписей"),
content: signListContent
});
if(this.signList.hasOwnProperty('formPlayerSigns') && this.signList.formPlayerSigns && this.signList.formPlayerSigns.length) {
const checkSignButton = $('<button>', {class: "uk-button uk-button-default uk-button-small"});
checkSignButton.text(i18n.tr('Проверить ЭЦП'));
signListContent.prepend(checkSignButton);
checkSignButton.on('click', e => {
this.checkEDSSigns();
});
}
}
// утверждения
const approvalListContent = getOtherListContent(this.signList.approval);
......@@ -450,18 +573,32 @@ this._RCC = class {
}
async init(){
Cons.showLoader();
this.parentContainer.empty();
try {
this.documentID = this.docInfo.documentID;
this.doctypes = await appAPI.getDoctypes();
this.docRCC = await appAPI.getDocumentRCC(this.documentID);
this.documentHistory = await appAPI.getDocumentHistory(this.documentID); //ход выполнения
this.docChanges = await appAPI.getDocChanges(this.documentID); //Изменения в документе
this.childDocuments = await appAPI.getChildDocuments(this.documentID); // Дочерние документы
this.signList.signs = await appAPI.getSignListXML(this.documentID, -1); // подписи
this.signList.approval = await appAPI.getSignListXML(this.documentID, 1); // утверждения
this.signList.agreement = await appAPI.getSignListXML(this.documentID, 0); // согласования
this.signList.acquaintance = await appAPI.getSignListXML(this.documentID, 2); // ознакомления
if(this.docInfo.asfDataID) {
this.signList.formPlayerSigns = await appAPI.formPlayerGetSigns(this.docInfo.asfDataID, -1); // подписи
}
this.documentID = this.docInfo.documentID;
this.doctypes = await appAPI.getDoctypes();
this.docRCC = await appAPI.getDocumentRCC(this.documentID);
this.documentHistory = await appAPI.getDocumentHistory(this.documentID); //ход выполнения
this.docChanges = await appAPI.getDocChanges(this.documentID); //Изменения в документе
this.signList.signs = await appAPI.getSignListXML(this.documentID, -1); // подписи
this.signList.approval = await appAPI.getSignListXML(this.documentID, 1); // утверждения
this.signList.agreement = await appAPI.getSignListXML(this.documentID, 0); // согласования
this.signList.acquaintance = await appAPI.getSignListXML(this.documentID, 2); // ознакомления
this.childDocuments = await appAPI.getChildDocuments(this.documentID); // Дочерние документы
this.render();
this.render();
Cons.hideLoader();
} catch (err) {
Cons.hideLoader();
console.log('ERROR _RCC: ', err.message);
showMessage(i18n.tr(err.message), 'error');
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment