From c39733cf66b6fe46ef9f8729c65cc3e9abe67311 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 18 May 2021 20:04:11 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=9Atab?= =?UTF-8?q?=E5=BC=95=E8=B5=B7=E7=9A=84=E8=AE=BE=E7=BD=AE=E5=92=8C=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 优化 perf: 移除不用的代码 perf: 修复不能刷新的bug perf: 去掉conole --- .../components/ColumnSettingPopover.vue | 14 ++++++++++---- src/components/AutoDataTable/index.vue | 12 +++++++----- .../ListTable/TableAction/ExportDialog.vue | 6 ++++-- .../ListTable/TableAction/ImportDialog.vue | 10 ++++------ src/components/ListTable/TableAction/RightSide.vue | 10 +++++----- src/utils/common.js | 10 ++++++++++ 6 files changed, 40 insertions(+), 22 deletions(-) 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 From 6a45fccfcd23ab6579ef50b55149e29b3884d71f Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 19 May 2021 18:06:34 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=94=A8=E6=88=B7=E5=90=8D=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/assets/SystemUser/SystemUserCreate/fields.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/views/assets/SystemUser/SystemUserCreate/fields.js b/src/views/assets/SystemUser/SystemUserCreate/fields.js index a947bac8f..ffdb30cb7 100644 --- a/src/views/assets/SystemUser/SystemUserCreate/fields.js +++ b/src/views/assets/SystemUser/SystemUserCreate/fields.js @@ -36,6 +36,8 @@ function getFields() { if (form.username_same_with_user) { this.fieldsMeta.username.el.disabled = true form.username = '' + } else { + this.fieldsMeta.username.el.disabled = false } } } From 8bd77fa6c9444db63fbd98299ac1fa14a680a3d1 Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 19 May 2021 18:27:27 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E4=BA=91=E7=AE=A1=E8=B4=A6=E5=8F=B7=E6=88=90=E5=8A=9F=E9=87=8D?= =?UTF-8?q?=E5=AE=9A=E5=90=91=E9=A1=B5=E9=9D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/xpack/Cloud/Account/AccountCreateUpdate.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/xpack/Cloud/Account/AccountCreateUpdate.vue b/src/views/xpack/Cloud/Account/AccountCreateUpdate.vue index 32414b596..b0471df16 100644 --- a/src/views/xpack/Cloud/Account/AccountCreateUpdate.vue +++ b/src/views/xpack/Cloud/Account/AccountCreateUpdate.vue @@ -40,8 +40,8 @@ export default { } } }, - updateSuccessNextRoute: { name: 'AccountList' }, - createSuccessNextRoute: { name: 'AccountList' }, + updateSuccessNextRoute: { name: 'CloudCenter', params: { activeMenu: 'AccountList' }}, + createSuccessNextRoute: { name: 'CloudCenter', params: { activeMenu: 'AccountList' }}, getUrl() { const params = this.$route.params let url = `/api/v1/xpack/cloud/accounts/` From fa6831b743f21c609a0491950e94e7d31e9b7dbb Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 19 May 2021 16:44:39 +0800 Subject: [PATCH 4/6] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E9=92=89?= =?UTF-8?q?=E9=92=89=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/UserProfile/PasswordUpdate.vue | 5 +++-- src/views/settings/DingTalk.vue | 8 ++++++++ src/views/settings/Email.vue | 19 +++++++------------ src/views/settings/WeCom.vue | 8 ++++++++ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/userviews/users/UserProfile/PasswordUpdate.vue b/src/userviews/users/UserProfile/PasswordUpdate.vue index 8f4f5d138..9a5440580 100644 --- a/src/userviews/users/UserProfile/PasswordUpdate.vue +++ b/src/userviews/users/UserProfile/PasswordUpdate.vue @@ -16,6 +16,7 @@ import GenericCreateUpdateForm from '@/layout/components/GenericCreateUpdateForm' import UserPassword from '@/components/FormFields/UserPassword' import { IBox } from '@/components' +import rules from '@/components/DataForm/rules' export default { name: 'PasswordUpdate', @@ -42,8 +43,8 @@ export default { }, new_password: { label: this.$t('users.NewPassword'), - component: UserPassword, - rules: [] + rules: [rules.RequiredChange], + component: UserPassword }, new_password_again: { label: this.$t('users.ConfirmPassword'), diff --git a/src/views/settings/DingTalk.vue b/src/views/settings/DingTalk.vue index 805140ddb..5b047476d 100644 --- a/src/views/settings/DingTalk.vue +++ b/src/views/settings/DingTalk.vue @@ -7,6 +7,7 @@ :fields-meta="fieldsMeta" :more-buttons="moreButtons" :has-detail-in-msg="false" + :clean-form-value="cleanFormValue" /> @@ -56,6 +57,13 @@ export default { methods: { getMethod() { return 'put' + }, + // 不清理的话,编辑secret,在删除提交会报错 + cleanFormValue(data) { + if (!data['DINGTALK_APPSECRET']) { + delete data['DINGTALK_APPSECRET'] + } + return data } } } diff --git a/src/views/settings/Email.vue b/src/views/settings/Email.vue index 41fad0cc5..d5cde7f27 100644 --- a/src/views/settings/Email.vue +++ b/src/views/settings/Email.vue @@ -3,7 +3,7 @@ @@ -56,6 +57,13 @@ export default { methods: { getMethod() { return 'put' + }, + // 不清理的话,编辑secret,在删除提交会报错 + cleanFormValue(data) { + if (!data['WECOM_SECRET']) { + delete data['WECOM_SECRET'] + } + return data } } } From 67ffda2fd0ca37d779f95ffd599cc7d038638746 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 19 May 2021 18:13:34 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dldap=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E4=B8=8D=E8=83=BD=E9=9A=90=E8=97=8Fdialog=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/settings/Ldap/ImportDialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/settings/Ldap/ImportDialog.vue b/src/views/settings/Ldap/ImportDialog.vue index 5608581d0..ec996a2a6 100644 --- a/src/views/settings/Ldap/ImportDialog.vue +++ b/src/views/settings/Ldap/ImportDialog.vue @@ -108,7 +108,7 @@ export default { } }, hiddenDialog() { - this.$emit('update:show', false) + this.$emit('update:visible', false) } } } From a80918139bec540f9902a670787c4a7bde47f20d Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 19 May 2021 18:40:38 +0800 Subject: [PATCH 6/6] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=AD=98=E5=82=A8=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/sessions/CommandStorageCreateUpdate.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/views/sessions/CommandStorageCreateUpdate.vue b/src/views/sessions/CommandStorageCreateUpdate.vue index e6d61d532..babe3d4a9 100644 --- a/src/views/sessions/CommandStorageCreateUpdate.vue +++ b/src/views/sessions/CommandStorageCreateUpdate.vue @@ -53,21 +53,23 @@ export default { return `${url}?type=${commandType}` }, url: '/api/v1/terminal/command-storages/' - } }, computed: { - }, methods: { afterGetFormValue(validValues) { + if (!validValues?.meta?.HOSTS) { + return validValues + } validValues.meta.HOSTS = validValues.meta.HOSTS.toString() return validValues }, performSubmit(validValues) { const method = this.getMethod() validValues.meta.HOSTS = validValues.meta.HOSTS.split(',').map(item => (item.trim())) - return this.$axios[method](`${this.getUrl()}`, validValues) + const url = this.getUrl() + return this.$axios[method](url, validValues) }, getMethod() { const params = this.$route.params