process/load-kp: run initElt before getQuote

This commit is contained in:
vchikalkin 2023-07-31 12:42:07 +03:00
parent 903b32084a
commit 5f7586bb0d

View File

@ -15,7 +15,7 @@ export function common({ store, trpcClient, apolloClient, user }: ProcessContext
reaction(
() => $calculation.$values.getValue('quote'),
() => {
async () => {
const quote = $calculation.element('selectQuote').getOption();
if (!quote || $process.has('LoadKP') || $process.has('Calculate') || $process.has('CreateKP'))
@ -28,6 +28,8 @@ export function common({ store, trpcClient, apolloClient, user }: ProcessContext
key,
});
const eltInitialValues = await initElt();
trpcClient.getQuote
.query({
values: {
@ -65,21 +67,19 @@ export function common({ store, trpcClient, apolloClient, user }: ProcessContext
if (fingap) $tables.fingap.setSelectedKeys(fingap.keys);
initElt().then((initialValues) => {
if (initialValues) {
$tables.elt.kasko.setRows(initialValues.kasko);
$tables.elt.osago.setRows(initialValues.osago);
}
if (eltInitialValues) {
$tables.elt.kasko.setRows(eltInitialValues.kasko);
$tables.elt.osago.setRows(eltInitialValues.osago);
}
if (elt?.kasko) {
$tables.elt.kasko.setRow(elt.kasko);
$tables.elt.kasko.setSelectedKey(elt.kasko.key);
}
if (elt?.osago) {
$tables.elt.osago.setRow(elt.osago);
$tables.elt.osago.setSelectedKey(elt.osago.key);
}
});
if (elt?.kasko) {
$tables.elt.kasko.setRow(elt.kasko);
$tables.elt.kasko.setSelectedKey(elt.kasko.key);
}
if (elt?.osago) {
$tables.elt.osago.setRow(elt.osago);
$tables.elt.osago.setSelectedKey(elt.osago.key);
}
message.success({
content: `КП ${quote.label} загружено`,