From c5972f1b591fc612d1397c5003bbab978518ec1b Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 8 Sep 2022 15:11:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=A7=A3=E5=86=B3=20form=20group=20?= =?UTF-8?q?=E4=B8=8D=E9=9A=90=E8=97=8F=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/components/AutoDataForm/index.vue | 48 ++++++---- src/components/AutoDataForm/utils.js | 12 ++- src/components/FormFields/AssetAccounts.vue | 10 +- .../ProtocolSettingDialog.vue | 92 ++++++++++++------- .../FormFields/ProtocolSelector/index.vue | 9 +- src/components/FormGroupHeader/index.vue | 2 +- .../assets/Platform/PlatformCreateUpdate.vue | 1 + src/views/tickets/index.vue | 2 +- 8 files changed, 113 insertions(+), 63 deletions(-) diff --git a/src/components/AutoDataForm/index.vue b/src/components/AutoDataForm/index.vue index 7c47630ca..7222d0d6c 100644 --- a/src/components/AutoDataForm/index.vue +++ b/src/components/AutoDataForm/index.vue @@ -1,20 +1,24 @@ @@ -66,16 +70,16 @@ export default { this.optionUrlMetaAndGenerateColumns() }, methods: { - optionUrlMetaAndGenerateColumns() { - this.$store.dispatch('common/getUrlMeta', { url: this.url }).then(data => { - this.remoteMeta = data.actions[this.method.toUpperCase()] || {} - this.generateColumns() - this.cleanFormValue() - }).catch(err => { - this.$log.error(err) - }).finally(() => { - this.loading = false - }) + async optionUrlMetaAndGenerateColumns() { + let data = { actions: {}} + if (this.url) { + data = await this.$store.dispatch('common/getUrlMeta', { url: this.url }) + } + this.remoteMeta = data.actions[this.method.toUpperCase()] || {} + this.generateColumns() + this.cleanFormValue() + this.loading = false + console.log('Loading: ', this.groups) }, generateColumns() { const generator = new FormFieldGenerator() @@ -114,6 +118,18 @@ export default { } else { field.attrs.error = error } + }, + groupHidden(group, i) { + for (const field of group.fields) { + let hidden = field.hidden + if (typeof hidden === 'function') { + hidden = hidden(this.iForm) + } + if (!hidden) { + return false + } + } + return true } } } diff --git a/src/components/AutoDataForm/utils.js b/src/components/AutoDataForm/utils.js index e77c07c21..eda6b93bb 100644 --- a/src/components/AutoDataForm/utils.js +++ b/src/components/AutoDataForm/utils.js @@ -148,13 +148,15 @@ export class FormFieldGenerator { } generateFieldGroup(field, fieldsMeta, remoteFieldsMeta) { const [groupTitle, fields] = field - this.groups.push({ + const _fields = this.generateFields(fields, fieldsMeta, remoteFieldsMeta) + const group = { id: groupTitle, title: groupTitle, - name: fields[0], - fields: fields - }) - return this.generateFields(fields, fieldsMeta, remoteFieldsMeta) + fields: _fields, + name: _fields[0].id + } + this.groups.push(group) + return _fields } generateFields(_fields, fieldsMeta, remoteFieldsMeta) { let fields = [] diff --git a/src/components/FormFields/AssetAccounts.vue b/src/components/FormFields/AssetAccounts.vue index f1c0fc6dc..d9e93872f 100644 --- a/src/components/FormFields/AssetAccounts.vue +++ b/src/components/FormFields/AssetAccounts.vue @@ -3,19 +3,21 @@ -