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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
27 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 => {
// 历史停留列表
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
=>
{
...
...
src/pages/monitor/historyLocation.vue
View file @
ca49ee0
...
...
@@ -175,6 +175,7 @@
standno
:
this
.
$route
.
query
.
standno
,
sortByTimeIsPositive
:
true
,
sortByStayIsPositive
:
true
,
sortType
:
''
,
pickerOptions
:
{
disabledDate
(
time
){
return
time
.
getTime
()
>
((
new
Date
()).
getTime
()
-
24
*
60
*
60
*
1000
)
...
...
@@ -236,8 +237,9 @@
params
.
minTime
=
this
.
form
.
stayMin
;
}
this
.
params
=
params
this
.
getSortParams
()
EventBus
.
$emit
(
'uiMap.historyLocation.destroy'
);
let
res
=
mock
.
getResidentByRealTime
let
res
=
mock
.
getResidentByRealTime
if
(
res
.
returnCode
==
0
)
{
const
data
=
res
.
data
if
(
data
.
length
)
{
...
...
@@ -257,8 +259,8 @@
}
this
.
isSearching
=
false
}
GET_HISTORY_LOCATION
(
params
).
then
((
res
)
=>
{
if
(
res
.
returnCode
==
0
){
GET_HISTORY_LOCATION
(
{...
this
.
params
}
).
then
((
res
)
=>
{
if
(
res
.
code
==
20
0
){
const
data
=
res
.
data
;
if
(
data
.
length
){
data
.
forEach
((
item
,
idx
)
=>
{
...
...
@@ -336,20 +338,33 @@
})
},
sortByTime
(){
let
sortArr
=
this
.
resultList
.
sort
((
a
,
b
)
=>
{
return
moment
(
a
.
begintime
).
isBefore
(
moment
(
b
.
begintime
))?(
this
.
sortByTimeIsPositive
?
-
1
:
1
):(
this
.
sortByTimeIsPositive
?
1
:
-
1
);
});
//
let sortArr = this.resultList.sort((a,b)=>{
//
return moment(a.begintime).isBefore(moment(b.begintime))?(this.sortByTimeIsPositive?-1:1):(this.sortByTimeIsPositive?1:-1);
//
});
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
(){
let
sortArr
=
this
.
resultList
.
sort
((
a
,
b
)
=>
{
let
aTime
=
(
new
Date
(
a
.
endtime
)).
getTime
()
-
(
new
Date
(
a
.
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
);
});
//
let sortArr = this.resultList.sort((a,b)=>{
//
let aTime = (new Date(a.endtime)).getTime() - (new Date(a.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);
//
});
this
.
sortByStayIsPositive
=
!
this
.
sortByStayIsPositive
;
this
.
resultList
=
[].
concat
(
sortArr
);
// this.resultList = [].concat(sortArr);
this
.
sortType
=
'duration'
this
.
getSortParams
()
this
.
searchSubmit
()
},
exportExcel
(){
// let arr = [];
...
...
@@ -362,8 +377,14 @@
// vmExportType: 6,
// jsonStr: encodeURI(JSON.stringify(arr))
// }, '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
)
{
exportExcel
(
'/trialdrive/monitor/exportStayPoint'
,
{...
this
.
params
},
'
get'
);
exportExcel
(
'/trialdrive/monitor/exportStayPoint'
,
{...
this
.
params
},
'
post'
,
''
,
true
);
}
else
{
this
.
$message
({
type
:
'error'
,
...
...
src/pages/monitor/resident.vue
View file @
ca49ee0
...
...
@@ -153,7 +153,7 @@
}
this
.
params
=
params
let
res
=
mock
.
getResidentByRealTime
if
(
res
.
returnCode
==
0
){
if
(
res
.
returnCode
==
0
){
const
data
=
res
.
data
;
if
(
data
.
length
){
data
.
forEach
((
item
,
idx
)
=>
{
...
...
@@ -173,7 +173,7 @@
this
.
isSearching
=
false
;
}
GET_RESIDENT_LOCATION
(
params
).
then
((
res
)
=>
{
if
(
res
.
returnCode
==
0
){
if
(
res
.
code
==
20
0
){
const
data
=
res
.
data
;
if
(
data
.
length
){
data
.
forEach
((
item
,
idx
)
=>
{
...
...
@@ -280,7 +280,7 @@
// jsonStr: encodeURI(JSON.stringify(paramArr)),
// vmExportType: 4
// }, 'post');
exportExcel
(
'/trialdrive/monitor/exportResident'
,
{...
this
.
params
},
'get'
);
exportExcel
(
'/trialdrive/monitor/exportResident'
,
{...
this
.
params
},
'get'
,
''
,
true
);
this
.
exporting
=
false
;
}
else
{
this
.
$message
({
...
...
src/utils/exportExcel.js
View file @
ca49ee0
...
...
@@ -4,7 +4,7 @@ import qs from 'qs'
import
{
Message
}
from
"element-ui"
;
import
store
from
'../vuex/store'
export
default
(
url
,
oParam
,
datatype
,
cb
)
=>
{
export
default
(
url
,
oParam
,
datatype
,
cb
,
requestBody
)
=>
{
/*let exportForm = document.querySelector("#exportForm");
if(exportForm){
document.body.removeChild(exportForm)
...
...
@@ -27,8 +27,26 @@ export default (url, oParam, datatype, cb) => {
exportForm.innerHTML = _input;
exportForm.submit();*/
let
BASE_URL
=
store
.
getters
.
baseURL
;
url
=
BASE_URL
+
url
if
(
datatype
==
'post'
)
{
url
=
BASE_URL
+
url
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
),
{
responseType
:
'blob'
,
//指定返回数据的格式为blob
headers
:
{
...
...
@@ -47,9 +65,8 @@ export default (url, oParam, datatype, cb) => {
console
.
log
(
err
);
});
}
else
{
}
else
if
(
datatype
==
'get'
&&
requestBody
)
{
axios
.
get
(
url
,
/*qs.stringify(oParam),*/
{
responseType
:
'blob'
,
//指定返回数据的格式为blob
params
:
oParam
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded; charset=UTF-8'
,
...
...
@@ -58,7 +75,7 @@ export default (url, oParam, datatype, cb) => {
})
.
then
(
response
=>
{
if
(
response
)
{
successCb
(
response
)
successCb
(
response
,
cb
,
requestBody
)
}
})
...
...
@@ -67,16 +84,51 @@ export default (url, oParam, datatype, cb) => {
console
.
log
(
err
);
});
}
else
{
axios
.
get
(
url
,
/*qs.stringify(oParam),*/
{
responseType
:
'blob'
,
//指定返回数据的格式为blob
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
);
});
}
function
successCb
(
response
,
cb
)
{
function
successCb
(
response
,
cb
,
requestBody
)
{
if
(
response
.
headers
&&
response
.
headers
.
sessionstatus
==
'timeout'
)
{
window
.
location
.
href
=
'../ots/login'
;
return
;
}
if
(
response
.
headers
&&
response
.
headers
[
'content-disposition'
])
{
if
(
requestBody
)
{
//新导出处理
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='
,
''
));
if
(
window
.
navigator
.
appVersion
.
toString
().
indexOf
(
'.NET'
)
>
0
)
{
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