* Code formatter for screen.
This commit is contained in:
+19
-23
@@ -67,7 +67,6 @@ class screenModel extends model
|
||||
public function getByID(int $screenID, int $year = 0, int $dept = 0, string $account = ''): object|bool
|
||||
{
|
||||
$screen = $this->dao->select('*')->from(TABLE_SCREEN)->where('id')->eq($screenID)->fetch();
|
||||
if($screen->id == 5) return $screen;
|
||||
if(!$screen) return false;
|
||||
|
||||
if(empty($screen->scheme)) $screen->scheme = file_get_contents(__DIR__ . '/json/screen.json');
|
||||
@@ -96,8 +95,8 @@ class screenModel extends model
|
||||
$this->filter->account = $account;
|
||||
$this->filter->charts = array();
|
||||
|
||||
if(!$screen->builtin || in_array($screen->id, $this->config->screen->builtinScreen)) return $this->genNewChartData($screen, $year, $dept, $account);
|
||||
if($screen->id == 5) return new stdclass();
|
||||
if(!$screen->builtin || in_array($screen->id, $this->config->screen->builtinScreen)) return $this->genNewChartData($screen, $year, $dept, $account);
|
||||
|
||||
$config = new stdclass();
|
||||
$config->width = 1300;
|
||||
@@ -154,10 +153,7 @@ class screenModel extends model
|
||||
foreach($scheme->componentList as $component)
|
||||
{
|
||||
$list = !empty($component->isGroup) ? $component->groupList : array($component);
|
||||
foreach($list as $groupComponent)
|
||||
{
|
||||
if(isset($groupComponent->key) && $groupComponent->key === 'Select') $groupComponent = $this->buildSelect($groupComponent);
|
||||
}
|
||||
foreach($list as $groupComponent) isset($groupComponent->key) && $groupComponent->key === 'Select' && $this->buildSelect($groupComponent);
|
||||
}
|
||||
|
||||
/** Fileter chart. */
|
||||
@@ -188,7 +184,7 @@ class screenModel extends model
|
||||
$table = $type == 'chart' ? TABLE_CHART : TABLE_PIVOT;
|
||||
$chart = $this->dao->select('*')->from($table)->where('id')->eq($chartID)->fetch();
|
||||
|
||||
$this->genComponentData($chart, $type, $component);
|
||||
$this->genComponentData($chart, $component, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,11 +194,11 @@ class screenModel extends model
|
||||
* @param object $chart
|
||||
* @param string $type
|
||||
* @param object $component
|
||||
* @param string $filters
|
||||
* @param array $filters
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function genComponentData(object $chart, string $type = 'chart', object $component = null, string $filters = ''): void
|
||||
public function genComponentData(object $chart, object $component, string $type = 'chart', array $filters = array()): void
|
||||
{
|
||||
$chart = clone($chart);
|
||||
if($type == 'pivot' && $chart)
|
||||
@@ -336,9 +332,9 @@ class screenModel extends model
|
||||
* 获取图表配置。
|
||||
* Get chart option.
|
||||
*
|
||||
* @param object $chart
|
||||
* @param object $component
|
||||
* @param array $filters
|
||||
* @param object $chart
|
||||
* @param object $component
|
||||
* @param array $filters
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
@@ -446,7 +442,7 @@ class screenModel extends model
|
||||
if($chart->sql)
|
||||
{
|
||||
$settings = json_decode($chart->settings, true);
|
||||
$langs = json_decode($chart->langs, true);
|
||||
$langs = json_decode($chart->langs, true);
|
||||
$settings = current($settings);
|
||||
|
||||
list($group, $metrics, $aggs, $xLabels, $yStats) = $this->loadModel('chart')->getMultiData($settings, $chart->sql, $filters);
|
||||
@@ -462,7 +458,7 @@ class screenModel extends model
|
||||
$fieldConfig = zget($fields, $metrics[$index]);
|
||||
$fieldName = $langs[$fieldConfig->field][$clientLang] ?? $fieldConfig->name;
|
||||
$field = $fieldName . '(' . zget($this->lang->chart->aggList, $aggs[$index]) . ')';
|
||||
$dimensions[] = $field;
|
||||
array_push($dimensions, $field);
|
||||
|
||||
foreach($dataList as $valueField => $value)
|
||||
{
|
||||
@@ -518,7 +514,6 @@ class screenModel extends model
|
||||
$sourceData = array();
|
||||
foreach($options['series'] as $dataList)
|
||||
{
|
||||
$field = $settings['metric'][0]['field'];
|
||||
foreach($dataList['data'] as $data)
|
||||
{
|
||||
$fieldValue = $data['name'];
|
||||
@@ -527,7 +522,7 @@ class screenModel extends model
|
||||
$sourceData[$fieldValue] = new stdclass();
|
||||
$sourceData[$fieldValue]->{$groupField} = (string)$fieldValue;
|
||||
}
|
||||
$sourceData[$fieldValue]->{$field} = $data['value'];
|
||||
$sourceData[$fieldValue]->{$metricField} = $data['value'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,8 +755,8 @@ class screenModel extends model
|
||||
*/
|
||||
public function processXLabel(array $xLabels, string $type, string $object, string $field): array
|
||||
{
|
||||
$options = $this->getSysOptions($type, $object, $field);
|
||||
$xLabelValues = array();
|
||||
$options = $this->getSysOptions($type, $object, $field);
|
||||
foreach($xLabels as $label) $xLabelValues[$label] = isset($options[$label]) ? $options[$label] : $label;
|
||||
|
||||
return $xLabelValues;
|
||||
@@ -804,7 +799,7 @@ class screenModel extends model
|
||||
case 'option':
|
||||
if($field)
|
||||
{
|
||||
$path = $this->app->getModuleRoot() . 'dataview' . DS . 'table' . DS . "$object.php";
|
||||
$path = $this->app->getModuleRoot() . 'dataview' . DS . 'table' . DS . "{$object}.php";
|
||||
if(is_file($path))
|
||||
{
|
||||
include $path;
|
||||
@@ -880,7 +875,7 @@ class screenModel extends model
|
||||
*
|
||||
* @param object $component
|
||||
* @access public
|
||||
* @return object
|
||||
* @return void
|
||||
*/
|
||||
public function buildGroup(object $component): void
|
||||
{
|
||||
@@ -892,13 +887,13 @@ class screenModel extends model
|
||||
*
|
||||
* @param object $component
|
||||
* @access public
|
||||
* @return object
|
||||
* @return void
|
||||
*/
|
||||
public function setComponentDefaults(object $component): void
|
||||
{
|
||||
if(!isset($component->styles)) $component->styles = json_decode('{"filterShow": false, "hueRotate": 0, "saturate": 1, "contrast": 1, "brightness": 1, "opacity": 1, "rotateZ": 0, "rotateX": 0, "rotateY": 0, "skewX": 0, "skewY": 0, "blendMode": "normal", "animations": []}');
|
||||
if(!isset($component->status)) $component->status = json_decode('{"lock": false, "hide": false}');
|
||||
if(!isset($component->request)) $component->request = json_decode('{ "requestDataType": 0, "requestHttpType": "get", "requestUrl": "", "requestIntervalUnit": "second", "requestContentType": 0, "requestParamsBodyType": "none", "requestSQLContent": { "sql": "select * from where" }, "requestParams": { "Body": { "form-data": {}, "x-www-form-urlencoded": {}, "json": "", "xml": "" }, "Header": {}, "Params": {} } }');
|
||||
if(!isset($component->styles)) $component->styles = $this->config->screen->chart->default->styles;
|
||||
if(!isset($component->status)) $component->status = $this->config->screen->chart->default->status;
|
||||
if(!isset($component->request)) $component->request = $this->config->screen->chart->default->request;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1547,6 +1542,7 @@ class screenModel extends model
|
||||
*/
|
||||
public function initComponent(object $chart, string $type, object $component)
|
||||
{
|
||||
if(!$component) return new stdclass();
|
||||
if(!$chart) return $component;
|
||||
|
||||
$settings = is_string($chart->settings) ? json_decode($chart->settings) : $chart->settings;
|
||||
|
||||
Reference in New Issue
Block a user