Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
frontend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Schedules
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
h5-communicate
frontend
Commits
3ad67e50
Commit
3ad67e50
authored
Jul 21, 2020
by
熊成伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug
parent
7b8975fe
Pipeline
#16379
passed with stages
in 1 minute and 1 second
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
63 deletions
+58
-63
Process.jsx
src/pages/EventProcessing/Process.jsx
+8
-3
api.js
src/utils/api.js
+0
-19
downloadFile.js
src/utils/downloadFile.js
+48
-0
exportFile.js
src/utils/exportFile.js
+0
-38
instance.js
src/utils/instance.js
+2
-3
No files found.
src/pages/EventProcessing/Process.jsx
View file @
3ad67e50
...
...
@@ -2,7 +2,7 @@ import React, {useState, useEffect} from 'react';
import
Document
from
'react-document-title'
import
{
WingBlank
,
WhiteSpace
,
ActionSheet
,
Toast
}
from
'antd-mobile'
import
axiosRequest
from
'../../utils/request'
;
import
{
exportExcel
}
from
'../../utils/api
'
import
downloadFile
from
'../../utils/downloadFile
'
import
TopTabs
from
'../../components/Tabs/BlankTabs'
import
Skeleton
from
'../../components/Skeleton'
import
Basic
from
'./commponents/Basic'
...
...
@@ -148,11 +148,16 @@ const Process = (props) => {
};
const
download
=
(
uuid
,
callback
)
=>
{
const
developer
=
localStorage
.
getItem
(
'developer'
);
exportExcel
({
downloadFile
({
method
:
'post'
,
url
:
`/idtAppServiceV6/oApp/downloadLargeFile`
,
body
:
{
uuid
,
tableId
,
developer
},
callback
:
callback
}).
then
(
res
=>
{
var
downloadElement
=
document
.
createElement
(
'a'
);
downloadElement
.
href
=
res
.
request
.
responseURL
;
document
.
body
.
appendChild
(
downloadElement
);
downloadElement
.
click
();
//点击下载
document
.
body
.
removeChild
(
downloadElement
);
//下载完成移除元素
})
}
...
...
src/utils/api.js
deleted
100644 → 0
View file @
7b8975fe
import
{
exportRequest
}
from
'./exportFile'
;
const
token
=
localStorage
.
getItem
(
'token'
)
// 导出
export
function
exportExcel
(
params
)
{
var
body
=
{
name
:
params
.
name
,
body
:
params
.
body
,
callback
:
params
.
callback
,
method
:
params
.
method
||
'post'
};
var
config
=
{
headers
:
{
token
}
};
return
exportRequest
(
params
.
url
,
body
,
config
);
}
src/utils/downloadFile.js
0 → 100644
View file @
3ad67e50
import
axios
from
'axios'
;
const
instance
=
axios
.
create
();
export
const
apiUrl
=
'/'
;
const
token
=
localStorage
.
getItem
(
"token"
);
let
defaultHeaders
=
{
token
,
};
const
createAPI
=
(
baseURL
)
=>
{
return
(
conf
=
{})
=>
{
let
opts
=
conf
.
opts
||
{};
let
headers
=
{
...
defaultHeaders
,
...
opts
.
headers
};
return
instance
(
Object
.
assign
({},
{
url
:
conf
.
url
,
baseURL
:
baseURL
,
params
:
conf
.
opts
,
method
:
conf
.
method
,
data
:
conf
.
payload
||
null
,
headers
,
responseType
:
'blob'
,
}))
.
then
(
function
(
response
)
{
return
response
})
.
catch
(
error
=>
{
return
false
;
});
};
}
const
instance2
=
createAPI
(
apiUrl
);
async
function
downloadFile
(
option
=
{})
{
return
await
instance2
({
method
:
option
.
method
||
'get'
,
url
:
option
.
url
,
opts
:
option
.
body
||
null
,
});
}
export
default
downloadFile
;
src/utils/exportFile.js
deleted
100644 → 0
View file @
7b8975fe
import
axios
from
'axios'
;
const
instance
=
axios
.
create
();
export
function
exportRequest
(
url
,
conf
=
{},
headers
=
{})
{
//导出添加header
const
handleFunction
=
(
res
)
=>
{
//这里res.data是返回的blob对象
try
{
var
enc
=
new
TextDecoder
(
'utf-8'
);
var
result
=
JSON
.
parse
(
enc
.
decode
(
new
Uint8Array
(
res
.
data
)));
//转化成json对象
console
.
log
(
result
)
}
catch
(
error
)
{
var
blob
=
new
Blob
([
res
.
data
]);
var
downloadElement
=
document
.
createElement
(
'a'
);
var
href
=
window
.
URL
.
createObjectURL
(
blob
);
//创建下载的链接
downloadElement
.
href
=
href
;
// downloadElement.download = `${conf.name || 'table'}.xls`; //下载后文件名
document
.
body
.
appendChild
(
downloadElement
);
downloadElement
.
click
();
//点击下载
document
.
body
.
removeChild
(
downloadElement
);
//下载完成移除元素
window
.
URL
.
revokeObjectURL
(
href
);
//释放掉blob对象
conf
.
callback
&&
typeof
conf
.
callback
===
'function'
&&
conf
.
callback
();
}
};
return
instance
({
url
:
'http://124.93.101.8:9988'
+
url
,
method
:
conf
.
method
,
params
:
conf
.
body
,
headers
,
}).
then
(
response
=>
{
handleFunction
(
response
);
console
.
log
(
response
)
})
}
src/utils/instance.js
View file @
3ad67e50
...
...
@@ -39,7 +39,6 @@ export const createAPI = (baseURL) => {
urlParams
+=
qs
.
stringify
(
conf
.
opts
)
}
// console.log(headers)
return
instance
(
Object
.
assign
({},
{
url
:
conf
.
url
+
urlParams
,
...
...
@@ -54,8 +53,8 @@ export const createAPI = (baseURL) => {
if
(
!
response
||
!
(
response
.
data
||
response
.
tree
))
{
// response.status === 'failure' && (window.location.href = '/login')
response
.
code
===
'idt-jwt-500'
&&
(
window
.
location
.
href
=
'/login'
)
console
.
log
(
'response出错, 无返回数据!'
);
response
.
status
===
'failure'
&&
Toast
.
fail
(
response
.
message
)
console
.
log
(
'response出错, 无返回数据!'
,
response
);
Toast
.
fail
(
response
.
message
)
// return false;
};
if
(
response
.
data
&&
response
.
data
.
errorMessage
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment