@@ -20,6 +20,7 @@ public function render()
20
20
$ this ->addVariables (['height ' =>$ height ]);
21
21
$ select = json_encode ($ this ->options , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
22
22
$ 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 ]);
23
24
$ this ->script = <<<EOT
24
25
new ComponentCascadeLine(" {$ id }",JSON.parse(' {$ select }'),' {$ xhr }');
25
26
EOT ;
@@ -31,21 +32,33 @@ public function render()
31
32
* @param array $select 全部选项
32
33
* @param string $xhr ajax接口地址
33
34
* @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 可删除
34
41
* @return string
35
42
*/
36
- public static function panel (array $ select ,string $ xhr ,array $ style =[])
43
+ public static function panel (array $ select ,string $ xhr ,array $ style =[], array $ options =[] )
37
44
{
38
45
$ select = json_encode ($ select , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
39
46
$ style = array_merge (['width ' =>'100% ' ,'height ' =>'230px ' ],$ style );
40
47
$ style_string = '' ;
48
+ $ options = json_encode (array_merge ([
49
+ 'movable ' => true ,
50
+ 'exchange ' => true ,
51
+ 'insert ' => true ,
52
+ 'update ' => true ,
53
+ 'delete ' => true ],$ options ));
41
54
foreach ($ style as $ k =>$ s ){
42
55
$ style_string .="$ k: $ s; " ;
43
56
}
44
57
$ id = 'cascade_line_ ' .mt_rand (0 ,100 );
45
58
return <<<EOF
46
59
<div id=" {$ id }" style=" $ style_string"></div>
47
60
<script>
48
- new ComponentCascadeLine(" {$ id }",JSON.parse(' {$ select }'),' {$ xhr }');
61
+ new ComponentCascadeLine(" {$ id }",JSON.parse(' {$ select }'),' {$ xhr }',JSON.parse(' { $ options } ') );
49
62
</script>
50
63
EOF ;
51
64
}
0 commit comments