fix: 修复多tab引起的设置和弹窗问题

fix: 优化

perf: 移除不用的代码

perf: 修复不能刷新的bug

perf: 去掉conole
This commit is contained in:
ibuler
2021-05-18 20:04:11 +08:00
committed by 老广
parent 6639614caf
commit c39733cf66
6 changed files with 40 additions and 22 deletions

View File

@@ -58,6 +58,10 @@ export default {
minColumns: {
type: Array,
default: () => []
},
url: {
type: String,
default: ''
}
},
data() {
@@ -67,15 +71,17 @@ export default {
}
},
mounted() {
this.$eventBus.$on('showColumnSettingPopover', () => {
this.showColumnSettingPopover = true
this.iCurrentColumns = this.currentColumns
this.$eventBus.$on('showColumnSettingPopover', ({ url }) => {
if (url === this.url) {
this.showColumnSettingPopover = true
this.iCurrentColumns = this.currentColumns
}
})
},
methods: {
handleColumnConfirm() {
this.showColumnSettingPopover = false
this.$emit('columnsUpdate', this.iCurrentColumns)
this.$emit('columnsUpdate', { columns: this.iCurrentColumns, url: this.url })
}
}
}

View File

@@ -5,6 +5,7 @@
:current-columns="popoverColumns.currentCols"
:total-columns-list="popoverColumns.totalColumnsList"
:min-columns="popoverColumns.minCols"
:url="config.url"
@columnsUpdate="handlePopoverColumnsChange"
/>
</div>
@@ -15,6 +16,7 @@ import DataTable from '../DataTable'
import { DateFormatter, DetailFormatter, DisplayFormatter, BooleanFormatter, ActionsFormatter } from '@/components/TableFormatters'
import i18n from '@/i18n/i18n'
import ColumnSettingPopover from './components/ColumnSettingPopover'
import { newURL } from '@/utils/common'
export default {
name: 'AutoDataTable',
components: {
@@ -228,7 +230,7 @@ export default {
const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(localStorage.getItem('tableConfig'))
: {}
const tableName = this.config.name || this.$route.name
const tableName = this.config.name || this.$route.name + '_' + newURL(this.iConfig.url).pathname
const configShowColumnsNames = _.get(_tableConfig[tableName], 'showColumns', null)
let showColumnsNames = configShowColumnsNames || defaultColumnsNames
if (showColumnsNames.length === 0) {
@@ -249,7 +251,7 @@ export default {
min: minColumnsNames,
configShow: configShowColumnsNames
}
this.$log.debug('Cleaned colums show: ', this.cleanedColumnsShow)
this.$log.debug('Cleaned columns show: ', this.cleanedColumnsShow)
},
filterShowColumns() {
this.cleanColumnsShow()
@@ -265,13 +267,13 @@ export default {
this.popoverColumns.minCols = this.cleanedColumnsShow.min
this.$log.debug('Popover cols: ', this.popoverColumns)
},
handlePopoverColumnsChange(columns) {
// this.$log.debug('Columns change: ', columns)
handlePopoverColumnsChange({ columns, url }) {
this.$log.debug('Columns change: ', columns)
this.popoverColumns.currentCols = columns
const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(localStorage.getItem('tableConfig'))
: {}
const tableName = this.config.name || this.$route.name
const tableName = this.config.name || this.$route.name + '_' + newURL(url).pathname
_tableConfig[tableName] = {
'showColumns': columns
}

View File

@@ -115,8 +115,10 @@ export default {
}
},
mounted() {
this.$eventBus.$on('showExportDialog', (row) => {
this.showExportDialog = true
this.$eventBus.$on('showExportDialog', ({ selectedRows, url }) => {
if (url === this.url) {
this.showExportDialog = true
}
})
},
methods: {

View File

@@ -7,7 +7,6 @@
:loading-status="loadStatus"
width="80%"
class="importDialog"
:confirm-title="confirmTitle"
:show-cancel="false"
:show-confirm="false"
@close="handleImportCancel"
@@ -118,9 +117,6 @@ export default {
} else {
return this.$t('common.Import') + this.$t('common.Update')
}
},
confirmTitle() {
return '导入'
}
},
watch: {
@@ -129,8 +125,10 @@ export default {
}
},
mounted() {
this.$eventBus.$on('showImportDialog', (row) => {
this.showImportDialog = true
this.$eventBus.$on('showImportDialog', ({ url }) => {
if (url === this.url) {
this.showImportDialog = true
}
})
},
methods: {

View File

@@ -1,6 +1,6 @@
<template>
<div>
<ActionsGroup :is-fa="true" :actions="rightSideActions" class="right-side-actions right-side-item" />
<ActionsGroup :is-fa="true" :actions="rightSideActions" :url="tableUrl" class="right-side-actions right-side-item" />
<ImExportDialog :selected-rows="selectedRows" :url="tableUrl" v-bind="$attrs" />
</div>
</template>
@@ -27,21 +27,21 @@ export default {
handleExport: {
type: Function,
default: function({ selectedRows }) {
this.$eventBus.$emit('showExportDialog', { selectedRows })
this.$eventBus.$emit('showExportDialog', { selectedRows, url: this.tableUrl })
}
},
hasImport: defaultTrue,
handleImport: {
type: Function,
default: function({ selectedRows }) {
this.$eventBus.$emit('showImportDialog', { selectedRows })
this.$eventBus.$emit('showImportDialog', { selectedRows, url: this.tableUrl })
}
},
hasColumnSetting: defaultTrue,
handleColumnConfig: {
type: Function,
default: function() {
this.$eventBus.$emit('showColumnSettingPopover')
default: function({ selectedRows }) {
this.$eventBus.$emit('showColumnSettingPopover', { url: this.tableUrl })
}
},
hasRefresh: defaultTrue,

View File

@@ -206,6 +206,16 @@ function customizer(objValue, srcValue) {
return _.isUndefined(objValue) ? srcValue : objValue
}
export function newURL(url) {
let obj
if (url.indexOf('//') > -1) {
obj = new URL(url)
} else {
obj = new URL(url, 'http://localhost')
}
return obj
}
export const assignIfNot = _.partialRight(_.assignInWith, customizer)
const scheme = document.location.protocol