elt fixes

This commit is contained in:
vchikalkin 2021-07-13 14:43:39 +03:00
parent 6272747ec6
commit b967c76501
5 changed files with 25 additions and 17 deletions

View File

@ -1,6 +1,7 @@
import CalculationStore from 'client/stores/CalculationStore';
import UserStore from 'client/stores/UserStore';
import CrmService from 'core/services/CrmService';
import { Process } from 'core/types/Calculation/Store/process';
import getUser from './getUser';
import insuranceQuery from './queries/insuranceQuery';
import optionsQuery from './queries/optionsQuery';
@ -12,7 +13,8 @@ export default () =>
new Promise(async (resolve, reject) => {
await getUser();
const domainname = UserStore.getDomainName();
const { calculationProcess } = CalculationStore.stores;
calculationProcess.addProcess(Process.Init);
Promise.all([
CrmService.crmgqlquery({
...initialOwnerQuery,
@ -79,6 +81,8 @@ export default () =>
);
}
calculationProcess.deleteProcess(Process.Init);
resolve();
},
)

View File

@ -36,20 +36,22 @@ const eltReactions: IReactionEffect[] = [
) => ({
expression: () => {
return calculationStore.getValues(
//@ts-ignore
(resetFields as ElementsNames[]).map(getValueName),
);
},
effect: () => {
cancelRequests(insType);
if (
calculationProcess.hasProcess(Process.Init) ||
calculationProcess.hasProcess(Process.ELT) ||
calculationProcess.hasProcess(Process.LoadKp)
) {
return;
}
const { ELTStore } = calculationStore.stores;
if (ELTStore[insType].isReseted() === true) {
if (ELTStore[insType]?.isReseted()) {
return;
}
message.warn({ content: RESET_MESSAGES[insType] });
@ -75,14 +77,17 @@ const eltReactions: IReactionEffect[] = [
},
effect: () => {
cancelRequests(insType);
if (
calculationProcess.hasProcess(Process.Init) ||
calculationProcess.hasProcess(Process.ELT) ||
calculationProcess.hasProcess(Process.LoadKp)
) {
return;
}
const { ELTStore } = calculationStore.stores;
if (ELTStore[insType].isReseted() === true) {
if (ELTStore[insType]?.isReseted()) {
return;
}
message.warn({ content: RESET_MESSAGES[insType] });

View File

@ -13,7 +13,7 @@ import { Process } from 'core/types/Calculation/Store/process';
import { ValuesNames } from 'core/types/Calculation/Store/values';
import { IEvoGraph } from 'core/types/Entities/crmEntities';
import { ElementStatus } from 'core/types/statuses';
import { get, isNil } from 'lodash';
import { get, isEqual, isNil } from 'lodash';
import NIL from 'uuid/dist/nil';
import { getKpPropName } from './mapKpToValues';
import { mainOptionsQuery, secondaryOptionsQuery } from './optionsQuery';
@ -498,7 +498,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
x => x.accountid === quote.evo_kasko_accountid,
);
if (kaskoIndex !== undefined) {
if (kaskoIndex >= 0) {
const mapQuoteToELTKasko = {
key: 'evo_kasko_accountid',
accountid: 'evo_kasko_accountid',
@ -530,7 +530,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
const osagoIndex = ELTStore.osago.list.findIndex(
x => x.accountid === quote.evo_osago_accountid,
);
if (osagoIndex !== undefined) {
if (osagoIndex >= 0) {
const mapQuoteToELTOsago = {
key: 'evo_osago_accountid',
accountid: 'evo_osago_accountid',
@ -545,14 +545,11 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
if (!isNil(quoteValue)) row[rowFieldName] = quoteValue;
});
if (quote.evo_id_elt_osago) {
row['evo_id_elt_osago'] = parseInt(quote.evo_id_elt_osago);
if (row['numCalc']) {
row['numCalc'] = parseInt(row['numCalc']);
}
if (
Object.keys(mapQuoteToELTOsago).length + 1 ===
Object.keys(row).length
) {
if (isEqual(Object.keys(row), Object.keys(mapQuoteToELTOsago))) {
ELTStore.addToCompanyRes('osago', osagoIndex, row);
ELTStore.osago.setKey(quote.evo_osago_accountid);
}

View File

@ -1,6 +1,7 @@
// @ts-nocheck
import { initFields } from 'client/Components/Calculation/ELT/Content/lib/resetIns';
import { makeAutoObservable } from 'mobx';
import { isEqual } from 'lodash';
import { makeAutoObservable, toJS } from 'mobx';
const ELTStore = makeAutoObservable(
Object.assign(
@ -8,8 +9,8 @@ const ELTStore = makeAutoObservable(
...['osago', 'kasko'].map(x => ({
[x]: {
isReseted() {
return this.list.every(
x => Object.keys(x).length === initFields.length,
return this.list.every(x =>
isEqual(Object.keys(toJS(x)), initFields),
);
},
reset(list) {
@ -34,7 +35,7 @@ const ELTStore = makeAutoObservable(
},
addToCompanyRes(insType, index, res) {
const companyData = this[insType].list[index];
this[insType].list[index] = { ...companyData, ...res };
this[insType].list[index] = Object.assign(companyData, res);
},
},
),

View File

@ -1,4 +1,5 @@
export enum Process {
Init,
LoadKp,
RecalcWithoutRevision,
ELT,