updates for graphic changes API

This commit is contained in:
merelendor 2022-08-13 08:44:27 +03:00
parent bb4f75c480
commit 3b6c7de531
10 changed files with 109 additions and 34 deletions

View File

@ -397,11 +397,13 @@ export const getContractGraphicChangeSignatories = ({ dispatch, number }) =>
export const getContractGraphicChangeVariants = ({ dispatch, number, variants = {} }) =>
{
console.log("ACTION", "getContractGraphicChangeVariants", { ...{ number }, ...variants });
console.log("ACTION", "getContractGraphicChangeVariants", { ...{ number }, ...{ variants: variants } });
return new Promise((resolve, reject) =>
{
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/change/variants`, { ...{ number }, ...variants },
console.log("{ ...{ number }, ...variants }", { ...{ number }, ...{ variants: variants } });
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/change/variants`, { ...{ number }, ...{ variants: variants } },
{
withCredentials: true,
})
@ -447,11 +449,31 @@ export const getContractGraphicChangeCalculationsList = ({ dispatch, number }) =
});
}
export const getContractGraphicChangeOptions = ({ dispatch, number }) =>
export const getContractGraphicChangeOptions = ({ dispatch, number, variants }) =>
{
console.log("ACTION", "getContractGraphicChangeOptions", { ...{ number }, ...variants });
return new Promise((resolve, reject) =>
{
resolve();
console.log("{ ...{ number }, ...variants }", { ...{ number }, ...variants });
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/change/options`, { ...{ number }, ...{ variants: variants } },
{
withCredentials: true,
})
.then(async (response) =>
{
console.log("ACTION", "getContractGraphicChangeOptions", "response.data", response.data);
dispatch({ type: actionTypes.CONTRACT_CHANGE, data: { options: response.data } });
resolve();
})
.catch((error) =>
{
console.error("ACTION", "getContractGraphicChangeOptions", "error");
console.error(error);
reject();
});
});
}

View File

@ -5,6 +5,7 @@ import cookie from 'cookie';
import moment from 'moment';
import jwt from 'jsonwebtoken';
import { cors } from '../cors';
import { inspect } from 'util';
export default async function CRMRequest(req, res, path, params)
{
@ -44,7 +45,7 @@ export default async function CRMRequest(req, res, path, params)
.then((crm_response) =>
{
console.log("crm_response for", path);
console.log(crm_response.data);
console.log(inspect(crm_response.data, true, null, true));
res.status(200).json(crm_response.data);
})

View File

@ -0,0 +1,12 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import CRMRequest from '../../../../lib/CRMRequest';
export default async function handler(req, res)
{
console.log("-".repeat(50));
console.log("API", "contract", "change", "options", "req.body.variants");
console.log(req.body.variants);
console.log("-".repeat(50));
await CRMRequest(req, res, `${ process.env.CRM_API_HOST }/lk/add-contract/GetTypeOptions`, { ...{ contract_number: req.body.number }, ...req.body.variants });
}

View File

@ -3,5 +3,9 @@ import CRMRequest from '../../../../lib/CRMRequest';
export default async function handler(req, res)
{
console.log("req.body.variantsreq.body.variantsreq.body.variantsreq.body.variants");
console.log(req.body.variants);
console.log("-".repeat(50));
await CRMRequest(req, res, `${ process.env.CRM_API_HOST }/lk/add-contract/GetAvaliableGraphChangeTypes`, { ...{ contract_number: req.body.number }, ...req.body.variants });
}

View File

@ -59,21 +59,23 @@ export default class CalculationsList extends React.Component
const { number, calculations } = this.props;
console.log("\x1B[31m calculations \x1B[34m", calculations);
return (
<div className="feed">
<div className="feed_list">
<Slider { ...settings }>
{ calculations.map((calculation, index) =>
{ calculations !== undefined && calculations !== null && calculations.map((calculation, index) =>
(
<div className="feed_item" key={ index }>
<p className="item_title">Расчет { calculation.label }</p>
<p className="item_desc">
{ calculation.date_offset_type_comment !== null && (<>{ calculation.date_offset_type_comment }<br/></>) }
{ calculation.number_paydate_comment !== null && (<>{ calculation.number_paydate_comment }<br/></>) }
{ calculation.insurance_price_result_comment !== null && (<>{ calculation.insurance_price_result_comment }<br/></>) }
{ calculation.fix_last_payment_available_comment !== null && (<>{ calculation.fix_last_payment_available_comment }<br/></>) }
{ calculation.period_new_comment !== null && (<>{ calculation.period_new_comment }<br/></>) }
{ calculation.sum_comment !== null && (<>{ calculation.sum_comment }<br/></>) }
{ calculation.date_offset_type_comment !== null && (<>{ `${ calculation.date_offset_type_comment.label }: ${ calculation.date_offset_type_comment.value }` }<br/></>) }
{ calculation.number_paydate_comment !== null && (<>{ `${ calculation.number_paydate_comment.label }: ${ calculation.number_paydate_comment.value }` }<br/></>) }
{ calculation.insurance_price_result_comment !== null && (<>{ `${ calculation.insurance_price_result_comment.label }: ${ calculation.insurance_price_result_comment.value } ` }<br/></>) }
{ calculation.fix_last_payment_available_comment !== null && (<>{ `${ calculation.fix_last_payment_available_comment.label }: ${ calculation.fix_last_payment_available_comment.value ? "да" : "нет" }` }<br/></>) }
{ calculation.period_new_comment !== null && (<>{ `${ calculation.period_new_comment.label }: ${ calculation.period_new_comment.value }` }<br/></>) }
{ calculation.sum_comment !== null && (<>{ `${ calculation.sum_comment.label }: ${ calculation.sum_comment.value }` }<br/></>) }
</p>
<a className="item_link interactive" onClick={ () => this._handle_onCalculation(calculation.addcontract_number) }>Подробнее</a>
</div>

View File

@ -110,42 +110,34 @@ export default class Comparison extends React.Component
<div className="compare_data">
{ calculation !== undefined && calculation !== null && calculation.fix_last_payment_available_comment !== null && (
<div className="form_field">
<input type="checkbox" hidden id="" name="" checked disabled />
<label htmlFor="">{ calculation.fix_last_payment_available_comment }</label>
<input type="checkbox" hidden id="" name="" checked={ calculation.fix_last_payment_available_comment.value ? true : false } disabled style={ calculation.fix_last_payment_available_comment.value ? {} : { background: "unset"} } />
<label htmlFor="">{ calculation.fix_last_payment_available_comment.label }</label>
</div>
) }
{ calculation !== undefined && calculation !== null && calculation.date_offset_type_comment !== null && (
<div className="form_field">
<input type="checkbox" hidden id="" name="" checked disabled />
<label htmlFor="">{ calculation.date_offset_type_comment }</label>
<input type="checkbox" hidden id="" name="" checked={ calculation.date_offset_type_comment.value ? true : false } disabled style={ calculation.date_offset_type_comment.value ? {} : { background: "unset"} } />
<label htmlFor="">{ calculation.date_offset_type_comment.label }</label>
</div>
) }
{ calculation !== undefined && calculation !== null && calculation.insurance_price_result_comment !== null && (
<div className="form_field">
<p>
{ calculation.insurance_price_result_comment }
</p>
<p><span>{ calculation.insurance_price_result_comment.label }:</span> { calculation.insurance_price_result_comment.value }</p>
</div>
) }
{ calculation !== undefined && calculation !== null && calculation.number_paydate_comment !== null && (
<div className="form_field">
<p>
{ calculation.number_paydate_comment }
</p>
<p><span>{ calculation.number_paydate_comment.label }:</span> { calculation.number_paydate_comment.value }</p>
</div>
) }
{ calculation !== undefined && calculation !== null && calculation.period_new_comment !== null && (
<div className="form_field">
<p>
{ calculation.period_new_comment }
</p>
<p><span>{ calculation.period_new_comment.label }:</span> { calculation.period_new_comment.value }</p>
</div>
) }
{ calculation !== undefined && calculation !== null && calculation.sum_comment !== null && (
<div className="form_field">
<p>
{ calculation.sum_comment }
</p>
<p><span>{ calculation.sum_comment.label }:</span> { calculation.sum_comment.value }</p>
</div>
) }
{/*}

View File

@ -1,4 +1,5 @@
import React from "react";
import { getContractGraphicChangeOptions } from "../../../../../actions";
import DateInput from "../../../../components/DatePicker";
export default class Options extends React.Component
@ -12,12 +13,34 @@ export default class Options extends React.Component
contract_date: null,
agreement: null,
rules: null,
loading: false,
loading: true,
};
}
componentDidMount()
{
const { dispatch, number, variants } = this.props;
const varianst_for_options = {};
for(let i in variants.types)
{
if(variants.types[i].value)
{
varianst_for_options[variants.types[i].name] = true;
}
}
console.log("varianst_for_options", varianst_for_options);
getContractGraphicChangeOptions({ dispatch, number, variants: varianst_for_options })
.then(() =>
{
})
.catch(() =>
{
});
}
_handle_onBack = (event) =>
@ -35,7 +58,9 @@ export default class Options extends React.Component
render()
{
const { loading, date, car, contract_date, agreement, rules } = this.state;
const { number } = this.props;
const { variants } = this.props;
console.log("Change", "Options", "render()", "variants", variants);
return (
<div className="block">

View File

@ -45,6 +45,11 @@ export default class VariantsList extends React.Component
return false;
}
_handle_onOptions = () =>
{
this.props.onOptions();
}
render()
{
const { number, variants_types, selected, blocked, loading } = this.props;
@ -53,7 +58,7 @@ export default class VariantsList extends React.Component
<div className="block" style={{ position: "relative" }}>
<p className="title">Варианты изменения графиков</p>
<div style={ loading ? { opacity: 0.5, } : {} }>
<form>
<form onSubmit={ (e) => e.preventDefault() }>
{ variants_types.map((variant, index) =>
{
const disabled = this._checkVariant(variant.type);
@ -82,7 +87,7 @@ export default class VariantsList extends React.Component
</div>
)
}) }
<button className="button button-blue" disabled={ blocked || loading ? true : selected.length > 0 ? false : true }>Далее</button>
<button className="button button-blue" disabled={ blocked || loading ? true : selected.length > 0 ? false : true } onClick={ this._handle_onOptions }>Далее</button>
</form>
</div>
{ loading && (

View File

@ -219,6 +219,9 @@ class ChangeGraphicPage extends React.Component
}
}
console.log("variantsvariantsvariantsvariantsvariants???????????");
console.log(variants);
getContractGraphicChangeVariants({ dispatch: this.props.dispatch, number: this.props.number, variants })
.then(() =>
{
@ -323,7 +326,14 @@ class ChangeGraphicPage extends React.Component
<InnerMenu number={ number } { ...this.props } />
<article className="changes">
{ mode_options ? (
<Options onVariants={ this._handle_onVariants } onCalculate={ this._handle_onCalculate }/>
<Options
dispatch={ this.props.dispatch }
number={ number }
variants={ variants }
options={ options }
onVariants={ this._handle_onVariants }
onCalculate={ this._handle_onCalculate }
/>
) : (
<>
{ variants !== null && (

View File

@ -135,7 +135,9 @@ class SupportAppealsPage extends React.Component
<div className="item_header">
<p>Номер обращения: <b>{ appeal.number } от { moment(appeal.created_date, "YYYY-MM-DD").format("DD.MM.YYYY") }</b></p>
<p>Отвественный ОРК: <b>{ appeal.owner }</b></p>
<p>Договор(ы): <b>{ appeal.contracts }</b></p>
{ appeal.contracts.length > 0 && (
<p>Договор{ appeal.contracts.length > 1 && "ы" }: <b>{ appeal.contracts.map((contract, contract_index) => (<span key={ contract_index }> { contract }{ contract_index < appeal.contracts.length - 1 && ", " }</span>)) }</b></p>
) }
<div className="status" style={{ backgroundColor: status[appeal.status].color }}>{ status[appeal.status].title }</div>
</div>
<div className="item_body">