This commit is contained in:
vchikalkin 2024-07-04 17:26:39 +03:00
parent 595d4f34f9
commit 70d26e472f

View File

@ -6,7 +6,7 @@ import { selectLeaseObjectUseFor } from '@/config/default-options';
import * as CRMTypes from '@/graphql/crm.types'; import * as CRMTypes from '@/graphql/crm.types';
import { normalizeOptions } from '@/utils/entity'; import { normalizeOptions } from '@/utils/entity';
import { debouncedReaction, disposableReaction } from '@/utils/mobx'; import { debouncedReaction, disposableReaction } from '@/utils/mobx';
import { comparer, reaction } from 'mobx'; import { reaction } from 'mobx';
export function common({ store, apolloClient }: ProcessContext) { export function common({ store, apolloClient }: ProcessContext) {
const { $calculation, $tables, $process } = store; const { $calculation, $tables, $process } = store;
@ -304,16 +304,13 @@ export function common({ store, apolloClient }: ProcessContext) {
} }
); );
debouncedReaction( reaction(
() => { () => $calculation.$values.getValues(['leaseObjectType', 'maxMass']),
const values = $calculation.$values.getValues(['leaseObjectType', 'maxMass']); async ({ leaseObjectType: leaseObjectTypeId, maxMass }) => {
const osago = $tables.insurance.row('osago').getValues();
return { ...values, osago };
},
async ({ leaseObjectType: leaseObjectTypeId, maxMass, osago }) => {
if (!leaseObjectTypeId) { if (!leaseObjectTypeId) {
$tables.insurance.row('osago').column('insuranceCompany').unblock(); $tables.insurance.row('osago').column('insuranceCompany').unblock();
$tables.insurance.row('osago').column('insured').unblock();
$tables.insurance.row('osago').column('insCost').unblock();
return; return;
} }
@ -333,7 +330,7 @@ export function common({ store, apolloClient }: ProcessContext) {
query: CRMTypes.GetInsuranceCompaniesDocument, query: CRMTypes.GetInsuranceCompaniesDocument,
}); });
if (evo_leasingobject_type?.evo_id === '9' && maxMass < 20 && osago.insured === 100_000_000) { if (evo_leasingobject_type?.evo_id === '9' && maxMass < 20) {
const otherInsuranceCompany = accounts?.find( const otherInsuranceCompany = accounts?.find(
(x) => x?.evo_type_ins_policy === null && x.label?.includes('ПРОЧИЕ') (x) => x?.evo_type_ins_policy === null && x.label?.includes('ПРОЧИЕ')
); );
@ -346,14 +343,14 @@ export function common({ store, apolloClient }: ProcessContext) {
.setValue(otherInsuranceCompany.value) .setValue(otherInsuranceCompany.value)
.block(); .block();
} }
$tables.insurance.row('osago').column('insured').setValue(100_000_000).block();
$tables.insurance.row('osago').column('insCost').setValue(0).block();
} else { } else {
$tables.insurance.row('osago').column('insuranceCompany').unblock(); $tables.insurance.row('osago').column('insuranceCompany').unblock();
$tables.insurance.row('osago').column('insured').unblock();
$tables.insurance.row('osago').column('insCost').unblock();
} }
},
{
delay: 1,
equals: comparer.structural,
wait: 100,
} }
); );
} }