dever 6 years ago
parent
commit
0d9cd72896
1 changed files with 42 additions and 5 deletions
  1. 42 5
      src/Database.php

+ 42 - 5
src/Database.php

@@ -1899,7 +1899,16 @@ class Database
                 $return[$i] = array();
 
                 if (isset($config['manage']['mul'])) {
-                    $checkbox = '<input type="checkbox" name="mul_where_id[]" class="checkbox-checkall-list" lay-ignore value="' . $v['id'] . '"/>';
+                    $mul_state = false;
+                    if ($config['manage']['mul'] && is_string($config['manage']['mul'])) {
+                        $mul_state = $this->value($config['manage']['mul'], $data[$k]);
+                    }
+                    if ($mul_state) {
+                        $checkbox = '<input type="checkbox" name="mul_where_id[]" class="checkbox-checkall-list" lay-ignore value="' . $v['id'] . '"/>';
+                    } else {
+                        $checkbox = '<input type="checkbox" name="mul_where_id[]" class="checkbox-checkall-list" lay-ignore value="-1" disabled/>';
+                    }
+
                     $result[$k] .= '<td>'.$checkbox.'</td>';
                     $return[$i]['checkbox'] = $checkbox;
                 }
@@ -1936,7 +1945,11 @@ class Database
                             $show = Html::modal($this->value($vi['modal'], $data[$k], $config['struct']), $show);
                         } elseif (isset($vi['option'])) {
                             # 验证option是否是匿名函数
-                            $vi['option'] = $this->option($vi['option']);
+                            if ((isset($vi['edit']) && $vi['edit'])) {
+                                $vi['option'] = $this->option($vi['option'], $vi['edit']);
+                            } else {
+                                $vi['option'] = $this->option($vi['option']);
+                            }
                             # 位运算
                             if (isset($vi['bit'])) {
                                 $ts = array();
@@ -2241,9 +2254,15 @@ class Database
                     
                     $v['edit'] = true;
                 }
-                if (isset($v['edit']) && isset($v['option']) && (is_array($v['option']) || is_object($v['option']))) {
+                $select = false;
+                if (isset($v['mul'])) {
+                    $select = $v['mul'];
+                } elseif (isset($v['edit'])) {
+                    $select = $v['edit'];
+                }
+                if ($select && isset($v['option']) && (is_array($v['option']) || is_object($v['option']))) {
                     $result .= '&nbsp;&nbsp;';
-                    $this->list_search_select($result, $mul, $prefix . 'set_' . $k, $v['name'], $this->option($v['option']), $v['default']);
+                    $this->list_search_select($result, $mul, $prefix . 'set_' . $k, $v['name'], $this->option($v['option'], $select), $v['default']);
                 }
             }
 
@@ -2260,6 +2279,9 @@ class Database
         if (!$data) {
             return $value;
         }
+        if (strstr($value, '={') && !strstr($value, '"')) {
+            $value = '"' . $value . '"';
+        }
         if (is_string($data)) {
             $eval = '$value = ' . $value . ';';
             eval($eval);
@@ -3358,13 +3380,28 @@ class Database
      *
      * @return string
      */
-    private function option($option)
+    private function option($option, $value = false)
     {
         if (is_object($option)) {
             $function = $option;
             $option = $function();
         }
 
+        if ($value) {
+            $state = false;
+            foreach ($value as $k => $v) {
+                if ($v === true) {
+                    $state = true;
+                    break;
+                }
+            }
+            if ($state) {
+                $option = array_intersect_key($option, $value);
+            } else {
+                $option = $value;
+            }
+        }
+
         return $option;
     }