updates for form validation, closing form edit in PDF

This commit is contained in:
merelendor 2023-04-13 09:29:16 +03:00
parent 2b88437b14
commit 4f95781c13
10 changed files with 288 additions and 178 deletions

View File

@ -9,7 +9,7 @@ import { SpinnerCircular } from 'spinners-react';
import { connect } from "react-redux";
import { withRouter } from 'next/router';
import InputMask from 'react-input-mask';
import CurrencyInput from 'react-currency-input';
import CurrencyInput from 'react-currency-input-field';
import QuestionnaireForm from "../QuestionnaireForm";
import { reduxWrapper } from '../../../../store';
@ -102,7 +102,7 @@ class Form_1_Main extends QuestionnaireForm
if(main.websiteurl !== null && main.websiteurl !== "")
{
const r = new RegExp('^(http:\/\/|^https:\/\/)?[a-zA-ZА-я0-9][a-zA-ZА-я0-9-]{1,61}[a-zA-ZА-я0-9](?:\.[a-zA-ZА-я]{2,})+', 'g');
const r = new RegExp('^(http:\/\/|https:\/\/)?[A-zА-я0-9][A-zА-я0-9-]{1,61}[A-zА-я0-9](?:\.[A-zА-я]{2,})+', 'g');
if(!r.test(main.websiteurl))
{
errors.push(`main.websiteurl`);
@ -243,7 +243,8 @@ class Form_1_Main extends QuestionnaireForm
placeholder="Например https://example.com"
onChange={ (event) => { this._removeError(event.target.name); this._handle_onTextFieldChange(event.target.name, event.target.value); } }
disabled={ checking }
pattern="^(http:\/\/|^https:\/\/)?[a-zA-ZА-я0-9][a-zA-ZА-я0-9-]{1,61}[a-zA-ZА-я0-9](?:\.[a-zA-ZА-я]{2,})+"
//pattern="[A-zА-я0-9\-]+"
pattern="^(http:\/\/|https:\/\/)?[A-zА-я0-9][A-zА-я0-9\-]{1,61}[A-zА-я0-9](?:\.[A-zА-я]{2,})+"
/>
</div>
</div>
@ -270,10 +271,14 @@ class Form_1_Main extends QuestionnaireForm
id="main.financial_loan"
name="main.financial_loan"
value={ this._checkStrValue(main.financial_loan) !== "" && parseFloat(main.financial_loan) > 0 ? this._checkStrValue(main.financial_loan) : null }
precision="0"
selectAllOnFocus={ true }
decimalsLimit={ 2 }
//selectAllOnFocus={ true }
placeholder="Укажите сумму"
onChangeEvent={ (event) => { this._removeError("main.financial_loan"); this._handle_onTextFieldChange(event.target.name, event.target.value); } }
decimalSeparator="."
groupSeparator=" "
suffix=" ₽"
maxLength={ 12 }
onValueChange={ (value, name) => { this._removeError(name); this._handle_onTextFieldChange(name, value); } }
required={ true }
disabled={ checking }
/>

View File

@ -91,7 +91,7 @@ class Form_2_Contacts extends QuestionnaireForm
errors.push(`contacts.fact_address`);
}
if(main.mail_delivery_address_type === 100000002)
if(parseInt(main.mail_delivery_address_type, 10) === 100000002)
{
if(contacts.postal_address.name === "")
{

View File

@ -30,6 +30,38 @@ import { removeAttachmentFiles, saveQuestionnaire, getSuggests } from "../../../
import DocumentIssuerSuggestsInput from "../../DocumentIssuerSuggestsInput";
import FormMessage from "../FormMessage";
const is_valid_inn = (i) =>
{
if ( i.match(/\D/) ) return false;
var inn = i.match(/(\d)/g);
if ( inn.length == 10 )
{
return inn[9] == String(((
2*inn[0] + 4*inn[1] + 10*inn[2] +
3*inn[3] + 5*inn[4] + 9*inn[5] +
4*inn[6] + 6*inn[7] + 8*inn[8]
) % 11) % 10);
}
else if ( inn.length == 12 )
{
return inn[10] == String(((
7*inn[0] + 2*inn[1] + 4*inn[2] +
10*inn[3] + 3*inn[4] + 5*inn[5] +
9*inn[6] + 4*inn[7] + 6*inn[8] +
8*inn[9]
) % 11) % 10) && inn[11] == String(((
3*inn[0] + 7*inn[1] + 2*inn[2] +
4*inn[3] + 10*inn[4] + 3*inn[5] +
5*inn[6] + 9*inn[7] + 4*inn[8] +
6*inn[9] + 8*inn[10]
) % 11) % 10);
}
return false;
}
const suggestsInnDebounce = (query) =>
{
return getSuggests("inn", { query });
@ -100,8 +132,8 @@ class Form_3_Signer extends QuestionnaireForm
middlename: "",
no_middle_name: false,
jobtitle: "",
signer_rule_basis: "",
signer_rule_basis_add: "",
signer_rule_basic: "",
signer_rule_basic_add: "",
docdate: "",
docnumber: "",
delegation_agreement: false,
@ -283,7 +315,7 @@ class Form_3_Signer extends QuestionnaireForm
{
this._handle_onBranchChange([
{ name: `${ branch }.identity_document.doctype`, value: element.value },
{ name: `${ branch }.identity_document.citizenship_code`, value: element.value === 100000000 ? 643 : null },
{ name: `${ branch }.identity_document.citizenship_code`, value: parseInt(element.value, 10) === 100000000 ? 643 : null },
]);
}
@ -300,7 +332,6 @@ class Form_3_Signer extends QuestionnaireForm
"lastname",
"firstname",
"jobtitle",
"telephone",
"email",
"identity_document.seria",
"identity_document.docnumber",
@ -375,6 +406,17 @@ class Form_3_Signer extends QuestionnaireForm
}
}
if(head_person.telephone === "" || head_person.telephone === null || isNaN(parseInt(head_person.telephone.replace(/[^\d]+/g, ''), 10)) || parseInt(head_person.telephone.replace(/[^\d]+/g, ''), 10).toString().length < 11)
{
errors.push(`head_person.telephone`);
}
const email_regex = new RegExp(/[^@\s]+@[^@\s]+\.[^@\s]+/);
if(!email_regex.test(head_person.email))
{
errors.push(`head_person.email`);
}
//переданы
if(signatory_person.delegation_agreement)
{
@ -390,9 +432,19 @@ class Form_3_Signer extends QuestionnaireForm
{
let v = _get(main, main_check[i]);
if(v === "" || v === null)
if(main_check[i] === "individual_executive_inn")
{
errors.push(`main.${ main_check[i] }`);
if(!is_valid_inn(v.replace(/[^\d]+/g, '')))
{
errors.push(`main.individual_executive_inn`);
}
}
else
{
if(v === "" || v === null)
{
errors.push(`main.${ main_check[i] }`);
}
}
}
@ -406,8 +458,7 @@ class Form_3_Signer extends QuestionnaireForm
"lastname",
"firstname",
"jobtitle",
"signer_rule_basis",
"telephone",
"signer_rule_basic",
"email",
"identity_document.seria",
"identity_document.docnumber",
@ -415,8 +466,6 @@ class Form_3_Signer extends QuestionnaireForm
"identity_document.placebirth",
"identity_document.citizenship.code",
"identity_document.registration_address.name",
"docnumber",
"docdate",
];
if(parseInt(_get(signatory_person, "identity_document.doctype"), 10) === 100000000)
@ -425,15 +474,30 @@ class Form_3_Signer extends QuestionnaireForm
signatory_person_check.push("identity_document.issueby");
}
if(signatory_person.signer_rule_basis === 100000003)
if(parseInt(signatory_person.signer_rule_basic, 10) === 100000003)
{
signatory_person_check.push("signer_rule_basis_add");
signatory_person_check.push("signer_rule_basic_add");
}
if(signatory_person.signer_rule_basis === 100000001 || signatory_person.signer_rule_basis === 100000003)
if(signatory_person.telephone === "" || signatory_person.telephone === null || isNaN(parseInt(signatory_person.telephone.replace(/[^\d]+/g, ''), 10)) || parseInt(signatory_person.telephone.replace(/[^\d]+/g, ''), 10).toString().length < 11)
{
errors.push(`signatory_person.telephone`);
}
const email_regex = new RegExp(/[^@\s]+@[^@\s]+\.[^@\s]+/);
if(!email_regex.test(signatory_person.email))
{
errors.push(`signatory_person.email`);
}
if(signatory_person_files.length === 0) { errors.push(`signatory_person_files`); }
if(parseInt(signatory_person.signer_rule_basic, 10) === 100000000 || parseInt(signatory_person.signer_rule_basic, 10) === 100000003)
{
signatory_person_check.push("docdate");
signatory_person_check.push("docnumber");
if(signatory_corporate_files.length === 0) { errors.push(`signatory_corporate_files`); }
}
for(let i in signatory_person_check)
@ -445,9 +509,6 @@ class Form_3_Signer extends QuestionnaireForm
errors.push(`signatory_person.${ signatory_person_check[i] }`);
}
}
if(signatory_person_files.length === 0) { errors.push(`signatory_person_files`); }
if(signatory_corporate_files.length === 0) { errors.push(`signatory_corporate_files`); }
}
if(head_person_files.length === 0) { errors.push(`head_person_files`); }
@ -712,13 +773,14 @@ class Form_3_Signer extends QuestionnaireForm
<div className="form_field">
<label>Адрес E-mail <sup className="required_label">*</sup></label>
<input type="text"
<input type="email"
className={ errors.indexOf("head_person.email") > -1 ? "error" : "" }
id={ "head_person.email" }
name={ "head_person.email" }
value={ this._checkStrValue(head_person.email) }
placeholder="Введите E-mail"
onChange={ (event) => { this._removeError(event.target.name); this._handle_onTextFieldChange(event.target.name, event.target.value); } }
pattern="[^@\s]+@[^@\s]+\.[^@\s]+"
required={ true }
disabled={ checking }
/>
@ -817,6 +879,11 @@ class Form_3_Signer extends QuestionnaireForm
<React.Fragment>
<p className="title">Информация об управляющей организации или управляющем</p>
{ errors.indexOf("main.individual_executive_inn") > -1 &&
(
<FormMessage type="error" title="Ошибка" message="Указанный вами ИНН невалиден, пожалуйста, убедитесь в правильности ввода."/>
) }
<div className="formgroup" style={{ width: "100%" }}>
<div className="form_field" style={{ flexDirection: "row", flexWrap: "nowrap" }}>
<label>ИНН <sup className="required_label">*</sup></label>
@ -1157,13 +1224,14 @@ class Form_3_Signer extends QuestionnaireForm
<div className="form_field">
<label>E-mail <sup className="required_label">*</sup></label>
<input type="text"
<input type="email"
className={ errors.indexOf("signatory_person.email") > -1 ? "error" : "" }
id="signatory_person.email"
name="signatory_person.email"
value={ this._checkStrValue(signatory_person.email) }
placeholder="E-mail"
onChange={ (event) => { this._removeError("signatory_person.email"); this._handle_onTextFieldChange(event.target.name, event.target.value); } }
pattern="[^@\s]+@[^@\s]+\.[^@\s]+"
required={ true }
disabled={ checking }
/>
@ -1190,38 +1258,38 @@ class Form_3_Signer extends QuestionnaireForm
<div className="form_field">
<label>Право подписи на основании <sup className="required_label">*</sup></label>
<Select
id="signatory_person.signer_rule_basis"
name="signatory_person.signer_rule_basis"
id="signatory_person.signer_rule_basic"
name="signatory_person.signer_rule_basic"
options={ doctypes_corporate }
placeholder="Вид документа"
noOptionsMessage={ ({ inputValue }) => !inputValue ? noOptionsText :"Ничего не найдено" }
isSearchable={ true }
className="autocomlete"
classNamePrefix="react-select"
value={ doctypes_corporate.filter((type) => signatory_person.signer_rule_basis === type.value) }
onChange={ (element) => { this._removeError("signatory_person.signer_rule_basis"); this._handle_onTextFieldChange(`signatory_person.signer_rule_basis`, element.value); } }
value={ doctypes_corporate.filter((type) => signatory_person.signer_rule_basic === type.value) }
onChange={ (element) => { this._removeError("signatory_person.signer_rule_basic"); this._handle_onTextFieldChange(`signatory_person.signer_rule_basic`, element.value); } }
required={ true }
isDisabled={ checking }
/>
</div>
{ signatory_person.signer_rule_basis === 100000003 && (
{ parseInt(signatory_person.signer_rule_basic, 10) === 100000003 && (
<div className="form_field">
<label>Наименование документа <sup className="required_label">*</sup></label>
<input type="text"
className={ errors.indexOf("signatory_person.signer_rule_basis_add") > -1 ? "error" : "" }
id="signatory_person.signer_rule_basis_add"
name="signatory_person.signer_rule_basis_add"
value={ this._checkStrValue(signatory_person.signer_rule_basis_add) }
className={ errors.indexOf("signatory_person.signer_rule_basic_add") > -1 ? "error" : "" }
id="signatory_person.signer_rule_basic_add"
name="signatory_person.signer_rule_basic_add"
value={ this._checkStrValue(signatory_person.signer_rule_basic_add) }
placeholder="Наименование документа"
onChange={ (event) => { this._removeError("signatory_person.signer_rule_basis_add"); this._handle_onTextFieldChange(event.target.name, event.target.value); } }
onChange={ (event) => { this._removeError("signatory_person.signer_rule_basic_add"); this._handle_onTextFieldChange(event.target.name, event.target.value); } }
required={ true }
disabled={ checking }
/>
</div>
) }
{ (signatory_person.signer_rule_basis === 100000000 || signatory_person.signer_rule_basis === 100000003) && (
{ (parseInt(signatory_person.signer_rule_basic, 10) === 100000000 || parseInt(signatory_person.signer_rule_basic, 10) === 100000003) && (
<>
<div className="formgroup">
<div className="form_field">

View File

@ -126,7 +126,7 @@ class ShareholderForm extends React.Component
name={ `founder_persons[${ index }].telephone` }
value={ this._checkStrValue(shareholder.telephone) }
placeholder="Введите номер телефона"
onChange={ (event) => { this._removeError("telephone"); this._handle_onTextFieldChange(event.target.name, event.target.value) } }
onChange={ (event) => { if(event.target.value !== "" && !isNaN(parseInt(event.target.value.replace(/[^\d]+/g, ''), 10)) && parseInt(event.target.value.replace(/[^\d]+/g, ''), 10) > 7) { this._removeError("telephone"); } this._handle_onTextFieldChange(event.target.name, event.target.value) } }
required={ true }
disabled={ checking }
/>
@ -134,13 +134,14 @@ class ShareholderForm extends React.Component
<div className="form_field">
<label>Адрес E-mail <sup className="required_label">*</sup></label>
<input type="text"
<input type="email"
className={ errors.indexOf("email") > -1 ? "error" : "" }
id={ `founder_persons[${ index }].email` }
name={ `founder_persons[${ index }].email` }
value={ this._checkStrValue(shareholder.email) }
placeholder="Введите E-mail"
onChange={ (event) => { this._removeError("email"); this._handle_onTextFieldChange(event.target.name, event.target.value) } }
pattern="[^@\s]+@[^@\s]+\.[^@\s]+"
required={ true }
disabled={ checking }
/>
@ -297,6 +298,50 @@ class ShareholderForm extends React.Component
/>
</div>
<div className="form_field">
<label>Доля в уставном капитале (%) <sup className="required_label">*</sup></label>
<InputMask
className={ errors.indexOf("founder_part") > -1 ? "error" : "" }
mask='999'
formatChars={{ '9': '[0-9]', }}
id={ `founder_persons[${ index }].founder_part` }
name={ `founder_persons[${ index }].founder_part` }
value={ this._checkStrValue(shareholder.founder_part) }
placeholder="Укажите размер доли"
onChange={ (event) => { this._removeError("founder_part"); this._handle_onTextFieldChange(event.target.name, parseInt(event.target.value, 10) > 100 ? 100 : parseInt(event.target.value, 10)); } }
required={ true }
disabled={ checking }
/>
</div>
<div className="form_field">
<label>Является ли бенифиальным владельцем</label>
<div className="formgroup">
<div className="form_field checkbox">
<input type="radio" hidden=""
value="1"
id={ `founder_persons[${ index }].is_beneficial_1` }
name={ `founder_persons[${ index }].is_beneficial` }
checked={ shareholder.is_beneficial ? true : false }
onChange={ (event) => this._handle_onCheckboxFieldChange(event.target.name, parseInt(event.target.value, 10)) }
disabled={ checking }
/>
<label className="unselectable" htmlFor={ `founder_persons[${ index }].is_beneficial_1` }>Да</label>
</div>
<div className="form_field checkbox">
<input type="radio" hidden=""
value="0"
id={ `founder_persons[${ index }].is_beneficial_0` }
name={ `founder_persons[${ index }].is_beneficial` }
checked={ shareholder.is_beneficial ? false : true }
onChange={ (event) => this._handle_onCheckboxFieldChange(event.target.name, parseInt(event.target.value, 10)) }
disabled={ checking }
/>
<label className="unselectable" htmlFor={ `founder_persons[${ index }].is_beneficial_0` }>Нет</label>
</div>
</div>
</div>
</React.Fragment>
)
}
@ -341,137 +386,85 @@ class Shareholder extends React.Component
<React.Fragment>
<div className="added_person">
{ index > 0 && (
<div className="form_field">
<label>Физическое лицо { index + 1 }</label>
<div className="formgroup control">
<div className="form_field">
<label>Физическое лицо { index + 1 }</label>
<div className="formgroup control">
{ !checking && (
<div className="form_field checkbox">
<input type="checkbox" hidden=""
checked={ shareholder.founder_from_list }
id={ `founder_persons[${ index }].founder_from_list` }
name={ `founder_persons[${ index }].founder_from_list` }
onChange={ (event) => clearFounderFromListSelection(`founder_persons[${ index }]`, { founder_from_list: !shareholder.founder_from_list ? true : false, lastname: "", firstname: "", middlename: "", no_middle_name: false, }) }
{ !checking && (
<div className="form_field checkbox">
<input type="checkbox" hidden=""
checked={ shareholder.founder_from_list }
id={ `founder_persons[${ index }].founder_from_list` }
name={ `founder_persons[${ index }].founder_from_list` }
onChange={ (event) => clearFounderFromListSelection(`founder_persons[${ index }]`, { founder_from_list: !shareholder.founder_from_list ? true : false, lastname: "", firstname: "", middlename: "", no_middle_name: false, }) }
/>
<label className="unselectable" htmlFor={ `founder_persons[${ index }].founder_from_list` }>Выбрать из списка</label>
</div>
) }
{ !checking && (
<button className="delete" onClick={ (event) => { event.preventDefault(); removeShareholder(index) } }>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20.25 5.25L3.75 5.25001" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M9.75 9.75V15.75" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M14.25 9.75V15.75" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M18.75 5.25V19.5C18.75 19.6989 18.671 19.8897 18.5303 20.0303C18.3897 20.171 18.1989 20.25 18 20.25H6C5.80109 20.25 5.61032 20.171 5.46967 20.0303C5.32902 19.8897 5.25 19.6989 5.25 19.5V5.25" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M15.75 5.25V3.75C15.75 3.35218 15.592 2.97064 15.3107 2.68934C15.0294 2.40804 14.6478 2.25 14.25 2.25H9.75C9.35218 2.25 8.97064 2.40804 8.68934 2.68934C8.40804 2.97064 8.25 3.35218 8.25 3.75V5.25" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
</button>
) }
</div>
</div>
{ shareholder.founder_from_list ? (
<div className="feed">
<div className="feed_list">
{ contacts !== undefined && contacts !== null && contacts.map((contact, s_index) =>
{
const hash = `${ contact.lastname }_${ contact.firstname }_${ contact.middlename }`;
const disabled = hash !== shareholder.hash ? this._checkContactListDisabled(hash) : false;
if(checking)
{
if(shareholder.hash !== hash)
{
return null;
}
}
return (
<div className="form_field checkbox" key={ s_index }>
<input type="radio" hidden=""
id={ `founder_persons[${ index }].contact_${ hash }` }
name={ `founder_persons[${ index }].contact_${ hash }` }
checked={ hash === shareholder.hash }
onChange={ () => changeFounderSelectionFromList(`founder_persons[${ index }]`, { ...shareholder, ...contact, ...{
founder_from_list: false,
founder_number: shareholders.length,
} }) }
disabled={ disabled }
/>
<label className="unselectable" htmlFor={ `founder_persons[${ index }].founder_from_list` }>Выбрать из списка</label>
</div>
) }
{ !checking && (
<button className="delete" onClick={ (event) => { event.preventDefault(); removeShareholder(index) } }>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20.25 5.25L3.75 5.25001" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M9.75 9.75V15.75" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M14.25 9.75V15.75" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M18.75 5.25V19.5C18.75 19.6989 18.671 19.8897 18.5303 20.0303C18.3897 20.171 18.1989 20.25 18 20.25H6C5.80109 20.25 5.61032 20.171 5.46967 20.0303C5.32902 19.8897 5.25 19.6989 5.25 19.5V5.25" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M15.75 5.25V3.75C15.75 3.35218 15.592 2.97064 15.3107 2.68934C15.0294 2.40804 14.6478 2.25 14.25 2.25H9.75C9.35218 2.25 8.97064 2.40804 8.68934 2.68934C8.40804 2.97064 8.25 3.35218 8.25 3.75V5.25" stroke="#ED0A34" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
</button>
) }
<label className="unselectable" style={ disabled ? { opacity: "0.5" } : {} } htmlFor={ `founder_persons[${ index }].contact_${ hash }` }>
<div className="feed_item user">
<img src="/assets/images/icons/avatar.svg" alt="" />
<div>
<p className="item_title">{ contact.lastname } { contact.firstname } { contact.middlename }</p>
<p className="item_desc">
<span>{ contact.jobtitle }</span>
</p>
</div>
</div>
</label>
</div>
);
}) }
</div>
</div>
) }
{ index > 0 ? (
<React.Fragment>
{ shareholder.founder_from_list ? (
<div className="feed">
<div className="feed_list">
{ contacts !== undefined && contacts !== null && contacts.map((contact, s_index) =>
{
const hash = `${ contact.lastname }_${ contact.firstname }_${ contact.middlename }`;
const disabled = hash !== shareholder.hash ? this._checkContactListDisabled(hash) : false;
if(checking)
{
if(shareholder.hash !== hash)
{
return null;
}
}
return (
<div className="form_field checkbox" key={ s_index }>
<input type="radio" hidden=""
id={ `founder_persons[${ index }].contact_${ hash }` }
name={ `founder_persons[${ index }].contact_${ hash }` }
checked={ hash === shareholder.hash }
onChange={ () => changeFounderSelectionFromList(`founder_persons[${ index }]`, { ...shareholder, ...contact, ...{
founder_from_list: false,
founder_number: shareholders.length,
} }) }
disabled={ disabled }
/>
<label className="unselectable" style={ disabled ? { opacity: "0.5" } : {} } htmlFor={ `founder_persons[${ index }].contact_${ hash }` }>
<div className="feed_item user">
<img src="/assets/images/icons/avatar.svg" alt="" />
<div>
<p className="item_title">{ contact.lastname } { contact.firstname } { contact.middlename }</p>
<p className="item_desc">
<span>{ contact.jobtitle }</span>
</p>
</div>
</div>
</label>
</div>
);
}) }
</div>
</div>
) : (
<ShareholderForm index={ index } shareholder={ shareholder } { ...this.props } />
) }
</React.Fragment>
) : (
<ShareholderForm index={ index } shareholder={ shareholder } { ...this.props } />
) }
<div className="form_field">
<label>Доля в уставном капитале (%) <sup className="required_label">*</sup></label>
<InputMask
className={ errors.indexOf("founder_part") > -1 ? "error" : "" }
mask='999'
formatChars={{ '9': '[0-9]', }}
id={ `founder_persons[${ index }].founder_part` }
name={ `founder_persons[${ index }].founder_part` }
value={ this._checkStrValue(shareholder.founder_part) }
placeholder="Укажите размер доли"
onChange={ (event) => { this._removeError("founder_part"); this._handle_onTextFieldChange(event.target.name, parseInt(event.target.value, 10) > 100 ? 100 : parseInt(event.target.value, 10)); } }
required={ true }
disabled={ checking }
/>
</div>
<div className="form_field">
<label>Является ли бенифиальным владельцем</label>
<div className="formgroup">
<div className="form_field checkbox">
<input type="radio" hidden=""
value="1"
id={ `founder_persons[${ index }].is_beneficial_1` }
name={ `founder_persons[${ index }].is_beneficial` }
checked={ shareholder.is_beneficial ? true : false }
onChange={ (event) => this._handle_onCheckboxFieldChange(event.target.name, parseInt(event.target.value, 10)) }
disabled={ checking }
/>
<label className="unselectable" htmlFor={ `founder_persons[${ index }].is_beneficial_1` }>Да</label>
</div>
<div className="form_field checkbox">
<input type="radio" hidden=""
value="0"
id={ `founder_persons[${ index }].is_beneficial_0` }
name={ `founder_persons[${ index }].is_beneficial` }
checked={ shareholder.is_beneficial ? false : true }
onChange={ (event) => this._handle_onCheckboxFieldChange(event.target.name, parseInt(event.target.value, 10)) }
disabled={ checking }
/>
<label className="unselectable" htmlFor={ `founder_persons[${ index }].is_beneficial_0` }>Нет</label>
</div>
</div>
</div>
</div>
</React.Fragment>
@ -640,7 +633,7 @@ class Form_4_Shareholders extends QuestionnaireForm
{
this._handle_onBranchChange([
{ name: `${ branch }.identity_document.doctype`, value: element.value },
{ name: `${ branch }.identity_document.citizenship_code`, value: element.value === 100000000 ? 643 : null },
{ name: `${ branch }.identity_document.citizenship_code`, value: parseInt(element.value, 10) === 100000000 ? 643 : null },
]);
}
@ -690,10 +683,27 @@ class Form_4_Shareholders extends QuestionnaireForm
for(let i in check)
{
const v = _get(founder_persons[f], check[i]);
if(v === "" || v === null)
if(check[i] === "telephone")
{
errors[f].push(check[i]);
if(v === "" || v === null || isNaN(parseInt(v.replace(/[^\d]+/g, ''), 10)) || parseInt(v.replace(/[^\d]+/g, ''), 10).toString().length < 11)
{
errors[f].push(`telephone`);
}
}
else if(check[i] === "email")
{
const r = new RegExp(/[^@\s]+@[^@\s]+\.[^@\s]+/);
if(!r.test(v))
{
errors[f].push(`email`);
}
}
else
{
if(v === "" || v === null)
{
errors[f].push(check[i]);
}
}
}
}
@ -795,12 +805,12 @@ class Form_4_Shareholders extends QuestionnaireForm
{ !checking && (
<div className="action">
{ founder_persons.length < 4 ? (
<button className="button button-blue" disabled={ false } onClick={ (event) => { event.preventDefault(); this._handle_onAddShareholder(); }}>Добавить еще одного владельца</button>
<button className="button button-blue" disabled={ false } onClick={ (event) => { event.preventDefault(); this._handle_onAddShareholder(); }}>{ founder_persons.length === 0 ? "Добавить владельца" : "Добавить еще одного владельца" }</button>
) : (
<div></div>
) }
<div>
<button type="submit" className="button button-blue" onClick={ this._handle_onNextPage }>
<button type="submit" className="button button-blue" onClick={ this._handle_onNextPage } disabled={ founder_persons.length === 0 ? true : founder_persons[0].founder_from_list ? true : false }>
{ loading ? (
<SpinnerCircular size={24} thickness={100} speed={100} color="rgba(255, 255, 255, 1)" secondaryColor="rgba(255, 255, 255, 0.5)" style={{ marginTop: "4px" }}/>
) : "Продолжить" }

View File

@ -41,6 +41,7 @@
"react": "17.0.2",
"react-cookie": "^4.1.1",
"react-currency-input": "^1.3.6",
"react-currency-input-field": "^3.6.10",
"react-dom": "17.0.2",
"react-dropzone": "^14.2.2",
"react-google-recaptcha-v3": "^1.10.0",

View File

@ -55,7 +55,7 @@ const fields = {
signatory_person: {
fullname: { name: "signer_fullname", type: "text", bind: null },
jobtitle: { name: "signer_jobtitle", type: "text", bind: null },
signer_rule_basis: { name: "signer_reason", type: "text", bind: null },
signer_rule_basic: { name: "signer_reason", type: "text", bind: null },
docdate: { name: "signer_docdate", type: "text", bind: null, date: true },
docnumber: { name: "signer_docnum", type: "text", bind: null },
telephone: { name: "signer_phone", type: "text", bind: null },
@ -306,6 +306,7 @@ export default async function handler(req, res)
}
form.updateFieldAppearances(formFont);
form.flatten();
const pdfBytes = await pdfDoc.save();
//responseType: 'blob',

View File

@ -16,6 +16,8 @@ export default async function handler(req, res)
console.log("API", "questionnaire", "save");
await cors(req, res);
const uploads = `${ __dirname }/../../../../../uploads/`;
return new Promise(async (resolve) =>
{
if(req.headers.cookie !== undefined)
@ -28,6 +30,15 @@ export default async function handler(req, res)
var crm_jwt = jwt.sign({ acc_number: client_jwt_decoded.acc_number }, process.env.JWT_SECRET_CRM, { noTimestamp: true });
const key = md5(`questionnaire_${ client_jwt_decoded.acc_number }`);
const files = fs.readdirSync(uploads);
files.forEach(file =>
{
if(file.indexOf(client_jwt_decoded.acc_number) === 0)
{
fs.unlinkSync(`${ uploads }${ file }`);
}
});
await RedisClient.del(key);
res.status(200).send();

View File

@ -35,6 +35,8 @@ export default async function handler(req, res)
console.log("API", "questionnaire", "send");
await cors(req, res);
const uploads = `${ __dirname }/../../../../../uploads/`;
return new Promise((resolve) =>
{
if(req.headers.cookie !== undefined)
@ -69,7 +71,7 @@ export default async function handler(req, res)
try
{
fs.writeFileSync(`${ __dirname }/../../../../../uploads/${ local_filename }`, file.buffer);
fs.writeFileSync(`${ uploads }${ local_filename }`, file.buffer);
console.log("multer.upload.single file");
console.log({ questionnaire });
@ -194,7 +196,7 @@ export default async function handler(req, res)
{
//console.log(parsed.signatory_corporate_files[i]);
files_to_send.push({ ...parsed.signatory_corporate_files[i], ...{ number: 22, } })
}
}
files_to_send.push({ ...{
name: `${ client_jwt_decoded.acc_number }_questionnaire.pdf`,
@ -225,12 +227,9 @@ export default async function handler(req, res)
eachSeries(files_to_send, (file_entry, callback) =>
{
const file_to_send_data = fs.readFileSync(`${ __dirname }/../../../../../uploads/${ file_entry.filename }`);
const file_to_send_data = fs.readFileSync(`${ uploads }${ file_entry.filename }`);
const data = new FormData();
data.append("file", file_to_send_data, file_entry.name);
//data.append("entity", "evo_client_questionnaire");
//data.append("documentTypeNumber", file_entry.number);
//data.append("name", id);
console.log({ data });
@ -255,8 +254,18 @@ export default async function handler(req, res)
console.error("crm_file_upload_error", { status: crm_file_upload_error.response.status, data: crm_file_upload_error.response.data });
callback();
});
}, () =>
}, async () =>
{
const existed_files = fs.readdirSync(uploads);
existed_files.forEach(file =>
{
if(file.indexOf(client_jwt_decoded.acc_number) === 0)
{
fs.unlinkSync(`${ uploads }${ file }`);
}
});
await RedisClient.del(key);
res.status(200).send();
resolve();
});

View File

@ -77,8 +77,8 @@ export const questionnaire_template = {
middlename: null,
no_middle_name: false,
jobtitle: null,
signer_rule_basis: 100000000,
signer_rule_basis_add: null,
signer_rule_basic: 100000000,
signer_rule_basic_add: null,
docdate: null,
docnumber: null,
delegation_agreement: false,

View File

@ -5353,6 +5353,11 @@ react-cookie@^4.1.1:
hoist-non-react-statics "^3.0.0"
universal-cookie "^4.0.0"
react-currency-input-field@^3.6.10:
version "3.6.10"
resolved "https://registry.yarnpkg.com/react-currency-input-field/-/react-currency-input-field-3.6.10.tgz#f04663a2074b894735edb6d9fae95499727596b1"
integrity sha512-KRAJJaLujarBTLlEVbznsUxQ56+Qyqwoe5w9DnGxmsGnHv4ycQRpRkuuCDfF9BcXHmegzsOXesfIGpW7Cw9mTQ==
react-currency-input@^1.3.6:
version "1.3.6"
resolved "https://registry.yarnpkg.com/react-currency-input/-/react-currency-input-1.3.6.tgz#a25188302f823d10ad16979d755ccc50dc955892"