* zin: add autoLoad property to load form automatically.
This commit is contained in:
@@ -27,6 +27,7 @@ class form extends formBase
|
||||
'data?: array|object', // 表单项值默认数据。
|
||||
'labelData?: array|object', // 表单项标签默认数据。
|
||||
'loadUrl?: string', // 动态更新 URL。
|
||||
'autoLoad?: array', // 自动更新策略。
|
||||
'actionsClass?: string="form-group no-label"' // 操作按钮栏的 CSS 类。
|
||||
);
|
||||
|
||||
@@ -221,6 +222,23 @@ class form extends formBase
|
||||
if($this->hasProp('formID')) $props[] = setID($this->prop('formID'));
|
||||
if($this->hasProp('loadUrl')) $props[] = setData('load-url', $this->prop('loadUrl'));
|
||||
|
||||
$autoLoad = $this->prop('autoLoad');
|
||||
if(is_array($autoLoad) || is_object($autoLoad))
|
||||
{
|
||||
$props[] = bind::change(implode('', array
|
||||
(
|
||||
'const autoLoad = ' . json_encode($autoLoad) . ';',
|
||||
'const $ele = $(event.target);',
|
||||
'Object.keys(autoLoad).forEach(selector => ',
|
||||
'{',
|
||||
'if(!".[#".includes(selector[0])) selector = `[name="${selector}"]`;',
|
||||
'if(!$ele.closest(selector).length) return;',
|
||||
'const setting = autoLoad[selector];',
|
||||
'loadForm($.extend({target: $ele}, typeof setting === "string" ? {items: setting} : setting));',
|
||||
'});'
|
||||
)));
|
||||
}
|
||||
|
||||
return $props;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ class formPanel extends panel
|
||||
'data?: array|object', // 表单项值默认数据。
|
||||
'labelData?: array|object', // 表单项标签默认数据。
|
||||
'loadUrl?: string', // 动态更新 URL。
|
||||
'autoLoad?: array', // 动态更新策略。
|
||||
'defaultMode?: string="lite"', // 默认表单模式(lite: 简洁版,full: 完整版)。
|
||||
'foldableItems?: array|string', // 可折叠的表单项。
|
||||
'pinnedItems?: array|string', // 固定显示的表单项。
|
||||
|
||||
Reference in New Issue
Block a user