createKP: update list & reset recalcWithRevision
This commit is contained in:
parent
d6e3739e76
commit
3049ceec7b
@ -1,11 +1,14 @@
|
||||
import { gql } from '@apollo/client';
|
||||
import { message } from 'antd';
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
import CrmService from 'client/services/CrmService';
|
||||
import { getUser } from 'client/tools/user';
|
||||
import { CRM_PROXY_URL } from 'core/constants/urls';
|
||||
import { unionBy } from 'lodash';
|
||||
import { toJS } from 'mobx';
|
||||
import CalculationStore, { calculationUrls } from '../..';
|
||||
import customValues from '../lib/customValues';
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
import { CRM_PROXY_URL } from 'core/constants/urls';
|
||||
import { quoteFields } from '../lib/queries';
|
||||
|
||||
export default async () => {
|
||||
const { values, tables, actions } = CalculationStore;
|
||||
@ -64,32 +67,56 @@ export default async () => {
|
||||
query: gql`
|
||||
query($quoteid: Uuid!) {
|
||||
quote(quoteId: $quoteid) {
|
||||
offerprintform
|
||||
offerprintformapi
|
||||
evo_quotename
|
||||
${quoteFields}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
quoteid,
|
||||
},
|
||||
}).then(({ entities: { quote } }) => {
|
||||
console.log('quote', quote);
|
||||
if (!Array.isArray(quote)) {
|
||||
}).then(async ({ entities: { quote: new_quote } }) => {
|
||||
console.log('quote', new_quote);
|
||||
if (!Array.isArray(new_quote)) {
|
||||
message.success({
|
||||
content: `КП ${quote?.evo_quotename || ''} создано!`,
|
||||
content: `КП ${new_quote?.evo_quotename || ''} создано!`,
|
||||
});
|
||||
|
||||
if (quote?.offerprintformapi) {
|
||||
if (new_quote?.offerprintformapi) {
|
||||
calculationUrls.setUrl({
|
||||
name: 'kpUrl',
|
||||
url: String.prototype.concat(
|
||||
'/proxy',
|
||||
CRM_PROXY_URL,
|
||||
quote.offerprintformapi,
|
||||
new_quote.offerprintformapi,
|
||||
),
|
||||
});
|
||||
}
|
||||
CalculationStore.setValue('recalcWithRevision', false);
|
||||
let quotes = toJS(CalculationStore.options.selectQuote);
|
||||
quotes = unionBy([new_quote], quotes);
|
||||
|
||||
const { quote: selected_quoteid } = CalculationStore.values;
|
||||
const {
|
||||
entities: { quote: updated_quote },
|
||||
} = await CrmService.crmgqlquery({
|
||||
query: gql`
|
||||
query($quoteid: Uuid!) {
|
||||
quote(quoteId: $quoteid) {
|
||||
${quoteFields}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
quoteid: selected_quoteid,
|
||||
},
|
||||
toOptions: ['quote'],
|
||||
});
|
||||
|
||||
if (updated_quote) {
|
||||
quotes = unionBy(quotes, [updated_quote], 'value');
|
||||
}
|
||||
|
||||
CalculationStore.setOptions('selectQuote', quotes);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
17
src/client/stores/CalculationStore/Effects/lib/queries.js
Normal file
17
src/client/stores/CalculationStore/Effects/lib/queries.js
Normal file
@ -0,0 +1,17 @@
|
||||
export const quoteFields = `
|
||||
quoteid
|
||||
name
|
||||
evo_quotename
|
||||
quotenumber
|
||||
evo_recalc_limit
|
||||
evo_object_count
|
||||
evo_approved_first_payment
|
||||
evo_statuscode: evo_statuscodeidData {
|
||||
evo_id
|
||||
}
|
||||
evo_max_price_change
|
||||
evo_max_mass
|
||||
evo_seats
|
||||
evo_year
|
||||
offerprintformapi
|
||||
`;
|
||||
@ -4,6 +4,7 @@ import { currentDate } from 'client/tools/date';
|
||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { quoteFields } from '../lib/queries';
|
||||
|
||||
export default [
|
||||
(calculationStore, calculationProcess) => ({
|
||||
@ -52,20 +53,7 @@ export default [
|
||||
query: gql`
|
||||
query($leadid: Uuid) {
|
||||
quote: quotes(evo_leadid: $leadid) {
|
||||
quoteid
|
||||
name
|
||||
evo_quotename
|
||||
quotenumber
|
||||
evo_recalc_limit
|
||||
evo_object_count
|
||||
evo_approved_first_payment
|
||||
evo_statuscode: evo_statuscodeidData {
|
||||
evo_id
|
||||
}
|
||||
evo_max_price_change
|
||||
evo_max_mass
|
||||
evo_seats
|
||||
evo_year
|
||||
${quoteFields}
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
Reference in New Issue
Block a user