diff --git a/actions/signActions.js b/actions/signActions.js index ecf097b..bee93fa 100644 --- a/actions/signActions.js +++ b/actions/signActions.js @@ -112,7 +112,7 @@ export const signGetPowerAttorneyClient = ({ contract_number }) => export const signGetWMDoc = (payload) => { - const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document`; + const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/create`; return new Promise((resolve, reject) => { @@ -129,6 +129,30 @@ export const signGetWMDoc = (payload) => console.error("ACTION", "sign", "signGetWMDoc()", "ERROR"); console.error(error); + reject(error.data); + }); + }); +} + +export const signDownloadFile = (payload) => +{ + const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/download`; + + return new Promise((resolve, reject) => + { + axios.post(url, payload, { + withCredentials: true, + }) + .then((response) => + { + console.log("ACTION", "sign", "signDownloadFile()", "response", response.data); + resolve(response.data); + }) + .catch((error) => + { + console.error("ACTION", "sign", "signDownloadFile()", "ERROR"); + console.error(error); + reject(error.data); }); }); diff --git a/components/DealsStatus/SingleDeal.js b/components/DealsStatus/SingleDeal.js index c67bfd9..01fc454 100644 --- a/components/DealsStatus/SingleDeal.js +++ b/components/DealsStatus/SingleDeal.js @@ -107,7 +107,7 @@ class Offers extends Step for(let i in checked) { offers.push({ - quote_numbers: checked[i], + quote_number: checked[i], agreed: true, }); } diff --git a/components/EDOSign/index.js b/components/EDOSign/index.js index 86b0c8f..8809413 100644 --- a/components/EDOSign/index.js +++ b/components/EDOSign/index.js @@ -5,9 +5,10 @@ import { SpinnerCircular } from "spinners-react"; import { concatSeries } from "async"; import { eachSeries } from 'async'; import Select from 'react-select'; +import fileDownload from 'js-file-download'; -import { createEDOProject, signCheckEDOCreatePrintForm, signCheckPowerAttorneyClient, signGetGUIDEntity, signGetPowerAttorneyClient, signGetWMDoc } from "../../actions"; +import { createEDOProject, signCheckEDOCreatePrintForm, signCheckPowerAttorneyClient, signDownloadFile, signGetGUIDEntity, signGetPowerAttorneyClient, signGetWMDoc } from "../../actions"; //import { getDeals, getDealOffers, getDealDocuments, getDealContracts } from "../../actions"; class EDOSign extends React.Component @@ -21,6 +22,7 @@ class EDOSign extends React.Component documents: [], operator_selected: {}, statuses: {}, + step: 0, } } @@ -61,12 +63,10 @@ class EDOSign extends React.Component }); } - _handle_onFormSubmit = (event) => + _sign = () => { - event.preventDefault(); - //const { documents } = this.props; - const { operator_selected } = this.state; + const { operator_selected, step } = this.state; const documents = [ ...this.state.documents ]; console.log("_handle_onFormSubmit"); @@ -177,11 +177,19 @@ class EDOSign extends React.Component contract_number: document.id, edo_box: operator_selected.edo_box, }); - + const get_guid_entity_result = await signGetGUIDEntity({ contract_number: document.id, }); - + + const wmdoc_result = await signGetWMDoc({ + entity_name: "evo_contract", + entity_id: get_guid_entity_result.entityid, + sign_type: "EDO", + evo_id: "144", + }); + console.log({ wmdoc_result }); + await this._updateDocs(document.index, { entity_id: get_guid_entity_result.entityid, completed: true, @@ -202,7 +210,37 @@ class EDOSign extends React.Component { this.setState({ loading: false }); }); - }) + }); + } + + _handle_onFormSubmit = (event) => + { + event.preventDefault(); + + //const { documents } = this.props; + const { operator_selected, step } = this.state; + const documents = [ ...this.state.documents ]; + + console.log("_handle_onFormSubmit"); + console.log({ documents, operator_selected }); + + switch(step) + { + case 0: + { + this.setState({ step: 1 }, () => + { + this._sign(); + }); + } + break; + + case 1: + { + this._sign(); + } + break; + } } _handle_onSelectOperator = (operator) => @@ -216,15 +254,16 @@ class EDOSign extends React.Component this._updateDocs(index, { attorney_selected: attorney }); } - _handle_onDownloadFile = (index, entity_id) => + _handle_onDownloadFile = (index, entity_id, name) => { - console.log("_handle_onDownloadFile", { index, entity_id }) + console.log("_handle_onDownloadFile", { index, entity_id }); this.setState({ loading: true }, async () => { await this._updateDocs(index, { loading: true }); - const wmdoc_result = await signGetWMDoc({ entity_name: "evo_contract", entity_id, sign_type: "EDO" }); + const wmdoc_result = await signDownloadFile({ entity_name: "evo_contract", entity_id, sign_type: "EDO", evo_id: "144", }); console.log({ wmdoc_result }); + fileDownload(wmdoc_result, `ЛК ЭВОЛЮЦИЯ ${ name }.pdf`); await this._updateDocs(index, { loading: false }); }); @@ -241,7 +280,7 @@ class EDOSign extends React.Component render() { - const { operators, documents, loading, operator_selected } = this.state; + const { step, operators, documents, loading, operator_selected } = this.state; const { onCancel, } = this.props; console.log({ operators, documents }); @@ -250,72 +289,7 @@ class EDOSign extends React.Component
Подписание через ЭДО
- { document.name } от { moment(document.date).format("DD.MM.YYYY") } - { document.type !== undefined && ({ document.type }) } -
-