@@ -53,23 +53,26 @@ public function textarea(string $column, string $label, string $value = '')
53
53
* @param string $label
54
54
* @param array $select
55
55
* @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 下拉列表高度限制
59
63
*/
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 = [])
61
65
{
62
66
$ selected = json_encode ($ selected , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
63
67
$ 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 ' ]]);
69
72
$ content = <<<EOF
70
- <div id=" {$ column }" style=" $ style_string "></div>
73
+ <div id=" {$ column }" style=" $ style "></div>
71
74
<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 });
73
76
</script>
74
77
EOF ;
75
78
$ this ->html .= $ this ->rowpanel ($ column , $ label , $ content );
@@ -78,18 +81,21 @@ public function select(string $column, string $label, array $select, array $sele
78
81
/**
79
82
* @param string $column
80
83
* @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 语言配置
83
88
*/
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 " ] )
85
90
{
86
91
if (!$ value ) {
87
92
$ value = date ('Y-m-d H:i:s ' );
88
93
}
94
+ $ settings = json_encode ($ settings );
89
95
$ content = <<<EOF
90
96
<input style="width: 160px" type="text" id=" {$ column }" name=" {$ column }" value=" {$ value }" class="dlp-input {$ column }" placeholder="输入 {$ label }" />
91
97
<script>
92
- $('# {$ column }').datetimepicker({"format": { $ format } ,"locale":"zh-CN"} );
98
+ $('# {$ column }').datetimepicker(JSON.parse( { $ settings } ) );
93
99
</script>
94
100
EOF ;
95
101
$ this ->html .= $ this ->rowpanel ($ column , $ label , $ content );
0 commit comments