Skip to content

Commit 8f7733f

Browse files
author
hikki
committed
beta
1 parent ae285e4 commit 8f7733f

File tree

3 files changed

+235
-162
lines changed

3 files changed

+235
-162
lines changed

ComponentViewer.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Admin\Controllers;
44

5+
use Encore\Admin\Actions\RowAction;
56
use Encore\Admin\Admin;
67
use Encore\Admin\Grid;
78
use Encore\Admin\Layout\Content;
@@ -15,7 +16,47 @@ public static function makeEditFormAction(Grid &$grid)
1516
$actions->disableEdit();
1617
$url = Request::capture()->getPathInfo();
1718
Admin::script(<<<EOF
18-
componentEditForm.apply('CEForm','{$url}');
19+
componentForm.make = function () {
20+
componentForm._clear();
21+
componentForm._createModal();
22+
let url = componentForm.url + '/'+this.getAttribute('data-id') + '/edit';
23+
componentForm._createBox(url);
24+
}
25+
componentForm.apply('CEForm','{$url}');
26+
EOF
27+
);
28+
29+
$actions->add(new
30+
class extends RowAction
31+
{
32+
public $name = '修改';
33+
34+
public function render()
35+
{
36+
$id = $this->getKey();
37+
return "<a href='javascript:void(0);' class='CEForm' data-id='$id', class=>{$this->name()}</a>";
38+
}
39+
});
40+
});
41+
}
42+
43+
/**
44+
* 旧版图标模式
45+
* @param Grid $grid
46+
*/
47+
public static function _makeEditFormAction(Grid &$grid)
48+
{
49+
$grid->actions(function ($actions) {
50+
$actions->disableEdit();
51+
$url = Request::capture()->getPathInfo();
52+
Admin::script(<<<EOF
53+
componentForm.make = function () {
54+
componentForm._clear();
55+
componentForm._createModal();
56+
let url = componentForm.url + '/'+this.getAttribute('data-id') + '/edit';
57+
componentForm._createBox(url);
58+
}
59+
componentForm.apply('CEForm','{$url}');
1960
EOF
2061
);
2162
$id = $actions->getKey();

0 commit comments

Comments
 (0)