Skip to content

Commit 0617e01

Browse files
author
hikki
committed
v3.7
1 parent bb6fb80 commit 0617e01

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/Widget/CascadeDot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function render()
3737
* @param array $style 组件样式设置 宽:width 高:height
3838
* @return string
3939
*/
40-
public static function panel($name, array $select, array $selected, int $limit = 1, array $style = [])
40+
public static function panel($name, array $select, array $selected, int $limit = 0, array $style = [])
4141
{
4242
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
4343
$select = json_encode($select, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);

src/Widget/Dot.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ public function render()
1919
$limit = isset($this->attributes['limit']) ? (int)$this->attributes['limit'] : 0;
2020
$width = isset($this->attributes['width']) ? $this->attributes['width'] : '100%';
2121
$height = isset($this->attributes['height']) ? $this->attributes['height'] : '200px';
22-
$menu_mode = isset($this->attributes['mode']) && $this->attributes['mode'] === true ? 'true' : 'false';
23-
$menu_placeholder = isset($this->attributes['placeholder']) ? $this->attributes['placeholder'] : '未选择';
22+
$menu = json_encode([
23+
'mode'=>isset($this->attributes['mode']) && $this->attributes['mode'] === true ? true : false,
24+
'placeholder'=>isset($this->attributes['placeholder']) ? $this->attributes['placeholder'] : '未选择',
25+
'height'=>isset($this->attributes['menu_height']) ? $this->attributes['menu_height'] : '150px']);
2426
$this->addVariables(['width' => $width, 'height' => $height]);
2527
$select = json_encode($this->options, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
2628
$selected = json_encode($this->checked);
2729
$this->script = <<<EOT
28-
new ComponentDot("{$id}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit},{$menu_mode},'{$menu_placeholder}');
30+
new ComponentDot("{$id}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit},{$menu});
2931
EOT;
3032
return parent::render();
3133
}
@@ -36,26 +38,24 @@ public function render()
3638
* @param array $select 全部选项
3739
* @param array $selected 已选择id组 [1,2,3...]
3840
* @param int $limit 选择限制数 默认0:无限
39-
* @param array $style 组件样式设置 宽:width 高:height
40-
* @param array $menu 组件外观模式配置
41-
* menu.mode false:默认DOT模式 true:下拉列表模式
42-
* menu.placeholder 下拉列表模式开启时 默认未选择占位
41+
* @param array $setting 组件配置
42+
* mode 选择器下拉列表模式 false:默认经典模式 true:下拉模式
43+
* placeholder 下拉列表默认展位
44+
* width 容器宽 例.100% 100px
45+
* height 容器高 例.200px
46+
* menu_height 下拉列表高度限制 例.200px
4347
* @return string
4448
*/
45-
public static function panel($name, array $select, array $selected, int $limit = 0, array $style = [], $menu = ['mode'=>false,'placeholder'=>'请选择'])
49+
public static function panel($name, array $select, array $selected, int $limit = 0, array $setting = [])
4650
{
4751
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
4852
$select = json_encode($select, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
49-
$style = array_merge(['width' => '100%', 'height' => '200px'], $style);
50-
$style_string = '';
51-
foreach ($style as $k => $s) {
52-
$style_string .= "$k:$s;";
53-
}
54-
$menu = array_merge(['mode'=>false,'placeholder'=>'请选择'], $style);
55-
$menu_mode = isset($menu['mode']) && $menu['mode'] === true ? 'true' : 'false';
53+
$setting = array_merge(['mode'=>false,'placeholder'=>'请选择','width' => '100%','height'=>'200px','menu_height'=>'150px'], $setting);
54+
$style = $setting['mode'] === true ? "witdh:{$setting['width']};" : "witdh:{$setting['width']};height:{$setting['height']}";
5655

56+
$menu = json_encode(['mode'=>$setting['mode'],'placeholder'=>$setting['placeholder'],'height'=>$setting['menu_height']]);
5757
return <<<EOF
58-
<div id="{$name}" style="$style_string"></div><script>new ComponentDot("{$name}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit},{$menu_mode},{$menu['placeholder']});</script>
58+
<div id="{$name}" style="$style"></div><script>new ComponentDot("{$name}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit},{$menu}});</script>
5959
EOF;
6060
}
6161
}

src/Widget/Linear.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public function render()
5454
* @param array $list 数据集 二维数据集列表格式
5555
* @param array $style 组件样式设置 宽:width 高:height
5656
* @param array $options 操作列设置
57-
* options.sortable bool 可排序
58-
* options.delete bool 可删除
59-
* options.insert bool 可新增
57+
* options.sortable bool 可排序 true开启
58+
* options.delete bool 可删除 true开启
59+
* options.insert bool 可新增 true开启
6060
* @return string
6161
*/
62-
public static function panel($name, array $columns, array $list, array $style = [], array $options = ['sortable' => true, 'delete' => true, 'insert' => true])
62+
public static function panel($name, array $columns, array $list, array $style = [], array $options = [])
6363
{
6464
$columns = json_encode($columns, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS | JSON_FORCE_OBJECT);
6565
$list = json_encode($list, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);

test/example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ protected function form($id)
134134
* attribute.limit 选择限制数 默认0:无限
135135
* attribute.mode 组件模式设置 false:默认模式 true:下拉列表模式
136136
* attribute.placeholder 下拉列表模式 默认未选择占位
137+
* attribute.menu_height 下拉列表高度限制
137138
*/
138139
$form->Dot('dot','标签选择器')
139140
->options([1=>'松下紗栄子',2=>'上原亜衣',3=>'白石茉莉奈',4=>'美谷朱里',5=>'沖田杏梨',6=>'由愛可奈',7=>'七瀬あいり',8=>'五十嵐星蘭',9=>'仲里紗羽',10=>'波多野結衣'])
140141
->checked([1,2,3])
141142
->attribute(['height'=>'200px']);
142-
143143
/**
144144
* 级联点组件
145145
* options 设置数据集 多维数组 格式[[key=>key1,val=>value1,nodes=>[...]],...]

0 commit comments

Comments
 (0)