改进排序

This commit is contained in:
haiyangcui
2020-11-08 12:28:12 +01:00
parent 7c08627e6f
commit b12cdf25d5
2 changed files with 9 additions and 12 deletions

View File

@@ -56,9 +56,8 @@
</template>
</el-table-column>
<el-table-column
sort-by="['group', 'name']"
sortable
:sort-method="sortByGroup"
:sort-method="(a , b) => sortByLocaleCompare(a.group, b.group)"
prop="group"
label="分组"
:filters="getFilters"
@@ -185,8 +184,8 @@ export default {
},
methods: {
...mapMutations(['SET_VIEW', 'SET_DETAIL', 'SET_VIDEO', 'SET_SHARE']),
sortByGroup (a, b) {
return a.group.localeCompare(b.group, 'zh')
sortByLocaleCompare (a, b) {
return a.localeCompare(b, 'zh')
},
selectionCellClick (selection, row) {
if (this.shiftDown && this.selectionBegin !== '' && selection.includes(row)) {

View File

@@ -17,7 +17,7 @@
@sort-change="handleSortChange">
<el-table-column
sortable
:sort-method="sortByName"
:sort-method="(a , b) => sortByLocaleCompare(a.name, b.name)"
prop="name"
label="片名">
</el-table-column>
@@ -30,9 +30,8 @@
</template>
</el-table-column>
<el-table-column
:sort-by="['detail.type', 'name']"
sortable
:sort-method="sortByType"
:sort-method="(a , b) => sortByLocaleCompare(a.detail.type, b.detail.type)"
prop="detail.type"
label="类型"
width="100">
@@ -51,6 +50,8 @@
label="备注">
</el-table-column>
<el-table-column v-if="list.some(e => e.rate)"
sortable
sort-by="rate"
prop="rate"
width="120"
label="豆瓣评分">
@@ -206,11 +207,8 @@ export default {
handleSortChange (column, prop, order) {
this.updateDatabase()
},
sortByName (a, b) {
return a.name.localeCompare(b.name, 'zh')
},
sortByType (a, b) {
return a.type.localeCompare(b.type)
sortByLocaleCompare (a, b) {
return a.localeCompare(b, 'zh')
},
detailEvent (e) {
this.detail = {