diff --git a/actions/companyActions.js b/actions/companyActions.js
index 1b70f05..24d986f 100644
--- a/actions/companyActions.js
+++ b/actions/companyActions.js
@@ -4,6 +4,7 @@ import Router from 'next/router';
import moment from 'moment';
import * as actionTypes from '../constants/actionTypes';
+import { getEDOOperatorList } from './index';
if(process.browser)
{
@@ -18,12 +19,12 @@ if(process.browser)
this.append(keyName, obj[key]);
}
}
- };
+ };
}
export const getCompanyInfo = ({ dispatch }) =>
{
- //console.log("getCompanyInfo");
+ console.log("ACTION", "company", "getCompanyInfo");
return new Promise((resolve, reject) =>
{
@@ -32,9 +33,9 @@ export const getCompanyInfo = ({ dispatch }) =>
})
.then((response) =>
{
+ getEDOOperatorList({ dispatch }).then(() => {}).catch(() => {});
//console.log("getCompanyInfo", "response", response.data);
-
dispatch({ type: actionTypes.COMPANY, data: response.data });
resolve();
})
diff --git a/actions/contractActions.js b/actions/contractActions.js
index 4bd959c..745ad17 100644
--- a/actions/contractActions.js
+++ b/actions/contractActions.js
@@ -336,7 +336,7 @@ export const getContractFines = ({ dispatch, contract, }) =>
//console.log("ACTION", "getContractFines", "response.data", response.data);
- let query = nSQL(response.data.fines).query("select");
+ let query = nSQL(response.data).query("select");
query = query.orderBy({ date: "desc" });
query.exec().then((rows) =>
{
diff --git a/actions/dealsActions.js b/actions/dealsActions.js
index 702199b..bd4eee3 100644
--- a/actions/dealsActions.js
+++ b/actions/dealsActions.js
@@ -3,101 +3,390 @@ import { Cookies } from 'react-cookie';
import Router from 'next/router';
import moment from 'moment';
import { nSQL } from "@nano-sql/core";
+import { eachSeries } from 'async';
+import fileDownload from 'js-file-download';
import * as actionTypes from '../constants/actionTypes';
import * as currentState from '../reducers/initialState';
-/*DEALS_LIST
-/lk/ConsiderationOpportunity/quote
-
-[{
- "quote_number": "582189",
- "price": 5490000,
- "first_payment_perc": 30,
- "first_payment_rub": 1647000,
- "brand_name": "Volkswagen",
- "model_name": "Touareg",
- "object_count": 1,
-}, {
- "quote_number": "580008",
- "price": 5341770,
- "first_payment_perc": 30,
- "first_payment_rub": 1647000,
- "brand_name": "Volkswagen",
- "model_name": "Touareg",
- "object_count": 1,
-}]
-
-[{
- "opp_number": "780",
- "statuscode_id": 107,
- "statuscode_name": " ",
- "comment": null,
-}, {
- "opp_number": "37197",
- "statuscode_id": 101,
- "statuscode_name": " ",
- "comment": null,
-}]
-opp_number- номер Лизинговой сделки
-statuscode_id - номер этапа
-statuscode_name - имя этапа
-comment - сопроводительный текст для данного этапа, который надо выводить
-
-*/
-
-export const getDeals = ({ dispatch }) =>
+if(process.browser)
{
- console.log("ACTION", "deals", "getDeals()", `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals`);
+ FormData.prototype.appendObject = function(obj, namespace)
+ {
+ let keyName;
+ for (var key in obj)
+ {
+ if (obj.hasOwnProperty(key))
+ {
+ keyName = [namespace, '[', key, ']'].join('');
+ this.append(keyName, obj[key]);
+ }
+ }
+ };
+}
+
+export const getDeals = ({ dispatch, update = false }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals`;
+
+ console.log("ACTION", "deals", "getDeals()", { url });
+
return new Promise((resolve, reject) =>
{
- console.log("??????????????????????? WTF");
-
- axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals`, {}, {
+ axios.post(url, {}, {
withCredentials: true,
})
.then((response) =>
{
- console.log("!!!!!!!!!!!!!!!!!!!!!!!!! GOOOOOOD");
console.log("ACTION", "deals", "getDeals()", "response", response.data);
+
+ /*
+ if(update)
+ {
+ for(let i in response.data)
+ {
+ if(response.data[i].opp_number == "20325")
+ {
+ response.data[i].statuscode_id = 101;
+ }
+ }
+ }
+ */
+
dispatch({
type: actionTypes.DEALS_LIST,
data: {
- list: [{
- "opp_number": "780",
- "statuscode_id": 107,
- "statuscode_name": " ",
- "comment": null,
- }, {
- "opp_number": "37197",
- "statuscode_id": 101,
- "statuscode_name": " ",
- "comment": null,
- }]
+ list: response.data
}
});
+
resolve();
})
.catch((error) =>
{
- console.log("!!!!!!!!!!!!!!!!!!!!!!!!! ERROR", { action: actionTypes.DEALS_LIST });
+ console.error("ACTION", "deals", "getDeals()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода ConsiderationOpportunity" } });
+ window.dispatchEvent(eventMessage);
+
dispatch({
type: actionTypes.DEALS_LIST,
data: {
- list: [{
- "opp_number": "780",
- "statuscode_id": 107,
- "statuscode_name": " ",
- "comment": null,
- }, {
- "opp_number": "37197",
- "statuscode_id": 101,
- "statuscode_name": " ",
- "comment": null,
- }]
+ list: []
}
});
+
+ reject();
+ });
+ });
+}
+
+export const getDealOffers = ({ dispatch, deal_id }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals/offer/list`;
+
+ console.log("ACTION", "deals", "getDealOffers()", { url });
+ console.log("ACTION", "deals", "getDealOffers()", { deal_id });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, { deal_id }, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "deals", "getDealOffers()", "response", response.data);
+
+ dispatch({
+ type: actionTypes.DEAL_OFFERS_LIST,
+ data: {
+ deal_id,
+ list: response.data
+ }
+ });
+
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "deals", "getDealOffers()", "ERROR");
console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода quote" } });
+ window.dispatchEvent(eventMessage);
+
+ dispatch({
+ type: actionTypes.DEAL_OFFERS_LIST,
+ data: {
+ deal_id,
+ list: []
+ }
+ });
+
+ reject();
+ });
+ });
+}
+
+export const downloadDealOffer = ({ quote_number, filename }) =>
+{
+ return new Promise((resolve, reject) =>
+ {
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals/offer/download`;
+
+ axios.get(url, {
+ params: { quote_number },
+ responseType: 'blob',
+ })
+ .then((response) =>
+ {
+ fileDownload(response.data, filename);
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "downloadDealOffer()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода offerprintform" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const acceptDealOffers = ({ deal_id, offers }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals/accept`;
+
+ console.log("ACTION", "deals", "acceptDealOffers()", { url });
+ console.log("ACTION", "deals", "acceptDealOffers()", { deal_id, offers, });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, { deal_id, offers }, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "deals", "acceptDealOffers()", "response", response.data);
+
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "deals", "acceptDealOffers()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода quote accept" } });
+ window.dispatchEvent(eventMessage);
+
+ reject();
+ });
+ });
+}
+
+export const getDealDocuments = ({ dispatch, deal_id }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals/documents`;
+
+ console.log("ACTION", "deals", "getDealDocuments()", { url });
+ console.log("ACTION", "deals", "getDealDocuments()", { deal_id, });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, { deal_id }, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "deals", "getDealDocuments()", "response", response.data);
+
+ dispatch({
+ type: actionTypes.DEAL_DOCUMENTS_LIST,
+ data: {
+ deal_id,
+ documents: response.data.documents,
+ uploaded: response.data.uploaded,
+ }
+ });
+
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "deals", "getDealDocuments()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода document" } });
+ window.dispatchEvent(eventMessage);
+
+ dispatch({
+ type: actionTypes.DEAL_DOCUMENTS_LIST,
+ data: {
+ deal_id,
+ documents: [],
+ uploaded: {},
+ }
+ });
+
+ reject();
+ });
+ });
+}
+
+export const sendDealDocuments = ({ deal_id }) =>
+{
+ return new Promise((resolve, reject) =>
+ {
+ const payload = {
+ deal_id,
+ };
+
+ axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals/upload`, payload,
+ {
+ withCredentials: true,
+ })
+ .then(async (response) =>
+ {
+ console.log("ACTION", "deals", "sendDealDocuments", "response.data", response.data);
+
+ setTimeout(() =>
+ {
+ resolve();
+ }, 20000);
+ })
+ .catch((error) =>
+ {
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при отправке пакета документов для сделки" } });
+ window.dispatchEvent(eventMessage);
+
+ reject();
+ });
+ });
+}
+
+export const getDealContracts = ({ dispatch, deal_id }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals/contracts`;
+
+ console.log("ACTION", "deals", "getDealContracts()", { url });
+ console.log("ACTION", "deals", "getDealContracts()", { deal_id, });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, { deal_id }, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "deals", "getDealContracts()", "response", response.data);
+
+ dispatch({
+ type: actionTypes.DEAL_CONTRACTS_LIST,
+ data: {
+ deal_id,
+ list: response.data
+ }
+ });
+
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "deals", "getDealContracts()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода contract" } });
+ window.dispatchEvent(eventMessage);
+
+ dispatch({
+ type: actionTypes.DEAL_CONTRACTS_LIST,
+ data: {
+ deal_id,
+ list: []
+ }
+ });
+
+ reject();
+ });
+ });
+}
+
+export const attachDealDocument = ({ deal_id, document_id, document_name, group, index, lastModified, filename, file, type }) =>
+{
+ return new Promise((resolve, reject) =>
+ {
+ let data = new FormData();
+ data.append('file', file);
+
+ const payload = new URLSearchParams({
+ deal_id,
+ document_id,
+ document_name,
+ group,
+ filename,
+ index,
+ lastModified,
+ type
+ });
+
+ axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals/file/attach?${ payload.toString() }`, data,
+ {
+ headers: {
+ "Content-Type": "multipart/form-data",
+ },
+ withCredentials: true,
+ })
+ .then(async (response) =>
+ {
+ console.log("ACTION", "deals", "attachDealDocument", "response.data", response.data);
+
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при загрузке документа" } });
+ window.dispatchEvent(eventMessage);
+
+ reject();
+ });
+ });
+}
+
+export const removeDealDocument = ({ deal_id, group, index, }) =>
+{
+ return new Promise((resolve, reject) =>
+ {
+ const payload = new URLSearchParams({
+ deal_id,
+ group,
+ index,
+ });
+
+ axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/deals/file/remove?${ payload.toString() }`, {},
+ {
+ withCredentials: true,
+ })
+ .then(async (response) =>
+ {
+ console.log("ACTION", "deals", "removeDocument", "response.data", response.data);
+
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при удалении документа" } });
+ window.dispatchEvent(eventMessage);
+
reject();
});
});
diff --git a/actions/edoActions.js b/actions/edoActions.js
new file mode 100644
index 0000000..2bca372
--- /dev/null
+++ b/actions/edoActions.js
@@ -0,0 +1,323 @@
+import axios from 'axios';
+import { Cookies } from 'react-cookie';
+import Router from 'next/router';
+import moment from 'moment';
+import { nSQL } from "@nano-sql/core";
+import { eachSeries } from 'async';
+
+import * as actionTypes from '../constants/actionTypes';
+import * as currentState from '../reducers/initialState';
+
+export const getEDOOperatorList = ({ dispatch, update = false }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/operators`;
+
+ console.log("ACTION", "edo", "getEDOOperatorList()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, {}, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "edo", "getEDOOperatorList()", "response", response.data);
+
+ /*
+ dispatch({
+ type: actionTypes.EDO_OPERATORS_LIST,
+ data: {
+ list: [
+ {
+ "box_name": "ООО С К \"МОНОЛИТ-РУ\"",
+ "box_id": "7785f775578d4646aea1d323e703065d@diadoc.ru"
+ }, {
+ "box_name": "ООО СК \"МОНОЛИТ-РУ\" (роуминг, ООО «Такском» (Файлер))",
+ "box_id": "b8fbc5c395f54deabe6b8d84a10921f0@diadoc.ru"
+ }
+ ]
+ }
+ });
+ */
+
+ dispatch({
+ type: actionTypes.EDO_OPERATORS_LIST,
+ data: {
+ operators: response.data.box_edo,
+ message: response.data.message,
+ }
+ });
+
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "edo", "getEDOOperatorList()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода GetEdoBox" } });
+ window.dispatchEvent(eventMessage);
+
+ dispatch({
+ type: actionTypes.EDO_OPERATORS_LIST,
+ data: {
+ operators: [],
+ message: "Невозможно получить список операторов ЭДО",
+ }
+ });
+
+ reject();
+ });
+ });
+}
+
+export const getEDOInvitesList = ({ dispatch, update = false }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/invites`;
+
+ console.log("ACTION", "edo", "getEDOInvitesList()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, {}, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "edo", "getEDOInvitesList()", "response", response.data);
+
+ dispatch({
+ type: actionTypes.EDO_INVITES_LIST,
+ data: {
+ invites: response.data.box_edo
+ }
+ });
+
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "edo", "getEDOInvitesList()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода GetInviteEdoBox" } });
+ window.dispatchEvent(eventMessage);
+
+ dispatch({
+ type: actionTypes.EDO_INVITES_LIST,
+ data: {
+ invites: []
+ }
+ });
+
+ reject();
+ });
+ });
+}
+
+export const inviteToEDO = () =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/invite/send`;
+
+ console.log("ACTION", "edo", "inviteToEDO()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, {}, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "edo", "inviteToEDO()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "edo", "inviteToEDO()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода InviteEdoBox" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const createEDOProject = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/project`;
+
+ console.log("ACTION", "edo", "createEDOProject()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "edo", "createEDOProject()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "edo", "createEDOProject()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода CreateEDOProject" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const docEDOSign = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/sign`;
+
+ if(parseInt(process.env.LOG, 10) === 1)
+ {
+ console.log("ACTION", "edo", "docEDOSign()", { url });
+ }
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ if(parseInt(process.env.LOG, 10) === 1)
+ {
+ console.log("ACTION", "edo", "docEDOSign()", "response", response.data);
+ }
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ if(parseInt(process.env.LOG, 10) === 1)
+ {
+ console.error("ACTION", "edo", "docEDOSign()", "ERROR");
+ console.error(error);
+ }
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода SignEDODocument" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const docEDOCancel = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/cancel`;
+
+ console.log("ACTION", "edo", "docEDOCancel()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "edo", "docEDOCancel()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "edo", "docEDOCancel()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода CancelDocument" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const docEDOConnect = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/connect`;
+
+ if(parseInt(process.env.LOG, 10) === 1)
+ {
+ console.log("ACTION", "edo", "docEDOConnect()", { url });
+ }
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ if(parseInt(process.env.LOG, 10) === 1)
+ {
+ console.log("ACTION", "edo", "docEDOConnect()", "response", response.data);
+ }
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ if(parseInt(process.env.LOG, 10) === 1)
+ {
+ console.error("ACTION", "edo", "docEDOConnect()", "ERROR");
+ console.error(error);
+ }
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода DocEdoConnect" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const docEDOStatus = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/status`;
+
+ if(parseInt(process.env.LOG, 10) === 1)
+ {
+ console.log("ACTION", "edo", "docEDOStatus()", { url });
+ }
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ if(parseInt(process.env.LOG, 10) === 1)
+ {
+ console.log("ACTION", "edo", "docEDOStatus()", "response", response.data);
+ }
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ if(parseInt(process.env.LOG, 10) === 1)
+ {
+ console.error("ACTION", "edo", "docEDOStatus()", "ERROR");
+ console.error(error);
+ }
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода GetEdoProjectID" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
diff --git a/actions/fileActions.js b/actions/fileActions.js
index c6554e3..131e7c3 100644
--- a/actions/fileActions.js
+++ b/actions/fileActions.js
@@ -5,6 +5,7 @@ import moment from 'moment';
import fileDownload from 'js-file-download';
import * as actionTypes from '../constants/actionTypes';
+import { logDocumentAccess } from './logsActions';
if(process.browser)
{
@@ -66,8 +67,6 @@ export const getFile = ({ id, filename }) =>
})
.catch((error) =>
{
- //console.log("error");
-
console.error(error);
reject();
@@ -166,6 +165,14 @@ export const getReconciliationFile = ({ contract, date_from, date_to, filename }
.then((response) =>
{
fileDownload(response.data, filename);
+ logDocumentAccess({
+ contract_number: contract,
+ document_name: "Акт сверки по ДЛ",
+ document_type: "act_bu",
+ document_period_from: date_from,
+ document_period_to: date_to,
+ });
+
resolve();
})
.catch((error) =>
diff --git a/actions/index.js b/actions/index.js
index 8b8f996..2e6213c 100644
--- a/actions/index.js
+++ b/actions/index.js
@@ -14,4 +14,6 @@ export * from './adminActions';
export * from './suggestsActions';
export * from './questionnaireActions';
export * from './feedbackActions';
-export * from './dealsActions';
\ No newline at end of file
+export * from './dealsActions';
+export * from './edoActions';
+export * from './signActions';
\ No newline at end of file
diff --git a/actions/logsActions.js b/actions/logsActions.js
new file mode 100644
index 0000000..0c88ab3
--- /dev/null
+++ b/actions/logsActions.js
@@ -0,0 +1,40 @@
+import axios from 'axios';
+import { Cookies } from 'react-cookie';
+import Router from 'next/router';
+import moment from 'moment';
+import { nSQL } from "@nano-sql/core";
+import { eachSeries } from 'async';
+
+import * as actionTypes from '../constants/actionTypes';
+import * as currentState from '../reducers/initialState';
+
+export const logDocumentAccess = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/logs/track`;
+
+ console.log("ACTION", "deals", "logDocumentAccess()", { url });
+ console.log("ACTION", "deals", "logDocumentAccess()", { payload });
+
+ return new Promise((resolve, reject) =>
+ {
+ payload.lk_user_id = global.store.getState().user.email;
+ payload.acc_number = global.store.getState().company.active;
+
+ axios.post(url, [ payload ], {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "deals", "logDocumentAccess()", "response", response.data);
+
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "deals", "logDocumentAccess()", "ERROR");
+ console.error(error);
+
+ reject();
+ });
+ });
+}
\ No newline at end of file
diff --git a/actions/questionnaireActions.js b/actions/questionnaireActions.js
index 4c222d5..fa22821 100644
--- a/actions/questionnaireActions.js
+++ b/actions/questionnaireActions.js
@@ -9,6 +9,7 @@ import { eachSeries, each } from "async";
import * as actionTypes from '../constants/actionTypes';
import { getCitizenshipTitleByCode } from '../utils/citizenship';
import { questionnaire_template } from '../reducers/initialState';
+import { getCompanyInfo } from './companyActions';
if(process.browser)
{
@@ -26,11 +27,28 @@ if(process.browser)
};
}
+export const createQuestionnaire = (deal_id) =>
+{
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/create`, { deal_id }, {
+ withCredentials: true,
+ })
+ .then(() => {}).catch(() => {}).finally(() =>
+ {
+ getCompanyInfo({ dispatch: global.store.dispatch })
+ .then(() => {}).catch(() => {}).finally(() =>
+ {
+ resolve();
+ });
+ });
+ });
+}
+
export const getQuestionnaire = ({ dispatch, id }) =>
{
//console.log("ACTION", "support", "getAppeals()", `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/get`);
-
return new Promise((resolve, reject) =>
{
axios.get(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/read`, {})
diff --git a/actions/signActions.js b/actions/signActions.js
new file mode 100644
index 0000000..b898fd9
--- /dev/null
+++ b/actions/signActions.js
@@ -0,0 +1,339 @@
+import axios from 'axios';
+import { Cookies } from 'react-cookie';
+import Router from 'next/router';
+import moment from 'moment';
+import { nSQL } from "@nano-sql/core";
+import { concatSeries, eachSeries } from 'async';
+import fileDownload from 'js-file-download';
+
+import * as actionTypes from '../constants/actionTypes';
+import * as currentState from '../reducers/initialState';
+
+export const signCheckCreatePrintForm = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/check`;
+
+ console.log("ACTION", "sign", "signCheckCreatePrintForm()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signCheckCreatePrintForm()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signCheckCreatePrintForm()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода CheckCreatePrintForm" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signGetGUIDEntity = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/entity`;
+
+ console.log("ACTION", "sign", "signGetGUIDEntity()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signGetGUIDEntity()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signGetGUIDEntity()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода GetGUIDEntity" } });
+ window.dispatchEvent(eventMessage);
+
+ resolve(response.data);
+ });
+ });
+}
+
+export const signCheckPowerAttorneyClient = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/attorney/check`;
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signCheckPowerAttorneyClient()", "response", response.data);
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signCheckPowerAttorneyClient()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода CheckPowerAttorneyClient" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signGetPowerAttorneyClient = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/attorney/get`;
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signGetPowerAttorneyClient()", "response", response.data);
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signGetPowerAttorneyClient()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода GetPowerAttorneyClient" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signGetWMDoc = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/create`;
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signGetWMDoc()", "response", response.data);
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signGetWMDoc()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода GetWMDoc" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signDownloadFile = ({ payload, filename }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/download`;
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.get(url, {
+ params: payload,
+ responseType: 'blob',
+ })
+ .then((response) =>
+ {
+ fileDownload(response.data, filename);
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signDownloadFile()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода GetWMDoc" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signGetFileContractProject = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/link`;
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ if(parseInt(process.env.LOG, 10) === 1) { console.log("ACTION", "sign", "signGetFileContractProject()", "response", response.data); }
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signGetFileContractProject()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода GetFileContractProject" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signCheckDownloadContractProject = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/check`;
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ if(parseInt(process.env.LOG, 10) === 1) { console.log("ACTION", "sign", "signCheckDownloadContractProject()", "response", response.data); }
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signCheckDownloadContractProject()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода CheckDownloadContractProject" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signUploadPaperDocument = (contract_number, deal_id, files) =>
+{
+ console.log({ contract_number, files });
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document/upload`;
+
+ return new Promise((resolve, reject) =>
+ {
+ let data = new FormData();
+ data.append('contract_number', contract_number);
+ data.append('deal_id', deal_id);
+
+ for(let i in files)
+ {
+ data.append('files', files[i]);
+ }
+
+ axios.post(url, data, {
+ headers: {
+ "Content-Type": "multipart/form-data",
+ },
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ if(parseInt(process.env.LOG, 10) === 1) { console.log("ACTION", "sign", "signUploadPaperDocument()", "response", response.data); }
+
+ setTimeout(() =>
+ {
+ resolve();
+ }, 2000);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signUploadPaperDocument()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при отправке подписанного пакета документов" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signCheckCancelDocument = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/cancel/check`;
+
+ console.log("ACTION", "sign", "signCheckCancelDocument()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signCheckCancelDocument()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signCheckCancelDocument()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода CheckCancelDocument" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signCancelDocument = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/cancel`;
+
+ console.log("ACTION", "sign", "signCancelDocument()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signCancelDocument()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signCancelDocument()", "ERROR");
+ console.error(error);
+
+ const eventMessage = new CustomEvent("_message", { detail: { type: "error", title: "Ошибка", content: "Ошибка при вызове метода CancelDocument" } });
+ window.dispatchEvent(eventMessage);
+
+ reject(error.data);
+ });
+ });
+}
\ No newline at end of file
diff --git a/components/DealsStatus/DealsList.js b/components/DealsStatus/DealsList.js
index 58f9c87..3c8a2d2 100644
--- a/components/DealsStatus/DealsList.js
+++ b/components/DealsStatus/DealsList.js
@@ -7,25 +7,65 @@ export default class DealsList extends React.Component
constructor(props)
{
super(props);
+ this.list_ref = React.createRef();
+ this.items_ref = [];
+ }
+
+ _scrollToDeal = (index) =>
+ {
+ const element = this.list_ref.current.children[index];
+ const y = (element.getBoundingClientRect().top + window.scrollY - 90);
+ window.scrollTo({top: y, behavior: 'smooth'});
+ }
+
+ _handle_onSelectDeal = (deal_id, index) =>
+ {
+ const { onSelectDeal } = this.props;
+ onSelectDeal(deal_id);
+ setTimeout(() =>
+ {
+ this._scrollToDeal(index);
+ }, 50);
+ }
+
+ _handle_onCloseDeal = () =>
+ {
+ const { onCloseDeal } = this.props;
+ onCloseDeal();
+
+ setTimeout(() =>
+ {
+ const element = this.list_ref.current;
+ const y = (element.getBoundingClientRect().top + window.scrollY - 160);
+ window.scrollTo({top: y, behavior: 'smooth'});
+ }, 50);
}
render()
{
- const { deals, dealSelected } = this.props;
-
- console.log({ deals });
+ const { status, deals, questionnaire_status, dealSelected, onCloseDeal, onDealsUpdate, onDealContractsUpdate, onQuestionnaire } = this.props;
return (
-
+
{ deals.list !== undefined && deals.list !== null && deals.list.map((deal, index) =>
{
- if(index === dealSelected)
+ if(dealSelected === deal.opp_number)
{
return (
{
- this._handleModalToggle("current")
- }}
+ index={ index }
+ ref={ ref => this.items_ref[index] = ref }
+ status={ status }
+ dealSelected={ dealSelected }
+ deals={ deals }
+ questionnaire_status={ questionnaire_status }
+ onFocusDeal={ () => this._scrollToDeal(index) }
+ onCloseDeal={ this._handle_onCloseDeal }
+ onDealsUpdate={ onDealsUpdate }
+ onDealContractsUpdate={ onDealContractsUpdate }
+ onQuestionnaire={ onQuestionnaire }
+ { ...deal }
/>)
}
else
@@ -34,7 +74,9 @@ export default class DealsList extends React.Component
this.items_ref[index] = ref }
{ ...deal }
+ onSelectDeal={ this._handle_onSelectDeal }
/>
)
}
diff --git a/components/DealsStatus/DealsListDeal.js b/components/DealsStatus/DealsListDeal.js
index 2c5dfe2..6a5cf53 100644
--- a/components/DealsStatus/DealsListDeal.js
+++ b/components/DealsStatus/DealsListDeal.js
@@ -1,12 +1,48 @@
import React from "react";
import pluralize from 'pluralize-ru';
-const statuses = [
- {
+const statuses = {
+ "100": {
+ index: undefined,
+ title: "Выбор КП",
+ icon: "/assets/images/status/icon_deal_status_100.svg",
+ },
+ "101": {
+ index: 1,
+ title: "Выбор программы финансирования",
+ icon: "/assets/images/status/icon_deal_status_101.svg",
+ },
+ "102": {
+ index: 2,
title: "Сбор пакета документов",
- icon: "/assets/images/status/1.svg",
- }
-];
+ icon: "/assets/images/status/icon_deal_status_102.svg",
+ },
+ "103": {
+ index: 3,
+ title: "Проверка документов",
+ icon: "/assets/images/status/icon_deal_status_103.svg",
+ },
+ "104": {
+ index: 4,
+ title: "Принятие решения по сделке",
+ icon: "/assets/images/status/icon_deal_status_104.svg",
+ },
+ "105": {
+ index: 5,
+ title: "Требуется изменение параметров",
+ icon: "/assets/images/status/icon_deal_status_105.svg",
+ },
+ "106": {
+ index: 5,
+ title: "Принято положительное решение",
+ icon: "/assets/images/status/icon_deal_status_106.svg",
+ },
+ "107": {
+ index: 6,
+ title: "Оформление лизинга",
+ icon: "/assets/images/status/icon_deal_status_107.svg",
+ },
+};
export default class DealsListDeal extends React.Component
{
@@ -15,21 +51,21 @@ export default class DealsListDeal extends React.Component
super(props)
}
+ //getDealOffers
+
render()
{
- const { index, comment, opp_number, statuscode_id, statuscode_name } = this.props;
+ const { onSelectDeal, index, comment, opp_number, statuscode_id, statuscode_name } = this.props;
const step = statuscode_id - 100;
- console.log("deal list item", { props: this.props });
-
return (
-
Сделка { index + 1 }
+
№ { opp_number }
- { step === 0 ? "Не начата" : `${ step } ${ pluralize(step, 'этапа', 'этап', 'этапа', 'этапов') } ${ pluralize(step, 'пройдено', 'пройден', 'пройдено', 'пройдено') }` }
+ { statuses[ statuscode_id ].index === undefined ? "Новая сделка" : `${ statuses[ statuscode_id ].index } ${ pluralize(step, 'этапа', 'этап', 'этапа', 'этапов') } ${ pluralize(statuses[ statuscode_id ].index, 'пройдено', 'пройден', 'пройдено', 'пройдено') }` }
{/*}
-

-
Сбор пакета документов
+

+ {/*}
{ statuscode_name }
{*/}
+
{ statuses[ statuscode_id ].title }
-