Skip to content

Commit 80a6afd

Browse files
author
hikki
committed
7.3
1 parent 96c7711 commit 80a6afd

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

src/Assembly/Abs/Layer.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
4+
namespace DLP\Assembly\Abs;
5+
6+
7+
interface Layer
8+
{
9+
public function __toString();
10+
public function trigger($selector, $event = 'click');
11+
public function setTitle($title);
12+
public function options(array $options);
13+
}

src/Assembly/Unit/Button.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
namespace DLP\Assembly\Unit;
55

66
use DLP\Assembly\Abs\Input;
7+
use DLP\Assembly\Abs\Layer;
8+
use DLP\Layer\Dialog;
79
use DLP\Tool\Assistant;
810

911
/**
@@ -79,6 +81,19 @@ public function bindRequest($xhr = ['url'=>'','method'=>'','data'=>[],'callback'
7981
return $this;
8082
}
8183

84+
/**
85+
* @param \Closure $closure
86+
* @param array $xhr
87+
* @return $this
88+
*/
89+
public function bindDialog(\Closure $closure,array $xhr = ['url' => '', 'method' => 'POST'])
90+
{
91+
$dialog = (new Dialog($xhr))->trigger("#{$this->domId}");
92+
$closure($dialog);
93+
$this->trigger = $dialog;
94+
return $this;
95+
}
96+
8297
public function __toString()
8398
{
8499
$content = <<<EOF

src/Layer/Dialog.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace DLP\Layer;
44

5-
class Dialog
5+
use DLP\Assembly\Abs\Layer;
6+
7+
class Dialog implements Layer
68
{
79
private $trigger;
810
private $button;
@@ -34,11 +36,12 @@ public function trigger($selector, $event = 'click')
3436
}
3537

3638
/**
37-
* @param array $options
39+
* @param array $options ['width' => '420px', 'height' => '93px', 'f' => false]
3840
*/
3941
public function options(array $options)
4042
{
4143
$this->options = array_merge($this->options, $options);
44+
return $this;
4245
}
4346

4447
/**

src/Layer/Window.php

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

33
namespace DLP\Layer;
44

5-
class Window
5+
use DLP\Assembly\Abs\Layer;
6+
7+
class Window implements Layer
68
{
79
private $trigger;
810
private $content;
@@ -65,6 +67,7 @@ public function setTitle($title)
6567
public function options(array $options)
6668
{
6769
$this->options = array_merge($this->options, $options);
70+
return $this;
6871
}
6972

7073
public function __toString()

test/example.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace App\Admin\Controllers;
44

5+
use DLP\Assembly\Unit\Button;
56
use DLP\Assembly\Unit\Linear;
67
use DLP\Assembly\Wing;
8+
use DLP\Layer\Dialog;
79
use DLP\Tool\Assistant;
810
use DLP\Widget\Plane;
911
use Encore\Admin\Admin;
@@ -124,6 +126,7 @@ public function update($id)
124126
protected function form($id)
125127
{
126128
$form = new Form(new Model());
129+
/*在LA的form中使用组件*/
127130
$form->html((new Linear('source',
128131
[
129132
'id' => ['name' => 'ID', 'type' => 'text'],
@@ -139,12 +142,16 @@ protected function form($id)
139142
["id"=>4,"title" => "妻晒し 表の顔は貞淑妻、裏の顔は変態妻の公開記録―。 木下凛々子", "url" => "https://img.9618599.com/resources//d41d8cd98f00b204e9800998ecf8427e/b1a3cffd40eca68c.jpg", "type" => 1, "time" => "2021-12-14 13:24:46"],
140143
["id"=>5,"title" => "担任教師に3年分の妄想・愛・性欲をぶち撒けた卒業式前夜 miru (ブルーレイディスク)","url" => "https://img.9618599.com/resources/javdb.com/61e1171d16a76b11f7375cde/small_cover.jpg", "type" => 2, "time" => "2021-12-14 13:24:46"]])
141144
->setStyle(['height' => '240px']), '列表组件');
145+
/*自定义按钮弹窗*/
146+
$form->html((new Button('删除'))->bindDialog(function (Dialog $dialog)use($id){
147+
$dialog->setTitle('删除')->info('确认删除资源?')->button('确认',['id'=>$id]);
148+
},['url'=>'...del']));
142149
return $form;
143150
}
144151

145152
public function blank()
146153
{
147-
/*wing辅助控件工具包*/
154+
/*wing组装器*/
148155
$W = new Wing();
149156
$W->display('id')->label('序号');
150157
$W->section(function ($W){
@@ -206,15 +213,6 @@ public function blank()
206213
return $W->form();
207214
}
208215

209-
/**
210-
* 级联线组件
211-
* 链表数据结构 [[key=>key1,val=>value1,nodes=>[...]],...]
212-
* 链表结构数据辅助组装(例)
213-
* 1.倒排父节点查询 注:id name parent_id 必须命别名 key val par
214-
* $select = Model::orderBy('parent_id','DESC')->select('id as key','name as val','parent_id as par')->get()->toArray();
215-
* 2.辅助函数dimension 组装后的$select结构参考$this->cascadeExampleData()返回数据
216-
* Assistant::dimension($select);
217-
*/
218216
private function cascadeExampleData()
219217
{
220218
return [

0 commit comments

Comments
 (0)