编写时间档案的按时间降序排序
This commit is contained in:
parent
0a199d7f68
commit
b645b36005
@ -2,7 +2,7 @@
|
||||
import ZooArchiveFormDialog from "@/components/ZooArchiveFormDialog.vue";
|
||||
import {Delete, DocumentAdd, Document,Edit, Search} from "@element-plus/icons-vue";
|
||||
import {mapState,mapActions} from "vuex";
|
||||
import {copy, splitKeyWords,fuzzyMatching} from "@/utils/common.js";
|
||||
import {copy, splitKeyWords, fuzzyMatching, sortByDateTime} from "@/utils/common.js";
|
||||
|
||||
export default {
|
||||
name: "ZooArchive",
|
||||
@ -177,6 +177,7 @@ export default {
|
||||
mounted() {
|
||||
this.getArchives()
|
||||
this.tableData = copy(this.archives);//复制一份给表格展示
|
||||
sortByDateTime(this.tableData)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -156,4 +156,17 @@ function keywordMatching(object, keyword) {
|
||||
return (object[key] + '').includes(keyword)
|
||||
})
|
||||
}
|
||||
//endregion
|
||||
//endregion
|
||||
|
||||
//日期时间降序排序
|
||||
export function sortByDateTime(archives) {
|
||||
archives.sort((a, b) => {
|
||||
return Number(b.date.split('-').join(''))-Number(a.date.split('-').join(''))
|
||||
})
|
||||
archives.sort((a, b) => {
|
||||
//日期相同再按时间排序
|
||||
if (a.date===b.date) {
|
||||
return Number(b.time.split(':').join('')) - Number(a.time.split(':').join(''))
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user