diff --git a/components/questionnaire/forms/DigitalSignaturesList.js b/components/questionnaire/forms/DigitalSignaturesList.js index 2b41d5c..55ba372 100644 --- a/components/questionnaire/forms/DigitalSignaturesList.js +++ b/components/questionnaire/forms/DigitalSignaturesList.js @@ -76,21 +76,27 @@ export default class DigitalSignaturesList extends React.Component _sign = () => { downloadQuestionnaire(false) - .then(({ filedata, filename }) => + .then(({ file, filename }) => { //let created_at = moment().format('DD-MM-yyyy'); //let filename = `Коммерческое предложение №${this.props.proposal.proposalId} от ${createAt}.docx` - let file = new File([ filedata ], filename); + let file_to_sign = new File([ file ], filename); console.log("this.state", this.state); + console.log("file"); + console.log(file); - generateSignature(file, this.state.certificate_selected.certificate) + console.log("file_to_sign"); + console.log(file_to_sign); + + const now = moment().format("DDMMYYYY_HHmmss"); + generateSignature(file_to_sign, this.state.certificate_selected.certificate) .then(signature => { console.log("signature"); console.log(signature); - fileDownload(signature, `${ filename }.sig`); - fileDownload(filedata, filename); + fileDownload(signature, `${ now }_${ filename }.sig`); + fileDownload(file, `${ now }_${ filename }`); alert("Подписание ЭЦП прошло успешно."); }); }) diff --git a/utils/digital_signature/index.js b/utils/digital_signature/index.js index 06c9c60..8eba6ae 100644 --- a/utils/digital_signature/index.js +++ b/utils/digital_signature/index.js @@ -11,23 +11,30 @@ export function isPluginCryptoProInstalled() { console.log("window.cadesplugin", "AFTER", window.cadesplugin); - window.cadesplugin.async_spawn(function *(args) + if(window.cadesplugin !== undefined) { - try + window.cadesplugin.async_spawn(function *(args) { - yield window.cadesplugin - } - catch (e) - { - console.error("isPluginCryptoProInstalled"); - console.error(e); - - reject({ message: e }) - return; - } - - resolve(); - }); + try + { + yield window.cadesplugin + } + catch (e) + { + console.error("isPluginCryptoProInstalled"); + console.error(e); + + reject({ message: e }) + return; + } + + resolve(); + }); + } + else + { + reject(); + } }, 500); }); }