dever il y a 3 ans
Parent
commit
3213e975ab
1 fichiers modifiés avec 33 ajouts et 9 suppressions
  1. 33 9
      src/Lib/Input.php

+ 33 - 9
src/Lib/Input.php

@@ -620,14 +620,23 @@ class Input
 
         if (isset($param['option'])) {
             if (isset($param['option']['state']) && $param['option']['state'] >= 1) {
-                if (isset($param['value'])) {
-                    $param['value'] = explode(',', $param['value']);
+                # 处理比较复杂的多维数组
+                $state = $param['option']['state'];
+                unset($param['option']['state']);
+
+                if (isset($param['value']) && $param['value']) {
+                    if ($state == 2) {
+                        $param['value'] = Dever::json_decode($param['value']);
+                    } else {
+                        $param['value'] = explode(',', $param['value']);
+                    }
+                    
                 } else {
                     $param['value'] = array();
                 }
-                # 处理比较复杂的多维数组
-                unset($param['option']['state']);
+                
                 $j = -1;
+                $name = $param['name'];
                 foreach ($param['option'] as $k => $v) {
                     $check = '';
                     if (isset($param['update_parent'])) {
@@ -636,8 +645,17 @@ class Input
                         $input_type = $param['update'];
                     }
 
-                    //{check}
-                    $html .= '<input update_type="checked" class="update_value checkbox-checkall ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $input_type . '" name="temp[]" value="'.$param['name'] . '-' . $k . '"/> -----【' . $v['name'] . '】-----&nbsp;&nbsp;<br />';
+                    if ($state == 2) {
+                        $parent_check = '';
+                        if (isset($param['value']) && isset($param['value'][$v['id']])) {
+                            $parent_check = 'checked';
+                        }
+
+                        $name = $name . '['.$v['id'].']';
+                        $html .= '<input update_type="checked" class="update_value checkbox-checkall ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $input_type . '" name="temp[]" value="'.$param['name'] . '-' . $k . '" ' . $parent_check . '/> -----【' . $v['name'] . '】-----&nbsp;&nbsp;<br />';
+                    } else {
+                        $html .= '<input update_type="checked" class="update_value checkbox-checkall ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $input_type . '" name="temp[]" value="'.$param['name'] . '-' . $k . '"/> -----【' . $v['name'] . '】-----&nbsp;&nbsp;<br />';
+                    }
 
                     $span = array('', '');
 
@@ -657,11 +675,17 @@ class Input
                             }
                             $check = '';
                             $disabled = 'disabled="true"';
-                            if (isset($param['value']) && in_array($ki, $param['value'])) {
+                            if ($state == 2) {
+                                if (isset($param['value']) && isset($param['value'][$v['id']]) && in_array($vi['id'], $param['value'][$v['id']])) {
+                                    $check = 'checked';
+                                    $disabled = '';
+                                    $j++;
+                                }
+                            } elseif (isset($param['value']) && in_array($vi['id'], $param['value'])) {
                                 $check = 'checked';
                                 $disabled = '';
                                 $j++;
-                            } elseif (isset($param['default']) && is_array($param['default']) && (in_array($k . '_' . $ki, $param['default']))) {
+                            } elseif (isset($param['default']) && is_array($param['default']) && (in_array($k . '_' . $vi['id'], $param['default']))) {
                                 $check = 'checked';
                                 $disabled = '';
                                 $j++;
@@ -686,7 +710,7 @@ class Input
                                 $input = $input . ': <input class="form-control" name="' . $param['name'] . '_input[]" type="text" value="' . $input_value . '" style="width:20%;margin:5px;display:inline" placeholder="' . $param['update_input'] . '" ' . $disabled . '/>';
                             }
 
-                            $html .= '<li><input update_type="checked" class="update_value checkbox-checkall-' . $param['name'] . '-'. $k . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $param['update'] . '" name="' . $param['name'] . '[]" value="' . $ki . '" ' . $check . '/> ' . $span[0] . $vi['name'] . $span[1] . '&nbsp;&nbsp;' . $input . '</li>';
+                            $html .= '<li><input update_type="checked" class="update_value checkbox-checkall-' . $param['name'] . '-'. $k . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" data-state="'.$state.'" type="' . $param['update'] . '" name="' . $name . '[]" value="' . $vi['id'] . '" ' . $check . '/> ' . $span[0] . $vi['name'] . $span[1] . '&nbsp;&nbsp;' . $input . '</li>';
 
                             //++$i;
                         }