В реакцию где обновляется/формируется список в поле Карта техпомощи необходимо добавить:
если ранее значение в поле было пусто, то указывается значение из списка с максимальной стоимостью, иначе как сейчас подбирается по соответствию Типа карты
This commit is contained in:
parent
ce0b6290f7
commit
39dc4bfa9e
@ -8,9 +8,10 @@ import { getCurrentISODate } from '@/utils/date';
|
|||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { debouncedReaction } from '@/utils/mobx';
|
import { debouncedReaction } from '@/utils/mobx';
|
||||||
import { reaction, toJS } from 'mobx';
|
import { reaction, toJS } from 'mobx';
|
||||||
|
import { max } from 'radash';
|
||||||
|
|
||||||
export default function reactions({ store, apolloClient }: ProcessContext) {
|
export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||||
const { $calculation, $tables } = store;
|
const { $calculation, $tables, $process } = store;
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType', 'maxMass']),
|
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType', 'maxMass']),
|
||||||
@ -47,9 +48,9 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$calculation.element('selectTechnicalCard').setOptions(normalizeOptions(options));
|
|
||||||
|
|
||||||
const currentTechnicalCardId = $calculation.element('selectTechnicalCard').getValue();
|
const currentTechnicalCardId = $calculation.element('selectTechnicalCard').getValue();
|
||||||
|
|
||||||
|
$calculation.element('selectTechnicalCard').setOptions(normalizeOptions(options));
|
||||||
if (currentTechnicalCardId) {
|
if (currentTechnicalCardId) {
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_type },
|
data: { evo_addproduct_type },
|
||||||
@ -74,6 +75,54 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Устанавливаем самую дорогую техническую карточку по умолчанию первый раз при формировании списка карт
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
const dispose = reaction(
|
||||||
|
() => {
|
||||||
|
const technicalCards = $calculation.element('selectTechnicalCard').getOptions();
|
||||||
|
const isLoadKP = $process.has('LoadKP');
|
||||||
|
|
||||||
|
return { isLoadKP, technicalCards };
|
||||||
|
},
|
||||||
|
async ({ technicalCards, isLoadKP }) => {
|
||||||
|
if (isLoadKP) {
|
||||||
|
dispose();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentTechnicalCard = $calculation.element('selectTechnicalCard').getValue();
|
||||||
|
|
||||||
|
if (technicalCards.length && !currentTechnicalCard) {
|
||||||
|
const evo_addproduct_types = await Promise.all(
|
||||||
|
technicalCards.map(async (x) => {
|
||||||
|
const {
|
||||||
|
data: { evo_addproduct_type },
|
||||||
|
} = await apolloClient.query({
|
||||||
|
query: CRMTypes.GetAddProductTypeDocument,
|
||||||
|
variables: { addproductTypeId: x.value },
|
||||||
|
});
|
||||||
|
|
||||||
|
return evo_addproduct_type;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const maxPriceTechnicalCard = max(evo_addproduct_types, (x) => x?.evo_graph_price ?? 0);
|
||||||
|
|
||||||
|
if (maxPriceTechnicalCard) {
|
||||||
|
$calculation
|
||||||
|
.element('selectTechnicalCard')
|
||||||
|
.setValue(maxPriceTechnicalCard?.evo_addproduct_typeid);
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']),
|
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']),
|
||||||
async ({ leasingPeriod, leaseObjectType }) => {
|
async ({ leasingPeriod, leaseObjectType }) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user