From 58f4e63cebce20b16e50afe4914697d0e20274fd Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Tue, 10 Sep 2024 07:26:14 +0000 Subject: [PATCH] * [story#66940] fix error. --- lib/zin/wg/pivottable/js/v1.js | 48 ---------------------------------- lib/zin/wg/pivottable/v1.php | 35 +++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 50 deletions(-) diff --git a/lib/zin/wg/pivottable/js/v1.js b/lib/zin/wg/pivottable/js/v1.js index 8454ae4443..2285f98c32 100644 --- a/lib/zin/wg/pivottable/js/v1.js +++ b/lib/zin/wg/pivottable/js/v1.js @@ -17,51 +17,3 @@ window.getHeight = function(height = 800, filterCount = 0) return Math.min(dtableContent - titleContent - conditionHeight, height); } - -/** - * 如果列包含切片字段,重新渲染单元格。 - * If column contains slice field, re-render cell. - * - * @param array result - * @param object cell - * @access public - * @return array - */ -window.renderCell = function(result, {row, col}) -{ - if(result && col.setting.colspan) - { - let values = result.shift(); - if(typeof(values.type) != 'undefined' && values.type == 'a') values = values.props['children']; - - result.push({className: 'gap-0 px-0'}); - values.forEach((value, index) => - result.push({ - html: value || !Number.isNaN(value) ? `${value}` : ' ', - className: 'flex justify-center items-center h-full w-1/2' + (index == 0 ? ' border-r': ''), - style: 'border-color: var(--dtable-border-color)' - }) - ); - } - - return result; -} - -/** - * 合并单元格。 - * Merge cell. - * - * @param object cell - * @access public - * @return object|void - */ -window.getCellSpan = function(cell) -{ - const options = this.options.cellSpanOptions[cell.col.name]; - if(options) - { - const rowSpan = cell.row.data[options.rowspan ?? 'rowspan'] ?? 1; - const colSpan = cell.row.data[options.colspan ?? 'colspan'] ?? 1; - return {rowSpan, colSpan}; - } -} diff --git a/lib/zin/wg/pivottable/v1.php b/lib/zin/wg/pivottable/v1.php index ad4706b51f..a295ade247 100644 --- a/lib/zin/wg/pivottable/v1.php +++ b/lib/zin/wg/pivottable/v1.php @@ -56,7 +56,27 @@ class pivotTable extends wg list($cols, $data, $cellSpan, $filters, $onRenderCell, $onCellClick) = $this->prop(array('cols', 'data', 'cellSpan', 'filters', 'onRenderCell', 'onCellClick')); $filterCount = count($filters); - if(empty($onRenderCell)) $onRenderCell = jsRaw('renderCell'); + if(empty($onRenderCell)) $onRenderCell = jsRaw(<< + result.push({ + html: value || !Number.isNaN(value) ? `\${value}` : ' ', + className: 'flex justify-center items-center h-full w-1/2' + (index == 0 ? ' border-r': ''), + style: 'border-color: var(--dtable-border-color)' + }) + ); + } + + return result; + } + JS); return dtable ( setID('designTable'), @@ -70,7 +90,18 @@ class pivotTable extends wg set::onCellClick($onCellClick), set::rowKey('ROW_ID'), set::plugins(array('header-group', $cellSpan ? 'cellspan' : null)), - $cellSpan ? set::getCellSpan(jsRaw('getCellSpan')) : null, + $cellSpan ? set::getCellSpan(jsRaw(<<