diff --git a/src/plugin/admin/app/common/LayuiForm.php b/src/plugin/admin/app/common/LayuiForm.php index 439be5f..20fc665 100644 --- a/src/plugin/admin/app/common/LayuiForm.php +++ b/src/plugin/admin/app/common/LayuiForm.php @@ -1,6 +1,8 @@ htmlContent); } @@ -31,7 +33,7 @@ class LayuiForm * @param $indent * @return string */ - public function js($indent = 0) + public function js($indent = 0): string { return str_replace("\n", "\n" . str_repeat(' ', $indent), $this->jsContent); } @@ -41,7 +43,7 @@ class LayuiForm * @param $options * @return array */ - protected function options($options) + protected function options($options): array { array_walk_recursive($options, function(&$item, $key){ if (is_string($item)) { @@ -572,10 +574,11 @@ EOF; $options['props']['clickClose'] = $options['props']['clickClose'] ?? true; $options['props']['radio'] = $options['props']['radio'] ?? true; $options['props']['tree'] = array_merge_recursive([ - 'show' => true, - 'strict' => false, - 'clickCheck' => true, - 'clickExpand' => false + '$show' => true, + '$strict' => false, + '$clickCheck' => true, + '$clickExpand' => false, + '$expandedKeys' => '$initValue' ], $options['props']['tree'] ?? []); $this->apiSelect($options); } @@ -586,10 +589,11 @@ EOF; */ public function treeSelectMulti($options) { - $options['props']['tree'] = array_merge_recursive(['show' => true], $options['props']['tree'] ?? []); + $options['props']['tree'] = array_merge_recursive(['show' => true, + '$expandedKeys' => '$initValue'], $options['props']['tree'] ?? []); $options['props']['toolbar'] = array_merge_recursive([ - 'show' => true, - 'list' => [ 'ALL', 'CLEAR', 'REVERSE' ] + '$show' => true, + '$list' => [ 'ALL', 'CLEAR', 'REVERSE' ] ], $options['props']['toolbar'] ?? []); $this->apiSelect($options); } @@ -611,6 +615,7 @@ EOF; foreach ($props as $key => $item) { if (is_array($item)) { $item = json_encode($item, JSON_UNESCAPED_UNICODE); + $item = preg_replace('/"\$([^"]+)"/', '$1', $item); $options_string .= "\n".($url?' ':' ')."$key: $item,"; } else if (is_string($item)) { $options_string .= "\n".($url?' ':' ')."$key: \"$item\","; @@ -675,10 +680,11 @@ EOF; /** * 构建表单 * @param $table - * @param $type + * @param string $type * @return LayuiForm + * @throws BusinessException */ - static public function buildForm($table, $type = 'insert') + static public function buildForm($table, string $type = 'insert'): LayuiForm { if (!in_array($type, ['insert', 'update', 'search'])) { $type = 'insert'; @@ -735,10 +741,11 @@ EOF; /** * 构建表格 * @param $table - * @param $indent + * @param int $indent * @return array|string|string[] + * @throws BusinessException */ - static public function buildTable($table, $indent = 0) + static public function buildTable($table, int $indent = 0) { $schema = Util::getSchema($table); $forms = $schema['forms']; diff --git a/src/plugin/admin/app/common/Util.php b/src/plugin/admin/app/common/Util.php index 9d77363..de7f0c4 100644 --- a/src/plugin/admin/app/common/Util.php +++ b/src/plugin/admin/app/common/Util.php @@ -6,7 +6,7 @@ use Illuminate\Database\Connection; use Illuminate\Database\Schema\Builder; use plugin\admin\app\model\Option; use support\Db; -use Support\Exception\BusinessException; +use support\exception\BusinessException; use Throwable; use function config; diff --git a/src/plugin/admin/app/controller/TableController.php b/src/plugin/admin/app/controller/TableController.php index c80770e..528af27 100644 --- a/src/plugin/admin/app/controller/TableController.php +++ b/src/plugin/admin/app/controller/TableController.php @@ -9,8 +9,8 @@ use plugin\admin\app\common\Util; use plugin\admin\app\model\Role; use plugin\admin\app\model\Rule; use plugin\admin\app\model\Option; -use Support\Exception\BusinessException; -use Support\Request; +use support\exception\BusinessException; +use support\Request; use support\Response; class TableController extends Base diff --git a/src/plugin/admin/app/exception/Handler.php b/src/plugin/admin/app/exception/Handler.php index 0a897f6..8f76b9f 100644 --- a/src/plugin/admin/app/exception/Handler.php +++ b/src/plugin/admin/app/exception/Handler.php @@ -20,9 +20,9 @@ use Webman\Http\Response; /** * Class Handler - * @package Support\Exception + * @package support\exception */ -class Handler extends \Support\Exception\Handler +class Handler extends \support\exception\Handler { public function render(Request $request, Throwable $exception): Response { diff --git a/src/plugin/admin/app/view/admin/update.html b/src/plugin/admin/app/view/admin/update.html index e8f78a4..869ac2c 100644 --- a/src/plugin/admin/app/view/admin/update.html +++ b/src/plugin/admin/app/view/admin/update.html @@ -159,9 +159,9 @@ el: "#roles", name: "roles", initValue: initValue, - data: e.data, - tree: {"show":true}, - toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]}, + data: e.data, + tree: {show: true, expandedKeys: initValue}, + toolbar: {show: true, list: ["ALL","CLEAR","REVERSE"]}, }) } }); diff --git a/src/plugin/admin/app/view/role/update.html b/src/plugin/admin/app/view/role/update.html index c08b1fc..79f4b89 100644 --- a/src/plugin/admin/app/view/role/update.html +++ b/src/plugin/admin/app/view/role/update.html @@ -89,8 +89,8 @@ name: "rules", initValue: initValue, data: e.data, - tree: {"show":true}, - toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]}, + tree: {show: true, expandedKeys: initValue}, + toolbar: {show: true, list: ["ALL","CLEAR","REVERSE"]}, }) } }); diff --git a/src/plugin/admin/app/view/rule/update.html b/src/plugin/admin/app/view/rule/update.html index 7bd7d78..813ebff 100644 --- a/src/plugin/admin/app/view/rule/update.html +++ b/src/plugin/admin/app/view/rule/update.html @@ -138,7 +138,7 @@ model: {"icon":"hidden","label":{"type":"text"}}, clickClose: true, radio: true, - tree: {show: true,"strict":false,"clickCheck":true,"clickExpand":false}, + tree: {show: true,"strict":false,"clickCheck":true,"clickExpand":false,expandedKeys: initValue}, }) } });