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

26873 就业毕业辅助管理-毕业生档案邮寄管理,导出网络超时

上级 dc4254ed
......@@ -9,6 +9,8 @@ import { getToken } from '../utils/token';
import config from '@/webPublic/one_stop_public/config';
import FormdataWrapper from '../utils/object-to-formdata-custom';
import ButtonDiy from './ButtonDiy/ButtonDiy';
import { queryIsSafe } from '@/webPublic/one_stop_public/utils/queryConfig';
import { giveFilePostData, giveFilePostDataInfoForTrue } from '@/webPublic/one_stop_public/Base16';
/**
*
* 2019/02/21 修改导出方式为fetch
......@@ -52,10 +54,11 @@ export default class ExportCurrentInfo extends React.Component {
downloadFile(url, params) {
this.setState({ confirmLoading: true });
fetch(url, {
let newApi = giveFilePostDataInfoForTrue(params, url);
fetch(newApi.url, {
method: 'POST',
body: FormdataWrapper(params),
body: FormdataWrapper(newApi.datas,
),
})
.then((res) => {
if (res.status != '200') {
......
......@@ -7,6 +7,7 @@ import FormdataWrapper from '../utils/object-to-formdata-custom';
import config from '@/webPublic/one_stop_public/config';
import { connect } from 'dva';
import { getMessage, getModal } from '@/webPublic/one_stop_public/utils/utils';
import { giveFilePostDataInfoForTrue } from '@/webPublic/one_stop_public/Base16';
const Modal = getModal();
const message = getMessage();
......@@ -218,9 +219,11 @@ export default class ImportUtil extends React.PureComponent {
fileName,
token: getToken(),
};
fetch(`${config.httpServer}/DataObjApi/importTemplateDownload`, {
let url = `${config.httpServer}/DataObjApi/importTemplateDownload`;
let newParams = giveFilePostDataInfoForTrue(params, url);
fetch(newParams.url, {
method: 'POST',
body: FormdataWrapper(params),
body: FormdataWrapper(newParams.datas),
})
.then((res) => {
if (res.status != '200') {
......
......@@ -4,6 +4,7 @@ import { isJSON } from '@/webPublic/zyd_public/utils/utils';
import { queryApiActionPath, queryIsSafe } from '@/webPublic/one_stop_public/utils/queryConfig';
import { getToken, getUserInfo } from '@/webPublic/one_stop_public/utils/token';
import encryptApiList from './encryptApiList';
import { uploadFile } from '@/webPublic/one_stop_public/libs/PictureSignature/ShowItem';
var BASE16 = '0123456789abcdef';
var bs16 = baseX(BASE16);
......@@ -92,20 +93,62 @@ export function requestFileInfo(url, datas) {
});
}
export function giveFilePostDataInfoForTrue(datas, url){
if(!queryIsSafe()){
return {
datas,
url,
}
}
for (let i in datas) {
if (datas[i] === null || (Array.isArray(datas[i]) && datas[i].length === 0) || datas[i] === undefined) {
delete datas[i];
}
}
if (url) {
const roleGroup = getUserInfo().groupsId;
if (url.indexOf('http') > -1) {
url = url.replace('/onestop/', `/onestop/safe/${roleGroup}/`);
} else {
url = url.replace(url, `/safe/${roleGroup}/` + url);
url = url.replaceAll('//', '/');
}
console.table({
datas,
url,
});
let file = new File([JSON.stringify(datas)], 'fileParams.jpeg', {
type: 'image/jpeg',
});
datas = {
fileParams: file,
};
return {
datas,
url,
}
}
}
function giveFilePostData(datas, url) {
for (let i in datas) {
if (datas[i] === null || (Array.isArray(datas[i]) && datas[i].length === 0) || datas[i] === undefined) {
delete datas[i];
}
}
url = url.replaceAll('//', '/');
if (url && typeof url === 'string') {
for (let item of encryptApiList) {
if (url.indexOf(item.api) > -1) {
const roleGroup = getUserInfo().groupsId;
url = url.replace(url, `/safe/${roleGroup}/` + url);
url = url.replaceAll('//', '/');
if (url.indexOf('http') > -1) {
url = url.replace('/onestop/', `/onestop/safe/${roleGroup}/` + url);
} else {
url = url.replace(url, `/safe/${roleGroup}/` + url);
url = url.replaceAll('//', '/');
}
console.table({
datas,
url,
......
import { giveFilePostDataInfoForTrue } from '@/webPublic/one_stop_public/Base16';
export function giveSmartFormGlobalProps({
fromStart = false,
hasSingle = false,
......@@ -18,6 +20,10 @@ export function giveSmartFormGlobalProps({
nextUsers,
calculateFlowData,
onlyRead,
apiList: {
giveFilePostDataInfoForTrue,
remark: 'giveFilePostDataInfoForTrue(params, url); 将接口参数 二进制文件化 并返回新的接口地址与参数',
}
};
return true;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论