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

// 按欢哥的要求 getSqlData 接口要加上appId 参数

// 解决北电科接口越权的问题.
上级 f84eaaa1
import encryptApiList, { resBinaryApiList } from '@/webPublic/one_stop_public/Base16/encryptApiList'; import encryptApiList, {
resBinaryApiList,
} from '@/webPublic/one_stop_public/Base16/encryptApiList';
import { getToken, getUserInfo } from '@/webPublic/one_stop_public/utils/token'; import { getToken, getUserInfo } from '@/webPublic/one_stop_public/utils/token';
import { queryApiActionPath } from '@/webPublic/one_stop_public/utils/queryConfig'; import { queryApiActionPath } from '@/webPublic/one_stop_public/utils/queryConfig';
import { qqCw } from '@/webPublic/one_stop_public/utils/request'; import { qqCw } from '@/webPublic/one_stop_public/utils/request';
...@@ -11,191 +13,190 @@ import { strToBinary } from './strToBinary'; // 字符串转二进制 混淆代 ...@@ -11,191 +13,190 @@ import { strToBinary } from './strToBinary'; // 字符串转二进制 混淆代
import { binaryToStr } from './binaryToStr'; import { binaryToStr } from './binaryToStr';
import { getVisitorToken } from '@/webPublic/zyd_public/utils/getHeaders'; // 二进制字符串转JSON字符串 混淆代码 import { getVisitorToken } from '@/webPublic/zyd_public/utils/getHeaders'; // 二进制字符串转JSON字符串 混淆代码
const test = !!(getUrlInfo().test); const test = !!getUrlInfo().test;
function formatDatas(datas, url = '') { function formatDatas(datas, url = '') {
let datasCode = JSON.stringify(datas); if (url && url.indexOf('getSqlData') > -1 && window.smartFormGlobalProps?.data) {
const openIsBinary = window.CONFIG?.IS_BINARY; // 按欢哥的要求 getSqlData 接口要加上appId 参数
if (test) { // 解决北电科接口越权的问题.
console.log(url, datas); datas.appId = window.smartFormGlobalProps?.data.appId || window.smartFormGlobalProps?.data.id;
} console.log('getSqlData,AppId', datas.appId);
if (openIsBinary) { }
datasCode = strToBinary(datasCode); let datasCode = JSON.stringify(datas);
} const openIsBinary = window.CONFIG?.IS_BINARY;
let file = new File([datasCode], 'fileParams.jpeg', {
type: 'image/jpeg', if (test) {
}); console.log(url, datas);
}
let datasTrue = { if (openIsBinary) {
fileParams: file, datasCode = strToBinary(datasCode);
}; }
if (openIsBinary) { let file = new File([datasCode], 'fileParams.jpeg', {
datasTrue.bin = true; type: 'image/jpeg',
if (window.CONFIG?.ALL_R_BIN) { });
datasTrue.rbin = true;
} else {
let findIndexA = resBinaryApiList.findIndex(g => {
return url.includes(g.api);
});
if (findIndexA >= 0) {
datasTrue.rbin = true;
}
}
} let datasTrue = {
return datasTrue; fileParams: file,
};
if (openIsBinary) {
datasTrue.bin = true;
if (window.CONFIG?.ALL_R_BIN) {
datasTrue.rbin = true;
} else {
let findIndexA = resBinaryApiList.findIndex((g) => {
return url.includes(g.api);
});
if (findIndexA >= 0) {
datasTrue.rbin = true;
}
}
}
return datasTrue;
} }
export async function giveFilePostData(datas, url) { export async function giveFilePostData(datas, url) {
for (let i in datas) { for (let i in datas) {
if ( if (
datas[i] === null || datas[i] === null ||
(Array.isArray(datas[i]) && datas[i].length === 0) || (Array.isArray(datas[i]) && datas[i].length === 0) ||
datas[i] === undefined datas[i] === undefined
) { ) {
delete datas[i]; delete datas[i];
} }
} }
if (url && typeof url === 'string') { if (url && typeof url === 'string') {
for (let item of encryptApiList) { for (let item of encryptApiList) {
if ((window.CONFIG?.ALLBIN && url.indexOf('/onestop/') > -1) || url.indexOf(item.api) > -1) { if ((window.CONFIG?.ALLBIN && url.indexOf('/onestop/') > -1) || url.indexOf(item.api) > -1) {
const roleGroup = getUserInfo().groupsId; const roleGroup = getUserInfo().groupsId;
if (url.indexOf('http') > -1) { if (url.indexOf('http') > -1) {
url = url.replace('/onestop/', `/onestop/safe/${roleGroup}/`); url = url.replace('/onestop/', `/onestop/safe/${roleGroup}/`);
} else { } else {
url = url.replace(url, `/safe/${roleGroup}/` + url); url = url.replace(url, `/safe/${roleGroup}/` + url);
url = url.replaceAll('//', '/'); url = url.replaceAll('//', '/');
} }
datas = await countAllValues(datas, item); datas = await countAllValues(datas, item);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve({ resolve({
datas: formatDatas(datas, url), datas: formatDatas(datas, url),
url, url,
}); });
}); });
} }
} }
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve(datas); resolve(datas);
return datas; return datas;
}); });
} }
function testPromise(d) { function testPromise(d) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve(d); resolve(d);
}); });
} }
export async function requestFileInfo(url, datas) { export async function requestFileInfo(url, datas) {
// for (let i = 0; i < 100; i++) { // for (let i = 0; i < 100; i++) {
// datas = await testPromise(datas); // datas = await testPromise(datas);
// } // }
const formData = new FormData(); const formData = new FormData();
if (getVisitorToken()) { if (getVisitorToken()) {
datas.token = getVisitorToken(); datas.token = getVisitorToken();
} }
for (let key in datas) { for (let key in datas) {
formData.append(key, datas[key]); formData.append(key, datas[key]);
} }
if (!url || typeof url !== 'string') { if (!url || typeof url !== 'string') {
return false; return false;
} }
let trueUrl = url && url.indexOf('http') > -1 ? url : queryApiActionPath() + url;
if (test) {
console.log('转换前', trueUrl);
}
const {transformApi, headersApi } = await getTransformApi(trueUrl);
if (test) {
console.log('转换后' + transformApi, headersApi);
}
return fetch(transformApi, {
headers: {
Accept: 'application/json',
...getHeaders(transformApi).headers,
// apis: headersApi,
// axxx: `select * from user123 where id = 1`,
},
method: 'POST',
credentials: 'omit',
mode: 'cors',
body: formData,
})
.then(res => {
if (res.status === 401) {
qqCw({
title: '登录过期401',
customErrMsg: '登录已过期,请重新登录',
});
return false;
}
if (res.status === 404) {
qqCw({
title: 'http404报错',
customErrMsg: '请联系系统管理员',
});
return false;
}
return res.json();
})
.then(res => {
if (res && typeof res === 'object' && res.rbin) {
res = binaryToStr(res.rbin); let trueUrl = url && url.indexOf('http') > -1 ? url : queryApiActionPath() + url;
if (isJSON(res)) { const { transformApi, headersApi } = await getTransformApi(trueUrl);
res = JSON.parse(res); return fetch(transformApi, {
} headers: {
} Accept: 'application/json',
if (res && res.errCode) { ...getHeaders(transformApi).headers,
qqCw({ // apis: headersApi,
msg: res.errMsg || res.message, // axxx: `select * from user123 where id = 1`,
customErrMsg: res.customErrMsg, },
}); method: 'POST',
return false; credentials: 'omit',
} mode: 'cors',
body: formData,
})
.then((res) => {
if (res.status === 401) {
qqCw({
title: '登录过期401',
customErrMsg: '登录已过期,请重新登录',
});
return false;
}
if (res.status === 404) {
qqCw({
title: 'http404报错',
customErrMsg: '请联系系统管理员',
});
return false;
}
return res.json();
})
.then((res) => {
if (res && typeof res === 'object' && res.rbin) {
res = binaryToStr(res.rbin);
if (isJSON(res)) {
res = JSON.parse(res);
}
}
if (res && res.errCode) {
qqCw({
msg: res.errMsg || res.message,
customErrMsg: res.customErrMsg,
});
return false;
}
if (test) { if (test) {
console.log({ console.log({
url, url,
res, res,
}); });
} }
return res; return res;
}); });
} }
export function giveFilePostDataInfoForTrue(datas, url) { export function giveFilePostDataInfoForTrue(datas, url) {
if (!window.CONFIG?.IS_SAFE) { if (!window.CONFIG?.IS_SAFE) {
return { return {
datas, datas,
url, url,
}; };
} }
datas = deepCopy(datas); datas = deepCopy(datas);
for (let i in datas) { for (let i in datas) {
if ( if (
datas[i] === null || datas[i] === null ||
(Array.isArray(datas[i]) && datas[i].length === 0) || (Array.isArray(datas[i]) && datas[i].length === 0) ||
datas[i] === undefined datas[i] === undefined
) { ) {
delete datas[i]; delete datas[i];
} }
} }
if (url) { if (url) {
const roleGroup = getUserInfo().groupsId; const roleGroup = getUserInfo().groupsId;
if (url.indexOf('http') > -1) { if (url.indexOf('http') > -1) {
url = url.replace('/onestop/', `/onestop/safe/${roleGroup}/`); url = url.replace('/onestop/', `/onestop/safe/${roleGroup}/`);
} else { } else {
url = url.replace(url, `/safe/${roleGroup}/` + url); url = url.replace(url, `/safe/${roleGroup}/` + url);
url = url.replaceAll('//', '/'); url = url.replaceAll('//', '/');
} }
return { return {
datas: formatDatas(datas, url), datas: formatDatas(datas, url),
url, url,
}; };
} }
} }
...@@ -14,6 +14,9 @@ export default function prepareShow(postData = {}, content = '') { ...@@ -14,6 +14,9 @@ export default function prepareShow(postData = {}, content = '') {
giveSmartFormGlobalProps({ giveSmartFormGlobalProps({
data: postData || content, data: postData || content,
}); });
if(process.env.NODE_ENV === 'development'){
// console.log(window.smartFormGlobalProps.data);
}
let agg = deepCopy(postData); let agg = deepCopy(postData);
window.beforeApplySubmit = undefined; // 流程发起时执行的异步回调函数 这里清空 防止泄露 window.beforeApplySubmit = undefined; // 流程发起时执行的异步回调函数 这里清空 防止泄露
window.beforeAuditSubmit = undefined; // 流程审批时执行的异步回调函数 这里清空 防止泄露 window.beforeAuditSubmit = undefined; // 流程审批时执行的异步回调函数 这里清空 防止泄露
...@@ -25,7 +28,7 @@ export default function prepareShow(postData = {}, content = '') { ...@@ -25,7 +28,7 @@ export default function prepareShow(postData = {}, content = '') {
window.moment = moment; window.moment = moment;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
console.log(agg?.unifiedServicePatternModel?.id); // 表单id; console.log(agg?.unifiedServicePatternModel?.id); // 表单id;
if (agg?.unifiedServicePatternModel?.id && (window.location.href.indexOf('localhost') > -1 || test)) { if (agg?.unifiedServicePatternModel?.id && process.env.NODE_ENV === 'development' || test) {
const SystemConfig = window.specialImportantSystemConfig || {}; const SystemConfig = window.specialImportantSystemConfig || {};
console.log('%c' + `${SystemConfig?.gateWayPort}/onestop/#/admin/processServices/modelConfig/templateDetail/designById?id=${agg.unifiedServicePatternModel.id}&token=${getToken()}`, 'color: green;background: white;font-size: 14px'); console.log('%c' + `${SystemConfig?.gateWayPort}/onestop/#/admin/processServices/modelConfig/templateDetail/designById?id=${agg.unifiedServicePatternModel.id}&token=${getToken()}`, 'color: green;background: white;font-size: 14px');
console.log('%c' + `${SystemConfig?.gateWayPort}/wisdomSchool/#/designFormByUrl?id=${agg.unifiedServicePatternModel.id}&token=${getToken()}`, 'color: green;background: white;font-size: 14px'); console.log('%c' + `${SystemConfig?.gateWayPort}/wisdomSchool/#/designFormByUrl?id=${agg.unifiedServicePatternModel.id}&token=${getToken()}`, 'color: green;background: white;font-size: 14px');
......
...@@ -26,7 +26,7 @@ export function getVisitorToken(){ ...@@ -26,7 +26,7 @@ export function getVisitorToken(){
headers: {}, headers: {},
}; };
if(process.env.NODE_ENV === 'development'){ if(process.env.NODE_ENV === 'development' && getIsBei_Dian()){
res.headers.env = 'test'; res.headers.env = 'test';
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论