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

北电科 安全漏洞 解决 getSqlData 接口参数的问题

上级 9a9bf1e2
......@@ -388,20 +388,23 @@ export default class ZdyTable extends Component {
}
const data = datas[tr.key];
const all = [];
for (var i = 0; i < data.items.length; i++) {
const row = data.items[i];
const r = [];
for (var j = 0; j < row.length; j++) {
const col = row[j];
if (col.content?.comName == 'Excel') {
r.push(col.content.initialValue);
} else {
r.push('');
if(data && data.item){
for (var i = 0; i < data.items.length; i++) {
const row = data.items[i];
const r = [];
for (var j = 0; j < row.length; j++) {
const col = row[j];
if (col.content?.comName == 'Excel') {
r.push(col.content.initialValue);
} else {
r.push('');
}
}
all.push(r);
}
all.push(r);
}
sheetData[tr.title] = all;
};
configs;
......
......@@ -861,11 +861,22 @@ export default class TableCom extends Component {
return 'norefeshxxxxxxxxxxxxxxxxxxxx';
};
sqlUtil = (base52, json, orgCallback, sqlKey, params, callback, options = {}) => {
let otherParams = {};
if(params && params.otherParams){
otherParams = {
...params.otherParams,
}
}
// console.log({
// base52, json, orgCallback, sqlKey, params, callback, options
// })
//查缓存
// console.log(params && params.otherParams, JSON.stringify(params));
var isChange = false;
const { sqlKeys } = this.state;
......@@ -968,10 +979,13 @@ export default class TableCom extends Component {
...this.props.defaultValues[this.props.formKey],
...options,
});
let pp = {
sqlKey,
params,
allValues,
...otherParams,
};
if (getToken() != null) {
pp.token = getToken();
......
return {
onClick:()=>{
let year = obj.id_967fc7b52d2252402829eb2291b62a1e3c6a.toString();
let faculty = obj.id_45ebeb1625a17240d62bed62f17ff2cdc977;
if( !(year && year.length > 0) ){
let messageName = `请选择年级!`;
console.log(messageName);
utils.message.warning(messageName);
return
}
let region = obj.id_f2ba7db325e44240222bc7c2597f009e4351;
let regionLength = 0;
if(region){
regionLength = region.length;
}
let regionField = `sa.unit_adress_province_name`;
let regionFieldSql = ` `;
switch(regionLength){
case 1 :
regionField = `sa.unit_adress_city_name`;
regionFieldSql = ` and sa.unit_adress_province_name = '${region[0]}'`;
break;
case 2 :
regionField = `sa.unit_adress_name`;
regionFieldSql = ` and sa.unit_adress_province_name = '${region[0]}' and sa.unit_adress_city_name = '${region[1]}'`;
break;
default:
regionField = `sa.unit_adress_province_name`;
regionFieldSql = ` `;
}
let dataSql = `WITH basics AS (
SELECT
sa.graduate_year AS grade_name,
${regionField} AS 'statistics',
sa.institution_name AS 'header',
count( 1 ) AS amount
FROM
zy_dxg_produce.vi_jy_contract_assignment_student sa
WHERE
sa.graduate_year = '${year}' ${regionFieldSql}
and sa.unit_adress_province_title is not null
GROUP BY
${regionField},
sa.institution_name
),
total AS (
SELECT
grade_name,
institution_name AS header,
sum( sum ) AS total
FROM
(
SELECT
stu.graduate_year AS grade_name,
xm.NAME AS major_name,
xi.NAME AS institution_name,
count( 1 ) AS sum
FROM
zy_dxg_produce.jy_student stu
LEFT JOIN zy_dxg_produce.xg_student xs ON stu.student_id = xs.id
LEFT JOIN zy_dxg_produce.jc_dict jc ON stu.gender_id = jc.dict_id
LEFT JOIN zy_dxg_produce.xg_grade xg ON stu.grade_id = xg.id
LEFT JOIN zy_dxg_produce.xg_clazz xc ON stu.clazz_id = xc.id
LEFT JOIN zy_dxg_produce.xg_major xm ON xm.id = xc.major_id
LEFT JOIN zy_dxg_produce.xg_institution xi ON xi.id = xc.institution_id
WHERE
TRUE and stu.graduate_year = '${year}'
GROUP BY
xm.NAME,
xi.NAME
) a WHERE true
GROUP BY
a.grade_name,
a.institution_name
),sum as (
SELECT
sum( amount ) AS amount,
sum( total ) AS total
FROM
(
SELECT
basics.statistics,
basics.header,
sum( basics.amount ) AS amount,
total.total
FROM
basics
LEFT JOIN total ON basics.grade_name = total.grade_name
AND basics.header = total.header
GROUP BY
header
) a
),
tj1 AS (
SELECT
basics.statistics,
basics.header,
basics.amount,
total.total,
round( ( basics.amount / total.total ) * 100, 2 ) AS probability,
RANK ( ) OVER ( ORDER BY statistics DESC ) AS paging_sort,
0 AS list_sort
FROM
basics
LEFT JOIN total ON basics.grade_name = total.grade_name
AND basics.header = total.header
),
tj2 AS (
SELECT
tj1.statistics,
'小计' AS header,
sum( tj1.amount ) AS amount,
sum.total AS total,
round( ( sum( tj1.amount ) / sum.total ) * 100, 2 ) AS probability,
tj1.paging_sort,
9999999 AS list_sort
FROM
tj1 LEFT JOIN sum on true
GROUP BY
tj1.paging_sort
),
tj3 AS (
SELECT
'合计' AS statistics,
header,
sum( amount ) AS amount,
total,
sum( probability ) AS probability,
( SELECT max( paging_sort ) + 1 FROM tj1 ) AS paging_sort,
9999999 AS list_sort
FROM
tj1
GROUP BY
header
),
tj4 AS (
SELECT
'合计' AS statistics,
'小计' AS header,
sum( amount ) AS amount,
sum( total ) AS total,
round( ( sum( amount ) / sum( total ) ) * 100, 2 ) AS probability,
( SELECT max( paging_sort ) + 1 FROM tj1 ) AS paging_sort,
9999999 AS list_sort
FROM
sum
) SELECT
*
FROM
( SELECT * FROM tj1 UNION ALL SELECT * FROM tj2 UNION ALL SELECT * FROM tj3 UNION ALL SELECT * FROM tj4 ) a
ORDER BY
list_sort,paging_sort ASC;`;
let dataFacultySql = `WITH basics AS (
SELECT
sa.graduate_year AS grade_name,
${regionField} AS 'statistics',
sa.major_name AS 'header',
count( 1 ) AS amount
FROM
zy_dxg_produce.vi_jy_contract_assignment_student sa
WHERE
sa.graduate_year = '${year}' and sa.institution_name = '${faculty}' ${regionFieldSql}
and sa.unit_adress_province_title is not null
GROUP BY
${regionField},
sa.major_name
),
total AS (
SELECT
grade_name,
major_name AS header,
sum( sum ) AS total
FROM
(
SELECT
stu.graduate_year AS grade_name,
xm.NAME AS major_name,
xi.NAME AS institution_name,
count( 1 ) AS sum
FROM
zy_dxg_produce.jy_student stu
LEFT JOIN zy_dxg_produce.xg_student xs ON stu.student_id = xs.id
LEFT JOIN zy_dxg_produce.jc_dict jc ON stu.gender_id = jc.dict_id
LEFT JOIN zy_dxg_produce.xg_grade xg ON stu.grade_id = xg.id
LEFT JOIN zy_dxg_produce.xg_clazz xc ON stu.clazz_id = xc.id
LEFT JOIN zy_dxg_produce.xg_major xm ON xm.id = xc.major_id
LEFT JOIN zy_dxg_produce.xg_institution xi ON xi.id = xc.institution_id
WHERE
TRUE and stu.graduate_year = '${year}'
GROUP BY
xm.NAME,
xi.NAME
) a
WHERE true and a.institution_name = '${faculty}'
GROUP BY
a.grade_name,
a.major_name
),sum as (
SELECT
sum( amount ) AS amount,
sum( total ) AS total
FROM
(
SELECT
basics.statistics,
basics.header,
sum( basics.amount ) AS amount,
total.total
FROM
basics
LEFT JOIN total ON basics.grade_name = total.grade_name
AND basics.header = total.header
GROUP BY
header
) a
),
tj1 AS (
SELECT
basics.statistics,
basics.header,
basics.amount,
total.total,
round( ( basics.amount / total.total ) * 100, 2 ) AS probability,
RANK ( ) OVER ( ORDER BY statistics DESC ) AS paging_sort,
0 AS list_sort
FROM
basics
LEFT JOIN total ON basics.grade_name = total.grade_name
AND basics.header = total.header
),
tj2 AS (
SELECT
tj1.statistics,
'小计' AS header,
sum( tj1.amount ) AS amount,
sum.total AS total,
round( ( sum( tj1.amount ) / sum.total ) * 100, 2 ) AS probability,
tj1.paging_sort,
9999999 AS list_sort
FROM
tj1 LEFT JOIN sum on true
GROUP BY
tj1.paging_sort
),
tj3 AS (
SELECT
'合计' AS statistics,
header,
sum( amount ) AS amount,
total,
sum( probability ) AS probability,
( SELECT max( paging_sort ) + 1 FROM tj1 ) AS paging_sort,
9999999 AS list_sort
FROM
tj1
GROUP BY
header
),
tj4 AS (
SELECT
'合计' AS statistics,
'小计' AS header,
sum( amount ) AS amount,
sum( total ) AS total,
round( ( sum( amount ) / sum( total ) ) * 100, 2 ) AS probability,
( SELECT max( paging_sort ) + 1 FROM tj1 ) AS paging_sort,
9999999 AS list_sort
FROM
sum
) SELECT
*
FROM
( SELECT * FROM tj1 UNION ALL SELECT * FROM tj2 UNION ALL SELECT * FROM tj3 UNION ALL SELECT * FROM tj4 ) a
ORDER BY
list_sort,paging_sort ASC;`;
let titleSql =`WITH basics AS (
SELECT
sa.graduate_year AS grade_name,
${regionField} AS 'statistics',
sa.institution_name AS 'header',
count( 1 ) AS amount
FROM
zy_dxg_produce.vi_jy_contract_assignment_student sa
WHERE
sa.graduate_year = '${year}' ${regionFieldSql}
GROUP BY
${regionField},
sa.institution_name
),
total AS (
SELECT
grade_name,
institution_name AS header,
sum( sum ) AS total
FROM
(
SELECT
stu.graduate_year AS grade_name,
xm.NAME AS major_name,
xi.NAME AS institution_name,
count( 1 ) AS sum
FROM
zy_dxg_produce.jy_student stu
LEFT JOIN zy_dxg_produce.xg_student xs ON stu.student_id = xs.id
LEFT JOIN zy_dxg_produce.jc_dict jc ON stu.gender_id = jc.dict_id
LEFT JOIN zy_dxg_produce.xg_grade xg ON stu.grade_id = xg.id
LEFT JOIN zy_dxg_produce.xg_clazz xc ON stu.clazz_id = xc.id
LEFT JOIN zy_dxg_produce.xg_major xm ON xm.id = xc.major_id
LEFT JOIN zy_dxg_produce.xg_institution xi ON xi.id = xc.institution_id
WHERE
TRUE AND stu.graduate_year = '${year}'
GROUP BY
xm.NAME,
xi.NAME
) a
WHERE
TRUE
GROUP BY
a.grade_name,
a.institution_name
) SELECT DISTINCT
JSON_OBJECT( total.header, total.total ) AS totals
FROM
total
LEFT JOIN basics ON basics.grade_name = total.grade_name
AND basics.header = total.header`;
let titleFacultySql =`WITH basics AS (
SELECT
sa.graduate_year AS grade_name,
sa.unit_adress_province_name AS 'statistics',
sa.major_name AS 'header',
count( 1 ) AS amount
FROM
zy_dxg_produce.vi_jy_contract_assignment_student sa
WHERE
sa.graduate_year = '${year}' and sa.institution_name = '${faculty}' ${regionFieldSql}
GROUP BY
sa.unit_adress_province_name,
sa.major_name
),
total AS (
SELECT
grade_name,
major_name AS header,
sum( sum ) AS total
FROM
(
SELECT
stu.graduate_year AS grade_name,
xm.NAME AS major_name,
xi.NAME AS institution_name,
count( 1 ) AS sum
FROM
zy_dxg_produce.jy_student stu
LEFT JOIN zy_dxg_produce.xg_student xs ON stu.student_id = xs.id
LEFT JOIN zy_dxg_produce.jc_dict jc ON stu.gender_id = jc.dict_id
LEFT JOIN zy_dxg_produce.xg_grade xg ON stu.grade_id = xg.id
LEFT JOIN zy_dxg_produce.xg_clazz xc ON stu.clazz_id = xc.id
LEFT JOIN zy_dxg_produce.xg_major xm ON xm.id = xc.major_id
LEFT JOIN zy_dxg_produce.xg_institution xi ON xi.id = xc.institution_id
WHERE
TRUE and stu.graduate_year = '${year}'
GROUP BY
xm.NAME,
xi.NAME
) a
WHERE
TRUE and a.institution_name = '${faculty}'
GROUP BY
a.grade_name,
a.major_name
) SELECT DISTINCT
JSON_OBJECT( total.header, total.total ) AS totals
FROM
total
LEFT JOIN basics ON basics.grade_name = total.grade_name
AND basics.header = total.header`;
const paramsThis = [];
paramsThis.__proto__.otherParams = {
jsParams: true,
};
utils.sql(!faculty ? dataSql : dataFacultySql,paramsThis,(result,com) => {
// let userData = JSON.parse(localStorage.getItem('user'));
utils.sql(!faculty ? titleSql : titleFacultySql,[],(titleResult,com) => {
let DataList = result;
let {headerList,headerJson} = getHeaderData(DataList,titleResult);
let xs = {
btns:{
before:[
{children:"导出",type:"primary",onClick:()=>{
let {columnsList,columnsMerges,columnsKey} = getColumns(headerJson);
// getColumnsSqlKeyRealize("LeBEHNTzXyo",columnsList,columnsMerges,columnsKey);
getColumnsDataRealize(getProcessingData(DataList),columnsList,columnsMerges,columnsKey,"0")
}}
]},
columns:headerJson,
time:new Date().valueOf(),
getPage:(params, callback) => {
let listdata = getProcessingData(DataList);
if(params.pageNo == null){
params.pageNo = 1;
params.pageSize = 1000;
}
const x = {
list: listdata ,
pagination: {
current: params.pageNo,
pageSize: params.pageSize,
total: listdata.length
}
}
callback(x);
}
};
utils.setValues({"id_a6fc01522869b243792982a2cb03c94a2bee":xs});
});
});
}
}
function getHeaderData(data,titleData){
let headerMapKey = {};
let headerMapSum = 0;
titleData.map(function (item, index) {
headerMapKey={...headerMapKey,...JSON.parse(item.totals) };
});
for(var i in headerMapKey){
headerMapSum += Number(headerMapKey[i]);
}
headerMapKey['小计'] = headerMapSum;
// let headerList = new Set(data.map(function (item, index) {return item.header }));
let headerList = new Set(Object.keys(headerMapKey));
data.map(function (item, index) {
headerList.add(item.header);
})
let headerJson = [
//{title:"序号",dataIndex:"paging_sort",width:80},
{title:"各生源地(省)就业率",dataIndex:"statistics",width:200}
];
headerList.forEach((v,i)=>{
headerJson.push({
title:v,
children:[
// {title:"总人数",dataIndex:v+'total',width:100},
{
title:`总人数:${headerMapKey[v]}`,
children:[
{title:"就业人数",dataIndex:v+'amount',width:100,render:(val)=>val ? val : "0"},
{title:"就业率",dataIndex:v+'probability',width:100,render:(val)=>val ? val+"%" : "0%"}
]
}
]
});
});
return {"headerList":headerList,"headerJson":headerJson}
}
function getProcessingData(data){
let showData = [];
let CompareKey = "paging_sort";
let dataList = new Set(data.map(function (item, index) { return item[CompareKey] }));
for(var i of dataList){
let insertJson = {};
data.forEach((dv,di)=>{
if(i==dv[CompareKey]){
insertJson["paging_sort"] = dv.paging_sort;
insertJson["statistics"] = dv.statistics;
insertJson[dv.header+"probability"] = dv.probability;
insertJson[dv.header+"amount"] = dv.amount;
// insertJson[dv.header+"total"] = dv.total;
}
});
showData.push(insertJson);
}
return showData
}
//let {columnsList,columnsMerges,columnsKey} = getColumns(headerJson);
//所有数据走配置项导出 getColumnsDataRealize(getProcessingData(DataList),columnsList,columnsMerges,columnsKey,"0")
//表头配置项,数据sqlKey getColumnsSqlKeyRealize("LeBEHNTzXyo",columnsList,columnsMerges,columnsKey);
function getHeaderData(data,titleData){
// debugger;
let headerMapKey = {};
let headerMapSum = 0;
titleData.map(function (item, index) {
headerMapKey={...headerMapKey,...JSON.parse(item.totals) };
});
for(var i in headerMapKey){
headerMapSum += Number(headerMapKey[i]);
}
headerMapKey['小计'] = headerMapSum;
// let headerList = new Set(data.map(function (item, index) {return item.header }));
let headerList = new Set(Object.keys(headerMapKey));
data.map(function (item, index) {
headerList.add(item.header);
})
let headerJson = [
//{title:"序号",dataIndex:"paging_sort",width:80},
{title:"各生源地(省)就业率",dataIndex:"statistics",width:200}
];
headerList.forEach((v,i)=>{
headerJson.push({
title:v,
children:[
// {title:"总人数",dataIndex:v+'total',width:100},
{
title:`总人数:${headerMapKey[v]}`,
children:[
{title:"就业人数",dataIndex:v+'amount',width:100,render:(val)=>val ? val : "0"},
{title:"就业率",dataIndex:v+'probability',width:100,render:(val)=>val ? val+"%" : "0%"}
]
}
]
});
});
return {"headerList":headerList,"headerJson":headerJson}
}
function getProcessingData(data){
let showData = [];
let CompareKey = "paging_sort";
let dataList = new Set(data.map(function (item, index) { return item[CompareKey] }));
for(var i of dataList){
let insertJson = {};
data.forEach((dv,di)=>{
if(i==dv[CompareKey]){
insertJson["paging_sort"] = dv.paging_sort;
insertJson["statistics"] = dv.statistics;
insertJson[dv.header+"probability"] = dv.probability;
insertJson[dv.header+"amount"] = dv.amount;
// insertJson[dv.header+"total"] = dv.total;
}
});
showData.push(insertJson);
}
return showData
}
function getColumns(columns){
const uj = {"t":1,"v":"序号",s:"header"};
let columnsHeight = getColumnsMaxLevel(columns);//递归行数
console.log("getColumnsMaxLevel(columns)",columnsHeight);
let columnsKey = [];
const columnsList = new Array(columnsHeight).fill([]);
let col = 1;
for(var i in columnsList){
columnsList[i] = new Array(getColumnsWidth(columns)).fill({});
};
function getColumnsData(data = [], res = [], level = 1){
for(let item of data ){
//item.key = i;
let isLast = !item.children;
item.level = level;
item.isLast = isLast;
item.width = !isLast ? getColumnsWidth(item.children) : 1;
item.col = col;
res.push(item);
columnsList[level-1][col-1] = {...uj,v:item.title};
if(!isLast){
if(Array.isArray(item.children)){
let x = level + 1;
getColumnsData(item.children, res, x);
}
}else{
col++;
columnsKey.push(item["dataIndex"]);
}
}
return res;
};
//递归行数
function getColumnsMaxLevel(d = [],sum = 0){
function xxxxxx(data = [],level = 1){
for(let item of data ){
let isLast = !item.children;
if(!isLast && Array.isArray(item.children)){
let x = level + 1;
if(sum < x){
sum=x;
}
xxxxxx(item.children, x);
}
}
}
xxxxxx(d);
return sum;
};
//递归当前数据宽度
function getColumnsWidth(data = [],sum = 0){
for(let item of data ){
if(!item.children){
sum++;
}else{
sum = getColumnsWidth(item.children,sum);
}
}
return sum;
};
let columnsHandle = getColumnsData(columns).filter((v,i)=>{
return ( v.level < columnsHeight && v.isLast ) || v.width > 1
});
let columnsMerges = [];
columnsHandle.forEach((v, i) => {
let {isLast,width,col,level} = v;
let nowCol = col-1;
let nowLevel = level-1;
if(isLast && width===1){
//合并表格的 开始行、结束行、开始列、结束列
columnsMerges.push([nowLevel,columnsHeight-1,nowCol,nowCol]);
};
if(!isLast && width>1){
columnsMerges.push([nowLevel,nowLevel,nowCol,nowCol+width-1]);
};
});
return {columnsList,columnsMerges,columnsKey};
};
// 表头和sql数据导出
function getColumnsSqlKeyRealize(sqlKey,columnsList,columnsMerges,columnsKey,fileName="导出EXCL文件",ext = 'xlsx',url = `/DataObjApi/exportCustom`){
let content = {
"sheets":[
{
"name":fileName,
"cells":columnsList,
"merges":columnsMerges,
"sqlKey":sqlKey,//sql编码
"sqlKeyHeader":columnsKey//sql对应key对应列
}
],
"styles": {
"header": {
"font": {
"bold": false,
"fontHeightInPoints":12
},
"alignment": "CENTER",
"borderLeft": "THIN",
"borderTop": "THIN",
"borderBottom": "THIN",
"borderRight": "THIN",
"verticalAlignment":true,
"wrapText":true,
"rowHeights":20,
"colWidths":200
},
"head": {
"font": {
"bold": true
},
"alignment": "CENTER",
}
}
};
let {apiList} = window.smartFormGlobalProps;
let getFileData = apiList.giveFilePostDataInfoForTrue(
{
content:content,
title:fileName
},
`${window.location.origin}/produce/v1/api/onestop${url}`
);
downloadFile(getFileData.url,getFileData.datas, fileName,ext);
}
// 表头和数据 合并导出
function getColumnsDataRealize(data = [],columnsList,columnsMerges,columnsKey,defect = null,fileName="导出EXCL文件",ext = 'xlsx',url = `/DataObjApi/exportCustom`){
let bodyData = [];
const uj = {"t":1,"v":"序号",s:"header"};
data.forEach((dv, di) => {
let nowArroy = new Array(columnsKey.length).fill({});
columnsKey.forEach((av, ai) => {
nowArroy[ai] = {
...uj,
v: av in dv ? dv[av].toString() : (defect || "")
};
});
bodyData.push(nowArroy);
})
// console.log("data",data);
// console.log("columnsList",columnsList);
// console.log("columnsMerges",columnsMerges);
// console.log("columnsKey",columnsKey);
// console.log("bodyData",bodyData);
let content = {
"sheets":[
{
"name":fileName,
"cells":[...columnsList,...bodyData],
"merges":columnsMerges
}
],
"styles": {
"header": {
"font": {
"bold": false,
"fontHeightInPoints":12
},
"alignment": "CENTER",
"borderLeft": "THIN",
"borderTop": "THIN",
"borderBottom": "THIN",
"borderRight": "THIN",
//"verticalAlignment":true,
"wrapText":true,
"rowHeights":20,
"colWidths":200
},
"head": {
"font": {
"bold": true
},
"alignment": "CENTER",
}
}
};
let {apiList} = window.smartFormGlobalProps;
let getFileData = apiList.giveFilePostDataInfoForTrue(
{
content:content,
title:fileName
},
`${window.location.origin}/produce/v1/api/onestop${url}`
);
let token = localStorage.getItem('antd-pro-token-onestop');
downloadFile(getFileData.url,{
...getFileData.datas,
token:token
}, fileName,ext);
}
function isObject (value) {
return value === Object(value)
}
function isArray (value) {
return Array.isArray(value)
}
function isFile (value) {
return value instanceof File
}
function makeArrayKey (key) {
return key
}
function FormdataWrapper (obj, fd, pre) {
fd = fd || new FormData()
Object.keys(obj).forEach(function (prop) {
var key = pre ? (pre + '[' + prop + ']') : prop
if (isObject(obj[prop]) && !isArray(obj[prop]) && !isFile(obj[prop])) {
FormdataWrapper(obj[prop], fd, key)
} else if (isArray(obj[prop])) {
obj[prop].forEach(function (value) {
var arrayKey = makeArrayKey(key)
if (isObject(value) && !isFile(value)) {
FormdataWrapper(value, fd, arrayKey)
} else {
fd.append(arrayKey, value)
}
})
} else {
if(obj[prop]!=null) fd.append(key, obj[prop])
}
})
return fd
}
function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx') {
// console.log("downloadFile",url);
fetch(url, {
method: 'POST',
body: FormdataWrapper(params),
})
.then((res) => {
if (res.status + '' !== '200') {
return res.json();
} else {
return res.blob();
}
})
.then((data) => {
if (data instanceof Blob) {
let a = document.createElement('a');
let url = window.URL.createObjectURL(data);
let filename = fileName + '.' + ext;
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(url);
a = null;
} else {}
})
.catch((err) => {
console.log(err);
})
.finally(() => {
return true;
});
}
......@@ -129,11 +129,7 @@ const getUrl = url => (url.startsWith('/') ? url : '/' + url);
export const request = (url, data, options = {}) => {
if (url && url.indexOf('getSqlData') > -1) {
console.log({
url,
data,
options,
});
console.log(data);
}
return giveBase16EnCode(data, url)
.then((newData) => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论