优化排序

jc
fanluyan 11 months ago
parent 21fc05bb1d
commit 5d1f9b05cf

@ -184,6 +184,7 @@
min-width="130"
show-overflow-tooltip
sortable
:sort-method="sortfirstTime"
>
<template slot-scope="scope">
{{ scope.row.photoInfo.firstPhotoTime }}
@ -195,6 +196,7 @@
min-width="130"
show-overflow-tooltip
sortable
:sort-method="sortRecvTime"
>
<template slot-scope="scope">
{{ scope.row.photoInfo.lastRecvTime }}
@ -328,6 +330,34 @@ export default {
formatLastHeartbeat(timestamp) {
return this.$moment(timestamp * 1000).format("YYYY-MM-DD HH:mm:ss");
},
sortRecvTime(a, b) {
// null
const dateA = a.photoInfo.lastRecvTime
? new Date(a.photoInfo.lastRecvTime)
: new Date(0);
const dateB = b.photoInfo.lastRecvTime
? new Date(b.photoInfo.lastRecvTime)
: new Date(0);
//
if (dateA < dateB) return -1;
if (dateA > dateB) return 1;
return 0;
},
sortfirstTime(a, b) {
// null
const dateA = a.photoInfo.firstPhotoTime
? new Date(a.photoInfo.firstPhotoTime)
: new Date(0);
const dateB = b.photoInfo.firstPhotoTime
? new Date(b.photoInfo.firstPhotoTime)
: new Date(0);
//
if (dateA < dateB) return -1;
if (dateA > dateB) return 1;
return 0;
},
//
getSearchdy() {
getSearchInfo({ type: 1 })

Loading…
Cancel
Save