На изменение поля Тариф selectTarif добавляем фильрацию в полях:
в поле Вид графика radioGraphType должны закрываться значения для выбора,
которые указаны в массиве поля "Недопустимые виды графиков" evo_graphtype_exception.
Если в массиве пусто, значит допустимы все значения
This commit is contained in:
parent
ee538152b4
commit
bdc360fec0
@ -122,6 +122,13 @@ export type GetCurrencySymbolQueryVariables = Exact<{
|
||||
|
||||
export type GetCurrencySymbolQuery = { __typename?: 'Query', transactioncurrency: { __typename?: 'transactioncurrency', currencysymbol: string | null } | null };
|
||||
|
||||
export type GetTarif_ProcessConfiguratorQueryVariables = Exact<{
|
||||
tarifId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetTarif_ProcessConfiguratorQuery = { __typename?: 'Query', evo_tarif: { __typename?: 'evo_tarif', evo_irr: number | null, evo_graphtype_exception: Array<number> | null } | null };
|
||||
|
||||
export type GetLeaseObjectTypes_ProcessConfiguratorQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
@ -167,13 +174,6 @@ export type GetTarifs_ProcessConfiguratorQueryVariables = Exact<{
|
||||
|
||||
export type GetTarifs_ProcessConfiguratorQuery = { __typename?: 'Query', evo_tarifs: Array<{ __typename?: 'evo_tarif', evo_tarifid: string | null, evo_baseproductid: string | null, evo_min_period: number | null, evo_max_period: number | null, evo_delivery_time: Array<number> | null, evo_min_first_payment: number | null, evo_max_first_payment: number | null, evo_min_last_payment: number | null, evo_max_last_payment: number | null, evo_used: boolean | null } | null> | null };
|
||||
|
||||
export type GetTarif_ProcessConfiguratorQueryVariables = Exact<{
|
||||
tarifId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetTarif_ProcessConfiguratorQuery = { __typename?: 'Query', evo_tarif: { __typename?: 'evo_tarif', evo_irr: number | null } | null };
|
||||
|
||||
export type GetRisksDataFromQuoteQueryVariables = Exact<{
|
||||
quoteId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
11
apps/web/process/configurator/lib/query.ts
Normal file
11
apps/web/process/configurator/lib/query.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const QUERY_GET_TARIF = gql`
|
||||
query GetTarif_ProcessConfigurator($tarifId: Uuid!) {
|
||||
evo_tarif(evo_tarifid: $tarifId) {
|
||||
evo_irr
|
||||
evo_graphtype_exception
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -4,6 +4,7 @@ import type * as CRMTypes from 'graphql/crm.types';
|
||||
import { reaction } from 'mobx';
|
||||
import type { ReactionsContext } from 'process/types';
|
||||
import { normalizeOptions } from 'tools';
|
||||
import { QUERY_GET_TARIF } from '../lib/query';
|
||||
|
||||
const QUERY_GET_LEASE_OBJECT_TYPES = gql`
|
||||
query GetLeaseObjectTypes_ProcessConfigurator {
|
||||
@ -264,4 +265,41 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex
|
||||
$calculation.element('selectDealerPerson').setOptions(normalizeOptions(dealerPersons));
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* На изменение поля Тариф selectTarif добавляем фильрацию в полях:
|
||||
в поле Вид графика radioGraphType должны закрываться значения для выбора,
|
||||
которые указаны в массиве поля "Недопустимые виды графиков" evo_graphtype_exception.
|
||||
Если в массиве пусто, значит допустимы все значения
|
||||
*/
|
||||
reaction(
|
||||
() => $calculation.element('selectTarif').getValue(),
|
||||
async (tarifId) => {
|
||||
let evo_tarif: CRMTypes.GetTarif_ProcessConfiguratorQuery['evo_tarif'] = null;
|
||||
|
||||
if (tarifId) {
|
||||
const { data } = await apolloClient.query<
|
||||
CRMTypes.GetTarif_ProcessConfiguratorQuery,
|
||||
CRMTypes.GetTarif_ProcessConfiguratorQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_TARIF,
|
||||
variables: {
|
||||
tarifId,
|
||||
},
|
||||
});
|
||||
|
||||
({ evo_tarif } = data);
|
||||
}
|
||||
|
||||
const filteredGraphTypes = $calculation
|
||||
.element('radioGraphType')
|
||||
.getOptions()
|
||||
.map((type) => ({
|
||||
...type,
|
||||
disabled: evo_tarif?.evo_graphtype_exception?.includes(type.value),
|
||||
}));
|
||||
|
||||
$calculation.element('radioGraphType').setOptions(filteredGraphTypes);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import { autorun, reaction } from 'mobx';
|
||||
import type * as CRMTypes from 'graphql/crm.types';
|
||||
import type { ReactionsContext } from 'process/types';
|
||||
import { makeDisposable } from 'tools';
|
||||
import { QUERY_GET_TARIF } from '../lib/query';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
@ -31,14 +32,6 @@ const QUERY_GET_TARIFS = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_TARIF = gql`
|
||||
query GetTarif_ProcessConfigurator($tarifId: Uuid!) {
|
||||
evo_tarif(evo_tarifid: $tarifId) {
|
||||
evo_irr
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default function valuesReactions({ store, apolloClient }: ReactionsContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
|
||||
@ -13,3 +13,8 @@ export const FORBIDDEN_HIGH_SEASON_START: Record<number, Array<string>> = {
|
||||
export const SEASONS_PERIOD_NUMBER = 12;
|
||||
|
||||
export const DEFAULT_SEASONS_VALUES = [100, 75, 50];
|
||||
|
||||
export const SEASON_TYPES = {
|
||||
100_000_001: [100_000_003, 100_000_004, 100_000_005, 100_000_006, 100_000_007],
|
||||
100_000_003: [100_000_000, 100_000_001, 100_000_002],
|
||||
};
|
||||
|
||||
@ -4,7 +4,6 @@ import { selectHighSeasonStart, selectSeasonType } from 'config/default-options'
|
||||
import { comparer, reaction, toJS } from 'mobx';
|
||||
import type { ReactionsContext } from 'process/types';
|
||||
import { shift } from 'radash';
|
||||
import type { CalculationOptions } from 'stores/calculation/options/types';
|
||||
import type { Row } from 'stores/tables/payments/types';
|
||||
import ValidationHelper from 'stores/validation/helper';
|
||||
import { difference } from 'tools/array';
|
||||
@ -208,11 +207,6 @@ export default function paymentsReactions({ store }: ReactionsContext) {
|
||||
/**
|
||||
* Дегрессия
|
||||
*/
|
||||
// TODO: const exeption = tarif?.evo_seasons_type_exception
|
||||
const degressionSeasonTypes = new Set([
|
||||
100_000_003, 100_000_004, 100_000_005, 100_000_006, 100_000_007,
|
||||
]);
|
||||
const seasonSeasonTypes = new Set([100_000_000, 100_000_001, 100_000_002]);
|
||||
|
||||
reaction(
|
||||
() => {
|
||||
@ -221,18 +215,23 @@ export default function paymentsReactions({ store }: ReactionsContext) {
|
||||
return graphType;
|
||||
},
|
||||
(graphType) => {
|
||||
let selectSeasonTypeOptions: CalculationOptions['selectSeasonType'] = [];
|
||||
if (!graphType) {
|
||||
$calculation.element('selectSeasonType').resetOptions();
|
||||
|
||||
if (graphType === 100_000_001) {
|
||||
selectSeasonTypeOptions = selectSeasonType.filter((option) =>
|
||||
degressionSeasonTypes.has(option.value)
|
||||
);
|
||||
} else if (graphType === 100_000_003) {
|
||||
selectSeasonTypeOptions = selectSeasonType.filter((option) =>
|
||||
seasonSeasonTypes.has(option.value)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (graphType === 100_000_001 || graphType === 100_000_003) {
|
||||
const allowedSeasonTypes = seasonsConstants.SEASON_TYPES[graphType];
|
||||
|
||||
const selectSeasonTypeOptions = selectSeasonType.filter((option) =>
|
||||
allowedSeasonTypes.includes(option.value)
|
||||
);
|
||||
|
||||
$calculation.element('selectSeasonType').setOptions(selectSeasonTypeOptions);
|
||||
} else {
|
||||
$calculation.element('selectSeasonType').resetOptions();
|
||||
}
|
||||
$calculation.element('selectSeasonType').setOptions(selectSeasonTypeOptions);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user