From ac9c7adc8a7fe2a0d4eb5e13b0377e05b8a37f7c Mon Sep 17 00:00:00 2001 From: likunming Date: Fri, 19 Jan 2024 17:11:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E4=BC=98=E5=8C=96=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/components/grid/TreeGridRow.vue | 30 ++- .../src/platform/components/grid/WGrid.vue | 230 ++++++++++-------- .../src/views/likm/Grid.vue | 36 ++- .../src/views/likm/TreeGrid.vue | 14 +- 4 files changed, 175 insertions(+), 135 deletions(-) diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/TreeGridRow.vue b/io.sc.platform.core.frontend/src/platform/components/grid/TreeGridRow.vue index cf3e39d9..500faf9f 100644 --- a/io.sc.platform.core.frontend/src/platform/components/grid/TreeGridRow.vue +++ b/io.sc.platform.core.frontend/src/platform/components/grid/TreeGridRow.vue @@ -18,7 +18,7 @@ - @@ -76,8 +75,13 @@ const props = defineProps({ return []; }, }, - checkboxSelection: { type: Boolean, default: true }, - rowKey: { type: String, default: 'id' }, + gridProps: { + type: Object, + default: () => { + return {}; + }, + }, + rowKey: { type: String, default: 'rowKey_' }, }); const table = inject('table'); @@ -107,15 +111,15 @@ const getCurrRow = (arr) => { getCurrRow(table.rows); // 根据数组记录获取传入的key对应的行对象 -const getRow = (arr, key) => { +const getRow = (arr, key, parent) => { let result = undefined; for (let i = 0; i < arr.length; i++) { let item = arr[i]; - if (item[props.rowKey] === key) { + if (parent ? item[props.gridProps.treePrimaryField] === key : item[props.rowKey] === key) { result = item; break; } else if (item.children && item.children.length > 0) { - const temp = getRow(item.children, key); + const temp = getRow(item.children, key, parent); if (temp) { result = temp; } @@ -135,10 +139,10 @@ const expandFun = () => { const selectedFun = (value, row) => { if (value) { selectedPush(row); - getRow(table.rows, row[props.rowKey]).selected = true; + getRow(table.rows, row[props.rowKey], false).selected = true; } else { selectedRemove(row); - getRow(table.rows, row[props.rowKey]).selected = false; + getRow(table.rows, row[props.rowKey], false).selected = false; } selectedChildren(row, value); selectedParent(row, value); @@ -162,7 +166,7 @@ const selectedChildren = (row, selected) => { // 设置父节点选中状态 const selectedParent = (row, selected) => { if (row.parent) { - const parent = getRow(table.rows, row.parent); + const parent = getRow(table.rows, row.parent, true); if (parent) { if (selected && childrenSelectedStatus(parent).allSelected) { parent.selected = true; diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue b/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue index 7216cc8b..57f5893b 100644 --- a/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue +++ b/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue @@ -13,7 +13,9 @@ separator="cell" :rows="table.rows" :columns="extractTableColumns" - :rows-per-page-options="pagination.rowsPerPage && table.refHeightWidth.middleWidth > 600 ? table.pagination.rowsPerPageOptions : []" + :rows-per-page-options=" + table.pagination.rowsPerPage && pagination.rowsPerPage && table.refHeightWidth.middleWidth > 600 ? table.pagination.rowsPerPageOptions : [] + " :loading="table.loading" :class="tableClassComputed" :table-style="tableHeightComputed" @@ -73,7 +75,11 @@