еще частичка leasing-object реакций
This commit is contained in:
parent
9e3076a8fe
commit
ad02352f46
@ -214,6 +214,7 @@ query GetLeaseObjectType($leaseObjectTypeId: Uuid!) {
|
||||
evo_leasingobject_type(evo_leasingobject_typeid: $leaseObjectTypeId) {
|
||||
evo_vehicle_type
|
||||
evo_id
|
||||
evo_category
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -246,7 +246,7 @@ export type GetLeaseObjectTypeQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetLeaseObjectTypeQuery = { __typename?: 'Query', evo_leasingobject_type: { __typename?: 'evo_leasingobject_type', evo_vehicle_type: Array<number> | null, evo_id: string | null } | null };
|
||||
export type GetLeaseObjectTypeQuery = { __typename?: 'Query', evo_leasingobject_type: { __typename?: 'evo_leasingobject_type', evo_vehicle_type: Array<number> | null, evo_id: string | null, evo_category: number | null } | null };
|
||||
|
||||
export type GetBrandsQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
@ -483,7 +483,7 @@ export const GetImportProgramDocument = {"kind":"Document","definitions":[{"kind
|
||||
export const GetRegionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_regions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_regionid"}}]}}]}}]} as unknown as DocumentNode<GetRegionsQuery, GetRegionsQueryVariables>;
|
||||
export const GetGpsBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_brandid"}}]}}]}}]} as unknown as DocumentNode<GetGpsBrandsQuery, GetGpsBrandsQueryVariables>;
|
||||
export const GetLeaseObjectTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectTypes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_leasingobject_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]} as unknown as DocumentNode<GetLeaseObjectTypesQuery, GetLeaseObjectTypesQueryVariables>;
|
||||
export const GetLeaseObjectTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leasingobject_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}}]}}]} as unknown as DocumentNode<GetLeaseObjectTypeQuery, GetLeaseObjectTypeQueryVariables>;
|
||||
export const GetLeaseObjectTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leasingobject_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}}]}}]}}]} as unknown as DocumentNode<GetLeaseObjectTypeQuery, GetLeaseObjectTypeQueryVariables>;
|
||||
export const GetBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode<GetBrandsQuery, GetBrandsQueryVariables>;
|
||||
export const GetBrandDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrand"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brand"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}}]}}]}}]} as unknown as DocumentNode<GetBrandQuery, GetBrandQueryVariables>;
|
||||
export const GetModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode<GetModelsQuery, GetModelsQueryVariables>;
|
||||
|
||||
@ -377,4 +377,32 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
() => $calculation.element('selectLeaseObjectType').getValue(),
|
||||
async (leaseObjectTypeId) => {
|
||||
if (!leaseObjectTypeId) {
|
||||
$calculation.element('selectLeaseObjectCategory').resetValue();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_leasingobject_type },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
||||
variables: {
|
||||
leaseObjectTypeId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_leasingobject_type?.evo_category) {
|
||||
$calculation
|
||||
.element('selectLeaseObjectCategory')
|
||||
.setValue(evo_leasingobject_type?.evo_category);
|
||||
} else {
|
||||
$calculation.element('selectLeaseObjectCategory').resetValue();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -83,45 +83,82 @@ export default function validationReactions({ store, apolloClient }: ReactionsCo
|
||||
}
|
||||
);
|
||||
|
||||
const validationHelper = new ValidationHelper();
|
||||
{
|
||||
const validationHelper = new ValidationHelper();
|
||||
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['leaseObjectType', 'countSeats', 'maxMass']),
|
||||
async ({ countSeats, leaseObjectType: leaseObjectTypeId, maxMass }) => {
|
||||
if (!leaseObjectTypeId) {
|
||||
validationHelper.removeErrors();
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['leaseObjectType', 'countSeats', 'maxMass']),
|
||||
async ({ countSeats, leaseObjectType: leaseObjectTypeId, maxMass }) => {
|
||||
if (!leaseObjectTypeId) {
|
||||
validationHelper.removeErrors();
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_leasingobject_type },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
||||
variables: {
|
||||
leaseObjectTypeId,
|
||||
},
|
||||
});
|
||||
|
||||
$calculation.element('tbxCountSeats').validate({
|
||||
helper: validationHelper,
|
||||
invalid: evo_leasingobject_type?.evo_id === '1' && countSeats >= 9,
|
||||
message: 'Количество мест должно быть меньше 9',
|
||||
});
|
||||
|
||||
$calculation.element('tbxCountSeats').validate({
|
||||
helper: validationHelper,
|
||||
invalid:
|
||||
(evo_leasingobject_type?.evo_id === '4' || evo_leasingobject_type?.evo_id === '5') &&
|
||||
countSeats <= 8,
|
||||
message: 'Количество мест должно быть больше 8',
|
||||
});
|
||||
|
||||
$calculation.element('tbxMaxMass').validate({
|
||||
helper: validationHelper,
|
||||
invalid: evo_leasingobject_type?.evo_id === '2' && maxMass <= 0,
|
||||
message: 'Не заполнено поле',
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_leasingobject_type },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
||||
variables: {
|
||||
leaseObjectTypeId,
|
||||
},
|
||||
});
|
||||
{
|
||||
const validationHelper = new ValidationHelper();
|
||||
|
||||
$calculation.element('tbxCountSeats').validate({
|
||||
helper: validationHelper,
|
||||
invalid: evo_leasingobject_type?.evo_id === '1' && countSeats >= 9,
|
||||
message: 'Количество мест должно быть меньше 9',
|
||||
});
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['leaseObjectType', 'leaseObjectCategory']),
|
||||
async ({ leaseObjectCategory, leaseObjectType: leaseObjectTypeId }) => {
|
||||
if (!leaseObjectTypeId) {
|
||||
validationHelper.removeErrors();
|
||||
|
||||
$calculation.element('tbxCountSeats').validate({
|
||||
helper: validationHelper,
|
||||
invalid:
|
||||
(evo_leasingobject_type?.evo_id === '4' || evo_leasingobject_type?.evo_id === '5') &&
|
||||
countSeats <= 8,
|
||||
message: 'Количество мест должно быть больше 8',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$calculation.element('tbxMaxMass').validate({
|
||||
helper: validationHelper,
|
||||
invalid: evo_leasingobject_type?.evo_id === '2' && maxMass <= 0,
|
||||
message: 'Не заполнено поле',
|
||||
});
|
||||
}
|
||||
);
|
||||
const {
|
||||
data: { evo_leasingobject_type },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
||||
variables: {
|
||||
leaseObjectTypeId,
|
||||
},
|
||||
});
|
||||
|
||||
$calculation.element('selectLeaseObjectCategory').validate({
|
||||
helper: validationHelper,
|
||||
invalid:
|
||||
!leaseObjectCategory &&
|
||||
Boolean(
|
||||
evo_leasingobject_type?.evo_id &&
|
||||
!['6', '9', '10'].includes(evo_leasingobject_type?.evo_id)
|
||||
),
|
||||
message: 'Не заполнено поле',
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user