代码调整

This commit is contained in:
joylink_cuiweidong 2019-12-12 10:40:54 +08:00
parent a358b9cdd6
commit df31cb9138
2 changed files with 71 additions and 14 deletions

View File

@ -28,6 +28,7 @@
@select="onSelect"
@select-all="onSelectAll"
@selection-change="onSelectionChange"
@sort-change="sortChange"
>
<el-table-column v-if="queryList.selectCheckShow" type="selection" width="55" />
<el-table-column v-if="queryList.indexShow" type="index" width="50" :label="this.$t('global.index')" />
@ -45,6 +46,7 @@
:width="column.width"
show-overflow-tooltip
:sortable="column.sortable"
:sort-by="column.sortBy"
/>
<el-table-column
v-else-if="checkColumnTyep(column, 'basicText')"
@ -52,6 +54,7 @@
:label="column.title"
:width="column.width"
:sortable="column.sortable"
:sort-by="column.sortBy"
>
<template slot-scope="scope">
<span class="hideOutContent">{{ column.columnValue(scope.row, scope.$index) }}</span>
@ -63,6 +66,7 @@
:label="column.title"
:width="column.width"
:sortable="column.sortable"
:sort-by="column.sortBy"
>
<template slot-scope="scope">
<el-tag v-if="column.columnValue(scope.row, scope.$index)" :type="column.tagType(scope.row, scope.$index)">{{ column.columnValue(scope.row, scope.$index) }}</el-tag>
@ -74,6 +78,7 @@
:label="column.title"
:width="column.width"
:sortable="column.sortable"
:sort-by="column.sortBy"
>
<template slot-scope="scope">
<span>{{ column.columnValue(scope.row, scope.$index) }}</span>
@ -85,6 +90,7 @@
:label="column.title"
:width="column.width"
:sortable="column.sortable"
:sort-by="column.sortBy"
>
<template slot-scope="scope">
<template v-for="tag in column.columnValue(scope.row)">
@ -103,6 +109,7 @@
:label="column.title"
:formatter="column.formatter"
:sortable="column.sortable"
:sort-by="column.sortBy"
/>
<el-table-column
v-else-if="checkColumnTyep(column, 'button') && !(column.hide && column.hide(column))"
@ -189,7 +196,8 @@ export default {
pageIndex: 1,
pageOffset: 0,
canQuery: true, //
thirdQRCodeMakeUrl: 'http://s.jiathis.com/qrcode.php?url='
thirdQRCodeMakeUrl: 'http://s.jiathis.com/qrcode.php?url=',
sortBy:''
};
},
computed: {
@ -461,6 +469,36 @@ export default {
this.commitQuery();
}
this.queryList.data = [...this.queryList.data];
},
sortChange(data) {
const self = this;
if (data.order && data.column.sortable == 'custom') {
switch (data.order) {
case 'ascending': {
if (data.column.sortBy) {
const temp = {};
temp[data.column.sortBy] = data.prop;
self.queryData = { ...self.queryData, ...temp };
self.sortBy = data.column.sortBy;
self.refresh(true);
}
break;
}
case 'descending': {
if (data.column.sortBy) {
const temp = {};
temp[data.column.sortBy] = data.prop + ' desc';
self.queryData = { ...self.queryData, ...temp };
self.sortBy = data.column.sortBy;
self.refresh(true);
}
break;
}
}
} else {
delete self.queryData[self.sortBy];
self.refresh(true);
}
}
}

View File

@ -61,29 +61,32 @@ export default {
config: {
data: []
}
},
sortOrder:{
type: 'select',
label: this.$t('permission.sortType'),
default:'id desc',
noClearable:true,
config: {
data: [
{value:'id desc', label:'ID倒序'},
{value:'userName', label:'用户名正序'}
]
}
}
// sortOrder:{
// type: 'select',
// label: this.$t('permission.sortType'),
// default:'id desc',
// noClearable:true,
// config: {
// data: [
// {value:'id desc', label:'ID'},
// {value:'userName', label:''}
// ]
// }
// }
}
},
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
defaultSort:{prop:'sortOrder', order:''},
columns: [
{
title: this.$t('permission.userName'),
prop: 'userName'
prop: 'userName',
sortable:'custom',
sortBy:'sortOrder'
},
{
title: this.$t('permission.permissionName'),
@ -184,6 +187,22 @@ export default {
]
}
],
// sortChange:function(data) {
// switch (data.order) {
// case 'ascending': {
// this.data=[];
// break;
// }
// case 'descending': {
// break;
// }
// default: {
// // sortOrder
// debugger;
// break;
// }
// }
// },
actions: [
]
}