* zin: support to set priList and severityList data automatically.
This commit is contained in:
@@ -118,9 +118,13 @@ class dtable extends wg
|
||||
*/
|
||||
public function initCols(string $module)
|
||||
{
|
||||
global $app;
|
||||
$colConfigs = $this->prop('cols');
|
||||
$dataPairs = $this->prop('userMap', array());
|
||||
global $app, $lang;
|
||||
|
||||
$colConfigs = $this->prop('cols');
|
||||
$dataPairs = $this->prop('userMap', array());
|
||||
$hasPriCols = false;
|
||||
$hasSeverityCols = false;
|
||||
|
||||
foreach($colConfigs as $field => &$config)
|
||||
{
|
||||
if(is_object($config)) $config = (array)$config;
|
||||
@@ -140,9 +144,29 @@ class dtable extends wg
|
||||
$delimiter = is_string($config['delimiter']) ? $config['delimiter'] : ',';
|
||||
$config['map'] = jsRaw("(value) => {return window.setMultipleCell(value, '" . json_encode($dataPairs). "', '{$delimiter}')}");
|
||||
}
|
||||
|
||||
if(isset($config['type']) && $config['type'] === 'pri')
|
||||
{
|
||||
$hasPriCols = true;
|
||||
}
|
||||
if(isset($config['type']) && $config['type'] === 'severity')
|
||||
{
|
||||
$hasSeverityCols = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setProp('cols', array_values($colConfigs));
|
||||
|
||||
if($hasPriCols && !$this->prop('priList'))
|
||||
{
|
||||
$moduleName = $app->getModuleName();
|
||||
if(isset($lang->$moduleName->priList)) $this->setProp('priList', $lang->$moduleName->priList);
|
||||
}
|
||||
if($hasSeverityCols && !$this->prop('severityList'))
|
||||
{
|
||||
$moduleName = $app->getModuleName();
|
||||
if(isset($lang->$moduleName->severityList)) $this->setProp('severityList', $lang->$moduleName->severityList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ class priLabel extends wg
|
||||
{
|
||||
protected static array $defineProps = array(
|
||||
'pri: int|string', // 优先级的值。
|
||||
'text?: string|array' // 优先级显示的文本或优先级文本映射对象。
|
||||
'text?: string|array' // 优先级显示的文本或优先级文本映射对象,如果不指定从 $lang->$moduleName->priList 中获取。
|
||||
);
|
||||
|
||||
protected function onAddChild(mixed $child)
|
||||
@@ -32,6 +32,13 @@ class priLabel extends wg
|
||||
$pri = $this->prop('pri', 0);
|
||||
$text = $this->prop('text');
|
||||
|
||||
if(is_null($text))
|
||||
{
|
||||
global $app, $lang;
|
||||
$moduleName = $app->getModuleName();
|
||||
if(isset($lang->$moduleName->priList)) $text = $lang->$moduleName->priList;
|
||||
}
|
||||
|
||||
if(is_array($text)) $text = isset($text[$pri]) ? $text[$pri] : null;
|
||||
|
||||
$pri = trim("$pri");
|
||||
|
||||
@@ -6,7 +6,7 @@ class severityLabel extends wg
|
||||
{
|
||||
protected static array $defineProps = array(
|
||||
'level: string|int', // 严重程度等级。
|
||||
'text?: string|array', // 标签文本或标签文本映射对象。
|
||||
'text?: string|array', // 标签文本或标签文本映射对象,如果不指定从 $lang->$moduleName->severityList 中获取。
|
||||
'isIcon?: bool=false' // 是否显示为图标。
|
||||
);
|
||||
|
||||
@@ -34,6 +34,13 @@ class severityLabel extends wg
|
||||
$text = $this->prop('text');
|
||||
$isIcon = $this->prop('isIcon');
|
||||
|
||||
if(is_null($text))
|
||||
{
|
||||
global $app, $lang;
|
||||
$moduleName = $app->getModuleName();
|
||||
if(isset($lang->$moduleName->severityList)) $text = $lang->$moduleName->severityList;
|
||||
}
|
||||
|
||||
if(is_array($text)) $text = isset($text[$level]) ? $text[$level] : null;
|
||||
|
||||
$level = trim("$level");
|
||||
|
||||
Reference in New Issue
Block a user