updates for deal EDO sign process

This commit is contained in:
merelendor 2023-10-19 15:48:56 +03:00
parent 1b98fe1a62
commit f702573890
13 changed files with 112 additions and 143 deletions

View File

@ -43,7 +43,8 @@ export const getEDOOperatorList = ({ dispatch, update = false }) =>
dispatch({ dispatch({
type: actionTypes.EDO_OPERATORS_LIST, type: actionTypes.EDO_OPERATORS_LIST,
data: { data: {
operators: response.data.box_edo operators: response.data.box_edo,
message: response.data.message,
} }
}); });
@ -57,7 +58,8 @@ export const getEDOOperatorList = ({ dispatch, update = false }) =>
dispatch({ dispatch({
type: actionTypes.EDO_OPERATORS_LIST, type: actionTypes.EDO_OPERATORS_LIST,
data: { data: {
operators: [] operators: [],
message: "Невозможно получить список операторов ЭДО",
} }
}); });

View File

@ -50,6 +50,7 @@ export default class DealsList extends React.Component
if(dealSelected === deal.opp_number) if(dealSelected === deal.opp_number)
{ {
return (<SingleDeal return (<SingleDeal
router={ this.props.router }
key={ index } key={ index }
index={ index } index={ index }
ref={ ref => this.items_ref[index] = ref } ref={ ref => this.items_ref[index] = ref }

View File

@ -1126,6 +1126,13 @@ class LeasingRegistration extends Step
}); });
} }
_handle_onGoToEDOInvites = () =>
{
console.log("_handle_onGoToEDOInvites", { props: this.props });
this.props.router.push("/settings/digital");
}
_getDocuments = () => _getDocuments = () =>
{ {
const contracts = this.props.contracts['prepared_contracts']; const contracts = this.props.contracts['prepared_contracts'];
@ -1164,6 +1171,7 @@ class LeasingRegistration extends Step
documents={ this._getDocuments() } documents={ this._getDocuments() }
onCancel={ this._handle_onCancelEDO } onCancel={ this._handle_onCancelEDO }
onFinish={ this._handle_onFinishEDO } onFinish={ this._handle_onFinishEDO }
onGoToEDOInvites={ this._handle_onGoToEDOInvites }
/> />
) )
} }

View File

@ -186,6 +186,7 @@ class DealsStatus extends React.Component
</div> </div>
<DealsList <DealsList
dispatch={ this.props.dispatch } dispatch={ this.props.dispatch }
router={ this.props.router }
status={ status } status={ status }
deals={ deals } deals={ deals }
questionnaire_status={ questionnaire_status } questionnaire_status={ questionnaire_status }

View File

@ -17,6 +17,7 @@ class EDOSign extends React.Component
this.state = { this.state = {
finished: false, finished: false,
operators: null, operators: null,
edo_message: null,
loading: false, loading: false,
disabled: false, disabled: false,
documents: [], documents: [],
@ -31,6 +32,7 @@ class EDOSign extends React.Component
console.log("EDOSign", "getDerivedStateFromProps", { nextProps }); console.log("EDOSign", "getDerivedStateFromProps", { nextProps });
return { return {
operators: nextProps.operators, operators: nextProps.operators,
edo_message: nextProps.edo_message,
} }
} }
@ -262,7 +264,12 @@ class EDOSign extends React.Component
} }
else else
{ {
await this._updateDocs(document.index, { loading: false, error: true, ready: true, message: "Возникла ошибка при создании документа для подписания." }); await this._updateDocs(document.index, {
loading: false,
error: true,
ready: true,
message: create_print_form_result.message !== undefined && create_print_form_result.message !== null ? create_print_form_result.message : "Возникла ошибка при создании документа для подписания.",
});
callback(); callback();
} }
} }
@ -285,35 +292,42 @@ class EDOSign extends React.Component
{ {
event.preventDefault(); event.preventDefault();
const { onFinish } = this.props; const { onFinish, onGoToEDOInvites } = this.props;
const { operator_selected, step, finished } = this.state; const { operators, operator_selected, step, finished } = this.state;
const documents = [ ...this.state.documents ]; const documents = [ ...this.state.documents ];
console.log("_handle_onFormSubmit"); console.log("_handle_onFormSubmit");
console.log({ documents, operator_selected }); console.log({ documents, operator_selected });
if(finished) if(operators !== null && operators.length === 0)
{ {
onFinish(); onGoToEDOInvites();
} }
else else
{ {
switch(step) if(finished)
{ {
case 0: onFinish();
}
else
{
switch(step)
{ {
this.setState({ step: 1 }, () => case 0:
{
this.setState({ step: 1 }, () =>
{
this._sign();
});
}
break;
case 1:
{ {
this._sign(); this._sign();
}); }
break;
} }
break;
case 1:
{
this._sign();
}
break;
} }
} }
} }
@ -431,7 +445,7 @@ class EDOSign extends React.Component
render() render()
{ {
const { step, operators, documents, loading, disabled, finished, operator_selected } = this.state; const { step, operators, edo_message, documents, loading, disabled, finished, operator_selected } = this.state;
const { onCancel, } = this.props; const { onCancel, } = this.props;
console.log({ operators, documents }); console.log({ operators, documents });
@ -443,20 +457,33 @@ class EDOSign extends React.Component
{ step === 0 && ( { step === 0 && (
<div className="form_field edo_list_field"> <div className="form_field edo_list_field">
<label>Выберите оператора для отправки пакета документов</label> <label>Выберите оператора для отправки пакета документов</label>
<div className="edo_list_selection"> <div className="edo_list_selection edo_sign_documents_document" style={{ flexDirection: "column", border: "none", padding: "0px 0px 0px 15px", }}>
{ operators !== undefined && operators !== null && operators.map((operator, index) => ( { operators !== undefined && operators !== null && (
<div className="form_field checkbox item" key={ index }> <>
<input type="radio" { operators.length === 0 ? (
checked={ operator.box_id === operator_selected.box_id } <div className="edo_sign_documents_document_right" style={{ border: "none", }}>
hidden="" <div className="status_icon await"></div>
id={ `operator_${ index }` } <div className="status_title">
name={ `operator_${ index }` } <i>{ edo_message }</i>
onChange={ (event) => this._handle_onSelectOperator(operator) } </div>
disabled={ false } </div>
/> ) : (
<label htmlFor={ `operator_${ index }` } className="unselectable">{ operator.provider_edo }</label> operators.map((operator, index) => (
</div> <div className="form_field checkbox item" key={ index }>
)) } <input type="radio"
checked={ operator.box_id === operator_selected.box_id }
hidden=""
id={ `operator_${ index }` }
name={ `operator_${ index }` }
onChange={ (event) => this._handle_onSelectOperator(operator) }
disabled={ false }
/>
<label htmlFor={ `operator_${ index }` } className="unselectable">{ operator.provider_edo }</label>
</div>
) )
)}
</>
) }
</div> </div>
</div> </div>
) } ) }
@ -578,6 +605,7 @@ function mapStateToProps(state, ownProps)
console.log("EDOSign", "mapStateToProps", { state: state }); console.log("EDOSign", "mapStateToProps", { state: state });
return { return {
operators: state.edo.operators, operators: state.edo.operators,
edo_message: state.edo.message,
} }
} }

View File

@ -18,24 +18,34 @@ export default class FileDropzoneDeals extends FileDropzone
const { uploaded, onAddFile, onDeleteFile, uploading, document, } = this.props; const { uploaded, onAddFile, onDeleteFile, uploading, document, } = this.props;
console.log("FileDropzoneDeals", { uploaded, document }); console.log("FileDropzoneDeals", { uploaded, document });
let show_comment = false;
if(document.comment !== null && document.comment !== "")
{
show_comment = true;
if(!uploaded.sent)
{
show_comment = false;
}
}
return ( return (
<> <>
{ show_comment && (
<div className="horizontal_dropzone_files_item horizontal_dropzone_files_error">
<p className="horizontal_dropzone_files_comment">
<span>{ document.check }</span>
<span>{ document.comment }</span>
</p>
</div>
) }
{ uploaded.files.length > 0 && ( { uploaded.files.length > 0 && (
<div className="horizontal_dropzone_files_wrapper"> <div className="horizontal_dropzone_files_wrapper">
{ document.comment !== null && document.comment !== "" && (
<div className="horizontal_dropzone_files_item horizontal_dropzone_files_error">
<p className="horizontal_dropzone_files_comment">
<span>{ document.check }</span>
<span>{ document.comment }</span>
</p>
</div>
) }
<div className="horizontal_dropzone_files horizontal_dropzone_files_item"> <div className="horizontal_dropzone_files horizontal_dropzone_files_item">
{ uploaded.files.map((file, index) => { uploaded.files.map((file, index) =>
{ {
return ( return (
<div className="file" key={ index }> <div className="file" key={ index }>
{ file.sent ? ( { uploaded.sent ? (
<div className="delete" onClick={ () => onDeleteFile(file.group, index) }> <div className="delete" onClick={ () => onDeleteFile(file.group, index) }>
<div className="icon"></div> <div className="icon"></div>
</div> </div>

View File

@ -6169,13 +6169,13 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0px 20px; gap: 0px 20px;
padding-top: 15px; padding: 15px 0px;
} }
.horizontal_dropzone_files_wrapper .horizontal_dropzone_files_item { .horizontal_dropzone_files_wrapper .horizontal_dropzone_files_item {
width: 100%; width: 100%;
} }
.horizontal_dropzone_files_wrapper .horizontal_dropzone_files_error { .horizontal_dropzone_files_error {
padding-bottom: 24px; padding-bottom: 15px;
} }
.horizontal_dropzone_files_comment { .horizontal_dropzone_files_comment {
background: rgba(131, 3, 84, 0.1); background: rgba(131, 3, 84, 0.1);

View File

@ -7099,15 +7099,15 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0px 20px; gap: 0px 20px;
padding-top: 15px; padding: 15px 0px;
.horizontal_dropzone_files_item { .horizontal_dropzone_files_item {
width: 100%; width: 100%;
} }
}
.horizontal_dropzone_files_error { .horizontal_dropzone_files_error {
padding-bottom: 24px; padding-bottom: 15px;
}
} }
.horizontal_dropzone_files_comment { .horizontal_dropzone_files_comment {

View File

@ -45,7 +45,6 @@ export default async function handler(req, res)
index, index,
type, type,
lastModified, lastModified,
sent: true
}; };
try try

View File

@ -160,6 +160,7 @@ export default async function handler(req, res)
eachSeries(Object.keys(deals[ deal_id ].uploaded), (group, callback) => eachSeries(Object.keys(deals[ deal_id ].uploaded), (group, callback) =>
{ {
const document = deals[ deal_id ].uploaded[ group ]; const document = deals[ deal_id ].uploaded[ group ];
deals[ deal_id ].uploaded[ group ].sent = true;
console.log({ group, document }); console.log({ group, document });
if(document.files.length === 1) if(document.files.length === 1)
@ -201,40 +202,11 @@ export default async function handler(req, res)
}); });
}) })
} }
}, async () =>
/*
try
{
if(fs.existsSync(`${ uploads }${ file.filename }`))
{
*/
/*
*/
/*
}
else
{
callback();
}
*/
/*
console.log({ file_upload_url });
*/
/*
}
catch(e)
{
console.error(e)
callback();
}
*/
}, () =>
{ {
console.log("ALL FILES SENT"); console.log("ALL FILES SENT");
await RedisClient.set(key, JSON.stringify(deals));
res.status(200).json({}); res.status(200).json({});
resolve(); resolve();
}); });
@ -256,65 +228,6 @@ export default async function handler(req, res)
res.status(403).json({}); res.status(403).json({});
resolve(); resolve();
} }
/*
const payload = new URLSearchParams({
name: number,
entity: entity,
documentTypeNumber: id,
documentName: filename,
});
const path = `${ process.env.CRM_API_HOST }/lk/document/upload?${ payload.toString() }`;
console.log({ path });
upload.single("file")(req, {}, err =>
{
const { file } = req;
file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8');
const data = new FormData();
data.append("file", file.buffer, file.originalname);
try
{
axios.post(path, data,
{
headers: {
"Content-Type": `multipart/form-data; boundary=${ data._boundary }`,
"Authorization": `Bearer ${ crm_jwt }`,
},
withCredentials: true,
})
.then((crm_response) =>
{
console.log("/lk/document/upload SUCCESS");
res.status(200).json(crm_response.data);
resolve();
})
.catch((error) =>
{
console.error("-".repeat(30), "error.response.data:");
console.error(error.response);
res.status(500).json(error.response.data);
resolve();
});
}
catch(e)
{
console.error(e);
res.status(500).send(e);
resolve();
}
});
}
else
{
res.status(403).send();
resolve();
}
*/
} }
else else
{ {

View File

@ -316,7 +316,11 @@ class IndexPage extends React.Component
) } ) }
{/*}{*/} {/*}{*/}
<DealsStatus questionnaire_status={ company.questionnaire_status } onQuestionnaire={ this._handle_onQuestionnaire }/> <DealsStatus
questionnaire_status={ company.questionnaire_status }
onQuestionnaire={ this._handle_onQuestionnaire }
router={ this.props.router }
/>
{/*}{*/} {/*}{*/}
{ contracts !== null && contracts.length > 0 && ( { contracts !== null && contracts.length > 0 && (

View File

@ -21,11 +21,13 @@ const edoReducer = (state = initialState.edo, action) =>
console.log({ console.log({
...state, ...state,
operators: action.data.operators, operators: action.data.operators,
message: action.data.message,
}); });
return { return {
...state, ...state,
operators: action.data.operators, operators: action.data.operators,
message: action.data.message,
}; };
} }

View File

@ -257,6 +257,7 @@ export const defaultState = {
loaded: false, loaded: false,
operators: null, operators: null,
invites: null, invites: null,
message: null,
} }
}; };