* Fix bug #34275.
This commit is contained in:
@@ -87,3 +87,17 @@ function initDatepicker($obj, callback)
|
||||
|
||||
if(typeof callback == 'function') callback($obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attr date check.
|
||||
*
|
||||
* @param object $obj
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function attrDateCheck($obj)
|
||||
{
|
||||
$obj.find('.form-date').attr('onchange', 'checkDate(this, this.value)');
|
||||
$obj.find('.form-datetime').attr('onchange', 'checkDate(this, this.value)');
|
||||
}
|
||||
|
||||
|
||||
+44
-42
@@ -1,10 +1,8 @@
|
||||
$(function()
|
||||
{
|
||||
initCheckBox();
|
||||
initQueryBtn();
|
||||
$('#exportchart').modalTrigger();
|
||||
|
||||
chartMap = new Map();
|
||||
if(charts.length > 0)
|
||||
{
|
||||
var chartPros = charts.map(function(chart)
|
||||
@@ -12,7 +10,6 @@ $(function()
|
||||
var echartDom = $('#chartDraw' + chart.currentGroup + '_' + chart.id).get(0);
|
||||
var echart = echarts.init(echartDom);
|
||||
ajaxGetChart(false, chart, echart);
|
||||
chartMap.set(chart.cudrrentGroup + chart.id, chart);
|
||||
return renderFilters(chart);
|
||||
});
|
||||
|
||||
@@ -21,9 +18,14 @@ $(function()
|
||||
calcPreviewGrowFilter();
|
||||
$('body').resize(() => {calcPreviewGrowFilter(true);});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
chartMap = new Map();
|
||||
charts.forEach(function(chart)
|
||||
{
|
||||
chartMap.set(chart.currentGroup + '_' + chart.id, chart);
|
||||
});
|
||||
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
})
|
||||
|
||||
@@ -73,53 +75,53 @@ function initCheckBox()
|
||||
/**
|
||||
* Init query button.
|
||||
*
|
||||
* @param object $obj
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function initQueryBtn()
|
||||
function queryData(obj)
|
||||
{
|
||||
$('.btn-query').click(function()
|
||||
var chartID = $(obj).parents('.filterBox').attr('data-chart');
|
||||
var chartInfo = chartMap.get(chartID);
|
||||
chartInfo.searchFilters = JSON.parse(JSON.stringify(chartInfo.filters));
|
||||
|
||||
// Foreach filters and set current value in searchFilters. */
|
||||
$('#filterItems' + chartID + ' .filter-items').children().each(function(index)
|
||||
{
|
||||
var chartID = $(this).attr('data-chart');
|
||||
var chartInfo = chartMap.get(chartID);
|
||||
chartInfo.searchFilters = JSON.parse(JSON.stringify(chartInfo.filters));
|
||||
var $child = $(this);
|
||||
if(!$child.hasClass('filter-item')) return;
|
||||
|
||||
// Foreach filters and set current value in searchFilters. */
|
||||
$('#filterItems' + chartID + ' .filter-items').children().each(function(index)
|
||||
var filter = chartInfo.searchFilters[index];
|
||||
var type = filter.type;
|
||||
var value = null;
|
||||
|
||||
if(type == 'input' || type == 'select')
|
||||
{
|
||||
var $child = $(this);
|
||||
var filter = chartInfo.searchFilters[index];
|
||||
var type = filter.type;
|
||||
var value = null;
|
||||
var value = $child.find('#default').val();
|
||||
chartInfo.searchFilters[index].default = value;
|
||||
}
|
||||
else if(type == 'date' || type == 'datetime')
|
||||
{
|
||||
var begin = $child.find('input').first().val();
|
||||
var end = $child.find('input').last().val();
|
||||
|
||||
if(type == 'input' || type == 'select')
|
||||
{
|
||||
var value = $child.find('#default').val();
|
||||
chartInfo.searchFilters[index].default = value;
|
||||
}
|
||||
else if(type == 'date' || type == 'datetime')
|
||||
{
|
||||
var begin = $child.find('input').first().val();
|
||||
var end = $child.find('input').last().val();
|
||||
var value = {"begin":begin, "end":end};
|
||||
chartInfo.searchFilters[index].default = value;
|
||||
}
|
||||
else if(type == 'condition')
|
||||
{
|
||||
var operator = $child.find('#operator').data('zui.picker').getValue();
|
||||
var value = $child.find('#value').val();
|
||||
|
||||
var value = {"begin":begin, "end":end};
|
||||
chartInfo.searchFilters[index].default = value;
|
||||
}
|
||||
else if(type == 'condition')
|
||||
{
|
||||
var operator = $child.find('#operator').data('zui.picker').getValue();
|
||||
var value = $child.find('#value').val();
|
||||
|
||||
chartInfo.searchFilters[index].operator = operator;
|
||||
chartInfo.searchFilters[index].value = value;
|
||||
}
|
||||
});
|
||||
|
||||
//* Reload echart. */
|
||||
var echartDom = $('#chartDraw' + chartID).get(0);
|
||||
var echartInfo = echarts.init(echartDom);
|
||||
ajaxGetChart(false, chartInfo, echartInfo);
|
||||
chartInfo.searchFilters[index].operator = operator;
|
||||
chartInfo.searchFilters[index].value = value;
|
||||
}
|
||||
});
|
||||
|
||||
//* Reload echart. */
|
||||
var echartDom = $('#chartDraw' + chartID).get(0);
|
||||
var echartInfo = echarts.init(echartDom);
|
||||
ajaxGetChart(false, chartInfo, echartInfo);
|
||||
}
|
||||
|
||||
function calcPreviewGrowFilter(resize = false)
|
||||
@@ -247,6 +249,6 @@ function renderFilterItem(filter, resp, index, step)
|
||||
};
|
||||
var html = $($.zui.formatString(tpl, data))
|
||||
initPicker(html, 'picker-select', true);
|
||||
initDatepicker(html);
|
||||
initDatepicker(html, attrDateCheck);
|
||||
return html;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<?php js::set('WIDTH_INPUT', $config->chart->widthInput);?>
|
||||
<?php js::set('WIDTH_DATE', $config->chart->widthDate);?>
|
||||
<?php js::set('pickerHeight', $config->bi->pickerHeight);?>
|
||||
<?php $queryDom = "<div class='queryBtn query-inside hidden'> <button type='submit' id='submit' class='btn btn-primary btn-query' data-loading='Loading...'>{$lang->chart->query}</button></div>";?>
|
||||
<?php $queryDom = "<div class='queryBtn query-inside hidden'> <button type='submit' id='submit' onclick='queryData(this)' class='btn btn-primary btn-query' data-loading='Loading...'>{$lang->chart->query}</button></div>";?>
|
||||
<?php js::set('queryDom', $queryDom);?>
|
||||
|
||||
<div id='mainMenu' class='clearfix main-position'>
|
||||
@@ -94,10 +94,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class='panel-body'>
|
||||
<div id="filterItems<?php echo $chart->currentGroup . '_';?><?php echo $chart->id;?>" class='filterBox'>
|
||||
<div id="filterItems<?php echo $chart->currentGroup . '_';?><?php echo $chart->id;?>" data-chart="<?php echo $chart->currentGroup . '_' . $chart->id?>"class='filterBox'>
|
||||
<div class='filter-items'></div>
|
||||
<?php if(!empty($chart->filters)):?>
|
||||
<div class='queryBtn query-outside'><?php echo html::submitButton($lang->chart->query, "data-chart={$chart->currentGroup}{$chart->id}", 'btn btn-primary btn-query');?></div>
|
||||
<div class='queryBtn query-outside'><?php echo html::submitButton($lang->chart->query, "onclick='queryData(this)'", 'btn btn-primary btn-query');?></div>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<div id="chartDraw<?php echo $chart->currentGroup . '_';?><?php echo $chart->id;?>" data-group="<?php echo $chart->currentGroup;?>" data-id="<?php echo $chart->id;?>" class='echart-content'></div>
|
||||
|
||||
Reference in New Issue
Block a user