From acceaeee96a157e24fa3239a16577a683bdec09f Mon Sep 17 00:00:00 2001 From: BoBoooooo <17746714@qq.com> Date: Tue, 15 Sep 2020 15:37:35 +0800 Subject: [PATCH] =?UTF-8?q?perf(BaseModule):=20=E8=A1=A8=E5=8D=95=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E7=BB=84=E4=BB=B6=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseDialog/FormDesignerDialog.vue | 6 +- .../BaseDialog/GenerateFormDialog.vue | 15 -- src/components/BaseTable/BaseTable.vue | 54 +------ src/components/BaseTable/SearchForm.vue | 14 +- src/components/BaseTable/SeniorSearchForm.vue | 8 +- src/components/CrudTable/CrudTable.vue | 135 +++++------------- 6 files changed, 51 insertions(+), 181 deletions(-) diff --git a/src/components/BaseDialog/FormDesignerDialog.vue b/src/components/BaseDialog/FormDesignerDialog.vue index 6efcd1f..56f095e 100644 --- a/src/components/BaseDialog/FormDesignerDialog.vue +++ b/src/components/BaseDialog/FormDesignerDialog.vue @@ -198,9 +198,9 @@ 自动生成表单(初始化,暂时默认一行两列) - 自动绑定key(已有表单的情况) + @click="handleGenerateKey(true)">自动生成表单(根据数据库字段初始化,默认一行两列) + diff --git a/src/components/BaseDialog/GenerateFormDialog.vue b/src/components/BaseDialog/GenerateFormDialog.vue index 1003f1c..f73fba9 100644 --- a/src/components/BaseDialog/GenerateFormDialog.vue +++ b/src/components/BaseDialog/GenerateFormDialog.vue @@ -14,7 +14,6 @@ :append-to-body="appendToBody" :fullscreen="fullscreen" :close-on-click-modal="closeOnClickModal"> - - @@ -66,9 +62,6 @@ const STATUS = { }, }) export default class GenerateFormDialog extends Vue { - // 异步更新表单数据 - @Prop({ default: () => ({}), type: Object }) formValuesAsync!: any; - // 子表tableConfig 详情看GenerateFormItem中解释 @Prop({ default: () => ({}), type: Object }) formTableConfig!: any; @@ -289,13 +282,5 @@ export default class GenerateFormDialog extends Vue { formDesign: this.formDesign, }); } - - @Watch('formValuesAsync', { deep: true }) - onValueChange(value: any) { - Object.keys(value).forEach((k) => { - // 异步赋值 - this.$set(this.formValues, k, value[k]); - }); - } } diff --git a/src/components/BaseTable/BaseTable.vue b/src/components/BaseTable/BaseTable.vue index 3bcb667..250b6c6 100644 --- a/src/components/BaseTable/BaseTable.vue +++ b/src/components/BaseTable/BaseTable.vue @@ -19,25 +19,16 @@ - + - - - {{ scope.row[column.prop] }} @@ -216,7 +205,7 @@ export default class BaseTable extends Vue { maxHeight: string | number = '100%'; // 表格高度 - tableHeight:number|string = '100%'; + tableHeight: number | string = '100%'; // 是否需要多选 @Prop({ default: false, type: Boolean }) isMultiple!: boolean; @@ -336,25 +325,6 @@ export default class BaseTable extends Vue { default: () => ({}), }) tableParams!: any; - // 请求类型(远端,本地) - @Prop({ - type: String, - default: 'remote', - validator(value) { - const types = ['remote', 'local']; - const validType = types.indexOf(value) !== -1; - if (!validType) { - throw new Error(`Invalid type of '${value}', please set one type of 'remote' or 'local'.`); - } - return validType; - }, - }) type!: string; - - // 表格数据data - @Prop({ - type: Array, - }) data: any; - // 表格设计json @Prop({ type: Array, @@ -393,7 +363,6 @@ export default class BaseTable extends Vue { get view() { return { searchForm: true, - showSeniorSearchForm: true, ...this.visibleList, }; } @@ -416,15 +385,12 @@ export default class BaseTable extends Vue { mounted() { // event: expand changed to `expand-change` in Element v2.x this.$refs.table.$on('expand', (row, expanded) => this.emitEventHandler('expand', row, expanded)); - const { type, data } = this; + + // 初始化表格高度 this.setMaxHeight(); + // 请求数据 + this.fetchHandler(true); - // type为remote则加载远程数据,否则加载本地数据 - if (type === 'remote') { - this.fetchHandler(true); - } else { - this.tableData = this.data; - } // 自适应分页组件按钮; window.addEventListener('resize', () => { this.setPagerByWidth(); @@ -624,14 +590,6 @@ export default class BaseTable extends Vue { // 最后再刷新表格 this.dataChangeHandler(); } - - @Watch('data') - onDataChange(value: any, oldval: any) { - // 监听本地数据变动实时更新列表 - if (Array.isArray(value) && this.type === 'local') { - this.tableData = this.data; - } - } }