Last active
May 18, 2021 11:11
-
-
Save daniilgrigoryev/6a5f7b91263ed58855c0acde093b29f3 to your computer and use it in GitHub Desktop.
main.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.documents = { | |
| file_storage: [], | |
| file_managed: [ | |
| "47642988", | |
| "47642987", | |
| "47642989", | |
| "47643069", | |
| "47643070", | |
| "47643068", | |
| "47643072", | |
| "47643014", | |
| "47643016", | |
| "47643015", | |
| "47642986", | |
| "47642936", | |
| "47643011", | |
| "47642985", | |
| "17819751", | |
| "47642937", | |
| "47642940", | |
| "47642983", | |
| "47642984", | |
| "17819750", | |
| "47642939", | |
| "47643017", | |
| "47643066", | |
| "47643067", | |
| "47643065", | |
| "47643021", | |
| "47643022", | |
| "47643024", | |
| "47643023", | |
| "47643025", | |
| "47643026", | |
| "47643027", | |
| "47643012", | |
| "47643013", | |
| ], | |
| }; | |
| async getFileBase(fileSystem, fileID) { | |
| return await $axios | |
| .get(`/api/v2/application/doc-for-sign/${fileSystem}/${fileID}`) | |
| .then((response) => response.data) | |
| .catch(() => { | |
| throw new Error('Возникла проблема при запросе файла для подписи') | |
| }) | |
| } | |
| async getSig(fileSystem, fileID) { | |
| try { | |
| const fileBase = await this.getFileBase(fileSystem, fileID) | |
| console.log(fileBase) | |
| } catch (error) { | |
| throw new Error(error) | |
| } | |
| } | |
| async signFiles() { | |
| try { | |
| await this.initCryptoThumbprint() | |
| let toFlatArrayDocIDS = Object.entries(this.documents) | |
| .map( | |
| ([fileSystem, files]) => | |
| !!files.length && | |
| files.map((fileID) => { | |
| return { | |
| fileSystem, | |
| fileID | |
| } | |
| }) | |
| ) | |
| .filter((item) => item !== false) | |
| .flat() | |
| let promisesArray = toFlatArrayDocIDS.map((item) => { | |
| return this.getSig(item.fileSystem, item.fileID) | |
| }) | |
| let handleAllPromises = await Promise.all(promisesArray) | |
| handleAllPromises.catch((reason) => { | |
| console.log('One of the promises failed with the following reason', reason) | |
| }) | |
| } catch (error) { | |
| let errorMessage = error.message || `Возникла проблема во время подписания документов` | |
| this.$emit('dialog', false) | |
| this.pushSnackbar(true, 'red', errorMessage) | |
| throw new Error(errorMessage) | |
| } | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment