fix:修复表格图表默认排序失效

This commit is contained in:
zyh
2023-10-13 10:49:10 +08:00
parent 0adef81e36
commit c34e896619
2 changed files with 11 additions and 6 deletions

View File

@@ -14345,7 +14345,7 @@
},
"node-sass": {
"version": "4.14.1",
"resolved": "https://registry.npmmirror.com/node-sass/-/node-sass-4.14.1.tgz",
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.14.1.tgz",
"integrity": "sha512-sjCuOlvGyCJS40R8BscF5vhVlQjNN069NtQ1gSxyK1u9iqvn6tf7O1R4GNowVZfiZUCRt5MmMs1xd+4V/7Yr0g==",
"dev": true,
"requires": {
@@ -20732,7 +20732,7 @@
},
"webpack-bundle-analyzer": {
"version": "2.13.1",
"resolved": "https://registry.npmmirror.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.13.1.tgz",
"resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.13.1.tgz",
"integrity": "sha512-rwxyfecTAxoarCC9VlHlIpfQCmmJ/qWD5bpbjkof+7HrNhTNZIwZITxN6CdlYL2axGmwNUQ+tFgcSOiNXMf/sQ==",
"dev": true,
"requires": {

View File

@@ -141,10 +141,15 @@ export default {
// 设置默认排序
setDefaultSort () {
const columns = this.chartInfo.param.columns
const defaultSortColumn = lodash.get(this, 'chartInfo.param.tableOptions.defaultSortColumn', columns[0].title)
const defaultSort = lodash.get(this, 'chartInfo.param.tableOptions.defaultSort', 'asc')
const order = defaultSort === 'asc' ? 'ascending' : 'descending'
this.$refs.dataTable.sort(defaultSortColumn, order)
if (columns.length) {
let defaultSortColumn = lodash.get(this, 'chartInfo.param.tableOptions.defaultSortColumn', undefined)
if (!defaultSortColumn) {
defaultSortColumn = columns[0].title
}
const defaultSort = lodash.get(this, 'chartInfo.param.tableOptions.defaultSort', 'asc')
const order = defaultSort === 'asc' ? 'ascending' : 'descending'
this.$refs.dataTable.sort(defaultSortColumn, order)
}
},
// 设置pageSize
setPageSize () {