* pivot: reload custom pivot table when query conditions changed.
This commit is contained in:
@@ -76,6 +76,47 @@ function loadWorkload()
|
||||
loadPage(link, '#table-pivot-preview');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询条件改变时重新加载自定义透视表。
|
||||
* Reload custom pivot table when query conditions changed.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadCustomPivot()
|
||||
{
|
||||
let filterValues = [];
|
||||
$('#conditions .filter').each(function()
|
||||
{
|
||||
const $filter = $(this);
|
||||
if ($filter.hasClass('filter-input'))
|
||||
{
|
||||
filterValues.push($filter.find('input').val());
|
||||
}
|
||||
else if($filter.hasClass('filter-select'))
|
||||
{
|
||||
filterValues.push($filter.find('.pick-value').val().filter(Boolean));
|
||||
}
|
||||
else if($filter.hasClass('filter-date') || $filter.hasClass('filter-datetime'))
|
||||
{
|
||||
const $pickValue = $filter.find('.pick-value');
|
||||
if($pickValue.length == 1)
|
||||
{
|
||||
filterValues.push($pickValue.val());
|
||||
}
|
||||
else if($pickValue.length == 2)
|
||||
{
|
||||
filterValues.push({begin: $pickValue.eq(0).val(), end: $pickValue.eq(1).val()});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const data = {'filterValues': JSON.stringify(filterValues)};
|
||||
const params = window.btoa('dimensionID=' + dimension + '&groupID=' + groupID + '&pivotID=' + pivotID);
|
||||
const link = $.createLink('pivot', 'preview', 'dimension=' + dimension + '&group=' + groupID + '&module=pivot&method=show¶ms=' + params);
|
||||
postAndLoadPage(link, data, '#table-pivot-preview');
|
||||
}
|
||||
|
||||
/**
|
||||
* 把日期字符串转换成日期对象。
|
||||
* Convert date string to date object.
|
||||
|
||||
@@ -10,6 +10,8 @@ declare(strict_types = 1);
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
jsVar('pivotID', $pivot->id);
|
||||
|
||||
$filters = array();
|
||||
$options = array();
|
||||
foreach($pivot->filters as $filter)
|
||||
|
||||
+11
-3
@@ -332,12 +332,20 @@ class pivotZen extends pivot
|
||||
list($pivotTree, $pivot, $groupID) = $this->pivot->getPreviewPivots($dimensionID, $groupID, $pivotID);
|
||||
if($pivot)
|
||||
{
|
||||
if($this->post->filterValues)
|
||||
{
|
||||
$filterValues = json_decode($this->post->filterValues, true);
|
||||
foreach($filterValues as $key => $value) $pivot->filters[$key]['default'] = $value;
|
||||
}
|
||||
|
||||
list($sql, $filterFormat) = $this->pivot->getFilterFormat($pivot->sql, $pivot->filters);
|
||||
|
||||
$processSqlData = $this->loadModel('chart')->getTables($sql);
|
||||
$sql = $processSqlData['sql'];
|
||||
$tables = $this->loadModel('chart')->getTables($sql);
|
||||
$sql = $tables['sql'];
|
||||
$fields = json_decode(json_encode($pivot->fieldSettings), true);
|
||||
$langs = json_decode($pivot->langs, true);
|
||||
|
||||
list($data, $configs) = $this->pivot->genSheet(json_decode(json_encode($pivot->fieldSettings), true), $pivot->settings, $sql, $filterFormat, json_decode($pivot->langs, true));
|
||||
list($data, $configs) = $this->pivot->genSheet($fields, $pivot->settings, $sql, $filterFormat, $langs);
|
||||
$this->view->data = $data;
|
||||
$this->view->configs = $configs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user