提交 b97f4d53 authored 作者: 钟是志's avatar 钟是志

代码修改

上级 0e9afcb2
...@@ -8,6 +8,7 @@ import FormdataWrapper from '@/utils/object-to-formdata-custom'; ...@@ -8,6 +8,7 @@ import FormdataWrapper from '@/utils/object-to-formdata-custom';
import { getToken } from '@/utils/authority'; import { getToken } from '@/utils/authority';
import { offline } from './Toast'; import { offline } from './Toast';
import systemConfig from '@/config/config'; import systemConfig from '@/config/config';
import { uaaRequest } from "@/webPublic/one_stop_public/utils/request";
const codeMessage = { const codeMessage = {
200: '服务器成功返回请求的数据。', 200: '服务器成功返回请求的数据。',
...@@ -111,26 +112,6 @@ export const request = (url, data, options = {}) => { ...@@ -111,26 +112,6 @@ export const request = (url, data, options = {}) => {
}); });
}; };
const setRequestConfig = (config) => { export const apiRequest = uaaRequest;
return (url, data, options = {}) => {
if (Array.isArray(url)) {
return Promise.all(
url.map((ags) => {
return request(ags[0], ags[1], Object.assign({}, ags[2], config));
}),
);
}
return request(url, data, { ...options, ...config });
};
};
const createServerRequest = (config = {}) => {
return setRequestConfig(config);
};
export const apiRequest = createServerRequest({
method: 'POST',
prefix: systemConfig.sqlFormsServer || 'http://scjoyedu.eicp.net:18888/onestop/',
});
export default request; export default request;
import baseX from 'base-x'; import baseX from "base-x";
import { isEmpty, template } from 'lodash'; import { isEmpty, template } from "lodash";
import { apiRequest } from '../utils/request'; import { apiRequest } from "../utils/request";
var BASE16 = '0123456789abcdef'; import { isJSON } from "@/webPublic/zyd_public/utils/utils";
var BASE16 = "0123456789abcdef";
var bs16 = baseX(BASE16); var bs16 = baseX(BASE16);
export function Base16Encode(value) { export function Base16Encode(value) {
let is_open_base14 = sessionStorage.getItem('is_open_base16') let is_open_base14 = sessionStorage.getItem("is_open_base16")
? JSON.parse(sessionStorage.getItem('is_open_base16')) ? JSON.parse(sessionStorage.getItem("is_open_base16"))
: false; : false;
if (is_open_base14) return value ? bs16.encode(new Buffer(value)) : null; if (is_open_base14) return value ? bs16.encode(new Buffer(value)) : null;
return value; return value;
...@@ -22,107 +24,112 @@ const giveKey = (key, datas) => { ...@@ -22,107 +24,112 @@ const giveKey = (key, datas) => {
const encryptApiList = [ const encryptApiList = [
{ {
api: 'DataColumnApi/getOptions', api: "DataColumnApi/getOptions",
key: ['filterSql'], key: ["filterSql"]
}, },
{ {
api: 'DataColumnApi/getLabels', api: "DataColumnApi/getLabels",
key: ['allValues'], key: ["allValues"],
query: true, query: true,
setNull: true, setNull: true
}, },
{ {
api: 'DataColumnApi/getSqlOptions', api: "DataColumnApi/getSqlOptions",
key: ['allValues'], key: ["allValues"],
query: true, query: true
}, },
{ {
api: 'DataColumnApi/getSqlLabels', api: "DataColumnApi/getSqlLabels",
key: ['allValues'], key: ["allValues"],
query: true, query: true
}, },
{ {
api: 'DataColumnApi/getSqlData', api: "DataColumnApi/getSqlData",
key: ['allValues', 'sqlKey'], key: ["allValues", "sqlKey"],
query: true, query: true
}, },
{ {
api: 'DataRightApi/add', api: "DataRightApi/add",
key: ['filterSql'], key: ["filterSql"]
}, },
{ {
api: 'DataRightApi/addBatch', api: "DataRightApi/addBatch",
key: ['filterSql'], key: ["filterSql"]
}, },
{ {
api: 'DataObjApi/add', api: "DataObjApi/add",
key: ['sqlScript'], key: ["sqlScript"]
}, },
{ {
api: 'DataObjApi/getFormDataList', api: "DataObjApi/getFormDataList",
key: ['custom'], key: ["custom"]
}, },
{ {
api: 'DataObjApi/getFormDataPage', api: "DataObjApi/getFormDataPage",
key: ['sql', 'custom'], key: ["sql", "custom"]
}, },
{ {
api: 'UserApi/getPage', api: "UserApi/getPage",
key: ['addSignSql'], key: ["addSignSql"]
}, },
{ {
api: 'UnifiedAppFormApi/examineProcess', api: "UnifiedAppFormApi/examineProcess",
key: ['taskForm'], key: ["taskForm"]
}, },
{ {
api: 'UnifiedAppFormApi/saveDraft', api: "UnifiedAppFormApi/saveDraft",
key: ['content'], key: ["content"]
}, },
{ {
api: 'UnifiedAppFormApi/startProcess', api: "UnifiedAppFormApi/startProcess",
key: ['content'], key: ["content"]
}, },
{ {
api: 'UnifiedAppFormApi/startProcessByService', api: "UnifiedAppFormApi/startProcessByService",
key: ['content'], key: ["content"]
}, },
{ {
api: 'UnifiedAppFormApi/getHandleUser', api: "UnifiedAppFormApi/getHandleUser",
key: ['content'], key: ["content"]
}, }
] ];
export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
if (url && typeof url === 'string') { export function giveBase16EnCode(datas, url) { // 全局加解密函数.
if (url && typeof url === "string") {
for (let item of encryptApiList) { for (let item of encryptApiList) {
if (url.indexOf(item.api) > -1) { if (url.indexOf(item.api) > -1) {
for (let g of item.key) { for (let g of item.key) {
if (g == "allValues") { datas = giveKey(g, datas);
if (item.setNull) {
datas.allValues = "{}";
} else {
if (item.query) {
if (datas.sqlKey.length < 13) {
const response = await apiRequest("/SqlManageEntityApi/findParamsKey", { sqlKey: datas.sqlKey });
if (response.length == 0) { // if (g === "allValues" && false) {
datas.allValues = "{}"; // if (item.setNull) {
} else { // datas.allValues = "{}";
const x = JSON.parse(allValues); // } else {
const y = {}; // if (item.query) {
for (var i in response) { // if (datas.sqlKey.length < 13) {
if (x[i]) { // const response = await apiRequest("/SqlManageEntityApi/findParamsKey", { sqlKey: datas.sqlKey });
y[i] = x[i] //
} // if (response.length === 0) {
datas.allValues = JSON.stringify(y); // datas.allValues = "{}";
} // } else {
} // const x = isJSON(data.allValues) && JSON.parse(data.allValues) || {};
} else { // const y = {};
datas.allValues = "{}"; // for (let i in response) {
} // if (x[i]) {
} // y[i] = x[i];
} // }
datas = giveKey(g, datas); // datas.allValues = JSON.stringify(y);
} // }
// }
// } else {
// datas.allValues = "{}";
// }
// }
// }
// // datas = giveKey(g, datas);
// } else {
// datas = giveKey(g, datas);
// }
} }
return datas; return datas;
} }
......
...@@ -315,6 +315,7 @@ const setRequestConfig = config => { ...@@ -315,6 +315,7 @@ const setRequestConfig = config => {
}), }),
); );
} }
console.log(url, config);
return request(url, data, { ...options, ...config }); return request(url, data, { ...options, ...config });
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论