Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-customization-system
/
oEshield
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ca49ee07
authored
May 12, 2022
by
zhangxw
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
接口调试,导出方法修改
1 parent
4ce8dade
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
23 deletions
src/api/services/monitor.js
src/pages/monitor/historyLocation.vue
src/pages/monitor/resident.vue
src/utils/exportExcel.js
src/api/services/monitor.js
View file @
ca49ee0
...
@@ -164,7 +164,7 @@ export const GET_AMAP_PROVINCE = params => {
...
@@ -164,7 +164,7 @@ export const GET_AMAP_PROVINCE = params => {
// 历史停留列表
// 历史停留列表
export
const
GET_HISTORY_LOCATION
=
params
=>
{
export
const
GET_HISTORY_LOCATION
=
params
=>
{
return
request
(
params
,
'/trialdrive/monitor/stayPointList'
,
'
ge
t'
)
return
request
(
params
,
'/trialdrive/monitor/stayPointList'
,
'
pos
t'
)
}
}
// 常驻地数据
// 常驻地数据
export
const
GET_RESIDENT_LOCATION
=
params
=>
{
export
const
GET_RESIDENT_LOCATION
=
params
=>
{
...
...
src/pages/monitor/historyLocation.vue
View file @
ca49ee0
...
@@ -175,6 +175,7 @@
...
@@ -175,6 +175,7 @@
standno
:
this
.
$route
.
query
.
standno
,
standno
:
this
.
$route
.
query
.
standno
,
sortByTimeIsPositive
:
true
,
sortByTimeIsPositive
:
true
,
sortByStayIsPositive
:
true
,
sortByStayIsPositive
:
true
,
sortType
:
''
,
pickerOptions
:
{
pickerOptions
:
{
disabledDate
(
time
){
disabledDate
(
time
){
return
time
.
getTime
()
>
((
new
Date
()).
getTime
()
-
24
*
60
*
60
*
1000
)
return
time
.
getTime
()
>
((
new
Date
()).
getTime
()
-
24
*
60
*
60
*
1000
)
...
@@ -236,6 +237,7 @@
...
@@ -236,6 +237,7 @@
params
.
minTime
=
this
.
form
.
stayMin
;
params
.
minTime
=
this
.
form
.
stayMin
;
}
}
this
.
params
=
params
this
.
params
=
params
this
.
getSortParams
()
EventBus
.
$emit
(
'uiMap.historyLocation.destroy'
);
EventBus
.
$emit
(
'uiMap.historyLocation.destroy'
);
let
res
=
mock
.
getResidentByRealTime
let
res
=
mock
.
getResidentByRealTime
if
(
res
.
returnCode
==
0
)
{
if
(
res
.
returnCode
==
0
)
{
...
@@ -257,8 +259,8 @@
...
@@ -257,8 +259,8 @@
}
}
this
.
isSearching
=
false
this
.
isSearching
=
false
}
}
GET_HISTORY_LOCATION
(
params
).
then
((
res
)
=>
{
GET_HISTORY_LOCATION
(
{...
this
.
params
}
).
then
((
res
)
=>
{
if
(
res
.
returnCode
==
0
){
if
(
res
.
code
==
20
0
){
const
data
=
res
.
data
;
const
data
=
res
.
data
;
if
(
data
.
length
){
if
(
data
.
length
){
data
.
forEach
((
item
,
idx
)
=>
{
data
.
forEach
((
item
,
idx
)
=>
{
...
@@ -336,20 +338,33 @@
...
@@ -336,20 +338,33 @@
})
})
},
},
sortByTime
(){
sortByTime
(){
let
sortArr
=
this
.
resultList
.
sort
((
a
,
b
)
=>
{
//
let sortArr = this.resultList.sort((a,b)=>{
return
moment
(
a
.
begintime
).
isBefore
(
moment
(
b
.
begintime
))?(
this
.
sortByTimeIsPositive
?
-
1
:
1
):(
this
.
sortByTimeIsPositive
?
1
:
-
1
);
//
return moment(a.begintime).isBefore(moment(b.begintime))?(this.sortByTimeIsPositive?-1:1):(this.sortByTimeIsPositive?1:-1);
});
//
});
this
.
sortByTimeIsPositive
=
!
this
.
sortByTimeIsPositive
;
this
.
sortByTimeIsPositive
=
!
this
.
sortByTimeIsPositive
;
this
.
resultList
=
[].
concat
(
sortArr
);
// this.resultList = [].concat(sortArr);
this
.
sortType
=
'beginTime'
this
.
getSortParams
()
this
.
searchSubmit
()
},
getSortParams
()
{
this
.
params
.
sort
=
this
.
sortType
?
{
filed
:
this
.
sortType
,
order
:
this
.
sortType
===
'beginTime'
?
(
this
.
sortByTimeIsPositive
?
'ASC'
:
'DESC'
)
:
(
this
.
sortByStayIsPositive
?
'ASC'
:
'DESC'
)
}
:
undefined
return
this
.
params
},
},
sortByStay
(){
sortByStay
(){
let
sortArr
=
this
.
resultList
.
sort
((
a
,
b
)
=>
{
//
let sortArr = this.resultList.sort((a,b)=>{
let
aTime
=
(
new
Date
(
a
.
endtime
)).
getTime
()
-
(
new
Date
(
a
.
begintime
)).
getTime
();
//
let aTime = (new Date(a.endtime)).getTime() - (new Date(a.begintime)).getTime();
let
bTime
=
(
new
Date
(
b
.
endtime
)).
getTime
()
-
(
new
Date
(
b
.
begintime
)).
getTime
();
//
let bTime = (new Date(b.endtime)).getTime() - (new Date(b.begintime)).getTime();
return
aTime
>
bTime
?(
this
.
sortByStayIsPositive
?
-
1
:
1
):(
this
.
sortByStayIsPositive
?
1
:
-
1
);
//
return aTime>bTime?(this.sortByStayIsPositive?-1:1):(this.sortByStayIsPositive?1:-1);
});
//
});
this
.
sortByStayIsPositive
=
!
this
.
sortByStayIsPositive
;
this
.
sortByStayIsPositive
=
!
this
.
sortByStayIsPositive
;
this
.
resultList
=
[].
concat
(
sortArr
);
// this.resultList = [].concat(sortArr);
this
.
sortType
=
'duration'
this
.
getSortParams
()
this
.
searchSubmit
()
},
},
exportExcel
(){
exportExcel
(){
// let arr = [];
// let arr = [];
...
@@ -362,8 +377,14 @@
...
@@ -362,8 +377,14 @@
// vmExportType: 6,
// vmExportType: 6,
// jsonStr: encodeURI(JSON.stringify(arr))
// jsonStr: encodeURI(JSON.stringify(arr))
// }, 'post');
// }, 'post');
// let params = this.params
// params.sort = this.sortType ? {
// filed: this.sortType,
// order: this.sortType === 'beginTime' ? (this.sortByTimeIsPositive ? 'ASC' : 'DESC') : (this.sortByStayIsPositive ? 'ASC' : 'DESC')
// } : undefined
this
.
getSortParams
()
if
(
this
.
resultList
.
length
)
{
if
(
this
.
resultList
.
length
)
{
exportExcel
(
'/trialdrive/monitor/exportStayPoint'
,
{...
this
.
params
},
'
get'
);
exportExcel
(
'/trialdrive/monitor/exportStayPoint'
,
{...
this
.
params
},
'
post'
,
''
,
true
);
}
else
{
}
else
{
this
.
$message
({
this
.
$message
({
type
:
'error'
,
type
:
'error'
,
...
...
src/pages/monitor/resident.vue
View file @
ca49ee0
...
@@ -173,7 +173,7 @@
...
@@ -173,7 +173,7 @@
this
.
isSearching
=
false
;
this
.
isSearching
=
false
;
}
}
GET_RESIDENT_LOCATION
(
params
).
then
((
res
)
=>
{
GET_RESIDENT_LOCATION
(
params
).
then
((
res
)
=>
{
if
(
res
.
returnCode
==
0
){
if
(
res
.
code
==
20
0
){
const
data
=
res
.
data
;
const
data
=
res
.
data
;
if
(
data
.
length
){
if
(
data
.
length
){
data
.
forEach
((
item
,
idx
)
=>
{
data
.
forEach
((
item
,
idx
)
=>
{
...
@@ -280,7 +280,7 @@
...
@@ -280,7 +280,7 @@
// jsonStr: encodeURI(JSON.stringify(paramArr)),
// jsonStr: encodeURI(JSON.stringify(paramArr)),
// vmExportType: 4
// vmExportType: 4
// }, 'post');
// }, 'post');
exportExcel
(
'/trialdrive/monitor/exportResident'
,
{...
this
.
params
},
'get'
);
exportExcel
(
'/trialdrive/monitor/exportResident'
,
{...
this
.
params
},
'get'
,
''
,
true
);
this
.
exporting
=
false
;
this
.
exporting
=
false
;
}
else
{
}
else
{
this
.
$message
({
this
.
$message
({
...
...
src/utils/exportExcel.js
View file @
ca49ee0
...
@@ -4,7 +4,7 @@ import qs from 'qs'
...
@@ -4,7 +4,7 @@ import qs from 'qs'
import
{
Message
}
from
"element-ui"
;
import
{
Message
}
from
"element-ui"
;
import
store
from
'../vuex/store'
import
store
from
'../vuex/store'
export
default
(
url
,
oParam
,
datatype
,
cb
)
=>
{
export
default
(
url
,
oParam
,
datatype
,
cb
,
requestBody
)
=>
{
/*let exportForm = document.querySelector("#exportForm");
/*let exportForm = document.querySelector("#exportForm");
if(exportForm){
if(exportForm){
document.body.removeChild(exportForm)
document.body.removeChild(exportForm)
...
@@ -27,8 +27,26 @@ export default (url, oParam, datatype, cb) => {
...
@@ -27,8 +27,26 @@ export default (url, oParam, datatype, cb) => {
exportForm.innerHTML = _input;
exportForm.innerHTML = _input;
exportForm.submit();*/
exportForm.submit();*/
let
BASE_URL
=
store
.
getters
.
baseURL
;
let
BASE_URL
=
store
.
getters
.
baseURL
;
url
=
BASE_URL
+
url
url
=
BASE_URL
+
url
if
(
datatype
==
'post'
)
{
if
(
datatype
==
'post'
&&
requestBody
)
{
axios
.
post
(
url
,
oParam
,
{
headers
:
{
'Content-Type'
:
'application/json'
,
Authorization
:
localStorage
.
getItem
(
'token'
)
||
''
}
})
.
then
(
response
=>
{
if
(
response
)
{
successCb
(
response
,
cb
,
requestBody
)
}
})
.
catch
(
err
=>
{
console
.
log
(
`接口调用失败`
);
console
.
log
(
err
);
})
}
else
if
(
datatype
==
'post'
)
{
axios
.
post
(
url
,
typeof
oParam
==
'string'
?
oParam
:
qs
.
stringify
(
oParam
),
{
axios
.
post
(
url
,
typeof
oParam
==
'string'
?
oParam
:
qs
.
stringify
(
oParam
),
{
responseType
:
'blob'
,
//指定返回数据的格式为blob
responseType
:
'blob'
,
//指定返回数据的格式为blob
headers
:
{
headers
:
{
...
@@ -47,6 +65,25 @@ export default (url, oParam, datatype, cb) => {
...
@@ -47,6 +65,25 @@ export default (url, oParam, datatype, cb) => {
console
.
log
(
err
);
console
.
log
(
err
);
});
});
}
else
if
(
datatype
==
'get'
&&
requestBody
)
{
axios
.
get
(
url
,
/*qs.stringify(oParam),*/
{
params
:
oParam
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded; charset=UTF-8'
,
Authorization
:
localStorage
.
getItem
(
'token'
)
||
''
}
})
.
then
(
response
=>
{
if
(
response
)
{
successCb
(
response
,
cb
,
requestBody
)
}
})
.
catch
(
err
=>
{
console
.
log
(
`接口调用失败`
);
console
.
log
(
err
);
});
}
else
{
}
else
{
axios
.
get
(
url
,
/*qs.stringify(oParam),*/
{
axios
.
get
(
url
,
/*qs.stringify(oParam),*/
{
responseType
:
'blob'
,
//指定返回数据的格式为blob
responseType
:
'blob'
,
//指定返回数据的格式为blob
...
@@ -58,7 +95,7 @@ export default (url, oParam, datatype, cb) => {
...
@@ -58,7 +95,7 @@ export default (url, oParam, datatype, cb) => {
})
})
.
then
(
response
=>
{
.
then
(
response
=>
{
if
(
response
)
{
if
(
response
)
{
successCb
(
response
)
successCb
(
response
,
cb
,
requestBody
)
}
}
})
})
...
@@ -70,13 +107,28 @@ export default (url, oParam, datatype, cb) => {
...
@@ -70,13 +107,28 @@ export default (url, oParam, datatype, cb) => {
}
}
function
successCb
(
response
,
cb
)
{
function
successCb
(
response
,
cb
,
requestBody
)
{
if
(
response
.
headers
&&
response
.
headers
.
sessionstatus
==
'timeout'
)
{
if
(
response
.
headers
&&
response
.
headers
.
sessionstatus
==
'timeout'
)
{
window
.
location
.
href
=
'../ots/login'
;
window
.
location
.
href
=
'../ots/login'
;
return
;
return
;
}
}
if
(
requestBody
)
{
//新导出处理
if
(
response
.
headers
&&
response
.
headers
[
'content-disposition'
])
{
let
url
=
response
.
data
.
data
;
if
(
url
&&
response
.
data
.
code
===
200
)
{
let
filename
=
response
.
data
.
data
.
split
(
'/'
)[
response
.
data
.
data
.
split
(
'/'
).
length
-
1
]
var
a
=
document
.
createElement
(
"a"
);
document
.
body
.
appendChild
(
a
);
a
.
href
=
url
;
a
.
download
=
filename
;
a
.
click
();
window
.
URL
.
revokeObjectURL
(
url
);
}
else
{
Message
({
message
:
response
.
data
.
message
,
type
:
'error'
})
}
}
else
if
(
response
.
headers
&&
response
.
headers
[
'content-disposition'
])
{
let
filename
=
decodeURIComponent
(
response
.
headers
[
'content-disposition'
].
replace
(
'attachment;filename='
,
''
));
let
filename
=
decodeURIComponent
(
response
.
headers
[
'content-disposition'
].
replace
(
'attachment;filename='
,
''
));
if
(
window
.
navigator
.
appVersion
.
toString
().
indexOf
(
'.NET'
)
>
0
)
{
if
(
window
.
navigator
.
appVersion
.
toString
().
indexOf
(
'.NET'
)
>
0
)
{
window
.
navigator
.
msSaveBlob
(
response
.
data
,
filename
);
window
.
navigator
.
msSaveBlob
(
response
.
data
,
filename
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment