From 0f20d0d952536a6080137f0e1754da3fe99b77a2 Mon Sep 17 00:00:00 2001 From: merelendor Date: Thu, 26 Oct 2023 17:39:29 +0300 Subject: [PATCH] deal files update, EDO sign on additional --- actions/dealsActions.js | 7 +- actions/edoActions.js | 4 +- actions/signActions.js | 24 +- .../components/DealContractsSignEDO.js | 1 + .../components/DealContractsSignPaper.js | 1 + .../DealsStatus/components/DocumentsForm.js | 39 +- components/EDOSign/index.js | 1 + css/main/style.css | 6 +- css/main/style.less | 7 +- pages/api/contract/sign/attorney/check.js | 4 +- pages/api/contract/sign/attorney/get.js | 4 +- pages/api/contract/sign/cancel/check.js | 3 +- pages/api/contract/sign/cancel/index.js | 3 +- pages/api/contract/sign/check.js | 5 +- pages/api/contract/sign/document/check.js | 5 +- pages/api/contract/sign/document/connect.js | 5 +- pages/api/contract/sign/document/create.js | 4 +- pages/api/contract/sign/document/link.js | 5 +- pages/api/contract/sign/document/status.js | 5 +- pages/api/contract/sign/entity.js | 5 +- pages/api/deals/file/attach.js | 28 +- pages/api/deals/file/remove.js | 12 +- pages/api/deals/upload.js | 14 +- pages/api/edo/cancel.js | 3 +- pages/api/edo/project.js | 3 +- pages/contract/agreement.js | 4 +- .../Comparison/components/SignEDO/index.js | 426 ++++++++++++++++ .../change/components/Comparison/index.js | 97 ++-- pages/contract/change/index.js | 13 +- pages/contract/compare.js | 474 ------------------ 30 files changed, 608 insertions(+), 604 deletions(-) create mode 100644 pages/contract/change/components/Comparison/components/SignEDO/index.js delete mode 100644 pages/contract/compare.js diff --git a/actions/dealsActions.js b/actions/dealsActions.js index 7e55989..ed862f2 100644 --- a/actions/dealsActions.js +++ b/actions/dealsActions.js @@ -295,7 +295,7 @@ export const getDealContracts = ({ dispatch, deal_id }) => }); } -export const attachDealDocument = ({ deal_id, document_id, document_name, index, lastModified, filename, file, type }) => +export const attachDealDocument = ({ deal_id, document_id, document_name, group, index, lastModified, filename, file, type }) => { return new Promise((resolve, reject) => { @@ -306,6 +306,7 @@ export const attachDealDocument = ({ deal_id, document_id, document_name, index, deal_id, document_id, document_name, + group, filename, index, lastModified, @@ -333,13 +334,13 @@ export const attachDealDocument = ({ deal_id, document_id, document_name, index, }); } -export const removeDealDocument = ({ deal_id, document_id, index, }) => +export const removeDealDocument = ({ deal_id, group, index, }) => { return new Promise((resolve, reject) => { const payload = new URLSearchParams({ deal_id, - document_id, + group, index, }); diff --git a/actions/edoActions.js b/actions/edoActions.js index 6719cb6..27435d4 100644 --- a/actions/edoActions.js +++ b/actions/edoActions.js @@ -199,7 +199,7 @@ export const docEDOSign = (payload) => }); } -export const docEDOCancel = ({ contract_number, doc_type_id, }) => +export const docEDOCancel = (payload) => { const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/cancel`; @@ -207,7 +207,7 @@ export const docEDOCancel = ({ contract_number, doc_type_id, }) => return new Promise((resolve, reject) => { - axios.post(url, { contract_number, doc_type_id, }, { + axios.post(url, payload, { withCredentials: true, }) .then((response) => diff --git a/actions/signActions.js b/actions/signActions.js index 8bf4d25..d40900a 100644 --- a/actions/signActions.js +++ b/actions/signActions.js @@ -9,7 +9,7 @@ import fileDownload from 'js-file-download'; import * as actionTypes from '../constants/actionTypes'; import * as currentState from '../reducers/initialState'; -export const signCheckCreatePrintForm = ({ contract_number, sign_type }) => +export const signCheckCreatePrintForm = (payload) => { const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/check`; @@ -17,7 +17,7 @@ export const signCheckCreatePrintForm = ({ contract_number, sign_type }) => return new Promise((resolve, reject) => { - axios.post(url, { contract_number, sign_type }, { + axios.post(url, payload, { withCredentials: true, }) .then((response) => @@ -36,7 +36,7 @@ export const signCheckCreatePrintForm = ({ contract_number, sign_type }) => }); } -export const signGetGUIDEntity = ({ contract_number }) => +export const signGetGUIDEntity = (payload) => { const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/entity`; @@ -44,7 +44,7 @@ export const signGetGUIDEntity = ({ contract_number }) => return new Promise((resolve, reject) => { - axios.post(url, { contract_number }, { + axios.post(url, payload, { withCredentials: true, }) .then((response) => @@ -63,13 +63,13 @@ export const signGetGUIDEntity = ({ contract_number }) => }); } -export const signCheckPowerAttorneyClient = ({ contract_number }) => +export const signCheckPowerAttorneyClient = (payload) => { const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/attorney/check`; return new Promise((resolve, reject) => { - axios.post(url, { contract_number }, { + axios.post(url, payload, { withCredentials: true, }) .then((response) => @@ -87,13 +87,13 @@ export const signCheckPowerAttorneyClient = ({ contract_number }) => }); } -export const signGetPowerAttorneyClient = ({ contract_number }) => +export const signGetPowerAttorneyClient = (payload) => { const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/attorney/get`; return new Promise((resolve, reject) => { - axios.post(url, { contract_number }, { + axios.post(url, payload, { withCredentials: true, }) .then((response) => @@ -251,7 +251,7 @@ export const signUploadPaperDocument = (contract_number, deal_id, files) => }); } -export const signCheckCancelDocument = ({ contract_number, doc_type_id }) => +export const signCheckCancelDocument = (payload) => { const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/cancel/check`; @@ -259,7 +259,7 @@ export const signCheckCancelDocument = ({ contract_number, doc_type_id }) => return new Promise((resolve, reject) => { - axios.post(url, { contract_number, doc_type_id }, { + axios.post(url, payload, { withCredentials: true, }) .then((response) => @@ -278,7 +278,7 @@ export const signCheckCancelDocument = ({ contract_number, doc_type_id }) => }); } -export const signCancelDocument = ({ contract_number, doc_type_id }) => +export const signCancelDocument = (payload) => { const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/cancel`; @@ -286,7 +286,7 @@ export const signCancelDocument = ({ contract_number, doc_type_id }) => return new Promise((resolve, reject) => { - axios.post(url, { contract_number, doc_type_id }, { + axios.post(url, payload, { withCredentials: true, }) .then((response) => diff --git a/components/DealsStatus/components/DealContractsSignEDO.js b/components/DealsStatus/components/DealContractsSignEDO.js index b85932f..6c08989 100644 --- a/components/DealsStatus/components/DealContractsSignEDO.js +++ b/components/DealsStatus/components/DealContractsSignEDO.js @@ -158,6 +158,7 @@ class DealContractsSignEDO extends React.Component entity_id: get_guid_entity_result.entityid, sign_type: "EDO", evo_id: "144", + code: "Leas_Contract", }); console.log({ wmdoc_result }); diff --git a/components/DealsStatus/components/DealContractsSignPaper.js b/components/DealsStatus/components/DealContractsSignPaper.js index 9bf5026..19c1337 100644 --- a/components/DealsStatus/components/DealContractsSignPaper.js +++ b/components/DealsStatus/components/DealContractsSignPaper.js @@ -139,6 +139,7 @@ export default class DealContractsSignPaper extends React.Component entity_id: get_guid_entity_result.entityid, sign_type: "Paper", evo_id: "60", + code: "Leas_Contract", }); console.log({ wmdoc_result }); diff --git a/components/DealsStatus/components/DocumentsForm.js b/components/DealsStatus/components/DocumentsForm.js index 9941304..c792201 100644 --- a/components/DealsStatus/components/DocumentsForm.js +++ b/components/DealsStatus/components/DocumentsForm.js @@ -7,6 +7,7 @@ import FileDropzoneDeals from "../../FileDropzoneDeals"; import { attachDealDocument, removeDealDocument, sendDealDocuments, } from "../../../actions"; import Step from "./Step"; +import md5 from "md5"; export default class DocumentsForm extends Step { @@ -99,16 +100,17 @@ export default class DocumentsForm extends Step console.log({ document_id, document_name, files, update }); console.log("_handle_onAddFile", { existed_files }); - const document_files = existed_files[ document_id ] === undefined ? [] : existed_files[ document_id ].files; + const group = md5(`${ document_id }_${ document_name }`); + const document_files = existed_files[ group ] === undefined ? [] : existed_files[ group ].files; - if(existed_files[ document_id ] === undefined) + if(existed_files[ group ] === undefined) { - existed_files[ document_id ] = { + existed_files[ group ] = { files: [], }; } - let index = parseInt(existed_files[ document_id ].files.length, 10); + let index = parseInt(existed_files[ group ].files.length, 10); for(let nf in files) { @@ -126,7 +128,8 @@ export default class DocumentsForm extends Step // console.log({ new_index }); // files[nf].index = new_index; - files[nf].group = document_id; + files[nf].document_id = document_id; + files[nf].group = group; files[nf].group_name = document_name; files[nf].uploaded = false; files[nf].update = update; @@ -134,11 +137,12 @@ export default class DocumentsForm extends Step document_files.push(files[nf]); //} - existed_files[ document_id ].files = document_files; + existed_files[ group ].files = document_files; } this.setState({ uploaded: existed_files, uploading: true }, () => { + console.log({ existed_files }); const { opp_number } = this.props; console.log("DOUBLE", { files }); @@ -147,7 +151,8 @@ export default class DocumentsForm extends Step { const payload = { deal_id: opp_number, - document_id: file.group, + document_id: file.document_id, + group: file.group, document_name: file.group_name, filename: file.name, lastModified: file.lastModified, @@ -160,7 +165,7 @@ export default class DocumentsForm extends Step attachDealDocument(payload) .then(async () => { - await this._onSendFileStats(document_id, index); + await this._onSendFileStats(group, index); index++; callback(); }, 1000) @@ -172,15 +177,15 @@ export default class DocumentsForm extends Step }); } - _handle_onDeleteFile = (document_id, index) => + _handle_onDeleteFile = (group, index) => { const uploaded = { ...this.state.uploaded }; const { opp_number } = this.props; - const list = [ ...uploaded[document_id].files ]; + const list = [ ...uploaded[group].files ]; list.splice(index, 1); - uploaded[document_id].files = list; + uploaded[group].files = list; /* for(let i in uploaded[document_id].files) @@ -208,7 +213,7 @@ export default class DocumentsForm extends Step const completed = this._checkFilesCompleted(); this.setState({ completed }, () => { - removeDealDocument({ deal_id: opp_number, document_id, index }); + removeDealDocument({ deal_id: opp_number, group, index }); }); }); } @@ -240,8 +245,8 @@ export default class DocumentsForm extends Step continue; } - const group = documents[g].doc_id; - console.log({ g: documents[g] }); + const group = md5(`${ documents[g].doc_id }_${ documents[g].name }`); + console.log({ g: documents[g], group }); if(uploaded[group] === undefined || uploaded[group].files.length === 0) { @@ -336,9 +341,9 @@ export default class DocumentsForm extends Step <> ) : ( <> - { documents.map((document, index) => - { + { documents.map((document, index) => { console.log({ document }); + const group = md5(`${ document.doc_id }_${ document.name }`); return (
@@ -349,7 +354,7 @@ export default class DocumentsForm extends Step { this._handle_onAddFile({ document_id: document.doc_id, document_name: document.name, files, update }) } } onDeleteFile={ this._handle_onDeleteFile } document={ document } diff --git a/components/EDOSign/index.js b/components/EDOSign/index.js index 57f7356..c06eeb9 100644 --- a/components/EDOSign/index.js +++ b/components/EDOSign/index.js @@ -159,6 +159,7 @@ class EDOSign extends React.Component entity_id: get_guid_entity_result.entityid, sign_type: "EDO", evo_id: "144", + code: "Leas_Contract", }); console.log({ wmdoc_result }); diff --git a/css/main/style.css b/css/main/style.css index c2821ae..c1c0684 100644 --- a/css/main/style.css +++ b/css/main/style.css @@ -6016,6 +6016,7 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_ .contractStatus_modal .single_status > div .status_body .wrap .single_text p { margin-right: 0; padding-top: 0; + line-height: 15px; } } .contractStatus_modal .single_status > div .status_body .wrap .single_text p:before { @@ -6031,7 +6032,7 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_ } @media all and (max-width: 768px) { .contractStatus_modal .single_status > div .status_body .wrap .single_text p:before { - margin-top: 0; + margin-top: -13px; } } .contractStatus_modal .single_status > div .status_body .wrap table { @@ -6761,6 +6762,9 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_ width: 186px; margin-right: 12px; } +.edo_list_field label.wide { + width: 30%; +} .edo_list_selection { flex: 1; margin-top: -12px; diff --git a/css/main/style.less b/css/main/style.less index 0c5810c..8db9c97 100644 --- a/css/main/style.less +++ b/css/main/style.less @@ -6822,6 +6822,7 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { @media all and (max-width: 768px) { margin-right: 0; padding-top: 0; + line-height: 15px; } &:before { @@ -6837,7 +6838,7 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='40' height='40' rx='8' fill='%232F80ED' fill-opacity='0.1'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M20 29C24.9706 29 29 24.9706 29 20C29 15.0294 24.9706 11 20 11C15.0294 11 11 15.0294 11 20C11 24.9706 15.0294 29 20 29ZM21 14.5C21 13.9477 20.5523 13.5 20 13.5C19.4477 13.5 19 13.9477 19 14.5V19.75C19 20.4404 19.5596 21 20.25 21H23.5C24.0523 21 24.5 20.5523 24.5 20C24.5 19.4477 24.0523 19 23.5 19H21V14.5Z' fill='%232F80ED'/%3E%3C/svg%3E"); @media all and (max-width: 768px) { - margin-top: 0; + margin-top: -13px; } } } @@ -7723,6 +7724,10 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { label { width: 186px; margin-right: 12px; + + &.wide { + width: 30%; + } } } diff --git a/pages/api/contract/sign/attorney/check.js b/pages/api/contract/sign/attorney/check.js index fc137c0..b052b94 100644 --- a/pages/api/contract/sign/attorney/check.js +++ b/pages/api/contract/sign/attorney/check.js @@ -4,9 +4,11 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/attorney/check"); - const { contract_number } = req.body; + const { contract_number, addcontract_number, contactid, } = req.body; const payload = { contract_number, + addcontract_number, + contactid, }; await CRMRequestGet({ req, res, diff --git a/pages/api/contract/sign/attorney/get.js b/pages/api/contract/sign/attorney/get.js index bb699e2..b6ea7f3 100644 --- a/pages/api/contract/sign/attorney/get.js +++ b/pages/api/contract/sign/attorney/get.js @@ -4,9 +4,11 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/attorney/get"); - const { contract_number } = req.body; + const { contract_number, addcontract_number, contactid, } = req.body; const payload = { contract_number, + addcontract_number, + contactid, }; await CRMRequestGet({ req, res, diff --git a/pages/api/contract/sign/cancel/check.js b/pages/api/contract/sign/cancel/check.js index c7dc921..fe769a4 100644 --- a/pages/api/contract/sign/cancel/check.js +++ b/pages/api/contract/sign/cancel/check.js @@ -4,9 +4,10 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/cancel/check"); - const { contract_number, doc_type_id } = req.body; + const { contract_number, addcontract_number, doc_type_id } = req.body; const payload = { contract_number, + addcontract_number, doc_type_id, }; diff --git a/pages/api/contract/sign/cancel/index.js b/pages/api/contract/sign/cancel/index.js index c1a2756..0c0593d 100644 --- a/pages/api/contract/sign/cancel/index.js +++ b/pages/api/contract/sign/cancel/index.js @@ -4,9 +4,10 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/cancel"); - const { contract_number, doc_type_id } = req.body; + const { contract_number, addcontract_number, doc_type_id } = req.body; const payload = { contract_number, + addcontract_number, doc_type_id, }; diff --git a/pages/api/contract/sign/check.js b/pages/api/contract/sign/check.js index 738e3e0..6607325 100644 --- a/pages/api/contract/sign/check.js +++ b/pages/api/contract/sign/check.js @@ -4,10 +4,11 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/check"); - const { contract_number, sign_type } = req.body; + const { contract_number, addcontract_number, sign_type } = req.body; const payload = { contract_number, - sign_type + addcontract_number, + sign_type, }; await CRMRequestGet({ req, res, diff --git a/pages/api/contract/sign/document/check.js b/pages/api/contract/sign/document/check.js index c9a6bde..65b97fb 100644 --- a/pages/api/contract/sign/document/check.js +++ b/pages/api/contract/sign/document/check.js @@ -4,9 +4,10 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/document/check"); - const { contract_number } = req.body; + const { contract_number, addcontract_number } = req.body; const payload = { - contract_number + contract_number, + addcontract_number, }; console.log({ payload }); diff --git a/pages/api/contract/sign/document/connect.js b/pages/api/contract/sign/document/connect.js index 178e477..6c934ac 100644 --- a/pages/api/contract/sign/document/connect.js +++ b/pages/api/contract/sign/document/connect.js @@ -4,9 +4,10 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/document/connect"); - const { contract_number } = req.body; + const { contract_number, addcontract_number, } = req.body; const payload = { - contract_number + contract_number, + addcontract_number, }; console.log({ payload }); diff --git a/pages/api/contract/sign/document/create.js b/pages/api/contract/sign/document/create.js index 14d7055..b13be1c 100644 --- a/pages/api/contract/sign/document/create.js +++ b/pages/api/contract/sign/document/create.js @@ -4,11 +4,11 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/document/create"); - const { entity_name, entity_id, sign_type, evo_id } = req.body; + const { entity_name, entity_id, sign_type, evo_id, code } = req.body; const payload = { entityName: entity_name, entityId: entity_id, - reportCodes: [ "Leas_Contract" ], + reportCodes: [ code ], inputParameters: [ sign_type ], createDocument: true, openFile: false, diff --git a/pages/api/contract/sign/document/link.js b/pages/api/contract/sign/document/link.js index c63da55..0c09f7d 100644 --- a/pages/api/contract/sign/document/link.js +++ b/pages/api/contract/sign/document/link.js @@ -4,9 +4,10 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/document/link"); - const { contract_number } = req.body; + const { contract_number, addcontract_number, } = req.body; const payload = { - contract_number + contract_number, + addcontract_number, }; console.log({ payload }); diff --git a/pages/api/contract/sign/document/status.js b/pages/api/contract/sign/document/status.js index be1f12d..e26cbcd 100644 --- a/pages/api/contract/sign/document/status.js +++ b/pages/api/contract/sign/document/status.js @@ -4,9 +4,10 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/document/status"); - const { contract_number } = req.body; + const { contract_number, addcontract_number, } = req.body; const payload = { - contract_number + contract_number, + addcontract_number, }; console.log({ payload }); diff --git a/pages/api/contract/sign/entity.js b/pages/api/contract/sign/entity.js index b30c84f..3051f81 100644 --- a/pages/api/contract/sign/entity.js +++ b/pages/api/contract/sign/entity.js @@ -4,9 +4,10 @@ export default async function handler(req, res) { console.log("\n\n", "API", "SIGN", "/entity"); - const { contract_number } = req.body; + const { contract_number, addcontract_number, } = req.body; const payload = { - contract_number + contract_number, + addcontract_number, }; await CRMRequestGet({ req, res, diff --git a/pages/api/deals/file/attach.js b/pages/api/deals/file/attach.js index cd29de9..fe6c447 100644 --- a/pages/api/deals/file/attach.js +++ b/pages/api/deals/file/attach.js @@ -34,16 +34,17 @@ export default async function handler(req, res) upload.single("file")(req, {}, async (err) => { const { file, } = req; - const { deal_id, document_id, document_name, type, index, lastModified, } = req.query; + const { deal_id, document_id, document_name, group, type, index, lastModified, } = req.query; - console.log({ deal_id, document_id, document_name, type, index, lastModified, }); + console.log({ deal_id, document_id, document_name, group, type, index, lastModified, }); - const local_filename = `${ client_jwt_decoded.acc_number }_${ deal_id }_${ document_id }_${ index }`; + const local_filename = `${ client_jwt_decoded.acc_number }_${ deal_id }_${ group }_${ index }`; const file_payload = { name: Buffer.from(file.originalname, 'latin1').toString('utf8'), filename: local_filename, - group: document_id, + document_id: document_id, + group, index, type, uploaded: true, @@ -78,31 +79,20 @@ export default async function handler(req, res) if(uploaded !== undefined) { - if(uploaded[ document_id ] !== undefined) + if(uploaded[ group ] !== undefined) { - uploaded[ document_id ].files.push(file_payload); + uploaded[ group ].files.push(file_payload); } else { - uploaded[ document_id ] = { + uploaded[ group ] = { + id: document_id, name: document_name, files: [ file_payload ], } } } - /* - if(files[ document_id ] !== undefined) - { - files[ document_id ].push(file_payload); - } - else - { - files[ document_id ] = [ file_payload ]; - } - */ - - //files[ document_id ] = [ file_payload ]; deals[ deal_id ] = { uploaded }; await RedisClient.set(key, JSON.stringify(deals)); diff --git a/pages/api/deals/file/remove.js b/pages/api/deals/file/remove.js index 84aaa59..2f4ff27 100644 --- a/pages/api/deals/file/remove.js +++ b/pages/api/deals/file/remove.js @@ -31,8 +31,8 @@ export default async function handler(req, res) { var client_jwt_decoded = jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT); - const { deal_id, document_id, index } = req.query; - const local_filename = `${ client_jwt_decoded.acc_number }_${ deal_id }_${ document_id }_${ index }`; + const { deal_id, group, index } = req.query; + const local_filename = `${ client_jwt_decoded.acc_number }_${ deal_id }_${ group }_${ index }`; try { @@ -66,13 +66,13 @@ export default async function handler(req, res) if(uploaded !== undefined) { - if(uploaded[ document_id ] !== undefined) + if(uploaded[ group ] !== undefined) { - if(uploaded[ document_id ].files !== undefined) + if(uploaded[ group ].files !== undefined) { - console.log({ files: uploaded[ document_id ].files }); + console.log({ files: uploaded[ group ].files }); - uploaded[ document_id ].files.splice(index, 1); + uploaded[ group ].files.splice(index, 1); } } } diff --git a/pages/api/deals/upload.js b/pages/api/deals/upload.js index 3e5419a..7bbfbf1 100644 --- a/pages/api/deals/upload.js +++ b/pages/api/deals/upload.js @@ -70,24 +70,24 @@ function createZipFile(zip_filename, files) }); } -function uploadFile({ deal_id, filename, name, group, crm_jwt }) +function uploadFile({ deal_id, local_filename, filename, name, id, crm_jwt }) { return new Promise((resolve) => { - if(fs.existsSync(`${ uploads }${ filename }`)) + if(fs.existsSync(`${ uploads }${ local_filename }`)) { - const path = `${ uploads }${ filename }`; + const path = `${ uploads }${ local_filename }`; const file_to_send_data = fs.readFileSync(path); console.log("uploadFile", { filename, len: file_to_send_data.length, path }); const data = new FormData(); - data.append("file", file_to_send_data, name); + data.append("file", file_to_send_data, filename); const payload = new URLSearchParams({ name: deal_id, entity: "opportunity", - documentTypeNumber: group, + documentTypeNumber: id, documentName: name, }); @@ -170,7 +170,7 @@ export default async function handler(req, res) { const file = document.files[0]; - uploadFile({ deal_id, filename: file.filename, name: document.name, group, crm_jwt }) + uploadFile({ deal_id, local_filename: file.filename, filename: file.name, name: document.name, id: document.id, crm_jwt }) .then(() => { callback(); @@ -198,7 +198,7 @@ export default async function handler(req, res) createZipFile(`${ uploads }${ zip_filename }`, files_to_zip) .then(() => { - uploadFile({ deal_id, filename: zip_filename, name: zip_filename, group, crm_jwt }) + uploadFile({ deal_id, local_filename: zip_filename, filename: zip_filename, name: document.name, id: document.id, crm_jwt }) .then(() => { callback(); diff --git a/pages/api/edo/cancel.js b/pages/api/edo/cancel.js index 6455387..6396d17 100644 --- a/pages/api/edo/cancel.js +++ b/pages/api/edo/cancel.js @@ -7,9 +7,10 @@ export default async function handler(req, res) { console.log("\n\n", "API", "EDO", "/cancel"); - const { contract_number, doc_type_id, } = req.body; + const { contract_number, addcontract_number, doc_type_id, } = req.body; const payload = { contract_number, + addcontract_number, doc_type_id, }; diff --git a/pages/api/edo/project.js b/pages/api/edo/project.js index 92dfd38..f3cf779 100644 --- a/pages/api/edo/project.js +++ b/pages/api/edo/project.js @@ -4,9 +4,10 @@ export default async function handler(req, res) { console.log("\n\n", "API", "EDO", "/project"); - const { contract_number, power_attorney, power_attorney_number, edo_box, } = req.body; + const { contract_number, addcontract_number, power_attorney, power_attorney_number, edo_box, } = req.body; const payload = { contract_number, + addcontract_number, power_attorney, power_attorney_number, edo_box, diff --git a/pages/contract/agreement.js b/pages/contract/agreement.js index d989ab0..ced0dac 100644 --- a/pages/contract/agreement.js +++ b/pages/contract/agreement.js @@ -126,9 +126,9 @@ class ContractPage extends React.Component { file.type !== undefined && ({ file.type }) }

- {/**/} + {/* this._handle_onEDOClick({ ...file, ...{ name: types[ type ] } }) }>Подписать по ЭДО - {/**/} + */} + { + this.setState({ loading: false }) + }, 5000); + */ + } + + _update = (update) => + { + return new Promise((resolve) => + { + this.setState(update, () => + { + resolve(); + }); + }); + } + + _sign = async () => + { + const { calculation_id, contract_number, signer, onFinished } = this.props; + const { operator_selected, error, step, completed, signing, ready, attorney, attorney_selected, } = this.state; + + console.log("_handle_onFormSubmit"); + console.log({ operator_selected }); + + await this._update({ loading: true, disabled: true, }); + + if(!error) + { + if(attorney && attorney_selected !== undefined) + { + this._finalizeSign({ + power_attorney: attorney_selected.value, + power_attorney_number: attorney_selected.label, + }); + } + else + { + const create_print_form_result = await signCheckCreatePrintForm({ addcontract_number: calculation_id, sign_type: "EDO" }); + console.log({ create_print_form_result }); + + if(create_print_form_result.status === "success") + { + const get_guid_entity_result = await signGetGUIDEntity({ + addcontract_number: calculation_id, + }); + + console.log("\n\nENTITY !!!!!!!!!!\n\n"); + console.log({ get_guid_entity_result }); + + const graphic_change_comment = await signContractGraphicChange({ + contract_number: contract_number, + addcontract_number: calculation_id, + signatoryid: signer.signatoryid, + type: 1, + }); + + await signCancelDocument({ addcontract_number: calculation_id, doc_type_id: "64" }); + + await this._update({ graphic_change_comment, entity_id: get_guid_entity_result.entityid }); + + const check_attorney_client_result = await signCheckPowerAttorneyClient({ addcontract_number: calculation_id, contactid: signer.signatoryid, }) + console.log({ check_attorney_client_result }); + + await this._update({ attorney: check_attorney_client_result.power_attorney_required, }); + + if(check_attorney_client_result.power_attorney_required) + { + const get_attorney_client_result = await signGetPowerAttorneyClient({ addcontract_number: calculation_id, contactid: signer.signatoryid, }); + console.log({ get_attorney_client_result }); + + if(get_attorney_client_result === null) + { + await this._update({ loading: false, disabled: false, error: true, ready: false, message: "Возникла ошибка при создании документа для подписания." }); + } + else + { + if(get_attorney_client_result.length === null) + { + await this._update({ loading: false, disabled: false, error: true, ready: false, message: "Не обнаружена доверенность на подписанта. Для продолжения подписания обратитесь к своему персональному менеджеру" }); + } + else + { + const attorneys = []; + for(let i in get_attorney_client_result) + { + attorneys.push({ + value: get_attorney_client_result[i].power_attorney, + label: get_attorney_client_result[i].power_attorney_number, + }); + } + + await this._update({ loading: false, disabled: true, error: false, attorneys, attorney_selected: undefined }); + } + } + } + else + { + this._finalizeSign({}); + } + } + else + { + this.setState({ + loading: false, + error: true, + disabled: false, + message: create_print_form_result.message !== undefined && create_print_form_result.message !== null ? create_print_form_result.message : "Возникла ошибка при создании документа для подписания.", + }); + } + } + } + } + + _finalizeSign = async (attorney) => + { + await this._update({ ready: true, }); + + const { calculation_id, onFinished } = this.props; + const { operator_selected, } = this.state; + + const create_edo_project_result = await createEDOProject({ ...{ + addcontract_number: calculation_id, + edo_box: operator_selected.edo_box, + }, ...attorney }); + + if(create_edo_project_result.edoid !== undefined) + { + await this._update({ edoid: create_edo_project_result.edoid, }); + + const get_guid_entity_result = await signGetGUIDEntity({ + addcontract_number: calculation_id, + }); + + const wmdoc_result = await signGetWMDoc({ + entity_name: "evo_addcontract", + entity_id: get_guid_entity_result.entityid, + sign_type: "EDO", + evo_id: "156", + code: "AddcontractSale", + }); + + const connect_result = await docEDOConnect({ addcontract_number: calculation_id }); + const sign_result = await docEDOSign({ edoid: this.state.edoid, }); + + onFinished(this.state.graphic_change_comment); + } + else + { + this.setState({ + loading: false, + error: true, + disabled: false, + message: create_edo_project_result.message !== undefined && create_edo_project_result.message !== null ? create_edo_project_result.message : "Возникла ошибка при создании документа для подписания.", + }); + } + } + + _handle_onFormSubmit = (event) => + { + event.preventDefault(); + + const { onFinish, onCancel, onGoToEDOInvites } = this.props; + const { operators, operator_selected, step, finished, error } = this.state; + + console.log("_handle_onFormSubmit"); + console.log({ operator_selected }); + + if(operators !== null && operators.length === 0) + { + onGoToEDOInvites(); + } + else + { + if(error) + { + onCancel(); + } + else + { + if(finished) + { + onFinish(); + } + else + { + switch(step) + { + case 0: + { + this.setState({ step: 1 }, () => + { + this._sign(); + }); + } + break; + + case 1: + { + this._sign(); + } + break; + } + } + } + } + } + + _handle_onSelectOperator = (operator) => + { + this.setState({ operator_selected: operator }); + } + + _handle_onAttorneyChange = (attorney) => + { + console.log("_handle_onAttorneyChange", { attorney }); + this.setState({ attorney_selected: attorney, disabled: false, }); + } + + _handle_onCancel = () => + { + const { onCancel } = this.props; + onCancel(); + } + + render() + { + const { step, operators, edo_message, loading, disabled, operator_selected } = this.state; + const { error, message, ready, attorney, attorneys, attorney_selected, } = this.state; + + const { onCancel, calculation_id, } = this.props; + console.log({ operators, props: this.props }); + + return ( +
+
+

Подписание через ЭДО

+
+ <> + { step === 0 && ( +
+ +
+ { operators !== undefined && operators !== null && ( + <> + { operators.length === 0 ? ( +
+
+
+ { edo_message } +
+
+ ) : ( + operators.map((operator, index) => ( +
+ this._handle_onSelectOperator(operator) } + disabled={ false } + /> + +
+ ) ) + )} + + ) } +
+
+ ) } + { step === 1 && ( +
+
+
+

+ Дополнительное соглашение №{ calculation_id } от { moment().format("DD.MM.YYYY") } +

+
+
+ { loading ? ( + <> + + { !error && ( + { ready ? "Подписание дополнительного соглашения" : "Подготовка подписания" } + ) } + + ) : ( + <> + { error ? ( + <> +
+ { message !== undefined && message !== null ? message : "" } + + ) : ( + <> + { attorney && ( + <> +
+
+ this._handle_onSigner(person.signatoryid) }/> - - -
-

{ `${ person.lastname } ${ person.firstname } ${ person.middlename }` }

-

{ person.jobtitle }

-
+ { sign_edo ? ( + this.setState({ sign_edo: false }) } + onFinished={ this.props.onSignEDOFinished } + /> + ) : ( + <> +
+

+ Подписанты + { signatories !== undefined && signatories !== null && signatories.length > 3 && ( + { this.setState({ signatories_show_all: true })}}>Все + )} +

+
+ { signatories !== undefined && signatories !== null && signatories.slice(0, signatories_show_all ? signatories.length : 3).map((person, index) => ( +
+ this._handle_onSigner(person) }/> + + +
+

{ `${ person.lastname } ${ person.firstname } ${ person.middlename }` }

+

{ person.jobtitle }

+
+
+ )) }
- )) } -
-
-
- - {/*} - - {*/} -
+
+
+ + +
+ + ) } ); } diff --git a/pages/contract/change/index.js b/pages/contract/change/index.js index 297ad81..14b6c26 100644 --- a/pages/contract/change/index.js +++ b/pages/contract/change/index.js @@ -29,7 +29,8 @@ import { getContractGraphicChangeSignatories, getContractGraphicChangeCalculationsList, signContractGraphicChange, - getContractCalculationPDFFile, + getContractCalculationPDFFile, + signCheckCreatePrintForm, } from "../../../actions"; import Options from "./components/Options"; import Comparison from "./components/Comparison"; @@ -221,7 +222,7 @@ class ChangeGraphicPage extends React.Component signatoryid: signer, type }) - .then((comment) => + .then(async (comment) => { this.setState({ loading: false, mode_final: true, mode_options: false, mode_comparison: false, comment }); }) @@ -235,6 +236,11 @@ class ChangeGraphicPage extends React.Component }); } + _handle_onSignEDOFinished = (comment) => + { + this.setState({ loading: false, mode_final: true, mode_options: false, mode_comparison: false, comment }); + } + _handle_onDownloadPDF = () => { const { calculation_id, } = this.state; @@ -299,7 +305,6 @@ class ChangeGraphicPage extends React.Component //console.log("contracts_info", contracts_info); - return ( @@ -334,6 +339,7 @@ class ChangeGraphicPage extends React.Component ) : (
) } diff --git a/pages/contract/compare.js b/pages/contract/compare.js deleted file mode 100644 index d9bdc9f..0000000 --- a/pages/contract/compare.js +++ /dev/null @@ -1,474 +0,0 @@ -import React from "react"; -import Head from "next/head"; -import Image from "next/image"; -import { connect } from "react-redux"; -import { withRouter } from "next/router"; -import moment from "moment"; -import { SpinnerCircular } from "spinners-react"; -import Link from "next/link"; -import { reduxWrapper } from "../../store"; - -import Header from "../components/Header"; -import Footer from "../components/Footer"; -import Company from "../components/Company"; - -import { - getContractInfo, - getContractAgreement, - getContractRules, - getFile, -} from "../../actions"; - -class ChangeGraphicComparePage extends React.Component -{ - constructor(props) - { - super(props); - this.state = { - date: null, - car: null, - contract_date: null, - agreement: null, - rules: null, - loading: false, - }; - } - - static getDerivedStateFromProps(nextProps, prevState) - { - return { - date: nextProps.date, - car: nextProps.car, - contract_date: nextProps.contract_date, - agreement: nextProps.agreement, - rules: nextProps.rules, - }; - } - - componentDidMount() - { - if (!this.state.loading && this.props.number !== undefined) - { - this.setState({ loading: true }, () => - { - getContractInfo({ - dispatch: this.props.dispatch, - number: this.props.number, - }) - .then((info) => - { - //console.log("info", info); - - - getContractRules({ - dispatch: this.props.dispatch, - date: moment(info.date, "YYYY-MM-DD").format("DD.MM.YYYY"), - }) - .then(() => {}) - .catch(() => {}); - }) - .catch(() => {}); - - getContractAgreement({ - dispatch: this.props.dispatch, - number: this.props.number, - }) - .then(() => - { - this.setState({ loading: false }); - }) - .catch(() => {}); - }); - } - } - - render() - { - const { number } = this.props; - const { loading, date, car, contract_date, agreement, rules } = this.state; - - //console.log("rules", rules); - - - return ( - - - ЛК Эволюция автолизинга - - -
-
-
-
-
-
-
-

Договор №{ number }

-
- { date !== undefined && date !== null && date !== null && ( <> от {moment(date).format("DD.MM.YYYY")} ) } - { car !== undefined && car !== null ? ` - ${car.brand.name} ${car.model.name} | ${ car.reg_number !== null ? car.reg_number : "без рег. номера" } | ${ car.vin_number !== null ? car.vin_number : "без VIN номера" }` : "" } -
-
- -
-
-
-
-

- Выбранный(ые) варианты изменения графика - - Вернуться к параметрам изменения графика - -

- -
-
-
- - -
-
- - -
-
-

- Дата платежа: 1 месяц (37 платежей) -

-
-
-

- Тип каникул: С увеличением срока -

-
-
-
-
-

Текущий график

-
-
-
-
- Дата лизингового платежа -
-
Лизинговый платеж с НДС ₽
-
Сумма досрочного выкупа
-
-
- -
-
-
14
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
15
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
16
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
17
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
18
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
19
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
20
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
-
-

- Изменения с платежа №ХХ от ХХ.ХХ.ХХХХ -

-
-
-
-
- Дата лизингового платежа -
-
- Лизинговый платеж с НДС ₽ -
-
- Сумма досрочного выкупа -
-
-
- -
-
-
14
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
15
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
16
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
17
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
18
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
19
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
20
-
21.02.2021
-
239 724,05
-
43 079,18
-
-
-
-
-
- -
-

Платеж №14

-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
-
-

Платеж №15

-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
-
-

Платеж №15

-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
-
-

Платеж №15

-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
-
-

Платеж №15

-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
-
-

Платеж №15

-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
Текущий график 21.02.2021
-
На сумму 239 724,05
-
Сумма досрочного выкупа 43 079,18
-
-
-
-
-
-
-
-

- Подписанты - - Все - -

-
-
- - - -
-

Иванов Иван

-

Менеджер по продажам

-
-
-
- - - -
-

Иванов Иван

-

Менеджер по продажам

-
-
-
- - - -
-

Иванов Иван

-

Менеджер по продажам

-
-
-
- - - -
-

Иванов Иван

-

Менеджер по продажам

-
-
-
- - - -
-

Иванов Иван

-

Менеджер по продажам

-
-
-
-
-
- - -
-
-

- Дополнительное соглашение отправлено на согласование. После согласования документ появится на странице
- «Документы по договору» -

-
-
-
-
-
-
-