Добавить фильтр для поля selectProduct (работает на загрузку КП)

если  recalcWithRevision=True, то в списке поля selectProduct должны отображаться записи quote.evo_baseproductid из поля Предложение selectQuote + дать возможность выбирать продукт, связанный с оquote.evo_baseproductid из поля Предложение selectQuote по связи  evo_evo_baseproduct_evo_baseproduct
This commit is contained in:
Chika 2022-05-30 19:13:18 +03:00
parent 394b9447e8
commit 699f431969
9 changed files with 45 additions and 7 deletions

View File

@ -192,4 +192,32 @@ export default function ($calculation: ICalculationStore) {
},
{ fireImmediately: true },
);
/**
* @description
* Добавить фильтр для поля selectProduct (работает на загрузку КП)
* если recalcWithRevision=True, то в списке поля selectProduct должны отображаться
* записи quote.evo_baseproductid из поля Предложение selectQuote + дать возможность выбирать продукт,
* связанный с оquote.evo_baseproductid из поля Предложение selectQuote по связи evo_evo_baseproduct_evo_baseproduct
*/
reaction(
() => $calculation.getOption('selectQuote'),
quote => {
if ($calculation.getValue('recalcWithRevision')) {
const quote_product = $calculation.getOption('selectProduct', {
evo_baseproductid: quote?.evo_baseproductid,
});
$calculation.setFilter('selectProduct', products =>
products.filter(product =>
quote_product?.evo_baseproducts
?.map(x => x.evo_baseproductid)
.concat(quote?.evo_baseproductid)
.includes(product.evo_baseproductid),
),
);
} else {
$calculation.setFilter('selectProduct', undefined);
}
},
);
}

View File

@ -587,7 +587,6 @@ const elementsToDisable: (InteractionElementsNames | TableNames)[] = [
'tablePayments',
'selectLead',
'selectOpportunity',
'selectProduct',
'selectClientRisk',
'selectClientType',
'tbxLeasingPeriod',

View File

@ -4,10 +4,10 @@ import { TElementFilter } from 'core/types/Calculation/Store/filters';
const initialFilters: Partial<Record<ElementsNames, TElementFilter>> = {
selectSubsidy: subsidies =>
subsidies.filter(x =>
[100_000_000, 100_000_001].includes(x.evo_subsidy_type),
[100_000_000, 100_000_001].includes(x.evo_subsidy_type!),
),
selectImportProgram: subsidies =>
subsidies.filter(x => [100_000_002].includes(x.evo_subsidy_type)),
subsidies.filter(x => [100_000_002].includes(x.evo_subsidy_type!)),
};
export const noResetValueElements: ElementsNames[] = [

View File

@ -79,6 +79,11 @@ query GetMainOptions(
evo_cut_proportion_bonus_director
evo_cut_irr_with_bonus
evo_calculation_method
evo_baseproducts {
evo_id
evo_name
evo_baseproductid
}
}
selectRegistration: evo_addproduct_types(
statecode: $statecode

View File

@ -65,7 +65,6 @@ fragment quoteFields on quote {
evo_accept_control_addproduct_typeid
evo_payment_redemption_sum
evo_baseproductid
evo_client_typeid
evo_supplier_currency_price
evo_transactioncurrencyid

View File

@ -24,4 +24,5 @@ fragment quoteFieldsLite on quote {
evo_one_year_insurance
evo_last_payment_perc
evo_purchases_participation
evo_baseproductid
}

View File

@ -213,6 +213,7 @@ export interface IEvoBaseproduct extends BaseEntity {
evo_cut_proportion_bonus_director?: boolean;
evo_cut_irr_with_bonus?: boolean;
evo_calculation_method?: number[];
evo_baseproducts?: IEvoBaseproduct[];
}
export interface IEvoLeasingObjectType extends BaseEntity {

View File

@ -1,4 +1,9 @@
import { TOptionizedEntity } from 'core/services/CrmService/types/common';
import {
IBaseOption,
TOptionizedEntity,
} from 'core/services/CrmService/types/common';
import { CRMEntity } from 'core/services/CrmService/types/entities';
export type TElementFilter = (
options: TOptionizedEntity[],
options: (IBaseOption & CRMEntity)[],
) => TOptionizedEntity[];

View File

@ -39,7 +39,7 @@ interface ICalculationValues {
options: Record<ElementsNames, TOptionizedEntity[]>;
getOption: (
elementName: ElementsNames,
fields?: { [field in keyof TOptionizedEntity]?: any },
fields?: { [field in keyof (IBaseOption & CRMEntity)]?: any },
) => (IBaseOption & CRMEntity) | undefined;
getOptions: (
elementName: ElementsNames,