dever 3 years ago
parent
commit
200db9466b
3 changed files with 46 additions and 5 deletions
  1. 13 0
      database/admin.php
  2. 1 1
      src/Database.php
  3. 32 4
      src/Lib/Input.php

+ 13 - 0
database/admin.php

@@ -287,6 +287,19 @@ return array
 			# 或者加入可选项 待实现
 			'option' => $cate,
 		),
+
+		# 标签,根据分类变化的标签
+		'tag'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '标签',
+			'default' 	=> '',
+			'desc' 		=> '标签',
+			'match' 	=> 'is_string',
+			// 多级联动+多选
+			'update'	=> 'linkage_checkbox',
+			'option'	=> array(Dever::url('api.get', 'area'), '', Dever::url('api.get', 'area')),//先选择多级联动,再选择多选
+		),
 		
 		# 加载地图
 		'map'		=> array

+ 1 - 1
src/Database.php

@@ -2520,7 +2520,7 @@ class Database
         if ($value == 'table' && $struct) {
             $result = $this->struct_data($struct, $data);
             $value = Dever::table($result);
-        } elseif (strpos($value, '{') !== false) {
+        } elseif (strpos($value, '{') !== false && strpos($value, '{"') === false) {
             # 这里用到了/e,注意这里无论如何不能传入$_GET之类的用户参数 2015/7/21更新为callback方式
             //$eval = '$value = ' . preg_replace('/{(.*?)}/e', "\$data['$1']", $value) . ';';
             $func = function ($r) use ($data) {

+ 32 - 4
src/Lib/Input.php

@@ -836,11 +836,39 @@ class Input
             $param['value'] = implode(',', $param['value']);
         }
 
-        $html .= '<script>function linkage_' . $param['name'] . '(level){select_linkage(level, "' . $id . '","' . $param['option'] . '", "' . $param['name'] . '", "' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '", "' . (isset($param['valid']) ? $param['valid'] : '') . '", "' . $w . '", false, "'.$param['search_state'].'", "'.$level_param.'")};';
+        $col = $api = $type = $script = '';
+        $title = '';
+        $open = '';
+        if (is_array($param['option'])) {
+            $option = $param['option'];
+            $param['option'] = $option[0];
+            $col = $option[1];
+            $api = $option[2];
+            $type = 'checkbox';
+            
+            if (isset($option[3])) {
+                $title = $option[3];
+            }
+            if (isset($option[4])) {
+                $open = str_replace('{where_id}', Dever::input('where_id'), $option[4]);
+            }
+            if (!isset($option[3])) {
+                $type = 'checkbox';
+            } else {
+                $type = $option[3];
+            }
+            if (isset($param['value']) && $param['value']) {
+                $script = 'select_api = JSON.parse(\''.$param['value'].'\');';
+                $param['value'] = '';
+            }
+            
+        }
+
+        $html .= '<script>function linkage_' . $param['name'] . '(level){select_linkage(level, "' . $id . '","' . $param['option'] . '", "' . $param['name'] . '", \'' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '\', "' . (isset($param['valid']) ? $param['valid'] : '') . '", "' . $w . '", false, "'.$param['search_state'].'", "'.$level_param.'", "'.$col.'", "'.$api.'", "'.$type.'", "'.$title.'", "'.$open.'")};';
 
-        $html .= '$(document).ready(function(){linkage_' . $param['name'] . '(' . $level . ')});</script>';
+        $html .= '$(document).ready(function(){linkage_' . $param['name'] . '(' . $level . ');'.$script.'});</script>';
 
-        $html .= '</' . $div . '>';
+        $html .= '</' . $div . '><div id="'.$id.'_content"></div><div id="'.$id.'_data"></div>';
 
         return $html;
     }
@@ -1001,7 +1029,7 @@ class Input
         } else {
             $auto = $input = '';
             $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
-            if (isset($param['autocomplete'])) {
+            if (isset($param['autocomplete']) && $param['update'] == 'text') {
                 if (empty($param['autocomplete'][1])) {
                     $param['autocomplete'][1] = 'value';
                 }