All Files sort done
This commit is contained in:
@@ -17,12 +17,14 @@ export default defineStore('filesStore', {
|
|||||||
{
|
{
|
||||||
log: {},
|
log: {},
|
||||||
fileType: '',
|
fileType: '',
|
||||||
|
ownerName: '',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
allEventLog: [
|
allEventLog: [
|
||||||
{
|
{
|
||||||
parentLog: '',
|
parentLog: '',
|
||||||
fileType: '',
|
fileType: '',
|
||||||
|
ownerName: '',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
switchFilesTagData: {
|
switchFilesTagData: {
|
||||||
@@ -66,6 +68,7 @@ export default defineStore('filesStore', {
|
|||||||
this.allEventLog.map(o => {
|
this.allEventLog.map(o => {
|
||||||
o.parentLog = "-";
|
o.parentLog = "-";
|
||||||
o.fileType = "Log";
|
o.fileType = "Log";
|
||||||
|
o.ownerName = o.owner.name;
|
||||||
o.updated_at = moment(o.updated_at).format('YYYY-MM-DD HH:MM');
|
o.updated_at = moment(o.updated_at).format('YYYY-MM-DD HH:MM');
|
||||||
o.accessed_at = moment(o.accessed_at).format('YYYY-MM-DD HH:MM');
|
o.accessed_at = moment(o.accessed_at).format('YYYY-MM-DD HH:MM');
|
||||||
return this.allEventLog
|
return this.allEventLog
|
||||||
@@ -96,6 +99,7 @@ export default defineStore('filesStore', {
|
|||||||
this.allFilter = response.data;
|
this.allFilter = response.data;
|
||||||
this.allFilter.map(o => {
|
this.allFilter.map(o => {
|
||||||
o.fileType = "Filter";
|
o.fileType = "Filter";
|
||||||
|
o.ownerName = o.owner.name;
|
||||||
o.updated_at = moment(o.updated_at).format('YYYY-MM-DD HH:MM');
|
o.updated_at = moment(o.updated_at).format('YYYY-MM-DD HH:MM');
|
||||||
o.accessed_at = moment(o.accessed_at).format('YYYY-MM-DD HH:MM');
|
o.accessed_at = moment(o.accessed_at).format('YYYY-MM-DD HH:MM');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -43,36 +43,12 @@
|
|||||||
<table class="w-full border-separate border-spacing-x-4 text-sm table-fixed">
|
<table class="w-full border-separate border-spacing-x-4 text-sm table-fixed">
|
||||||
<thead class="sticky top-0 bg-neutral-10">
|
<thead class="sticky top-0 bg-neutral-10">
|
||||||
<tr>
|
<tr>
|
||||||
<th @click="addSortEvent('name')" class="cursor-pointer">
|
<th v-for="(item, index) in sortData" :key="index" @click="switchSort(item.sortKey)" class="cursor-pointer">
|
||||||
Name
|
{{ item.sortName }}
|
||||||
<span class="ml-2">
|
<span class="ml-2">
|
||||||
<IconVector class="inline-block fill-neutral-500"></IconVector>
|
<IconVector class="inline-block fill-neutral-500"></IconVector>
|
||||||
</span>
|
</span>
|
||||||
</th>
|
</th>
|
||||||
<th @click="addSortEvent('parentLog')" class="cursor-pointer">
|
|
||||||
Parent log
|
|
||||||
<span class="ml-2 cursor-pointer">
|
|
||||||
<IconVector class="inline-block fill-neutral-500"></IconVector>
|
|
||||||
</span>
|
|
||||||
</th>
|
|
||||||
<th @click="addSortEvent('parentLog')" class="cursor-pointer">
|
|
||||||
File type
|
|
||||||
<span class="ml-2 cursor-pointer">
|
|
||||||
<IconVector class="inline-block fill-neutral-500"></IconVector>
|
|
||||||
</span>
|
|
||||||
</th>
|
|
||||||
<th @click="addSortEvent('parentLog')" class="cursor-pointer">
|
|
||||||
Owner
|
|
||||||
<span class="ml-2 cursor-pointer">
|
|
||||||
<IconVector class="inline-block fill-neutral-500"></IconVector>
|
|
||||||
</span>
|
|
||||||
</th>
|
|
||||||
<th @click="addSortEvent('upadte')" class="cursor-pointer">
|
|
||||||
Last update
|
|
||||||
<span class="ml-2 cursor-pointer">
|
|
||||||
<IconVector class="inline-block fill-neutral-500"></IconVector>
|
|
||||||
</span>
|
|
||||||
</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -128,8 +104,29 @@
|
|||||||
switchListOrGrid: false,
|
switchListOrGrid: false,
|
||||||
filesTag: 'all',
|
filesTag: 'all',
|
||||||
sortReverseOrder: false,
|
sortReverseOrder: false,
|
||||||
reverse: false,
|
|
||||||
sortKey: 'name',
|
sortKey: 'name',
|
||||||
|
sortData: [
|
||||||
|
{
|
||||||
|
sortKey: 'name',
|
||||||
|
sortName: 'Name',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortKey: 'parentLog',
|
||||||
|
sortName: 'Parent log',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortKey: 'fileType',
|
||||||
|
sortName: 'File type',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortKey: 'ownerName',
|
||||||
|
sortName: 'Owner',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortKey: 'updated_at',
|
||||||
|
sortName: 'Last update',
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
@@ -154,17 +151,18 @@
|
|||||||
*/
|
*/
|
||||||
allFiles: function(value) {
|
allFiles: function(value) {
|
||||||
let sortFiles = Array.from(this.store.allFiles);
|
let sortFiles = Array.from(this.store.allFiles);
|
||||||
|
|
||||||
|
let dataSortOrder = sortFiles.sort((x,y) => x.updated_at - y.updated_at);
|
||||||
|
let dataSort = this.sortReverseOrder === false? dataSortOrder: dataSortOrder.reverse();
|
||||||
|
|
||||||
let strSortOrder = sortFiles.sort((x, y)=> x[this.sortKey].localeCompare(y[this.sortKey], 'en'));
|
let strSortOrder = sortFiles.sort((x, y)=> x[this.sortKey].localeCompare(y[this.sortKey], 'en'));
|
||||||
let strSort = this.sortReverseOrder === false? strSortOrder: strSortOrder.reverse();
|
let strSort = this.sortReverseOrder === false? strSortOrder: strSortOrder.reverse();
|
||||||
// let dataSort;
|
|
||||||
// let aaa = this.recentlyUsedFiles;
|
|
||||||
// // aaa.reverse();
|
|
||||||
// console.log(aaa)
|
|
||||||
|
|
||||||
return strSort;
|
|
||||||
|
|
||||||
|
return this.sortKey !== 'updated_at'? strSort: dataSort;
|
||||||
},
|
},
|
||||||
// 時間排序,如果沒有 accessed_at 就不加入 data
|
/**
|
||||||
|
* 時間排序,如果沒有 accessed_at 就不加入 data
|
||||||
|
*/
|
||||||
recentlyUsedFiles: function() {
|
recentlyUsedFiles: function() {
|
||||||
let recentlyUsedFiles = Array.from(this.store.allFiles);
|
let recentlyUsedFiles = Array.from(this.store.allFiles);
|
||||||
recentlyUsedFiles.filter(item => item.accessed_at !== null);
|
recentlyUsedFiles.filter(item => item.accessed_at !== null);
|
||||||
@@ -172,9 +170,10 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/**上下按鈕切換 */
|
/**
|
||||||
// 順序預設為 true,點擊變逆序 false,每改一次都會重新渲染一次
|
* switch sort
|
||||||
addSortEvent(value) {
|
*/
|
||||||
|
switchSort(value) {
|
||||||
this.sortReverseOrder = (this.sortKey === value)? !this.sortReverseOrder: false;
|
this.sortReverseOrder = (this.sortKey === value)? !this.sortReverseOrder: false;
|
||||||
this.sortKey = value;
|
this.sortKey = value;
|
||||||
},
|
},
|
||||||
@@ -184,7 +183,6 @@
|
|||||||
this.store.fetchFilter();
|
this.store.fetchFilter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user