From 88210a933907414d3c2fac0dd8e2ac9f8e7fb205 Mon Sep 17 00:00:00 2001 From: BoBoooooo <17746714@qq.com> Date: Fri, 19 Mar 2021 15:01:15 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E6=B7=BB=E5=8A=A0=E8=A1=8C=E5=88=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- .../form-designer/src/WidgetForm.vue | 32 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 14c88c5..8489d77 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "element-pro-crud", - "version": "0.9.1-12", + "version": "0.9.1-13", "author": "BoBo", "main": "lib/ProCrud.umd.min.js", "files": [ diff --git a/src/component/form-designer/src/WidgetForm.vue b/src/component/form-designer/src/WidgetForm.vue index 576b3d0..dded5da 100644 --- a/src/component/form-designer/src/WidgetForm.vue +++ b/src/component/form-designer/src/WidgetForm.vue @@ -193,10 +193,10 @@ export default { // 处理TD设置 handleTdSettingCommand(command, table, row, rowIndex, col, colIndex) { switch (command) { - case 'left-col': this.handleColAdd(table, row, 'left'); break; - case 'right-col': this.handleColAdd(table, row, 'right'); break; - case 'top-row': this.handleRowAdd(table, 'top'); break; - case 'bottom-row': this.handleRowAdd(table, 'bottom'); break; + case 'left-col': this.handleColAdd(table, row, rowIndex, col, colIndex, 'left'); break; + case 'right-col': this.handleColAdd(table, row, rowIndex, col, colIndex, 'right'); break; + case 'top-row': this.handleRowAdd(table, row, rowIndex, 'top'); break; + case 'bottom-row': this.handleRowAdd(table, row, rowIndex, 'bottom'); break; case 'merge-right': this.handleTdSpanMerge(table, row, rowIndex, col, colIndex, 'right'); break; case 'merge-bottom': this.handleTdSpanMerge(table, row, rowIndex, col, colIndex, 'bottom'); break; case 'split-col': this.handleTdSplitToCol(table, row, rowIndex, col, colIndex); break; @@ -376,33 +376,37 @@ export default { this.data.list.splice(index, 1); }); }, - handleColAdd(table, rowIndex, direction = 'right') { + handleColAdd(table, row, rowIndex, col, colIndex = null, direction = 'right') { const { rows } = table; - rows.forEach((row) => { - const { columns } = row; + rows.forEach((_row, _index) => { + const { columns } = _row; const newCol = this.generateNewTd(); // 此处判断是左添加列还是右添加列 if (direction === 'right') { - columns.push(newCol); + // eslint-disable-next-line no-unused-expressions + colIndex !== null ? columns.splice(colIndex + 1, 0, newCol) : columns.push(newCol); } else { - columns.unshift(newCol); + // eslint-disable-next-line no-unused-expressions + colIndex !== null ? columns.splice(colIndex, 0, newCol) : columns.unshift(newCol); } }); table.options.sumColSpan += 1; }, - handleRowAdd(table, direction = 'bottom') { - const row = { + handleRowAdd(table, row, rowIndex = null, direction = 'bottom') { + const _row = { columns: [], }; for (let i = 0; i < table.options.sumColSpan; i += 1) { const newCol = this.generateNewTd(); - row.columns.push(newCol); + _row.columns.push(newCol); } // 此处判断是上方添加行还是下方添加行 if (direction === 'bottom') { - table.rows.push(row); + // eslint-disable-next-line no-unused-expressions + rowIndex !== null ? table.rows.splice(rowIndex + 1, 0, _row) : table.rows.push(_row); } else { - table.rows.unshift(row); + // eslint-disable-next-line no-unused-expressions + rowIndex !== null ? table.rows.splice(rowIndex, 0, _row) : table.rows.unshift(_row); } table.options.sumRowSpan += 1; },