Skip to content

Commit abe0be5

Browse files
author
hikki
committed
v3.2
1 parent adc8aba commit abe0be5

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/Widget/CascadeLine.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function render()
2020
$this->addVariables(['height'=>$height]);
2121
$select = json_encode($this->options, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
2222
$xhr = $this->xhr ?? '';
23+
$options = isset($this->attributes['options']) ? json_encode($this->attributes['options']) : json_encode(['movable' => true,'exchange' => true,'insert' => true,'update' => true,'delete' => true]);
2324
$this->script = <<<EOT
2425
new ComponentCascadeLine("{$id}",JSON.parse('{$select}'),'{$xhr}');
2526
EOT;
@@ -31,21 +32,33 @@ public function render()
3132
* @param array $select 全部选项
3233
* @param string $xhr ajax接口地址
3334
* @param array $style 组件样式设置 宽:width 高:height
35+
* @param array $options
36+
* options.movable bool 可迁移节点 (迁移到其他节点子集)
37+
* options.exchange bool 可交换节点 (节点与其子节点相互交换)
38+
* options.insert bool 可新增
39+
* options.update bool 可修改
40+
* options.delete bool 可删除
3441
* @return string
3542
*/
36-
public static function panel(array $select,string $xhr,array $style=[])
43+
public static function panel(array $select,string $xhr,array $style=[],array $options=[])
3744
{
3845
$select = json_encode($select, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
3946
$style = array_merge(['width'=>'100%','height'=>'230px'],$style);
4047
$style_string = '';
48+
$options = json_encode(array_merge([
49+
'movable' => true,
50+
'exchange' => true,
51+
'insert' => true,
52+
'update' => true,
53+
'delete' => true],$options));
4154
foreach ($style as $k=>$s){
4255
$style_string.="$k:$s;";
4356
}
4457
$id = 'cascade_line_'.mt_rand(0,100);
4558
return <<<EOF
4659
<div id="{$id}" style="$style_string"></div>
4760
<script>
48-
new ComponentCascadeLine("{$id}",JSON.parse('{$select}'),'{$xhr}');
61+
new ComponentCascadeLine("{$id}",JSON.parse('{$select}'),'{$xhr}',JSON.parse('{$options}'));
4962
</script>
5063
EOF;
5164
}

src/Widget/Linear.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public function render()
4343
* 直接调用Linear组件
4444
* @param array $columns 头部字段样式定义
4545
* @param array $data 数据集
46-
* @param array $options 操作列设置 sortable可排序 delete可删除
46+
* @param array $options 操作列设置
47+
* options.sortable bool 可排序
48+
* options.delete bool 可删除
4749
* @return string
4850
*/
4951
public static function panel(array $columns,array $data,array $options=['sortable' => true, 'delete' => true])

test/example.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ protected function form($id)
184184
* 2.辅助函数dimension 组装后的$select结构参考$this->cascadeExampleData()返回数据
185185
* DLPHelper::dimension($select);
186186
* xhr 接口地址 编码参见:test\CascadeLineController 路由配置$router->resource('xhr地址', 'CascadeLineController')
187-
* attribute.height 设置高度 默认200px
187+
* attribute.height 设置高度 默认200px
188+
* attribute.options 设置
188189
*/
189190
$form->CascadeLine('cascadeLine','级联标签管理器')
190191
->options($this->cascadeExampleData())

0 commit comments

Comments
 (0)