From a6db7ae8c511ffb371608c9af0d71b391a46e25d Mon Sep 17 00:00:00 2001 From: likunming Date: Mon, 19 Feb 2024 11:31:25 +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 --- .../src/platform/components/grid/WGrid.vue | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) 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 3687dbd4..d62f1eb8 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 @@ -690,7 +690,21 @@ const buttonObj = { name: ButtonEnum.resetDefaultValues, icon: 'bi-copy', label: '恢复默认值', - click: (selected, context) => {}, + click: (selected, context) => { + let requestParams: any = { + method: 'POST', + url: url.dataUrl + '/resetDefaultValues', + }; + axios(requestParams) + .then((resp) => { + NotifyManager.info('操作成功'); + onRequest({ pagination: state.pagination }); + }) + .catch((error) => { + console.info('error====', error); + NotifyManager.error('操作失败'); + }); + }, }, }; const expandFun = (arr, treeExpand) => { @@ -858,7 +872,7 @@ const allColumnMap = new Map(); // 将所有列转换到 map 中 const columnToMap = (column: any) => { - if (column && column.childrenColumns && column.childrenColumns.length > 0) { + if (column && column.columns && column.columns.length > 0) { allColumnMap.set(column.name, column); moreColumnTitleMap.set(column.name, { name: column.name, @@ -872,7 +886,7 @@ const columnToMap = (column: any) => { classes: column.classes, parents: [], }); - column.childrenColumns.forEach((item) => { + column.columns.forEach((item) => { columnToMap(item); }); } else { @@ -891,15 +905,17 @@ const columnToMap = (column: any) => { }); } }; -let tmpChildrenLevel = 0; let tmpColspan = 0; -const getChildrenLevel = (column) => { - if (column && column.childrenColumns && column.childrenColumns.length > 0) { - tmpChildrenLevel += 1; - column.childrenColumns.forEach((item) => { - getChildrenLevel(item); +const deepArr = []; +const getChildrenLevel = (column, deep, deepArr) => { + if (column && column.columns && column.columns.length > 0) { + deep++; + column.columns.forEach((item) => { + getChildrenLevel(item, deep, deepArr); }); } else if (column) { + // deep++; + deepArr.push(deep); tmpColspan += 1; } }; @@ -911,8 +927,8 @@ function findParents(arrData: any, name: any) { if (arrData[i].name == name) { return []; } else { - if (arrData[i].childrenColumns) { - const res = findParents(arrData[i].childrenColumns, name); + if (arrData[i].columns) { + const res = findParents(arrData[i].columns, name); if (res !== undefined) { return res.concat(arrData[i].name).reverse(); } @@ -928,12 +944,15 @@ const handlerMoreRowColumnTitle = () => { let maxColumnChildrenLevel = 0; for (let key of allColumnMap.keys()) { // 处理列的 childrenLevel - getChildrenLevel(allColumnMap.get(key)); - moreColumnTitleMap.get(key)!.childrenLevel = tmpChildrenLevel; - if (tmpChildrenLevel > 0 && tmpChildrenLevel > maxColumnChildrenLevel) { + let tmpChildrenLevel = 0; + getChildrenLevel(allColumnMap.get(key), 0, deepArr); + tmpChildrenLevel = Math.max(...deepArr); + if (tmpChildrenLevel > maxColumnChildrenLevel) { maxColumnChildrenLevel = tmpChildrenLevel; } - tmpChildrenLevel = 0; + deepArr.splice(0, deepArr.length); + moreColumnTitleMap.get(key)!.childrenLevel = tmpChildrenLevel; + // 处理列的 colspan moreColumnTitleMap.get(key)!.colspan = tmpColspan; tmpColspan = 0; @@ -1556,10 +1575,10 @@ const stickyHeaderColumn = (time = 500) => { } tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableBodyPadding', bodyPadding); tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableBodyHeight', (denseBodyComputed.value ? 24 : 48) + 'px'); - if (denseBottomComputed.value) { + if (denseBottomComputed.value && !attrs.hideBottom) { tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 33 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 24 + 'px'); - } else { + } else if (!attrs.hideBottom) { tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 50 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 40 + 'px'); } @@ -1608,8 +1627,8 @@ const getMoreRowColumnTitleIndex = (name: any) => { const handlerStickyChildrenColumn = (item, columns) => { columns.push(item); - if (item.childrenColumns && item.childrenColumns.length > 0) { - item.childrenColumns.forEach((children) => { + if (item.columns && item.columns.length > 0) { + item.columns.forEach((children) => { handlerStickyChildrenColumn(children, columns); }); } @@ -1804,7 +1823,6 @@ const tableClassComputed = computed(() => { } } } else { - console.info('excludeColumnNum======', excludeColumnNum.value); // 不存在多行列头 if (excludeColumnNum.value === 2) { classArr.push('sticky-header-column-table-tr-1' + '-' + 1);