Skip to content

Commit 7e5f895

Browse files
author
hikki
committed
v3.8
1 parent 0f296e9 commit 7e5f895

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/Tool/FormPanel.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,26 @@ public function textarea(string $column, string $label, string $value = '')
5353
* @param string $label
5454
* @param array $select
5555
* @param array $selected
56-
* @param int $limit
57-
* @param array $style
58-
* @param bool $menu_mode
56+
* @param int $limit 选择数量限制 0无限
57+
* @param array $setting
58+
* mode 选择器下拉列表模式 false默认经典模式 true下拉模式
59+
* placeholder 下拉列表默认展位
60+
* width 容器宽
61+
* height 容器高
62+
* menu_height 下拉列表高度限制
5963
*/
60-
public function select(string $column, string $label, array $select, array $selected, $limit = 0, array $style = [],$menu_mode=true)
64+
public function select(string $column, string $label, array $select, array $selected, $limit = 0, array $setting = [])
6165
{
6266
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
6367
$select = json_encode($select, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
64-
$style = array_merge(['width' => '100%', 'height' => '62px'], $style);
65-
$style_string = '';
66-
foreach ($style as $k => $s) {
67-
$style_string .= "$k:$s;";
68-
}
68+
$setting = array_merge(['mode'=>false,'placeholder'=>'请选择','width' => '100%','height'=>'200px','menu_height'=>'150px'], $setting);
69+
$style = $setting['mode'] === true ? "witdh:{$setting['width']};" : "witdh:{$setting['width']};height:{$setting['height']}";
70+
71+
$menu = json_encode(['mode'=>$setting['mode'],'placeholder'=>$setting['placeholder'],'height'=>$setting['menu_height']]);
6972
$content = <<<EOF
70-
<div id="{$column}" style="$style_string"></div>
73+
<div id="{$column}" style="$style"></div>
7174
<script>
72-
new ComponentDot("{$column}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit},{$menu_mode},{$label});
75+
new ComponentDot("{$column}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit},{$menu});
7376
</script>
7477
EOF;
7578
$this->html .= $this->rowpanel($column, $label, $content);
@@ -78,18 +81,21 @@ public function select(string $column, string $label, array $select, array $sele
7881
/**
7982
* @param string $column
8083
* @param string $label
81-
* @param string|integer $value
82-
* @param string $format YYYY-MM-DD HH:mm:ss | YYYY-MM-DD | YYYY
84+
* @param string $value
85+
* @param array $settings
86+
* format: [YYYY-MM-DD HH:mm:ss | YYYY-MM-DD | YYYY ]
87+
* locale 语言配置
8388
*/
84-
public function datepicker(string $column, string $label, $value = '',$format = "YYYY-MM-DD HH:mm:ss")
89+
public function datepicker(string $column, string $label, $value = '',array $settings = ['format'=>"YYYY-MM-DD HH:mm:ss",'locale'=>"zh-CN"])
8590
{
8691
if (!$value) {
8792
$value = date('Y-m-d H:i:s');
8893
}
94+
$settings = json_encode($settings);
8995
$content = <<<EOF
9096
<input style="width: 160px" type="text" id="{$column}" name="{$column}" value="{$value}" class="dlp-input {$column}" placeholder="输入 {$label}" />
9197
<script>
92-
$('#{$column}').datetimepicker({"format":{$format},"locale":"zh-CN"});
98+
$('#{$column}').datetimepicker(JSON.parse({$settings}));
9399
</script>
94100
EOF;
95101
$this->html .= $this->rowpanel($column, $label, $content);

0 commit comments

Comments
 (0)