2023-09-18 15:17:52 +03:00

45 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as CRMTypes from '@/graphql/crm.types';
import type { ProcessContext } from '@/process/types';
import { reaction } from 'mobx';
export function common({ store, apolloClient }: ProcessContext) {
const { $calculation } = store;
/**
* Дополнить реакцию на изменение поля Салон приобретения selectDealer:
*
* если в поле selectDealer указан account, у которого evo_return_leasing_dealer = true, то
*
* 1) поле selectDealerPerson обнулять и закрывать для редактирования,
* иначе формировать список связанных значений
*
* 2) в таблице страхования в столбце Плательщик
* в строках ОСАГО и КАСКО указывать "Лизингополучатель" (100 000 000) и закрывать для редактирования ,
* иначе открывать данные поля для редактирования
*
* 3) ПЛ БУ cbxLeaseObjectUsed = true
*/
reaction(
() => $calculation.element('selectDealer').getValue(),
async (dealerId) => {
if (!dealerId) return;
const {
data: { dealer },
} = await apolloClient.query({
query: CRMTypes.GetDealerDocument,
variables: {
dealerId,
},
});
if (dealer?.evo_return_leasing_dealer === true) {
$calculation.element('selectDealerPerson').block().resetValue();
$calculation.element('cbxLeaseObjectUsed').setValue(true);
} else {
$calculation.element('selectDealerPerson').unblock();
}
}
);
}