В валидацию на кнопку Рассчитать внести изменение:
1) поле selectDealerPerson убрать из списка обязательных для расчета полей
2) добавить валидацию на поле selectDealerPerson :
Если в поле selectDealer указан account, у которого evo_return_leasing_dealer = False (или null)
и поле selectDealerPerson = null, то выводить ошибку и поле selectDealerPerson обводить красной рамкой,
иначе все ок
This commit is contained in:
parent
5a6db6c837
commit
88aa991f0f
@ -1,5 +1,6 @@
|
||||
/* eslint-disable max-len */
|
||||
import type * as CRMTypes from 'graphql/crm.types';
|
||||
import { reaction } from 'mobx';
|
||||
import { autorun, reaction } from 'mobx';
|
||||
import type { ReactionsContext } from 'process/types';
|
||||
import * as query from '../lib/query';
|
||||
|
||||
@ -80,4 +81,40 @@ export default function leasebackReactions({ store, apolloClient }: ReactionsCon
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* В валидацию на кнопку Рассчитать внести изменение:
|
||||
1) поле selectDealerPerson убрать из списка обязательных для расчета полей
|
||||
2) добавить валидацию на поле selectDealerPerson :
|
||||
Если в поле selectDealer указан account, у которого evo_return_leasing_dealer = False (или null)
|
||||
и поле selectDealerPerson = null, то выводить ошибку и поле selectDealerPerson обводить красной рамкой,
|
||||
иначе все ок
|
||||
*/
|
||||
|
||||
autorun(async () => {
|
||||
const dealerId = $calculation.element('selectDealer').getValue();
|
||||
const dealerPersonId = $calculation.element('selectDealerPerson').getValue();
|
||||
|
||||
let returnLeasing: boolean | null | undefined;
|
||||
|
||||
if (dealerId) {
|
||||
const {
|
||||
data: { dealer },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetDealerReturnLeasingQuery,
|
||||
CRMTypes.GetDealerReturnLeasingQueryVariables
|
||||
>({
|
||||
query: query.QUERY_GET_DEALER_RETURN_LEASING,
|
||||
variables: {
|
||||
dealerId,
|
||||
},
|
||||
});
|
||||
returnLeasing = dealer?.evo_return_leasing_dealer;
|
||||
}
|
||||
|
||||
$calculation.element('selectDealerPerson').validate({
|
||||
invalid: !!dealerId && !dealerPersonId && !returnLeasing,
|
||||
message: 'Не заполнено поле',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user