rabin 1 month ago
parent
commit
292f090787
5 changed files with 48 additions and 13 deletions
  1. 3 2
      api/Login.php
  2. 6 1
      api/Page/Update.php
  3. 2 2
      api/Page/View.php
  4. 16 2
      lib/Common.php
  5. 21 6
      lib/Page.php

+ 3 - 2
api/Login.php

@@ -35,8 +35,9 @@ class Login
             $info['info_id'] = $info['id'];
             $info['partition'] = $system['partition'];
             $info['system_id'] = $system['id'];
-            $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($info));
-            $role_db = Dever::db($system['role_table'], '', 'default', Dever::load('common', 'manage')->system($info));
+            $partition = Dever::load('common', 'manage')->system($info);
+            $db = Dever::db($system['user_table'], '', 'default', $partition);
+            $role_db = Dever::db($system['role_table'], '', 'default', $partition);
         }
         $where['mobile'] = Dever::input('mobile', Dever::rule('mobile'), '手机号');
         $password = Dever::input('password', 'is_string', '密码');

+ 6 - 1
api/Page/Update.php

@@ -149,7 +149,10 @@ class Update extends Page
                 if (isset($this->config['field'][$k]) && isset($this->config['field'][$k]['update'])) {
                     $v = $this->config['field'][$k]['update'];
                 }
-                if (strstr($k, 'date')) {
+                if ($k == 'cdate') {
+                   $this->config['field'][$k]['type'] = 'date';
+                }
+                if (isset($this->config['field'][$k]) && isset($this->config['field'][$k]['type']) && $this->config['field'][$k]['type'] == 'date' && $v) {
                     $v = date('Y-m-d H:i:s', $v);
                 }
                 if ($type == 1) {
@@ -384,6 +387,8 @@ class Update extends Page
                 }
                 return;
             }
+        } elseif (isset($this->config['field'][$key]) && isset($this->config['field'][$key]['type']) && $this->config['field'][$key]['type'] == 'date' && $value) {
+            $value = \Dever\Helper\Date::mktime($value);
         }
         $data[$key] = trim($value);
     }

+ 2 - 2
api/Page/View.php

@@ -4,9 +4,9 @@ use Manage\Lib\Page;
 # 详情页
 class View extends Page
 {
-    public function __construct($load = '', $id = false)
+    public function __construct($load = '', $input = true, $id = false)
     {
-        parent::__construct('view', $load, $id);
+        parent::__construct('view', $load, $input);
     }
     public function get()
     {

+ 16 - 2
lib/Common.php

@@ -43,7 +43,7 @@ class Common
     }
 
     # 获取当前使用的系统 一般为数据库隔离使用
-    public function system($info = array())
+    public function system($info = false, $module = true)
     {
         if (!$info) {
             $info = $this->extend();
@@ -51,7 +51,21 @@ class Common
         if ($info && isset($info['info_id']) && isset($info['partition'])) {
             # 这里后续增加从数据库中获取
             $value = $info['system_id'] . '_' . $info['info_id'];
-            return array($info['partition'] => $value);
+            $result = array();
+            if (strpos($info['partition'], '.')) {
+                $temp = explode('.', $info['partition']);
+                $result = array($temp[0] => $value);
+                if ($module && isset($info['data_id']) && $info['data_id']) {
+                    if ($temp[0] == $temp[1]) {
+                        $result[$temp[0]] .= '/' . $info['module_id'] . '_' . $info['data_id'];
+                    } else {
+                        $result[$temp[1]] = $info['module_id'] . '_' . $info['data_id'];
+                    }
+                }
+            } else {
+                $result = array($info['partition'] => $value);
+            }
+            return $result;
         }
         return false;
     }

+ 21 - 6
lib/Page.php

@@ -53,19 +53,34 @@ class Page extends Auth
     # 获取某个数据的具体展示值
     public function getValue($key, $value, $data, $field = array())
     {
+        if ($key == 'cdate') {
+            $this->db->config['manage']['update']['field'][$key]['type'] = 'date';
+        }
+        $update = $this->db->config['manage']['update']['field'] ?? array();
         if ($show = Dever::issets($field, 'show')) {
             $value = $this->getShow($show, $data);
         } elseif ($value && isset($this->db->config['struct'][$key]['value']) && $this->db->config['struct'][$key]['value']) {
             $value = $this->db->value($key, $value);
-        } elseif ($key == 'cdate') {
-            if (strstr($value, 'T')) {
-                $value = date('Y-m-d H:i:s', strtotime($value));
-            } elseif ($value) {
-                $value = date('Y-m-d H:i:s', $value);
+        } elseif ($value && (isset($update[$key]) && isset($update[$key]['type']) && $update[$key]['type'] == 'date')) {
+            if (isset($update[$key]['date_type']) && $update[$key]['date_type'] == 'year') {
+                if ($update[$key]['date_type'] == 'year') {
+                    $value = date('Y', $value);
+                } elseif ($update[$key]['date_type'] == 'month') {
+                    $value = date('Ym', $value);
+                } else {
+                    $value = date('Ymd', $value);
+                }
             } else {
-                $value = '-';
+                if (strstr($value, 'T')) {
+                    $value = date('Y-m-d H:i:s', strtotime($value));
+                } elseif ($value) {
+                    $value = date('Y-m-d H:i:s', $value);
+                } else {
+                    $value = '-';
+                }
             }
         }
+        
         return $value;
     }