This commit is contained in:
merelendor 2023-11-08 13:10:02 +03:00
commit 1cbcdd20ae
24 changed files with 1387 additions and 763 deletions

View File

@ -33,6 +33,10 @@ export const getCompanyInfo = ({ dispatch }) =>
})
.then((response) =>
{
console.log({ company: response.data });
// const eventTrack = new CustomEvent("_track", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода offerprintform" } });
// window.dispatchEvent(eventTrack);
getEDOOperatorList({ dispatch }).then(() => {}).catch(() => {});
//console.log("getCompanyInfo", "response", response.data);

View File

@ -33,6 +33,8 @@ export const getDeals = ({ dispatch, update = false }) =>
return new Promise((resolve, reject) =>
{
let last = 0;
axios.post(url, {}, {
withCredentials: true,
})
@ -40,23 +42,21 @@ export const getDeals = ({ dispatch, update = false }) =>
{
console.log("ACTION", "deals", "getDeals()", "response", response.data);
/*
if(update)
for(let i in response.data)
{
for(let i in response.data)
const n = parseInt(response.data[i].opp_number, 10);
if(n > last)
{
if(response.data[i].opp_number == "20325")
{
response.data[i].statuscode_id = 101;
}
last = n;
}
}
*/
dispatch({
type: actionTypes.DEALS_LIST,
data: {
list: response.data
list: response.data,
last,
}
});
@ -73,7 +73,8 @@ export const getDeals = ({ dispatch, update = false }) =>
dispatch({
type: actionTypes.DEALS_LIST,
data: {
list: []
list: [],
last,
}
});

View File

@ -16,4 +16,5 @@ export * from './questionnaireActions';
export * from './feedbackActions';
export * from './dealsActions';
export * from './edoActions';
export * from './signActions';
export * from './signActions';
export * from './invoicesActions';

112
actions/invoicesActions.js Normal file
View File

@ -0,0 +1,112 @@
import axios from 'axios';
import fileDownload from 'js-file-download';
import * as actionTypes from '../constants/actionTypes';
if(process.browser)
{
FormData.prototype.appendObject = function(obj, namespace)
{
let keyName;
for (var key in obj)
{
if (obj.hasOwnProperty(key))
{
keyName = [namespace, '[', key, ']'].join('');
this.append(keyName, obj[key]);
}
}
};
}
export const getContractInvoices = ({ dispatch, number }) =>
{
return new Promise((resolve, reject) =>
{
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/invoices`, { number },
{
withCredentials: true,
})
.then(async (response) =>
{
console.log("getContractInvoices", { response: response.data });
dispatch({ type: actionTypes.INVOICES_LIST, data: { number, invoices: response.data } });
resolve();
})
.catch((error) =>
{
console.error(error);
reject();
});
});
}
export const downloadInvoiceFile = ({ payload, filename }) =>
{
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/invoice/download`;
return new Promise((resolve, reject) =>
{
axios.get(url, {
params: payload,
responseType: 'blob',
})
.then((response) =>
{
fileDownload(response.data, filename);
resolve();
})
.catch((error) =>
{
console.error("ACTION", "sign", "downloadInvoiceFile()", "ERROR");
console.error(error);
const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода GetWMDoc" } });
window.dispatchEvent(eventMessage);
reject(error.data);
});
});
}
export const getInvoiceKASKO = ({ number }) =>
{
return new Promise((resolve, reject) =>
{
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/invoice/kasko`, { number },
{
withCredentials: true,
})
.then(async (response) =>
{
console.log("getInvoiceKASKO", { response: response.data });
resolve(response.data);
})
.catch((error) =>
{
console.error(error);
reject();
});
});
}
export const getInvoiceFinGap = ({ number }) =>
{
return new Promise((resolve, reject) =>
{
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/invoice/fingap`, { number },
{
withCredentials: true,
})
.then(async (response) =>
{
console.log("getInvoiceFinGap", { response: response.data });
resolve(response.data);
})
.catch((error) =>
{
console.error(error);
reject();
});
});
}

View File

@ -59,7 +59,7 @@ export default class DealsListDeal extends React.Component
const step = statuscode_id - 100;
return (
<div className="list_item">
<div className="list_item deal_list_item" onClick={() => { onSelectDeal(opp_number, index) }}>
<div>
<p> { opp_number }</p>
</div>
@ -79,7 +79,7 @@ export default class DealsListDeal extends React.Component
<p>{ statuses[ statuscode_id ].title }</p>
</div>
<div>
<button className="button" onClick={() => { onSelectDeal(opp_number, index) }} >
<button className="button">
{ statuscode_id === 105 || statuscode_id === 107 ? (
"Подробнее"
) : (

View File

@ -30,11 +30,11 @@ class QuestionnaireForm extends React.Component
_handle_onCreateQuestionnaire = (event) =>
{
event.preventDefault();
const { onQuestionnaire, deal_id } = this.props;
const { onQuestionnaire, deal_id, last_deal_id } = this.props;
this.setState({ loading: true, }, () =>
{
createQuestionnaire(deal_id)
createQuestionnaire(last_deal_id)
.then(() =>
{
onQuestionnaire();
@ -77,9 +77,11 @@ class QuestionnaireForm extends React.Component
case "up_to_date":
{
<div className="message ok">
<p>Вам не требуется актуализация данных анкеты Клиента</p>
</div>
return (
<div className="message ok">
<p>Вам не требуется актуализация данных анкеты Клиента</p>
</div>
)
}
default:
@ -313,6 +315,8 @@ export default class DocumentsForm extends Step
const { index, statuscode_id, dealSelected, documents, questionnaire_status, onQuestionnaire, } = this.props;
const { open, uploaded, uploading, loading, completed } = this.state;
console.log("DocumentsForm", "render", { props: this.props });
return (
<div className={`${ this.status === statuscode_id ? "current" : statuscode_id > this.status ? "done" : "" }`}>
<p> { dealSelected }</p>
@ -331,10 +335,11 @@ export default class DocumentsForm extends Step
<p><b>Анкета клиента:</b></p>
</div>
<div className="right">
<QuestionnaireForm
<QuestionnaireForm
questionnaire_status={ questionnaire_status }
onQuestionnaire={ onQuestionnaire }
deal_id={ dealSelected }
last_deal_id={ this.props.deals.last }
/>
</div>
</div>

View File

@ -178,7 +178,7 @@ export default class LeasingRegistration extends Step
return documents;
}
_render_preparedContracts = () =>
_render_preparedContracts = (type) =>
{
const { dealSelected } = this.props;
const { edo, paper, checked } = this.state;
@ -212,135 +212,162 @@ export default class LeasingRegistration extends Step
}
return (
<div className="block-column">
<div className="docs_list acts_list-checkbox medium-icon">
{ contracts.length > 0 ?
contracts.map((contract, index) => (
<div className="row" key={ index }>
<div className="doc_name i-doc i-medium blue deals_contracts" style={{ alignItems: "flex-start" }}>
<input type="checkbox" name="" id={ `contract_${ index }` } checked={ checked.indexOf(contract.name) > -1 ? true : false } onChange={ () => { this._handle_onPreparedContract(contract.name) } }/>
<label htmlFor={ `contract_${ index }` }>{ contract.name }</label>
<div className="info">
<span>{ moment(contract.date).format('MM.DD.YYYY') }</span>
<span>{ contract.brand_name }</span>
<span>{ contract.model_name }</span>
<div className="block deal_contracts_group_item" key={ type.key }>
{ !edo && ( <div className="left"><p><b>{ type.title }</b></p></div> )}
<div className="right" style={ edo ? { width: "100%" } : {} }>
<div className="block-column">
<div className={ `${ contracts.length === 0 ? "documents" : ""} docs_list acts_list-checkbox medium-icon` }>
{ contracts.length > 0 ?
contracts.map((contract, index) => (
<div className="row" key={ index }>
<div className="doc_name i-doc i-medium blue deals_contracts" style={{ alignItems: "flex-start" }}>
<input type="checkbox" name="" id={ `contract_${ index }` } checked={ checked.indexOf(contract.name) > -1 ? true : false } onChange={ () => { this._handle_onPreparedContract(contract.name) } }/>
<label htmlFor={ `contract_${ index }` }>{ contract.name }</label>
<div className="info">
<span>{ moment(contract.date).format('MM.DD.YYYY') }</span>
<span>{ contract.brand_name }</span>
<span>{ contract.model_name }</span>
</div>
</div>
</div>
</div>
)) : (
<p className="empty">Нет договоров</p>
) }
</div>
{ contracts.length > 0 &&
(
<div className="block_footer_btn">
<button className="button button-blue" onClick={ this._handle_onSignEDO } disabled={ checked.length > 0 ? false : true }>Подписать в ЭДО</button>
<button className="button button-blue" onClick={ this._handle_onSignPaper } disabled={ checked.length > 0 ? false : true }>Подписать в бумажном виде</button>
</div>
)) : (
<p className="empty">Нет договоров</p>
) }
</div>
{ contracts.length > 0 &&
(
<div className="block_footer_btn">
<button className="button button-blue" onClick={ this._handle_onSignEDO } disabled={ checked.length > 0 ? false : true }>Подписать в ЭДО</button>
<button className="button button-blue" onClick={ this._handle_onSignPaper } disabled={ checked.length > 0 ? false : true }>Подписать в бумажном виде</button>
) }
</div>
) }
</div>
</div>
)
}
_render_signingPlanContracts = () =>
_render_signingPlanContracts = (type) =>
{
const contracts = this.props.contracts['signing_plan_contracts'];
const { onDealContractsUpdate, dealSelected } = this.props;
console.log("_render_signingPlanContracts", { contracts });
return (
<div className="documents deal_contract_sign_list">
{ contracts.length > 0 ?
contracts.map((contract, index) => (
<SignPlannedContract
key={ `SignPlannedContract_${ contract.name }` }
index={ index }
contract={ contract }
deal_id={ dealSelected }
onDealContractsUpdate={ onDealContractsUpdate }
/>
)
) : (
<p className="empty">Нет договоров</p>
) }
<div className="block deal_contracts_group_item" key={ type.key }>
<div className="left"><p><b>{ type.title }</b></p></div>
<div className="right">
<div className="documents deal_contract_sign_list">
{ contracts.length > 0 ?
contracts.map((contract, index) => (
<SignPlannedContract
key={ `SignPlannedContract_${ contract.name }` }
index={ index }
contract={ contract }
deal_id={ dealSelected }
onDealContractsUpdate={ onDealContractsUpdate }
/>
)
) : (
<p className="empty">Нет договоров</p>
) }
</div>
</div>
</div>
)
}
_render_signingFactContracts = () =>
_render_signingFactContracts = (type) =>
{
const contracts = this.props.contracts['signing_fact_contracts'];
console.log("_render_signingFactContracts", { contracts });
return (
<div className="documents">
{ contracts.length > 0 ?
contracts.map((contract, index) => (
<SignedContract
key={ `SignedContract_${ contract.name }` }
index={ index }
contract={ contract }
/>
)
) : (
<p className="empty">Нет договоров</p>
) }
<div className="block deal_contracts_group_item" key={ type.key }>
<div className="left"><p><b>{ type.title }</b></p></div>
<div className="right">
<div className="documents">
{ contracts.length > 0 ?
contracts.map((contract, index) => (
<SignedContract
key={ `SignedContract_${ contract.name }` }
index={ index }
contract={ contract }
/>
)
) : (
<p className="empty">Нет договоров</p>
) }
</div>
</div>
</div>
)
}
_render_issuedContracts = () =>
_render_issuedContracts = (type) =>
{
const contracts = this.props.contracts['issued_contracts'];
console.log("_render_issuedContracts", { contracts });
return (
<div className="documents">
{ contracts.length > 0 ?
contracts.map((contract, index) => (
<div className="document" key={ index }>
<div className="icon formal"></div>
<div className="title">
<p><Link href={`/contract/${ contract.name }/payments`}><a>{ contract.name }</a></Link></p>
<div className="description">
<span>{ moment(contract.date).format("DD.MM.YYYY") }</span>
<span>{ contract.brand_name }</span>
<span>{ contract.model_name }</span>
<div className="block deal_contracts_group_item" key={ type.key }>
<div className="left"><p><b>{ type.title }</b></p></div>
<div className="right">
<div className="documents">
{ contracts.length > 0 ?
contracts.map((contract, index) => (
<div className="document" key={ index }>
<div className="icon formal"></div>
<div className="title">
<p><Link href={`/contract/${ contract.name }/payments`}><a>{ contract.name }</a></Link></p>
<div className="description">
<span>{ moment(contract.date).format("DD.MM.YYYY") }</span>
<span>{ contract.brand_name }</span>
<span>{ contract.model_name }</span>
</div>
</div>
</div>
</div>
</div>
)) : (
<p className="empty">Нет договоров</p>
) }
)) : (
<p className="empty">Нет договоров</p>
) }
</div>
</div>
</div>
)
}
_render_annuledContracts = () =>
_render_annuledContracts = (type) =>
{
const contracts = this.props.contracts['annulled_contracts'];
console.log("_render_annuledContracts", { contracts });
return (
<div className="documents">
{ contracts.length > 0 ?
contracts.map((contract, index) => (
<div className="document" key={ index }>
<div className="icon formal"></div>
<div className="title">
<p>{ contract.name }</p>
<div className="description">
<span>{ moment(contract.date).format("DD.MM.YYYY") }</span>
<span>{ contract.brand_name }</span>
<span>{ contract.model_name }</span>
</div>
</div>
if(contracts.length > 0)
{
return (
<div className="block deal_contracts_group_item" key={ type.key }>
<div className="left"><p><b>{ type.title }</b></p></div>
<div className="right">
<div className="documents">
{ contracts.map((contract, index) => (
<div className="document" key={ index }>
<div className="icon formal"></div>
<div className="title">
<p>{ contract.name }</p>
<div className="description">
<span>{ moment(contract.date).format("DD.MM.YYYY") }</span>
<span>{ contract.brand_name }</span>
<span>{ contract.model_name }</span>
</div>
</div>
</div>
)) }
</div>
)) : (
<p className="empty">Нет договоров</p>
) }
</div>
)
</div>
</div>
)
} else {
return null;
}
}
_render_contracts = (type) =>
@ -349,31 +376,31 @@ export default class LeasingRegistration extends Step
if(contracts !== undefined)
{
switch (type)
switch (type.key)
{
case "prepared_contracts":
{
return this._render_preparedContracts();
return this._render_preparedContracts(type);
}
case "signing_plan_contracts":
{
return this._render_signingPlanContracts();
return this._render_signingPlanContracts(type);
}
case "signing_fact_contracts":
{
return this._render_signingFactContracts();
return this._render_signingFactContracts(type);
}
case "issued_contracts":
{
return this._render_issuedContracts();
return this._render_issuedContracts(type);
}
case "annulled_contracts":
{
return this._render_annuledContracts();
return this._render_annuledContracts(type);
}
}
}
@ -399,26 +426,9 @@ export default class LeasingRegistration extends Step
<div style={{ minHeight: 200, display: "flex", justifyContent: "center", alignItems: "center", }}>
<SpinnerCircular size={ 90 } thickness={ 51 } speed={ 100 } color="rgba(28, 1, 169, 1)" secondaryColor="rgba(236, 239, 244, 1)" />
</div>
) : (
<>
{ this.types.map((type, index) => (
<div className="block deal_contracts_group_item" key={ index }>
{ edo ? (
<>
{ type.key !== "prepared_contracts" && (
<div className="left"><p><b>{ type.title }</b></p></div>
) }
</>
) : (
<div className="left"><p><b>{ type.title }</b></p></div>
) }
<div className="right" style={ edo && type.key === "prepared_contracts" ? { width: "100%" } : {} }>
{ this._render_contracts(type.key) }
</div>
</div>
)) }
</>
) }
) :
this.types.map((type, index) => this._render_contracts(type) )
}
</div>
</div>
</div>

View File

@ -16,6 +16,7 @@ class DealsStatus extends React.Component
currentSelected: null,
dealSelected: undefined,
deals: undefined,
lastDealNumber: 0,
}
}
@ -32,7 +33,17 @@ class DealsStatus extends React.Component
getDeals({ dispatch });
}
componentDidUpdate(prevProps, prevState) { }
componentDidUpdate(prevProps, prevState)
{
if(prevState.deals.list === null && this.state.deals.list !== null)
{
let lastDealNumber = 0;
for(let i in this.state.deals.list)
{
console.log("DealsStatus", this.state.deals.list[i]);
}
}
}
_onDealsUpdate = () =>
{
@ -102,6 +113,8 @@ class DealsStatus extends React.Component
const { currentContractModalOpened, allContractModalOpened, currentSelected, dealSelected, deals, status, } = this.state
const { questionnaire_status, onQuestionnaire, } = this.props;
console.log("render", { deals });
return (
<>
{ deals.list !== undefined && deals.list !== null && deals.list.length > 0 && (

View File

@ -58,4 +58,6 @@ export const DEAL_RESET = 'DEAL_RESET';
export const EDO_LOADED = 'EDO_LOADED';
export const EDO_OPERATORS_LIST = 'EDO_OPERATORS_LIST';
export const EDO_INVITES_LIST = 'EDO_INVITES_LIST';
export const EDO_RESET = 'EDO_RESET';
export const EDO_RESET = 'EDO_RESET';
export const INVOICES_LIST = 'INVOICES_LIST';

View File

@ -114,7 +114,7 @@ main .title_wrapper .right {
}
main .title_wrapper .company-dropdown {
position: relative;
z-index: 5;
z-index: 15;
}
main .title_wrapper .company-dropdown .arrow {
cursor: pointer;
@ -7148,3 +7148,81 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_
.offer_selection:hover {
text-decoration: underline;
}
.deal_list_item {
cursor: pointer;
}
.contract_invoices_list {
display: flex;
gap: 40px 20px;
flex-wrap: wrap;
}
.contract_invoices_list .invoice {
max-width: 23%;
width: 23%;
min-height: 85px;
padding-bottom: 10px;
align-items: flex-start;
justify-content: space-between;
display: flex;
flex-direction: column;
}
@media all and (max-width: 1280px) {
.contract_invoices_list .invoice {
max-width: 31%;
width: 31%;
}
}
@media all and (max-width: 900px) {
.contract_invoices_list .invoice {
max-width: 47%;
width: 47%;
}
}
@media all and (max-width: 400px) {
.contract_invoices_list .invoice {
max-width: 100%;
width: 100%;
}
}
.contract_invoices_list .invoice p {
line-height: 15px;
color: var(--gray);
}
@media all and (max-width: 1280px) {
.contract_invoices_list .invoice p {
font-size: 13px;
}
}
.contract_invoices_list .invoice .actions {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: flex-start;
width: 100%;
}
.contract_invoices_list .invoice .actions .icon {
margin-top: 5px;
display: flex;
align-items: center;
justify-content: center;
width: 56px;
height: 56px;
min-width: 56px;
min-height: 56px;
position: relative;
background: url(/assets/images/icons/icon-file.svg) no-repeat left center;
background-size: contain;
padding: 0;
zoom: 0.65;
}
.contract_invoices_list .invoice .actions .icon.formal {
background-image: url("data:image/svg+xml,%3Csvg width='26' height='28' viewBox='0 0 26 28' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 3.5C2 1.84315 3.34315 0.5 5 0.5H18.3701L20.7774 4L23.1848 7.06354V24.5C23.1848 26.1569 21.8417 27.5 20.1848 27.5H5C3.34314 27.5 2 26.1569 2 24.5V3.5Z' fill='%231C01A9'/%3E%3Cpath opacity='0.4' d='M23.1858 11.5V7L19.334 6.5L23.1858 11.5Z' fill='%230C0C0C'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 7.50098)' stroke='%23F0F0F0'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 12.501)' stroke='%23F0F0F0'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 17.501)' stroke='%23F0F0F0'/%3E%3Cline y1='-0.5' x2='11.5553' y2='-0.5' transform='matrix(1 -9.89866e-05 0.000132759 1 6.81445 22.501)' stroke='%23F0F0F0'/%3E%3Cpath d='M23.1858 7H19.3711C18.8188 7 18.3711 6.55228 18.3711 6V3.5V0.5L23.1858 7Z' fill='%232F80ED'/%3E%3C/svg%3E");
}
.contract_invoices_list .invoice .actions .icon .extension {
font-weight: 600;
font-size: 12px;
color: #fff;
}
.contract_invoices_list .invoice .actions .download {
min-width: 82px;
}

File diff suppressed because it is too large Load Diff

View File

@ -635,7 +635,9 @@ div {
margin-top: 35px;
margin-bottom: 15px;
}
.contracts_list_title {
.contracts_list_title,
.invoices_title,
.schedule_title {
font-size: 26px;
font-weight: 700;
line-height: 35px;
@ -682,3 +684,9 @@ div {
background: url("/assets/images/icons/close-white.svg") no-repeat center;
background-size: 16px;
}
.invoices_title {
margin-top: 0px;
}
.schedule_title {
margin-bottom: 15px;
}

View File

@ -731,4 +731,14 @@ div {
background-size: 16px;
}
}
}
.invoices_title {
&:extend(.contracts_list_title);
margin-top: 0px;
}
.schedule_title {
&:extend(.contracts_list_title);
margin-bottom: 15px;
}

View File

@ -0,0 +1,76 @@
import fs from 'fs';
import axios from 'axios';
import { Cookies } from 'react-cookie';
import cookie from 'cookie';
import moment from 'moment';
import jwt from 'jsonwebtoken';
import { inspect } from 'util';
export default async function handler(req, res)
{
console.log("\n\n", "API", "/contract/invoice/download");
const { entity_id, code } = req.query;
const payload = {
entityId: entity_id,
reportCodes: [ code ],
createDocument: false,
openFile: true,
};
console.log({ payload });
return new Promise(async (resolve) =>
{
if(req.headers.cookie !== undefined)
{
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
if(cookies.jwt !== undefined && cookies.jwt !== null)
{
var client_jwt_decoded = jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT);
var crm_jwt = jwt.sign({ acc_number: client_jwt_decoded.acc_number }, process.env.JWT_SECRET_CRM, { noTimestamp: true });
try
{
axios.post(`${ process.env.CRM_API_HOST }/File/GetWMDoc`, payload, {
responseType: 'arraybuffer',
headers: {
"Authorization": `Bearer ${ crm_jwt }`,
"Content-Type": "application/json",
},
})
.then((crm_response) =>
{
res.status(200).send(crm_response.data);
resolve();
})
.catch((error) =>
{
console.error(error);
console.error(error.data);
res.status(500).send(error.data);
resolve();
});
}
catch(e)
{
console.error(e);
res.status(500).send(e);
resolve();
}
}
else
{
res.status(403).send();
resolve();
}
}
else
{
res.status(403).send();
resolve();
}
});
}

View File

@ -0,0 +1,6 @@
import CRMRequestGet from '../../../../lib/CRMRequestGet';
export default async function handler(req, res)
{
await CRMRequestGet({ req, res, path: `${ process.env.CRM_API_HOST }/lk/Contract/GetFinGap`, params: { contract_number: req.body.number } });
}

View File

@ -0,0 +1,6 @@
import CRMRequestGet from '../../../../lib/CRMRequestGet';
export default async function handler(req, res)
{
await CRMRequestGet({ req, res, path: `${ process.env.CRM_API_HOST }/lk/Contract/GetKasko`, params: { contract_number: req.body.number } });
}

View File

@ -0,0 +1,6 @@
import CRMRequestGet from '../../../lib/CRMRequestGet';
export default async function handler(req, res)
{
await CRMRequestGet({ req, res, path: `${ process.env.CRM_API_HOST }/lk/Contract/GetInvoices`, params: { contract_number: req.body.number } });
}

View File

@ -18,6 +18,22 @@ export default class AccountLayout extends React.Component
window.addEventListener("_track", this._handle_onTrack);
window.addEventListener("_move", this._handle_onMove);
window.addEventListener("_message", this._handle_onMessage);
const store = global.store.getState();
const { company, user } = store;
console.log("LAYOUT", "CDM", { store });
const payload = {
userID: user.email !== undefined && user.email !== null && user.email !== "" ? user.email : user.phone,
companyID: company.active,
};
if(payload.companyID !== undefined && payload.companyID !== null && payload.companyID !== "")
{
console.log("LAYOUT", "CDM", { payload });
ym(process.env.YANDEX_METRIKA_ID, 'userParams', payload);
}
}
console.log("CDM", { state: this.state });
@ -37,6 +53,8 @@ export default class AccountLayout extends React.Component
{
//event.detail.path
console.log("LAYOUT", "_handle_onTrack", { event, props: this.props });
console.log({ ym });
}
_handle_onMove = (event) =>

View File

@ -14,10 +14,135 @@ import Footer from '../components/Footer';
import Company from "../components/Company";
import InnerMenu from "./components/InnerMenu";
import { getContract, getContractDebtInvoiceFile, getContractInfo, getContractPenaltyInvoiceFile } from './../../actions';
import { downloadInvoiceFile, getContract, getContractDebtInvoiceFile, getContractInfo, getContractInvoices, getContractPenaltyInvoiceFile, getFile, getInvoiceFinGap, getInvoiceKASKO, signGetGUIDEntity, signGetWMDoc } from './../../actions';
import AccountLayout from "../components/Layout/Account";
import ContractHeader from "./components/ContractHeader";
class Invoice extends React.Component
{
constructor(props)
{
super(props);
this.state = {
loading: false,
}
}
_handle_downloadFile = () =>
{
const { group, contract_number } = this.props;
this.setState({ loading: true }, async () =>
{
switch(group.type)
{
case "kaskoProlong":
{
getInvoiceKASKO({ number: contract_number })
.then(async (document_result) =>
{
let document = undefined;
console.log({ document_result });
for(let i in document_result)
{
if(document_result[i].period_type === "prolong")
{
document = document_result[i];
break;
}
}
if(document !== undefined)
{
await getFile({ id: document.invoice_url, filename: `ЛК ЭВОЛЮЦИЯ - договор ${ contract_number } - ${ group.title }.${ document.invoice_extension }` });
}
this.setState({ loading: false });
})
.catch((document_result_error) =>
{
console.error({ document_result_error });
this.setState({ loading: false });
});
}
break;
case "fingapProlong":
{
getInvoiceFinGap({ number: contract_number })
.then(async (document_result) =>
{
let document = undefined;
console.log({ document_result });
for(let i in document_result)
{
if(document_result[i].period_type === "prolong")
{
document = document_result[i];
break;
}
}
console.log({ document });
if(document !== undefined)
{
await getFile({ id: document.invoice_url, filename: `ЛК ЭВОЛЮЦИЯ - договор ${ contract_number } - ${ group.title }.${ document.invoice_extension }` });
}
this.setState({ loading: false });
})
.catch((document_result_error) =>
{
console.error({ document_result_error });
this.setState({ loading: false });
});
}
break;
default:
{
const guid_result = await signGetGUIDEntity({ contract_number });
console.log({ guid_result, code: group.code });
await downloadInvoiceFile({ payload: { entity_id: guid_result.entityid, code: group.code }, filename: `ЛК ЭВОЛЮЦИЯ - договор ${ contract_number } - ${ group.title }.pdf` });
this.setState({ loading: false });
}
break;
}
});
}
render()
{
const { group, invoices } = this.props;
const { loading } = this.state;
console.log({ invoices }, group.type)
if(invoices[group.type])
{
return (
<div className="invoice">
<p>{ group.title }</p>
<div className="actions">
<div className="icon formal">
</div>
<div className="download">
{ loading ? (
<SpinnerCircular style={{ margin: "8px 30px 0px", }} size={ 22 } thickness={ 100 } speed={ 100 } color="rgba(236, 239, 244, 1)" secondaryColor="rgba(28, 1, 169, 1)"/>
) : (
<button className="button blue" onClick={ this._handle_downloadFile }>Скачать</button>
) }
</div>
</div>
</div>
)
}
return null;
}
}
class ContractSchedulePage extends React.Component
{
constructor(props)
@ -30,6 +155,7 @@ class ContractSchedulePage extends React.Component
avans: null,
debt: null,
penalty: null,
invoices: {},
full: false,
opened: [],
debt_invoice_file_loading: false,
@ -45,6 +171,7 @@ class ContractSchedulePage extends React.Component
avans: nextProps.avans,
debt: nextProps.debt,
penalty: nextProps.penalty,
invoices: nextProps.invoices,
};
}
@ -63,11 +190,19 @@ class ContractSchedulePage extends React.Component
getContractInfo({ dispatch, number });
}
getContract({ dispatch, number }).then(() =>
getContract({ dispatch, number })
.then(() =>
{
this.setState({ loading: false });
}).catch(() => {});
});
})
.catch(() => {});
getContractInvoices({ dispatch, number, })
.then(() =>
{
})
.catch(() => {});
});
}
}
@ -155,7 +290,7 @@ class ContractSchedulePage extends React.Component
render()
{
const { number } = this.props;
const { loading, contracts_info, payments, avans, debt, penalty, full, opened, debt_invoice_file_loading, penalty_invoice_file_loading } = this.state;
const { loading, contracts_info, payments, avans, debt, penalty, full, opened, debt_invoice_file_loading, penalty_invoice_file_loading, invoices, } = this.state;
let { date, car, status } = contracts_info[ number ] !== undefined ? contracts_info[ number ] : {};
@ -166,6 +301,15 @@ class ContractSchedulePage extends React.Component
//console.log("avans", avans);
const invoice_types = [
{ type: "firstPayment", title: "Счет на аванс", code: "Invoice_Payment", },
{ type: "nextPayment", title: "Счет на очередной платеж", code: "InvoicePlanPayment_attach", },
{ type: "osagoInvoice", title: "Счет ОСАГО", code: "OSAGO_Pay_contract", },
{ type: "kaskoInvoice", title: "Счет КАСКО", code: "KASKO_Pay_contract", },
{ type: "kaskoProlong", title: "Счет на пролонгацию КАСКО", },
{ type: "fingapInvoice", title: "Счет EvoSafeFinance", code: "Fingap_Pay_contract", },
{ type: "fingapProlong", title: "Счет на пролонгацию EvoSafeFinance", },
];
const statuses = {
"NotPaid": "",
@ -203,7 +347,9 @@ class ContractSchedulePage extends React.Component
</div>
</div>
) }
{/* Вариант 1 */}
{ invoices[number] !== undefined && (
<div><p className="invoices_title">Подготовленные счета</p></div>
) }
<div className="payments_actions">
{ parseInt(debt, 10) > 0 && (
<div>
@ -231,6 +377,12 @@ class ContractSchedulePage extends React.Component
</div>
) }
</div>
<div className="contract_invoices_list">
{ invoices[number] !== undefined && invoice_types.map((group, index) => (
<Invoice group={ group } contract_number={ number } invoices={ invoices[number] } key={ index }/>
)) }
</div>
<div><p className="schedule_title">График платежей</p></div>
<div className="contract_table schedule">
<div className="table_row table_header">
<div className="table_cell"> платежа</div>
@ -345,6 +497,7 @@ function mapStateToProps(state, ownProps)
avans: state.contract.avans,
debt: state.contract.debt,
penalty: state.contract.penalty,
invoices: state.invoices.list,
//schedule: state.payments,
}
}

View File

@ -68,7 +68,7 @@ class Insurance extends React.Component
id={ entry.invoice_url }
filename={ `${ entry.number }.${ entry.invoice_extension}` }
title="Скачать счет на оплату"
class={ "services_invoice_button" }
className={ "services_invoice_button" }
log={{
contract_number: number,
document_type: `${ entry.period_type !== undefined ? entry.period_type : "current" }_polis_${ type }_invoice`,

View File

@ -18,14 +18,11 @@ const dealsReducer = (state = initialState.deals, action) =>
case actionTypes.DEALS_LIST:
{
console.log("actionTypes.DEALS_LIST", actionTypes.DEALS_LIST, { action });
console.log({
...state,
list: action.data.list,
});
return {
...state,
list: action.data.list,
last: action.data.last,
};
}

View File

@ -165,6 +165,9 @@ export const defaultState = {
page: 1,
pages: 1,
},
invoices: {
list: {},
},
contract:
{
payments: null,
@ -236,6 +239,7 @@ export const defaultState = {
{
loaded: false,
list: null,
last: 0,
details: {},
/*{
loaded: false,

View File

@ -0,0 +1,24 @@
import * as actionTypes from '../constants/actionTypes';
import initialState from "./initialState";
const invoicesReducer = (state = initialState.invoices, action) =>
{
switch (action.type)
{
case actionTypes.INVOICES_LIST:
{
const shrink = {};
shrink[ action.data.number ] = action.data.invoices;
return {
list: { ...state.list, ...shrink },
};
}
default: {
return state;
}
}
};
export default invoicesReducer;

View File

@ -7,6 +7,7 @@ import companyReducer from '../reducers/companyReducer';
import companiesReducer from '../reducers/companiesReducer';
import contractsReducer from '../reducers/contractsReducer';
import contractReducer from '../reducers/contractReducer';
import invoicesReducer from '../reducers/invoicesReducer';
import calendarReducer from '../reducers/calendarReducer';
import eventsReducer from '../reducers/eventsReducer';
import supportReducer from '../reducers/supportReducer';
@ -35,6 +36,7 @@ const combinedReducer = combineReducers({
questionnaire: questionnaireReducer,
deals: dealsReducer,
edo: edoReducer,
invoices: invoicesReducer,
});
const makeStore = (context) =>
@ -52,7 +54,7 @@ const makeStore = (context) =>
const persistConfig = {
key: 'lkevoleasing',
whitelist: [ 'auth', 'user', 'company', 'events', 'companies', 'contracts_info', 'contract_events', 'contract_fines', 'questionnaire', 'edo' ],
whitelist: [ 'auth', 'user', 'company', 'events', 'companies', 'contracts_info', 'invoices', 'contract_events', 'contract_fines', 'questionnaire', 'edo' ],
storage
};