diff --git a/src/components/AutoDataTable/components/ColumnSettingPopover.vue b/src/components/AutoDataTable/components/ColumnSettingPopover.vue index 18b3c8a11..3a00b3d7d 100644 --- a/src/components/AutoDataTable/components/ColumnSettingPopover.vue +++ b/src/components/AutoDataTable/components/ColumnSettingPopover.vue @@ -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 }) } } } diff --git a/src/components/AutoDataTable/index.vue b/src/components/AutoDataTable/index.vue index 685672c06..6d733aead 100644 --- a/src/components/AutoDataTable/index.vue +++ b/src/components/AutoDataTable/index.vue @@ -5,6 +5,7 @@ :current-columns="popoverColumns.currentCols" :total-columns-list="popoverColumns.totalColumnsList" :min-columns="popoverColumns.minCols" + :url="config.url" @columnsUpdate="handlePopoverColumnsChange" /> @@ -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 } diff --git a/src/components/ListTable/TableAction/ExportDialog.vue b/src/components/ListTable/TableAction/ExportDialog.vue index 4f6fba559..55e3b2ae1 100644 --- a/src/components/ListTable/TableAction/ExportDialog.vue +++ b/src/components/ListTable/TableAction/ExportDialog.vue @@ -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: { diff --git a/src/components/ListTable/TableAction/ImportDialog.vue b/src/components/ListTable/TableAction/ImportDialog.vue index fc440f281..c24976ac9 100644 --- a/src/components/ListTable/TableAction/ImportDialog.vue +++ b/src/components/ListTable/TableAction/ImportDialog.vue @@ -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: { diff --git a/src/components/ListTable/TableAction/RightSide.vue b/src/components/ListTable/TableAction/RightSide.vue index 65658eef9..e4cf949bf 100644 --- a/src/components/ListTable/TableAction/RightSide.vue +++ b/src/components/ListTable/TableAction/RightSide.vue @@ -1,6 +1,6 @@ @@ -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, diff --git a/src/utils/common.js b/src/utils/common.js index 7cfd1a3ec..bc67400d5 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -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