Skip to content

Commit 04f44f5

Browse files
author
hikki
committed
v1 点线面
1 parent 8b91eb2 commit 04f44f5

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

resources/assets/component.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ function componentPlane(url,xhr_url='',method='POST'){
413413

414414
X.addEventListener('click', function () {
415415
document.body.removeChild(modal);
416+
if(document.getElementById('kvFileinputModal') instanceof HTMLElement) {
417+
document.body.removeChild(document.getElementById('kvFileinputModal'));
418+
}
416419
});
417420

418421
let modal_body = document.createElement('div');
@@ -431,4 +434,8 @@ function componentPlane(url,xhr_url='',method='POST'){
431434
}
432435
};
433436
Form.make(url)
434-
}
437+
}
438+
439+
440+
441+

src/DLPViewer.php

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function makeComponentDot(Form $form, string $column, string $titl
3333
$select = json_encode($select, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS);
3434
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS);
3535
}
36-
self::script(<<<EOF
36+
Admin::script(<<<EOF
3737
componentDot("{$column}",JSON.parse('{$selected}'),JSON.parse('{$select}'));
3838
EOF
3939
);
@@ -57,7 +57,7 @@ public static function makeComponentLine(Form $form, string $column, string $tit
5757
$data = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
5858
}
5959
$settings = json_encode($settings, JSON_UNESCAPED_UNICODE);
60-
self::script(<<<EOF
60+
Admin::script(<<<EOF
6161
componentLine("{$column}",JSON.parse('{$settings}'),JSON.parse('{$data}'));
6262
EOF
6363
);
@@ -68,7 +68,7 @@ public static function makeComponentLine(Form $form, string $column, string $tit
6868
* 头部-多操作添加
6969
* @param Grid $grid
7070
* @param array $settings [setting,...]
71-
* setting.document_id 自定义DOM节点ID
71+
* setting.document_id 自定义节点ID
7272
* setting.title 自定义按钮名
7373
* setting.url 加载页地址
7474
* setting.xhr_url ajax提交地址
@@ -115,7 +115,7 @@ public function render()
115115
* 列-多操作添加
116116
* @param Grid $grid
117117
* @param array $settings [setting,...]
118-
* setting.document_class 自定义DOM节点CLASS
118+
* setting.document_class 自定义类名
119119
* setting.title 自定义按钮名
120120
* setting.url 加载页地址 url/{id}加参数匹配id
121121
* setting.xhr_url ajax提交地址 url/{id}加参数匹配id
@@ -170,7 +170,7 @@ public function render()
170170
* 列-多操作添加 (旧版图标按钮模式)
171171
* @param Grid $grid
172172
* @param array $settings [setting,...]
173-
* setting.document_class 自定义DOM节点CLASS
173+
* setting.document_class 自定义类名
174174
* setting.title 自定义按钮名 (图标css类 fa-edit fa-...)
175175
* setting.url 加载页地址
176176
* setting.xhr_url ajax提交地址
@@ -214,10 +214,22 @@ public static function _makeRowPlaneAction(Grid $grid,array $settings = [
214214
*/
215215
public static function makeForm(Content $content)
216216
{
217-
$items = [
217+
return view('component.content', [
218218
'_content_' => str_replace('pjax-container', '', $content->build())
219-
];
220-
return view('component.content', $items)->render();
219+
])->render();
220+
}
221+
222+
/**
223+
* 弹窗自定义视图生成
224+
* @param string $html
225+
* @return array|string
226+
* @throws \Throwable
227+
*/
228+
public static function makeHtml($html)
229+
{
230+
return view('component.content', [
231+
'_content_' => $html
232+
])->render();
221233
}
222234

223235
/**
@@ -238,31 +250,11 @@ public static function result($success = true, $message = 'OK', $data = [])
238250
->header('Access-Control-Allow-Origin', '*');
239251
}
240252

241-
/**
242-
* 表单代码段插入js片段代码
243-
* @param $script
244-
*/
245-
public static function script($script)
246-
{
247-
Admin::script(<<<EOF
248-
new Promise((resolve, reject) => {
249-
while (true){
250-
if(document.getElementById('component') instanceof HTMLElement){
251-
return resolve();
252-
}
253-
}
254-
}).then(function() {
255-
{$script}
256-
});
257-
EOF
258-
);
259-
}
260-
261253
/**
262254
* @param array $data
263255
* @return false|string
264256
*/
265-
protected static function safeJson(array $data)
257+
public static function safeJson(array $data)
266258
{
267259
self::recursiveJsonArray($data);
268260
return json_encode($data, JSON_UNESCAPED_UNICODE);

0 commit comments

Comments
 (0)