update
This commit is contained in:
parent
778f837fa4
commit
e72a283a5e
|
@ -18,7 +18,7 @@
|
|||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"tpext\\builder": "src/"
|
||||
"tpext\\builder\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/helper.php"
|
||||
|
|
|
@ -2,21 +2,24 @@
|
|||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use tpext\myadmin\common\Plugin;
|
||||
use think\response\View as ViewShow;
|
||||
use think\facade\View;
|
||||
use tpext\builder\common\Plugin;
|
||||
use tpext\myadmin\common\Module;
|
||||
|
||||
class Builder implements Renderable
|
||||
{
|
||||
private $view = '';
|
||||
|
||||
protected $title = null;
|
||||
public $title = '';
|
||||
|
||||
protected $desc = null;
|
||||
public $desc = null;
|
||||
|
||||
protected $rows = [];
|
||||
public $rows = [];
|
||||
|
||||
protected $__row__ = null;
|
||||
|
||||
public function __construct($title = '', $desc = '')
|
||||
public function __construct($title = 'tpext-builder', $desc = '')
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->desc = $desc;
|
||||
|
@ -52,6 +55,22 @@ class Builder implements Renderable
|
|||
|
||||
public function render()
|
||||
{
|
||||
return Response::create($template, 'view')->assign($vars)->config($config);
|
||||
$vars = [
|
||||
'title' => $this->title,
|
||||
'desc' => $this->desc,
|
||||
'rows' => $this->rows,
|
||||
];
|
||||
|
||||
$config = [];
|
||||
|
||||
$view = new ViewShow($this->view);
|
||||
|
||||
$instance = Module::getInstance();
|
||||
|
||||
$config = $instance->setConfig(['page_title' => $this->title, 'position' => '编辑']);
|
||||
|
||||
View::share(['admin' => $config]);
|
||||
|
||||
return $view->assign($vars)->config($config);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
class Column implements Renderable
|
||||
{
|
||||
protected $size = 12;
|
||||
use tpext\builder\common\Form;
|
||||
use tpext\builder\common\Table;
|
||||
|
||||
protected $elms = [];
|
||||
class Column
|
||||
{
|
||||
public $size = 12;
|
||||
|
||||
public $elms = [];
|
||||
|
||||
public function __construct($size = 12)
|
||||
{
|
||||
|
@ -15,16 +18,20 @@ class Column implements Renderable
|
|||
|
||||
public function form()
|
||||
{
|
||||
return 0;
|
||||
$form = new Form();
|
||||
$this->elms[] = $form;
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
return 0;
|
||||
$table = new Table();
|
||||
$this->elms[] = $table;
|
||||
return $table;
|
||||
}
|
||||
|
||||
public function render()
|
||||
public function getElms()
|
||||
{
|
||||
|
||||
return $this->elms;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,33 +2,24 @@
|
|||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
class Row implements Renderable
|
||||
use tpext\builder\common\Plugin;
|
||||
use think\response\View as ViewShow;
|
||||
|
||||
class Form
|
||||
{
|
||||
|
||||
protected $cols = [];
|
||||
|
||||
protected $__col__ = null;
|
||||
|
||||
public function column($size = 12)
|
||||
{
|
||||
$col = new Column($size);
|
||||
$this->cols[] = $col;
|
||||
$this->__col__ = $col;
|
||||
return $col;
|
||||
}
|
||||
|
||||
public function form($size = 12)
|
||||
{
|
||||
return $this->column($size)->form();
|
||||
}
|
||||
|
||||
public function table($size = 12)
|
||||
{
|
||||
return $this->column($size)->table();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
$this->view = Plugin::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'content.html']);
|
||||
|
||||
$config = [];
|
||||
|
||||
$view = new ViewShow($this->view);
|
||||
|
||||
return $view->assign([])->config($config)->isContent(false)->getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,5 +4,5 @@ namespace tpext\builder\common;
|
|||
|
||||
interface Renderable
|
||||
{
|
||||
public function reader();
|
||||
public function render();
|
||||
}
|
||||
|
|
|
@ -2,18 +2,14 @@
|
|||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
class Row implements Renderable
|
||||
class Row
|
||||
{
|
||||
|
||||
protected $cols = [];
|
||||
|
||||
protected $__col__ = null;
|
||||
public $cols = [];
|
||||
|
||||
public function column($size = 12)
|
||||
{
|
||||
$col = new Column($size);
|
||||
$this->cols[] = $col;
|
||||
$this->__col__ = $col;
|
||||
return $col;
|
||||
}
|
||||
|
||||
|
@ -27,8 +23,8 @@ class Row implements Renderable
|
|||
return $this->column($size)->table();
|
||||
}
|
||||
|
||||
public function render()
|
||||
public function getCols()
|
||||
{
|
||||
|
||||
return $this->cols;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace tpext\builder\common;
|
|||
|
||||
use tpext\builder\table\Column;
|
||||
|
||||
class Row implements Renderable
|
||||
class Table
|
||||
{
|
||||
protected $headers = [];
|
||||
|
||||
|
@ -40,6 +40,6 @@ class Row implements Renderable
|
|||
|
||||
public function render()
|
||||
{
|
||||
|
||||
return 'xxx';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace tpext\builder\displayer;
|
|||
|
||||
use tpext\builder\common\Renderable;
|
||||
|
||||
class Field implements Renderable
|
||||
class Field
|
||||
{
|
||||
protected $view = '';
|
||||
|
||||
|
@ -26,11 +26,13 @@ class Field implements Renderable
|
|||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function value($val)
|
||||
{
|
||||
$this->value = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEditable($editable = true)
|
||||
|
|
|
@ -12,7 +12,7 @@ use tpext\common\ExtLoader;
|
|||
|
||||
$classMap = [
|
||||
//'tpext\\lyatadmin\\common\\Module',
|
||||
//'tpext\\lyatadmin\common\\Plugin',
|
||||
'tpext\\builder\common\\Plugin',
|
||||
];
|
||||
|
||||
ExtLoader::watch('app_init',tpext\behavior\AppInit::class);
|
||||
ExtLoader::addClassMap($classMap);
|
|
@ -5,23 +5,26 @@
|
|||
{/block}
|
||||
|
||||
{block name="content"}
|
||||
{notempty name="rows"}
|
||||
<div class="content">
|
||||
{volist name="rows" id="row"}
|
||||
<div class="row">
|
||||
{notempty name="row.cols"}
|
||||
{volist name="row.cols" id="col"}
|
||||
<div class="col-md-{$col.size}}">
|
||||
{notempty name="col.elms"}
|
||||
|
||||
{/notempty}
|
||||
</div>
|
||||
{/volist}
|
||||
{/notempty}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header"><h4>{$title}<small>{$desc}</small></h4></div>
|
||||
<div class="card-body">
|
||||
{volist name="rows" id="row"}
|
||||
<div class="row">
|
||||
{volist name="row->cols" id="col"}
|
||||
<div class="col-md-{$col->size}">
|
||||
{volist name="col->elms" id="elm"}
|
||||
{:$elm->render()}
|
||||
{/volist}
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/notempty}
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
|
|
Loading…
Reference in New Issue