Skip to content

Commit a01d5d2

Browse files
author
hikki
committed
v3.6
1 parent d1b38be commit a01d5d2

File tree

6 files changed

+57
-42
lines changed

6 files changed

+57
-42
lines changed

resources/assets/component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ window.ComponentDot = class {
169169
delete: 'delete'
170170
};
171171

172-
constructor(name, selected, select, limit = 0,menu_mode= false,menu_placeholder='') {
172+
constructor(name, select, selected, limit = 0,menu_mode= false,menu_placeholder='') {
173173
if (!Array.isArray(selected)) {
174174
console.error('Dot param selected must be array!');
175175
return;
@@ -441,7 +441,7 @@ window.ComponentCascadeDot = class {
441441
delete: 'delete'
442442
};
443443

444-
constructor(name, selected, select, limit = 0) {
444+
constructor(name, select, selected, limit = 0) {
445445
if (!Array.isArray(selected) || !Array.isArray(select)) {
446446
console.error('CascadeDot param selected and select must be array!');
447447
return;

src/DLPField.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ public function options($options = [])
2525
return $this;
2626
}
2727

28+
/**
29+
* Set the field options.
30+
*
31+
* @param array $list
32+
*
33+
* @return $this
34+
*/
35+
public function list(array $list = [])
36+
{
37+
$this->list = $list;
38+
return $this;
39+
}
40+
2841
/**
2942
* Set the field option checked.
3043
*

src/Tool/FormPanel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ public function textarea(string $column, string $label, string $value = '')
5151
/**
5252
* @param string $column
5353
* @param string $label
54-
* @param array $selected
5554
* @param array $select
55+
* @param array $selected
5656
* @param int $limit
5757
* @param array $style
5858
* @param bool $menu_mode
5959
*/
60-
public function select(string $column, string $label, array $selected, array $select, $limit = 0, array $style = [],$menu_mode=true)
60+
public function select(string $column, string $label, array $select, array $selected, $limit = 0, array $style = [],$menu_mode=true)
6161
{
6262
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
6363
$select = json_encode($select, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
@@ -69,7 +69,7 @@ public function select(string $column, string $label, array $selected, array $se
6969
$content = <<<EOF
7070
<div id="{$column}" style="$style_string"></div>
7171
<script>
72-
new ComponentDot("{$column}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit},{$menu_mode},{$label});
72+
new ComponentDot("{$column}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit},{$menu_mode},{$label});
7373
</script>
7474
EOF;
7575
$this->html .= $this->rowpanel($column, $label, $content);

src/Widget/CascadeDot.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,36 @@ 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'] : '230px';
22-
$this->addVariables(['width'=>$width,'height' => $height]);
22+
$this->addVariables(['width' => $width, 'height' => $height]);
2323
$select = json_encode($this->options, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
2424
$selected = json_encode($this->checked);
2525
$this->script = <<<EOT
26-
new ComponentCascadeDot("{$id}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit});
26+
new ComponentCascadeDot("{$id}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit});
2727
EOT;
2828
return parent::render();
2929
}
3030

3131
/**
3232
* 直接调用ComponentCascadeDot组件
33-
* @param string $name 名称
34-
* @param array $selected 已选择id组 [1,2,3...]
35-
* @param array $select 全部选项
36-
* @param int $limit 选择限制数 默认0:无限
37-
* @param array $style 组件样式设置 宽:width 高:height
33+
* @param string $name 名称
34+
* @param array $select 全部选项
35+
* @param array $selected 已选择id组 [1,2,3...]
36+
* @param int $limit 选择限制数 默认0:无限
37+
* @param array $style 组件样式设置 宽:width 高:height
3838
* @return string
3939
*/
40-
public static function panel($name,array $selected,array $select,int $limit=1,array $style=[])
40+
public static function panel($name, array $select, array $selected, int $limit = 1, 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);
44-
$style = array_merge(['width'=>'100%','height'=>'230px'],$style);
44+
$style = array_merge(['width' => '100%', 'height' => '230px'], $style);
4545
$style_string = '';
46-
foreach ($style as $k=>$s){
47-
$style_string.="$k:$s;";
46+
foreach ($style as $k => $s) {
47+
$style_string .= "$k:$s;";
4848
}
4949

5050
return <<<EOF
51-
<div id="{$name}" style="$style_string"></div><script>new ComponentCascadeDot("{$name}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit});</script>
51+
<div id="{$name}" style="$style_string"></div><script>new ComponentCascadeDot("{$name}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit});</script>
5252
EOF;
5353
}
5454
}

src/Widget/Dot.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,30 @@ 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['menu_mode']) ? (bool)$this->attributes['menu_mode'] : false;
23-
$menu_placeholder = isset($this->attributes['menu_placeholder']) ? $this->attributes['menu_mode'] : '未选择';
22+
$menu_mode = isset($this->attributes['mode']) ? (bool)$this->attributes['mode'] : false;
23+
$menu_placeholder = isset($this->attributes['placeholder']) ? $this->attributes['placeholder'] : '未选择';
2424
$this->addVariables(['width' => $width, 'height' => $height]);
2525
$select = json_encode($this->options, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
2626
$selected = json_encode($this->checked);
2727
$this->script = <<<EOT
28-
new ComponentDot("{$id}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit},{$menu_mode},'{$menu_placeholder}');
28+
new ComponentDot("{$id}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit},{$menu_mode},'{$menu_placeholder}');
2929
EOT;
3030
return parent::render();
3131
}
3232

3333
/**
3434
* 直接调用ComponentDot组件
3535
* @param string $name 名称
36-
* @param array $selected 已选择id组 [1,2,3...]
3736
* @param array $select 全部选项
37+
* @param array $selected 已选择id组 [1,2,3...]
3838
* @param int $limit 选择限制数 默认0:无限
3939
* @param array $style 组件样式设置 宽:width 高:height
40-
* @param boolean $menu_mode 组件模式设置 false:默认模式 true:下拉列表模式
41-
* @param string $menu_placeholder 下拉列表模式 默认未选择占位
40+
* @param array $menu 组件外观模式配置
41+
* menu.mode false:默认DOT模式 true:下拉列表模式
42+
* menu.placeholder 下拉列表模式开启时 默认未选择占位
4243
* @return string
4344
*/
44-
public static function panel($name, array $selected, array $select, int $limit = 1, array $style = [], $menu_mode = false, $menu_placeholder = '未选择')
45+
public static function panel($name, array $select, array $selected, int $limit = 0, array $style = [], $menu = ['mode'=>false,'placeholder'=>'请选择'])
4546
{
4647
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
4748
$select = json_encode($select, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
@@ -50,9 +51,10 @@ public static function panel($name, array $selected, array $select, int $limit =
5051
foreach ($style as $k => $s) {
5152
$style_string .= "$k:$s;";
5253
}
54+
$menu = array_merge(['mode'=>false,'placeholder'=>'请选择'], $style);
5355

5456
return <<<EOF
55-
<div id="{$name}" style="$style_string"></div><script>new ComponentDot("{$name}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit},{$menu_mode},{$menu_placeholder});</script>
57+
<div id="{$name}" style="$style_string"></div><script>new ComponentDot("{$name}",JSON.parse('{$select}'),JSON.parse('{$selected}'),{$limit},{$menu['mode']},{$menu['placeholder']});</script>
5658
EOF;
5759
}
5860
}

src/Widget/Linear.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function render()
2020
$columns = json_encode($this->columns, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS | JSON_FORCE_OBJECT);
2121
} else {
2222
$columns = [];
23-
$record = current($this->options);
23+
$record = current($this->list);
2424
if (!is_array($record) || empty($record)) {
2525
return;
2626
}
@@ -32,37 +32,37 @@ public function render()
3232
$options = isset($this->attributes['options']) ? json_encode($this->attributes['options']) : json_encode(['sortable' => true, 'delete' => true, 'insert' => true]);
3333
$width = isset($this->attributes['width']) ? $this->attributes['width'] : '100%';
3434
$height = isset($this->attributes['height']) ? $this->attributes['height'] : '355px';
35-
$this->addVariables(['width'=>$width,'height' => $height]);
36-
$data = json_encode($this->options, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
35+
$this->addVariables(['width' => $width, 'height' => $height]);
36+
$list = json_encode($this->list, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
3737
$this->script = <<<EOT
38-
new ComponentLine("{$id}",JSON.parse('{$columns}'),JSON.parse('{$data}'),JSON.parse('{$options}'));
38+
new ComponentLine("{$id}",JSON.parse('{$columns}'),JSON.parse('{$list}'),JSON.parse('{$options}'));
3939
EOT;
4040
return parent::render();
4141
}
4242

4343
/**
4444
* 直接调用Linear组件
45-
* @param string $name 名称
46-
* @param array $columns[column...] 列数据格式配置
47-
* column.name 列表头名称
48-
* column.type 列数据 输出格式input,text,hidden,datetime,select,image,file
49-
* column.insert_type 增加列格式(默认不填同input) 格式input,datetime,select,image,file hidden表示置空
50-
* column.style 自定义style格式
51-
* column.options *insert_type或type为select时 多选项
52-
* column.options_limit *insert_type或type为select时 多选项选择限制数 数字类型默认0:无限制
53-
* column.format *insert_type或type为datetime时时间格式 数字类型默认0: YYYY-MM-DD HH:mm:ss | 1: YYYY-MM-DD | 2: YYYY
54-
* @param array $data 数据集
45+
* @param string $name 名称
46+
* @param array $columns [column...] 列数据格式配置
47+
* column.name 列表头名称
48+
* column.type 列数据 输出格式input,text,hidden,datetime,select,image,file
49+
* column.insert_type 增加列格式(默认不填同input) 格式input,datetime,select,image,file hidden表示置空
50+
* column.style 自定义style格式
51+
* column.options insert_type或type为select时 多选项
52+
* column.options_limit insert_type或type为select时 多选项选择限制数 数字类型默认0:无限制
53+
* column.format insert_type或type为datetime时时间格式 数字类型默认0: YYYY-MM-DD HH:mm:ss | 1: YYYY-MM-DD | 2: YYYY
54+
* @param array $list 数据集 二维数据集列表格式
5555
* @param array $style 组件样式设置 宽:width 高:height
5656
* @param array $options 操作列设置
5757
* options.sortable bool 可排序
5858
* options.delete bool 可删除
5959
* options.insert bool 可新增
6060
* @return string
6161
*/
62-
public static function panel($name,array $columns, array $data, array $style = [], array $options = ['sortable' => true, 'delete' => true, 'insert' => true])
62+
public static function panel($name, array $columns, array $list, array $style = [], array $options = ['sortable' => true, 'delete' => true, 'insert' => true])
6363
{
6464
$columns = json_encode($columns, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS | JSON_FORCE_OBJECT);
65-
$data = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
65+
$list = json_encode($list, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
6666
$style = array_merge(['width' => '100%', 'height' => '355px'], $style);
6767
$style_string = '';
6868
foreach ($style as $k => $s) {
@@ -71,7 +71,7 @@ public static function panel($name,array $columns, array $data, array $style = [
7171
$options = json_encode(array_merge(['sortable' => true, 'delete' => true, 'insert' => true], $options));
7272

7373
return <<<EOF
74-
<div id="{$name}" style="$style_string"></div><script>new ComponentLine("{$name}",JSON.parse('{$columns}'),JSON.parse('{$data}'),JSON.parse('{$options}'));</script>
74+
<div id="{$name}" style="$style_string"></div><script>new ComponentLine("{$name}",JSON.parse('{$columns}'),JSON.parse('{$list}'),JSON.parse('{$options}'));</script>
7575
EOF;
7676
}
7777
}

0 commit comments

Comments
 (0)