перенесено subsidy-import-program
This commit is contained in:
parent
8a7a713160
commit
cedcdb41aa
@ -10,6 +10,7 @@ import loadKpReactions from '../../load-kp/reactions';
|
||||
import * as paymentsReactions from '../../payments/reactions';
|
||||
import * as priceReactions from '../../price/reactions';
|
||||
import * as subsidyReactions from '../../subsidy/reactions';
|
||||
import subsidyImportProgram from '../../subsidy-import-program/reactions';
|
||||
import * as agentsReactions from '../../supplier-agent/reactions/agents';
|
||||
import leasebackReactions from '../../supplier-agent/reactions/leaseback';
|
||||
import * as supplierReactions from '../../supplier-agent/reactions/supplier';
|
||||
@ -46,4 +47,5 @@ export default function injectDefaultReactions(context) {
|
||||
bonusesReactions.common(context);
|
||||
bonusesReactions.validation(context);
|
||||
usedPl.default(context);
|
||||
subsidyImportProgram(context);
|
||||
}
|
||||
|
||||
80
apps/web/process/subsidy-import-program/reactions.ts
Normal file
80
apps/web/process/subsidy-import-program/reactions.ts
Normal file
@ -0,0 +1,80 @@
|
||||
/* eslint-disable no-negated-condition */
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import type { ReactionsContext } from '../types';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { reaction } from 'mobx';
|
||||
|
||||
export default function commonReactions({ store, apolloClient }: ReactionsContext) {
|
||||
const { $calculation } = store;
|
||||
|
||||
/**
|
||||
* на изменение selectProduct, selectSubsidy или selectImportProgram или selectDealer
|
||||
* если selectSusidy или selectItProgram содержит данные или в поле selectDealer указан account, у которого evo_return_leasing_dealer = true, то selectSupplierCurrency закрыта для редактирования,
|
||||
* иначе
|
||||
* если selectProduct не содержит данные, то selectSupplierCurrency закрыта для редактирования, иначе
|
||||
* если (в поле Продукт selectProduct выбрана запись, у которой БУбезНДС evo_sale_without_nds = True), то selectSupplierCurrency закрыта для редактирования
|
||||
* иначе selectSupplierCurrency открыто для редактирования
|
||||
*/
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['product', 'subsidy', 'importProgram', 'dealer']),
|
||||
async ({
|
||||
product: productId,
|
||||
subsidy: subsidyId,
|
||||
importProgram: importProgramId,
|
||||
dealer: dealerId,
|
||||
}) => {
|
||||
if (!productId) {
|
||||
$calculation.element('selectSupplierCurrency').resetValue().block();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_baseproduct },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: {
|
||||
productId,
|
||||
},
|
||||
});
|
||||
|
||||
if (subsidyId || importProgramId || evo_baseproduct?.evo_sale_without_nds) {
|
||||
$calculation.element('selectSupplierCurrency').resetValue().block();
|
||||
} else if (dealerId) {
|
||||
const {
|
||||
data: { dealer },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetDealerDocument,
|
||||
variables: {
|
||||
dealerId,
|
||||
},
|
||||
});
|
||||
if (dealer?.evo_return_leasing_dealer === true) {
|
||||
$calculation.element('selectSupplierCurrency').resetValue().block();
|
||||
}
|
||||
} else {
|
||||
$calculation.element('selectSupplierCurrency').unblock();
|
||||
}
|
||||
},
|
||||
{
|
||||
fireImmediately: true,
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* При изменении "Программа от производителя" selectImportProgram (работает при загрузке КП)
|
||||
* Если поле "Программа от производителя" selectImportProgram не содержит данные,
|
||||
* то поле "Стоимость доп.оборудования" tbxAddEquipmentPrice закрыть для редактирования и значение равно 0,
|
||||
* иначе оставлять открытым для редактирования
|
||||
*/
|
||||
reaction(
|
||||
() => $calculation.element('selectImportProgram').getValue(),
|
||||
(importProgramId) => {
|
||||
if (!importProgramId) {
|
||||
$calculation.element('tbxAddEquipmentPrice').resetValue().block();
|
||||
} else {
|
||||
$calculation.element('tbxAddEquipmentPrice').unblock();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user