@@ -29,7 +29,7 @@ public function render()
2929 }
3030 $ columns = json_encode ($ columns );
3131 }
32- $ options = isset ($ this ->attributes ['options ' ]) ? json_encode ($ this ->attributes ['options ' ]) : json_encode (['sortable ' => true , 'delete ' => true ]);
32+ $ options = isset ($ this ->attributes ['options ' ]) ? json_encode ($ this ->attributes ['options ' ]) : json_encode (['sortable ' => true , 'delete ' => true , ' insert ' => true ]);
3333 $ height = isset ($ this ->attributes ['height ' ]) ? $ this ->attributes ['height ' ] : '355px ' ;
3434 $ this ->addVariables (['height ' => $ height ]);
3535 $ data = json_encode ($ this ->options , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
@@ -41,25 +41,26 @@ public function render()
4141
4242 /**
4343 * 直接调用Linear组件
44- * @param array $columns 头部字段样式定义
45- * @param array $data 数据集
46- * @param array $style 组件样式设置 宽:width 高:height
47- * @param array $options 操作列设置
44+ * @param array $columns 头部字段样式定义
45+ * @param array $data 数据集
46+ * @param array $style 组件样式设置 宽:width 高:height
47+ * @param array $options 操作列设置
4848 * options.sortable bool 可排序
4949 * options.delete bool 可删除
50+ * options.insert bool 可新增
5051 * @return string
5152 */
52- public static function panel (array $ columns ,array $ data ,array $ style= [],array $ options= ['sortable ' => true , 'delete ' => true ])
53+ public static function panel (array $ columns , array $ data , array $ style = [], array $ options = ['sortable ' => true , 'delete ' => true , ' insert ' => true ])
5354 {
5455 $ columns = json_encode ($ columns , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
5556 $ data = json_encode ($ data , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
56- $ style = array_merge (['width ' => '100% ' ,'height ' => '355px ' ],$ style );
57+ $ style = array_merge (['width ' => '100% ' , 'height ' => '355px ' ], $ style );
5758 $ style_string = '' ;
58- foreach ($ style as $ k=> $ s ){
59- $ style_string.= "$ k: $ s; " ;
59+ foreach ($ style as $ k => $ s ) {
60+ $ style_string .= "$ k: $ s; " ;
6061 }
61- $ options = json_encode (array_merge (['sortable ' => true , 'delete ' => true ], $ options ));
62- $ id = 'linear_ ' . mt_rand (0 ,100 );
62+ $ options = json_encode (array_merge (['sortable ' => true , 'delete ' => true , ' insert ' => true ], $ options ));
63+ $ id = 'linear_ ' . mt_rand (0 , 100 );
6364 return <<<EOF
6465<div id=" {$ id }" style=" $ style_string"></div>
6566<script>
0 commit comments