rabin 1 anno fa
parent
commit
d894babf1e

+ 4 - 4
api/Admin.php

@@ -23,7 +23,7 @@ class Admin extends Auth
         $system = Dever::db('system')->select($where);
         $i = 0;
         foreach ($system as $k => $v) {
-            $child = Dever::db($v['relation_table'])->select([])->fetchAll();
+            $child = Dever::db($v['relation_table'])->select([]);
             if ($child) {
                 $data = array();
                 foreach ($child as $k1 => $v1) {
@@ -62,12 +62,12 @@ class Admin extends Auth
             return $result;
         }
         $result = array();
-        $role = Dever::db('role')->select(array('id' => array('in', $value)))->fetchAll();
+        $role = Dever::db('role')->select(array('id' => array('in', $value)));
         if ($role) {
             $info = $system = array();
             foreach ($role as $k => $v) {
                 if ($v['system']) {
-                    $child = Dever::db('system')->select(array('id' => array('in', $v['system'])))->fetchAll();
+                    $child = Dever::db('system')->select(array('id' => array('in', $v['system'])));
                     if ($child) {
                         foreach ($child as $k1 => $v1) {
                             if (isset($info[$v1['id']])) {
@@ -77,7 +77,7 @@ class Admin extends Auth
                             $v1['value'] = 's-' . $v1['id'];
                             $v1['label'] = $v1['name'];
                             $v1['children'] = array();
-                            $data = Dever::db($v1['relation_table'])->select([], array('col' => 'concat('.$v1['id'].', "-", id) as value, name as label'))->fetchAll();
+                            $data = Dever::db($v1['relation_table'])->select([], array('col' => 'concat('.$v1['id'].', "-", id) as value, name as label'));
                             if ($data) {
                                 $v1['children'] = array_merge($v1['children'], $data);
                             }

+ 25 - 0
api/Cron.php

@@ -0,0 +1,25 @@
+<?php namespace Manage\Api;
+use Dever;
+use Dever\Helper\Cmd;
+class Cron
+{
+    public function run()
+    {
+        $time = time();
+        # 获取所有的计划任务
+        $data = Dever::db('cron', 'manage')->load(array('ldate' => array('<=', $time)));
+        if ($data) {
+            foreach ($data as $k => $v) {
+                Cmd::run($v['interface'], $v['project']);
+                $param['ldate'] = $v['ldate'] + $v['time'];
+                if ($param['ldate'] < $time) {
+                    $param['ldate'] = $time + $v['time'];
+                }
+                if ($v['time'] <= 0) {
+                    $param['state'] = 2;
+                }
+                Dever::db('cron', 'manage')->update($v['id'], $param);
+            }
+        }
+    }
+}

+ 17 - 4
api/Login.php

@@ -4,6 +4,19 @@ use Dever\Helper\Str;
 use Dever\Helper\Code;
 class Login
 {
+    # 获取系统信息
+    public function getSystem()
+    {
+        $system = Dever::input('system', 'is_string', '系统', 'platform');
+        $system = Dever::db('system')->find(array('key' => $system));
+        if (!$system) {
+            Dever::error('当前系统不存在');
+        }
+        $system['placeholder'] = '请输入' . $system['name'] . '号';
+        return $system;
+    }
+
+    # 登录
     public function act()
     {
         //$this->checkCode();
@@ -12,12 +25,12 @@ class Login
         if (!$system) {
             Dever::error('登录失败,当前系统不存在');
         }
-        $relation_id = Dever::input('relation_id', 'is_numeric', '关联表', 1);
-        $info = Dever::db($system['relation_table'])->find($relation_id);
+        $number = Dever::input('number', '', $system['name'] . '号', 'default');
+        $info = Dever::db($system['relation_table'])->find(array('number' => $number));
         if (!$info) {
             Dever::error('登录失败,当前系统设置错误');
         }
-        if ($system['id'] == 1 && $relation_id == 1) {
+        if ($system['id'] == 1 && $info['id'] == 1) {
             # 如果是平台,暂时不做分库
             $db = Dever::db($system['relation_user_table']);
         } else {
@@ -49,7 +62,7 @@ class Login
         if (Dever::load('common')->hash($password, $admin['salt']) != $admin['password']) {
             Dever::error('登录失败,账号密码无效');
         }
-        return Dever::load('common')->token($admin['id'], $admin['mobile'], $system['id'], $relation_id);
+        return Dever::load('common')->token($admin['id'], $admin['mobile'], $system['id'], $info['id']);
     }
     private function checkCode()
     {

+ 20 - 9
api/Menu.php

@@ -37,10 +37,10 @@ class Menu extends Auth
             )
         );
         foreach ($top as $v) {
-            $menu = $this->getMenu($v);
-        }
-        if ($menu) {
-            $result[] = $menu;
+            $v = $this->getMenu($v);
+            if ($v) {
+                $result[] = $v;
+            }
         }
         return array('list' => $result);
     }
@@ -49,7 +49,7 @@ class Menu extends Auth
         $info = array
         (
             'path' => $parent ? '/' . $parent . '/' . $v['key'] : $v['key'],
-            'name' => $v['key'],
+            'name' => $parent ? $parent . '_' . $v['key'] : $v['key'],
             'meta' => array
             (
                 'title' => $v['name'],
@@ -59,7 +59,7 @@ class Menu extends Auth
                 'dynamicNewTab' => true,
             )
         );
-        if ($v['show'] == 2) {
+        if ($v['show'] > 1) {
             $info['meta']['hidden'] = true;
         }
         if (isset($v['active']) && $v['active']) {
@@ -75,17 +75,28 @@ class Menu extends Auth
             $info['component'] = 'Layout';
         }
         $where = array('parent_id' => $v['id'], 'system_id' => $this->user['select']['system_id']);
-        $child = Dever::db('menu')->select($where)->fetchAll();
+        $child = Dever::db('menu')->select($where);
         if ($child) {
             foreach ($child as $v1) {
-                if ($v1['func'] == 1 && $this->checkMenu($v1['id'])) {
+                if (($v1['level'] == 3 || $v1['show'] != 1) && $this->checkMenu($v1['id'])) {
                     continue;
                 }
-                $info['children'][] = $this->getMenu($v1, $v['key']);
+                $children = $this->getMenu($v1, $v['key']);
+                if ($children) {
+                    $info['children'][] = $children;
+                }
+            }
+            if (empty($info['children'])) {
+                return array();
             }
         } elseif ($v['path']) {
             $info['component'] = '@/dever/page/' . $v['path'];
         }
+        if (!$child) {
+            if (($v['level'] == 3 || $v['show'] != 1) && $this->checkMenu($v['id'])) {
+                return false;
+            }
+        }
         return $info;
     }
 }

+ 66 - 19
api/Page/Data.php

@@ -39,14 +39,15 @@ class Data extends Page
     public function out()
     {
         $where = $this->config['where'] ?? array();
+        $set = $this->config['set'] ?? array();
         $data['field'] = $data['head'] = array();
         $data['search'] = $this->search($where);
         if (isset($this->config['data'])) {
-            $result = Dever::call($this->config['data'], array($where));
+            $result = Dever::call($this->config['data'], array($where, $set));
             $data = array_merge($data, $result);
         } else {
             $data['field'] = $this->setting('field', $data['head'], true, 'show');
-            $data['body'] = $this->data($where);
+            $data['body'] = $this->data($where, $set);
         }
         $method = Dever::input('method');
         if ($method && strstr($method, '.')) {
@@ -62,7 +63,7 @@ class Data extends Page
         return $data;
     }
 
-    private function data($where)
+    private function data($where, $set = array())
     {
         $set['num'] = Dever::input('pgnum', '', '', 10);
         $order_col = Dever::input('order_col');
@@ -87,7 +88,11 @@ class Data extends Page
 
     public function handleData($v)
     {
-        $result['id'] = $v['id'];
+        # 是否保留html代码,1是保留,2是不保留
+        $html = Dever::input('html', '', '', 1);
+        if (isset($v['id'])) {
+            $result['id'] = $v['id'];
+        }
         $result['cdate'] = $v['cdate'];
         foreach ($this->field as $value) {
             $key = $value['key'];
@@ -109,9 +114,12 @@ class Data extends Page
                     }
                 }
             }
+            if ($html == 2) {
+                $result[$key] = strip_tags($result[$key]);
+            }
         }
         if (isset($this->config['expand']) && $this->config['expand']) {
-            $result['expand'] = Dever::call($this->config['expand'], array($result));
+            $result['expand'] = Dever::call($this->config['expand'], array($v));
             $this->expand = true;
         }
         return $result;
@@ -135,31 +143,69 @@ class Data extends Page
     private function search(&$where)
     {
         $search = Dever::input('search');
+        $set = Dever::input('set');
         $list_search = $result = array();
+        $result['form'] = $result['field'] = $result['option'] = array();
         $this->setting('search', $list_search, false, 'text');
         if ($list_search) {
             foreach ($list_search as $v) {
                 if ($v['type'] != 'hidden') {
-                    $result[] = $v;
+                    $result['form'][] = $v;
+                    $result['field'][$v['key']] = $v['value'];
+                    if ($v['type'] == 'sku') {
+                        $result['field'][$v['key'] . '_spec'] = [];
+                    }
+                    if (isset($v['option'])) {
+                        $result['option'][$v['key']] = $v['option'];
+                    }
                 }
-                if ($search) {
-                    if ($value = Dever::isset($search, $v['key'])) {
-                        if ($v['type'] == 'group') {
-                            $where[$v['key']] = array('group', $value);
-                        } elseif ($v['type'] == 'selects') {
-                            $where[$v['key']] = array('group', $value);
-                        } elseif ($v['type'] == 'like') {
-                            $where[$v['key']] = array('like', $value);
-                        } elseif ($v['type'] == 'in') {
-                            $where[$v['key']] = array('in', $value);
-                        } else {
-                            $where[$v['key']] = $value;
+                $this->where($search, $v, $where);
+                $this->where($set, $v, $where);
+            }
+        }
+        return $result;
+    }
+
+    private function where($value, $v, &$where)
+    {
+        if ($value) {
+            if ($value = Dever::isset($value, $v['key'])) {
+                if (isset($v['search'])) {
+                    if (is_callable($v['search'])) {
+                        $value = $v['search']($v['key'], $v['type'], $value);
+                    } elseif (isset($v['search']['table'])) {
+                        $v['search']['where'] = Dever::json_decode(str_replace('{value}', $value, Dever::json_encode($v['search']['where'])));
+                        $search = Dever::db($v['search']['table'])->select($v['search']['where'], $v['search']['set'] ?? array());
+                        $value = array();
+                        if ($search) {
+                            foreach ($search as $v1) {
+                                $value[] = $v1[$v['search']['field']];
+                            }
                         }
+                        $value = implode(',', $value);
+                        $v['type'] = 'in';
                     }
                 }
+                if ($v['type'] == 'group') {
+                    $where[$v['key']] = array('group', $value);
+                } elseif ($v['type'] == 'selects') {
+                    $where[$v['key']] = array('group', $value);
+                } elseif ($v['type'] == 'like') {
+                    $where[$v['key']] = array('like', $value);
+                } elseif ($v['type'] == 'in') {
+                    $where[$v['key']] = array('in', $value);
+                } elseif ($v['type'] == 'date') {
+                    if (strstr($v['date_type'], 'range')) {
+                        $where[$v['key']] = array('>=', \Dever\Helper\Date::mktime($value[0]));
+                        $where[$v['key'] . '#'] = array('<=', \Dever\Helper\Date::mktime($value[1]));
+                    } else {
+                        $where[$v['key']] = $value;
+                    }
+                } else {
+                    $where[$v['key']] = $value;
+                }
             }
         }
-        return $result;
     }
 
     private function button($key = 'button')
@@ -238,6 +284,7 @@ class Data extends Page
                     }
                     $this->selection = true;
                 }
+                $p = Dever::url($p);
                 $icon = 'Notification';
                 $button = 'warning';
             } elseif ($v == 'link') {

+ 9 - 4
api/Page/Oper.php

@@ -6,7 +6,7 @@ class Oper extends Page
 {
     public function __construct()
     {
-        parent::__construct();
+        parent::__construct('oper');
         $this->id = Dever::input('id');
         if (!$this->id) {
             Dever::error('无效数据');
@@ -28,9 +28,15 @@ class Oper extends Page
                 $data[$v] = $value;
             }
         }
+        if (isset($this->config['up_start']) && $this->config['up_start']) {
+            list($this->id, $data) = Dever::call($this->config['up_start'], array($this->id, $data));
+        }
         $where['id'] = array('in', $this->id);
         $state = $this->db->update($where, $data);
         if ($state) {
+            if (isset($this->config['up_end']) && $this->config['up_end']) {
+                Dever::call($this->config['up_end'], array($this->id, $data));
+            }
             return '操作成功';
         } else {
             Dever::error('操作失败');
@@ -42,10 +48,10 @@ class Oper extends Page
     public function recycle()
     {
         $where['id'] = array('in', $this->id);
-        $data = $this->db->select($where)->fetchAll();
+        $data = $this->db->select($where);
         if ($data) {
             foreach ($data as $k => $v) {
-                $insert['table'] = Dever::input('load');
+                $insert['table'] = $this->db->config['load'];
                 $insert['table_id'] = $v['id'];
                 $insert['content'] = Dever::json_encode($v);
                 $state = Dever::db('manage/recycler')->insert($insert);
@@ -70,7 +76,6 @@ class Oper extends Page
         if ($data) {
             foreach ($data as $k => $v) {
                 $v['content'] = Dever::json_decode($v['content']);
-                $v['table'] = ltrim($v['table'], '/');
                 $state = Dever::db($v['table'])->insert($v['content']);
                 if (!$state) {
                     Dever::error('恢复失败,请重试');

+ 46 - 25
api/Page/Update.php

@@ -4,22 +4,28 @@ use Manage\Lib\Page;
 # 更新页
 class Update extends Page
 {
-    public function __construct($load = '', $id = false)
+    public function __construct($load = '', $input = true)
     {
-        parent::__construct('update', $load, $id);
+        parent::__construct('update', $load, $input);
     }
     public function get(&$value = array(), &$option = array())
     {
         $func = $this->checkFunc();
-        $remote = $show = $spec = array();
+        $remote = $show = $spec = $source = array();
         $data['update'] = $data['field'] = $data['option'] = array();
         $this->setting('field', $data['update'], true, 'text');
         foreach ($data['update'] as $k => $v) {
-            if ($v['type'] == 'tree' || $v['type'] == 'upload') {
+            if ($v['type'] == 'tree' || $v['type'] == 'upload' || $v['type'] == 'cascader' || $v['type'] == 'checkbox' || isset($v['multiple'])) {
                 $v['value'] = array();
             }
+            if (isset($v['source'])) {
+                $source[$v['key']] = $v['source'];
+            }
             if (isset($v['remote'])) {
                 $remote[$v['key']] = array($k, $v['remote'], $v['key']);
+                if (isset($v['remote_default']) && !$v['remote_default']) {
+                    unset($remote[$v['key']][2]);
+                }
             }
             if (isset($v['spec_data'])) {
                 $spec[$v['key']] = array($k, $v['spec_data'], $v['key'] . '_spec');
@@ -57,7 +63,7 @@ class Update extends Page
         }
         if ($this->info) {
             $info = $this->info;
-            $this->setInfo($info, $data, $remote, $show);
+            $this->setInfo($info, $data, $remote, $show, $source);
             if ($spec) {
                 foreach ($spec as $k => $v) {
                     $data['update'][$spec[$k][0]]['remote'] = Dever::url($spec[$k][1]);
@@ -69,7 +75,7 @@ class Update extends Page
             }
         } elseif ($value) {
             foreach ($value as $k => &$v) {
-                $this->setInfo($v, $data, $remote, $show, 2);
+                $this->setInfo($v, $data, $remote, $show, $source, 2);
                 $option[$k] = $data['option'];
             }
         } else {
@@ -95,16 +101,25 @@ class Update extends Page
         $data['desc'] = $this->config['desc'] ?? '';
         $data['drag'] = $this->config['drag'] ?? false;
         $this->layout($data);
+        $this->control($data);
         $this->tab($data, 'step');
         if (!$data['step']) {
             $this->tab($data);
         }
-        $this->control($data);
         return $data;
     }
 
-    private function setInfo(&$info, &$data, $remote, $show, $type = 1)
+    private function setInfo(&$info, &$data, $remote, $show, $source, $type = 1)
     {
+        if ($source) {
+            foreach ($source as $k => $v) {
+                $t = array();
+                foreach ($v as $v1) {
+                    $t[] = $info[$v1] ?? '';
+                }
+                $info[$k] = implode(',', $t);
+            }
+        }
         foreach ($info as $k => $v) {
             if (isset($data['field'][$k])) {
                 if (is_array($data['field'][$k])) {
@@ -113,10 +128,14 @@ class Update extends Page
                     } else {
                         $v = array();
                     }
+                    $info[$k] = $v;
                 }
                 if (isset($this->config['field'][$k]) && isset($this->config['field'][$k]['update'])) {
                     $v = $this->config['field'][$k]['update'];
                 }
+                if (strstr($k, 'date')) {
+                    $v = date('Y-m-d H:i:s', $v);
+                }
                 if ($type == 1) {
                     $data['field'][$k] = $v;
                 }
@@ -189,7 +208,7 @@ class Update extends Page
 
     private function tab(&$data, $type = 'tab')
     {
-        $field = Dever::input('field');
+        $field = $this->input('field', '');
         $data[$type] = array();
         if (empty($data['layout']) && !$field && isset($this->config[$type])) {
             foreach ($this->config[$type] as $k => $v) {
@@ -218,7 +237,7 @@ class Update extends Page
 
     private function layout(&$data)
     {
-        $field = Dever::input('field');
+        $field = $this->input('field', '');
         $data['layout'] = array();
         if (!$field && isset($this->config['layout'])) {
             foreach ($this->config['layout'] as $k => $v) {
@@ -287,31 +306,33 @@ class Update extends Page
                     unset($data[$v['key']]);
                 }
             }
-            if (!$data) {
+            if (!$data && !$other && !$sku) {
                 Dever::error('无效数据');
             }
-            $this->exists($id, $data);
-            $this->start($id, $data);
-            if ($id) {
-                $info = $this->db->find($id);
-                if ($info) {
-                    $state = $this->db->update($info['id'], $data);
-                    if ($state) {
-                        $id = $info['id'];
+            if ($data) {
+                $this->exists($id, $data);
+                $this->start($id, $data);
+                if ($id) {
+                    $info = $this->db->find($id);
+                    if ($info) {
+                        $state = $this->db->update($info['id'], $data);
+                        if ($state) {
+                            $id = $info['id'];
+                        }
+                    } else {
+                        $data['id'] = $id;
+                        $id = $this->db->insert($data);
                     }
                 } else {
-                    $data['id'] = $id;
                     $id = $this->db->insert($data);
                 }
-            } else {
-                $id = $this->db->insert($data);
             }
             if (!$id) {
                 Dever::error('操作失败');
             }
-            $this->end($id, $data);
             $this->other($id, $data, $other);
             $this->sku($id, $data, $sku);
+            $this->end($id, $data);
             return '操作成功';
         }
     }
@@ -414,7 +435,7 @@ class Update extends Page
                     }
                     foreach ($update as $k2 => $v2) {
                         if (isset($v1[$k2])) {
-                            $value[$k2] = $v1[$k2];
+                            $this->doData($value, $k2, $v1[$k2]);
                         }
                     }
                     if ($drag) {
@@ -474,7 +495,7 @@ class Update extends Page
                             } else {
                                 $v2['id'] = Dever::db($spec_value_table)->insert($spec_value_data);
                             }
-                            $spec_value[$spec_data['name']][$spec_value_data['value']] = array($v1['id'] . '_' . $v2['id'], $spec_data['sort']);
+                            $spec_value[$v1['key']][$spec_value_data['value']] = array($v2['id'], $spec_data['sort']);
                         }
                     }
                 }

+ 13 - 9
lib/Auth.php

@@ -33,7 +33,7 @@ class Auth
         }
         $this->user['auth'] = array('system' => '', 'menu' => '', 'func' => '');
         if ($this->user['role']) {
-            $role = Dever::db($this->system['relation_role_table'])->select(array('id' => array('in', $this->user['role'])))->fetchAll();
+            $role = Dever::db($this->system['relation_role_table'])->select(array('id' => array('in', $this->user['role'])));
             foreach ($role as $k => $v) {
                 $this->user['auth']['system'] .= $v['system'] . ',';
                 $this->user['auth']['menu'] .= $v['menu'] . ',';
@@ -59,37 +59,41 @@ class Auth
     # 设置功能权限
     public function getFunc($key, $name, $sort = 1, $param = '')
     {
+
         if (!$key) {
             $key = md5(base64_encode($name));
         }
+        /*
         if ($param) {
             if (is_array($param)) {
                 $param = Dever::json_encode($name);
             }
             $key = $key . '_' . md5($param);
-        }
+        }*/
+
         $data['menu_id'] = $this->menu['id'];
         $data['key'] = $key;
-        $info = Dever::db('menu_func')->find($data);
+        $info = Dever::db('menu_func', 'manage')->find($data);
         $name = $this->menu['name'] . '-' . $name;
         if (!$info) {
             $data['name'] = $name;
             $data['sort'] = $sort;
-            $id = Dever::db('menu_func')->insert($data);
-            Dever::db('menu')->update($this->menu['id'], array('func' => 1));
+            $id = Dever::db('menu_func', 'manage')->insert($data);
+            Dever::db('menu', 'manage')->update($this->menu['id'], array('func' => 1));
         } else {
             if ($info['name'] != $name) {
                 $data['name'] = $name;
                 $data['sort'] = $sort;
-                Dever::db('menu_func')->update($info['id'], $data);
-                Dever::db('menu')->update($this->menu['id'], array('func' => 1));
+                Dever::db('menu_func', 'manage')->update($info['id'], $data);
+                Dever::db('menu', 'manage')->update($this->menu['id'], array('func' => 1));
             }
             $id = $info['id'];
         }
+
         if ($this->user['id'] == 1) {
             return $id;
         }
-        if ($this->user['auth']['func'] && strpos($this->user['auth']['func'], ',' . $id . ',')) {
+        if ($this->user['auth']['func'] && strstr($this->user['auth']['func'], ',' . $id . ',')) {
             return $id;
         }
         return false;
@@ -133,7 +137,7 @@ class Auth
         if ($this->user['id'] == 1) {
             return $id;
         }
-        if ($this->user['auth']['func'] && strpos($this->user['auth']['func'], ',' . $id . ',')) {
+        if ($this->user['auth']['func'] && strstr($this->user['auth']['func'], ',' . $id . ',')) {
             return $id;
         }
         Dever::error('无操作权限');

+ 75 - 1
lib/Common.php

@@ -3,6 +3,7 @@ use Dever;
 use Dever\Helper\Str;
 use Dever\Helper\Env;
 use Dever\Helper\Secure;
+use Dever\Helper\Date;
 class Common
 {
     public function auth()
@@ -56,6 +57,7 @@ class Common
         return array('token' => Secure::login($uid, $extand));
     }
 
+    # 生成密码
     public function createPwd($password)
     {
         $data['salt'] = Str::salt(8);
@@ -63,11 +65,71 @@ class Common
         return $data;
     }
 
+    # 生成时间
+    public function crateDate($date)
+    {
+        return Date::mktime($date);
+    }
+
+    # hash加密
     public function hash($password, $salt)
     {
         return hash('sha256', $password . $salt);
     }
 
+    # 根据load获取db
+    public function db($load)
+    {
+        $menu = array();
+        $load = explode('/', ltrim($load, '/'));
+        if (isset($load[2])) {
+            $app = $load[1];
+            $table = $load[2];
+        } else {
+            $app = $load[0];
+            $table = $load[1];
+        }
+        $parent = Dever::db('menu', 'manage')->find(array('key' => $app));
+        if ($parent) {
+            $menu = Dever::db('menu', 'manage')->find(array('parent_id' => $parent['id'], 'key' => $table));
+            if ($menu) {
+                $app = $menu['app'];
+            }
+        }
+        $set = Dever::project($app);
+        $manage = $set['path'] . 'table/manage/'.$table.'.php';
+        if (is_file($manage)) {
+            $manage = include $manage;
+            if ($source = Dever::isset($manage, 'source')) {
+                if (strpos($source, '/')) {
+                    $source = explode('/', $source);
+                    $app = $source[0];
+                    $table = $source[1];
+                } else {
+                    $table = $source;
+                }
+            }
+        }
+        $db = Dever::db($table, $app);
+        $db->config['manage'] = $manage;
+        return array($db, $menu);
+    }
+
+    # 获取项目
+    public function project()
+    {
+        $result = array();
+        $app = \Dever\Project::read();
+        foreach ($app as $k => $v) {
+            $result[] = array
+            (
+                'id' => $k,
+                'name' => $v['lang'] ?? $k,
+            );
+        }
+        return $result;
+    }
+
     # 仅为测试用
     public function out($data)
     {
@@ -83,7 +145,7 @@ class Common
     # 仅为测试用,展示表格更多内容
     public function show($data)
     {
-        # 返回类型:string字符串,table表格,list列表
+        # 返回类型:string字符串,table表格,card卡片,desc描述,list列表
         $result['type'] = 'string';
         $result['content'] = 'ddddd';
 
@@ -95,6 +157,18 @@ class Common
             array('id' => '2', 'name' => 'test2'),
         );
 
+        $result['type'] = 'card';
+        $result['content'][] = array
+        (
+            'title' => '订单信息',
+            'shadow' => 'never',//always | never | hover
+            'content' => array
+            (
+                '1111',
+                '2222',
+            ), 
+        );
+
         $result['type'] = 'list';
         $result['content'] = array
         (

+ 1 - 1
lib/Config.php

@@ -5,7 +5,7 @@ class Config extends Auth
 {
     public function getTree()
     {
-        $data = Dever::db('config')->select([])->fetchAll();
+        $data = Dever::db('config')->select([]);
         $result = array();
         $result[] = array
         (

+ 1 - 1
lib/Group.php

@@ -5,7 +5,7 @@ class Group extends Auth
 {
     public function getTree()
     {
-        $data = Dever::db('group')->select([])->fetchAll();
+        $data = Dever::db('group')->select([]);
         $result = array();
         $result[] = array
         (

+ 7 - 1
lib/Menu.php

@@ -7,7 +7,7 @@ class Menu
     public function init($name = '')
     {
         if ($name) {
-            $app = array($name => Project::read($name));
+            $app = array($name => Project::load($name));
         } else {
             $app = Project::read();
         }
@@ -51,7 +51,13 @@ class Menu
                     if ($parent) {
                         $where['parent_id'] = $parent['id'];
                         $where['system_id'] = $parent['system_id'];
+                        $where['level'] = 2;
+                        if ($parent['parent_id']) {
+                            $where['level'] = 3;
+                        }
                     }
+                } else {
+                    $where['level'] = 1;
                 }
                 if (isset($v['system'])) {
                     $system = Dever::db('system')->find(array('key' => $v['system']));

+ 28 - 48
lib/Page.php

@@ -5,59 +5,27 @@ class Page extends Auth
 {
     protected $db;
     protected $key;
-    protected $id = false;
+    protected $id = 0;
+    protected $input = false;
     protected $menu = array();
     protected $config = array();
     protected $field = array();
     public $info = array();
-    public function __construct($key = '', $load = '', $id = false)
+    public function __construct($key = '', $load = '', $input = true)
     {
         parent::__construct();
         $this->key = $key;
-        if ($id == -1) {
-            $this->id = false;
-        } else {
-            $this->id = $id ? $id : Dever::input('id');
-        }
+        $this->input = $input;
+        $this->id = $this->input('id', 0);
         if (!$load) {
             $load = Dever::input('load');
         }
-        $load = explode('/', ltrim($load, '/'));
-        if (isset($load[2])) {
-            $app = $load[1];
-            $table = $load[2];
-        } else {
-            $app = $load[0];
-            $table = $load[1];
-        }
-        $parent = Dever::db('menu')->find(array('key' => $app));
-        if ($parent) {
-            $this->menu = Dever::db('menu')->find(array('parent_id' => $parent['id'], 'key' => $table));
-            if ($this->menu) {
-                $this->checkMenu($this->menu['id'], false);
-                $app = $this->menu['app'];
-            }
-        }
-        $set = Dever::project($app);
-        $manage = $set['path'] . 'table/manage/'.$table.'.php';
-        if (is_file($manage)) {
-            $manage = include $manage;
-            if ($source = Dever::isset($manage, 'source')) {
-                if (strpos($source, '/')) {
-                    $source = explode('/', $source);
-                    $app = $source[0];
-                    $table = $source[1];
-                } else {
-                    $table = $source;
-                }
-            }
-            if ($key) {
-                $this->config = $manage[$key] ?? array();
-            }
+        list($this->db, $this->menu) = Dever::load('common', 'manage')->db($load);
+        if ($this->menu) {
+            $this->checkMenu($this->menu['id'], false);
         }
-        $this->db = Dever::db($table, $app);
-        $this->db->config['manage'] = $manage;
-        if ($this->id) {
+        $this->config = $this->db->config['manage'][$key] ?? array();
+        if ($this->id && !strstr($this->id, ',')) {
             $this->info = $this->db->find($this->id);
         }
     }
@@ -74,7 +42,7 @@ class Page extends Auth
         if (is_string($setting)) {
             $setting = explode(',', $setting);
         }
-        $field = Dever::input('field');
+        $field = $this->input('field', '');
         return $this->setData($setting, $data, $field, $type, $disable);
     }
 
@@ -86,7 +54,9 @@ class Page extends Auth
         } 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 ($value) {
+            if (strstr($value, 'T')) {
+                $value = date('Y-m-d H:i', strtotime($value));
+            } elseif ($value) {
                 $value = date('Y-m-d H:i', $value);
             } else {
                 $value = '-';
@@ -96,7 +66,7 @@ class Page extends Auth
     }
 
     # 获取关联数据
-    public function getOther($key, $set, $data, $method = 'fetchAll')
+    public function getOther($key, $set, $data)
     {
         $where = array();
         foreach ($set as $k => $v) {
@@ -107,7 +77,7 @@ class Page extends Auth
             }
         }
         if ($where) {
-            return Dever::db($key)->select($where)->$method();
+            return Dever::db($key)->select($where);
         }
         return array();
     }
@@ -279,7 +249,7 @@ class Page extends Auth
             }
             $sku = $value['type'] == 'sku' ? true : false;
             $value['value'] = $this->getOther($key, $value['where'], $this->info);
-            $update = new \Manage\Api\Page\Update($key, -1);
+            $update = new \Manage\Api\Page\Update($key, false);
             $value['option'] = array();
             $value['content'] = $update->get($value['value'], $value['option'], $sku);
             $data[] = $value;
@@ -291,6 +261,8 @@ class Page extends Auth
                 # 一般为更新页面需要的参数
                 $this->setShow($value);
                 $this->setRules($value);
+            } elseif (isset($value['remote'])) {
+                $value['remote'] = Dever::url($value['remote']);
             }
             if ($type == 'show') {
                 $in = array('switch', 'select', 'input');
@@ -321,7 +293,7 @@ class Page extends Auth
     {
         if ($value['type'] == 'hidden') {
             $value['show'] = false;
-        } elseif (empty($value['show'])) {
+        } elseif (!isset($value['show'])) {
             $value['show'] = true;
         }
     }
@@ -344,6 +316,9 @@ class Page extends Auth
         if (strpos($value['type'], '(')) {
             $value['type'] = $type;
         }
+        if (empty($value['width'])) {
+            $value['width'] = 'auto';
+        }
         if (isset($value['upload']) && Dever::project('upload')) {
             $value['url'] = Dever::url('upload/save.act', array('id' => $value['upload']));
             $value['config'] = Dever::load('upload/save')->get($value['upload']);
@@ -437,4 +412,9 @@ class Page extends Auth
             }
         }
     }
+
+    protected function input($key, $value = '')
+    {
+        return $this->input ? Dever::input($key) : $value;
+    }
 }

+ 11 - 1
lib/Recycler.php

@@ -14,7 +14,8 @@ class Recycler extends Auth
         $data['field'] = $page->setting('field', $data['head']);
 
         $set['num'] = Dever::input('pgnum', '', '', 10);
-        $recycler = Dever::db('recycler')->select(array('table' => $where['table']), $set);
+        list($db, $menu) = Dever::load('common', 'manage')->db($where['table']);
+        $recycler = Dever::db('recycler', 'manage')->select(array('table' => $db->config['load']), $set);
         foreach ($recycler as $k => $v) {
             $content = Dever::json_decode($v['content']);
             foreach ($content as $key => $value) {
@@ -23,6 +24,15 @@ class Recycler extends Auth
             $content['id'] = $v['id'];
             $data['body'][] = $content;
         }
+        if ($data['head']) {
+            $head = array();
+            foreach ($data['head'] as $k => $v) {
+                if ($v['type'] == 'show') {
+                    $head[] = $v;
+                }
+            }
+            $data['head'] = $head;
+        }
 
         return $data;
     }

+ 2 - 2
lib/Role.php

@@ -42,7 +42,7 @@ class Role extends Auth
         foreach ($system as $k => $v) {
             $result[$k]['value'] = 's-' . $v['id'];
             $result[$k]['label'] = $v['name'];
-            $result[$k]['children'] = Dever::db('menu')->tree(array('system_id' => $v['id']), array('parent_id', '0', 'id'), array($this, 'getAuthInfo'), array('col' => 'id,name as label,parent_id,`key`,func'));
+            $result[$k]['children'] = Dever::db('menu')->tree(array('system_id' => $v['id'], 'show' => array('<', '3')), array('parent_id', '0', 'id'), array($this, 'getAuthInfo'), array('col' => 'id,name as label,parent_id,`key`,func'));
         }
         return $result;
     }
@@ -50,7 +50,7 @@ class Role extends Auth
     {
         if ($info['func'] == 1) {
             $info['value'] = 'm-' . $info['id'];
-            $info['children'] = Dever::db('menu_func')->select(array('menu_id' => $info['id']), array('col' => 'id as value,name as label'))->fetchAll();
+            $info['children'] = Dever::db('menu_func')->select(array('menu_id' => $info['id']), array('col' => 'id as value,name as label'));
             if (!$info['children']) {
                 return array();
             }

+ 1 - 1
lib/System.php

@@ -5,7 +5,7 @@ class System extends Auth
 {
     public function getTree()
     {
-        $data = Dever::db('system')->select([])->fetchAll();
+        $data = Dever::db('system')->select([]);
         $result = array();
         $result[] = array
         (

+ 51 - 0
table/cron.php

@@ -0,0 +1,51 @@
+<?php
+return array
+(
+    'name' => '计划任务',
+    'struct' => array
+    (
+        'name'      => array
+        (
+            'type'      => 'varchar(32)',
+            'name'      => '任务名',
+        ),
+
+        'project'       => array
+        (
+            'type'      => 'varchar(30)',
+            'name'      => '项目',
+            'value'     => 'Dever::load("manage/common.project")',
+        ),
+        
+        'interface'     => array
+        (
+            'type'      => 'varchar(500)',
+            'name'      => '接口地址',
+        ),
+
+        'ldate'     => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '执行时间',
+        ),
+
+        'time'      => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '时间间隔',
+            'default'   => '0',
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint(1)',
+            'name'      => '状态',
+            'default'   => 1,
+            'value'    => array
+            (
+                1 => '可执行',
+                2 => '已完成',
+            )
+        ),
+    ),
+);

+ 7 - 2
table/group.php

@@ -10,6 +10,11 @@ return array
             'name'      => '集团名称',
             'type'      => 'varchar(200)',
         ),
+        'number' => array
+        (
+            'name'      => '集团号',
+            'type'      => 'varchar(60)',
+        ),
         'mobile' => array
         (
             'name'      => '手机号',
@@ -35,10 +40,10 @@ return array
     ),
     'default' => array
     (
-        'field' => 'name,sort,cdate',
+        'field' => 'name,number,sort,cdate',
         'value' => array
         (
-            '"默认集团",-100,' . DEVER_TIME,
+            '"默认集团","default",-100,' . DEVER_TIME,
         ),
         'num' => 1,
     ),

+ 10 - 5
table/manage/admin.php

@@ -41,7 +41,7 @@ return array
                 ),
             ),*/
 
-            'avatar' => 'image',
+            //'avatar' => 'image',
             'mobile' => array
             (
                 'sort' => true,
@@ -146,6 +146,8 @@ return array
             # 只处理某个字段,多个用逗号隔开
             //'编辑' => array('fastedit', 'name'),
             //'编辑' => array('fastedit'),
+            # 打开其他表的新增
+            //'新增子菜单' => array('fastadd', 'platform/admin'),
             '删除' => 'recycle',//删除到回收站
             //'彻底删除' => 'delete',
             //'操作' => array('oper', 'role'),
@@ -154,6 +156,7 @@ return array
             //'链接跳转' => array('link', 'https://www.baidu.com/'),
             # 第三个参数可以自定义图标:https://element-plus.org/zh-CN/component/icon.html#icon-collection
             //'路由跳转' => array('route', 'manage/menu?test=1', 'ChatLineSquare'),
+            //'管理账户列表' => array('route', array('path' => 'set_group/group_user', 'param' => array('set' => array('system_id' => 2, 'relation_id' => 'id')))),
         ),
         # 列表页导入
         'import' => array
@@ -316,14 +319,15 @@ return array
             max:多选限制选择数目,最大选择数目
 
             tree:树形选择器
-            tree2:大量数据下的树形选择器
-            area:地区选择器
+            tree2:大量数据下的树形选择器,暂时不支持
+            cascader:级联选择器,可以做地区等
             select:选择器
             select_tree:选择器,多选的树形模式
             set:
             clearable:是否可清空选择,true/false
             multiple:开启多选,true/false
-            remote:开启远程搜索,这里定义远程搜索的url
+            url:开启远程搜索,这里定义远程搜索的url
+            remote:开启远程控制,这里定义远程控制的url
 
             rate:评分
             set:
@@ -450,6 +454,7 @@ return array
             ),
             # 定义另外一个表或者方法里的字段,带有"."就是方法,调用manage/role里的upload配置,这里也可以自行配置
             //'manage/role' => 'upload',
+            /*
             'avatar' => array
             (
                 'type' => 'upload',
@@ -461,7 +466,7 @@ return array
                 'multiple' => false,
                 # 提示
                 'tip' => '',
-            ),
+            ),*/
         ),
 
         # 是否开启控制功能

+ 13 - 5
table/manage/core.php

@@ -43,7 +43,7 @@ return array
             'parent' => 'set',
             'name' => '平台管理',
             'icon' => 'book-open-line',
-            'sort' => '200',
+            'sort' => '50',
         ),
         # 定义三级菜单 一般和表名一致,如果不是表名则为自定义菜单
         'admin' => array
@@ -78,8 +78,8 @@ return array
             'name'      => '回收站',
             'icon'      => '',
             'sort'      => '100',
-            # 不显示在菜单中
-            'show'      => 2,
+            # 不显示在菜单中 也不显示在菜单管理中
+            'show'      => 3,
         ),
 
         'set_my' => array
@@ -89,7 +89,7 @@ return array
             'icon'      => '',
             'sort'      => '100',
             # 不显示在菜单中
-            'show'      => 2,
+            'show'      => 3,
             'path'      => 'set/my',
         ),
 
@@ -117,7 +117,15 @@ return array
             'sort'      => '5',
             'path'      => 'update',
             # 后续完善配置功能
-            'show'      => 2,
+            'show'      => 3,
+        ),
+
+        'cron' => array
+        (
+            'parent'    => 'platform',
+            'name'      => '计划任务',
+            'icon'      => 'stack-line',
+            'sort'      => '100',
         ),
 
         'set_group' => array

+ 56 - 0
table/manage/cron.php

@@ -0,0 +1,56 @@
+<?php
+$manage = Dever::project('manage');
+$path = $manage['setup'];
+return array
+(
+    'source' => 'manage/cron',
+    'list' => array
+    (
+        'desc' => '请将 * * * * * root php '.$path.'index.php \'{"l":"cron.run"}\'放到cron中[建议每分钟执行一次]',
+        'field'      => array
+        (
+            'name',
+            'project',
+            'interface',
+            'ldate' => array
+            (
+                'show' => 'date("Y-m-d H:i:s", {ldate})',
+            ),
+            'time',
+            'state' => array
+            (
+                'type' => 'switch',
+                'show'  => '{state}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ),
+        ),
+    ),
+
+    'update' => array
+    (
+        'field'      => array
+        (
+            'name',
+            'project',
+            'interface',
+            'ldate' => array
+            (
+                'type' => 'date',
+                'date_type' => 'datetime',
+                //'value_format' => 'YYYY-MM-DD HH:mm:ss',
+                'handle' => 'manage/common.crateDate',
+                'rules' => true,
+            ),
+            'time' => array
+            (
+                'desc' => '输入秒数',
+            ),
+            /*
+            'state' => array
+            (
+                'type' => 'radio',
+            ),*/
+        ),
+    ),
+);

+ 10 - 2
table/manage/group_manage.php

@@ -4,9 +4,12 @@ return array
     'source' => 'manage/group',
     'list' => array
     (
+        'desc' => '集团即您的客户,如果系统为集团客户开发了后台管理功能,可以使用集团来为客户开启后台权限',
         'field'      => array
         (
+            'id',
             'name',
+            'number',
             'sort' => 'input',
             'status' => array
             (
@@ -29,11 +32,16 @@ return array
         'field'    => array
         (
             'name',
+            'number' => array
+            (
+                'desc' => '集团号不能为空,且必须唯一,尽量使用字符串',
+                'rules' => true,
+            ),
             'mobile' => array
             (
                 'show'      => '"{mobile}" ? false : true',
                 'type'      => 'text',
-                'desc'      => '请输入管理员手机号,默认密码123456',
+                'desc'      => '请输入管理员手机号,默认密码123456,集团必须有管理员才能登录',
                 'placeholder' => '管理员手机号',
                 'rules'     => array
                 (
@@ -56,7 +64,7 @@ return array
             'sort',
             'status' => 'radio',
         ),
-
+        'check' => 'key',
         'end' => 'group.update',
     ),
 );

+ 18 - 5
table/manage/menu.php

@@ -4,6 +4,7 @@ return array
 (
     'list' => array
     (
+        'where' => array('system_id' => $system, 'show' => array('<', '3')),
         # 展示左侧分栏
         'column' => array
         (
@@ -25,12 +26,13 @@ return array
             # 对应的where条件的key
             'where' => 'system_id',
         ),
-        # 默认where条件
-        'where' => array('system_id' => $system),
         # 展示的字段
         'field'      => array
         (
-            'name',
+            'name' => array
+            (
+                'width' => '400',
+            ),
             'key',
             /*
             'system_id' => array
@@ -40,6 +42,8 @@ return array
             //'path',
             'icon' => 'icon',
             'sort' => 'input',
+            'show',
+            /*
             'show' => array
             (
                 # 行中修改 仅支持switch、select、input,太复杂的咱就别在行中修改了吧
@@ -47,7 +51,7 @@ return array
                 'show'  => '{show}',
                 'active_value' => 1,
                 'inactive_value' => 2,
-            ),
+            ),*/
         ),
         # 树形表格 仅type=table时支持,这里设置获取根数据的条件即可
         'tree' => array('parent_id', '0', 'id'),
@@ -55,6 +59,7 @@ return array
         'search'    => array
         (
             'system_id' => 'hidden',
+            'name',
         ),
 
         'button' => array
@@ -86,7 +91,15 @@ return array
             'link',
             'icon' => 'icon',
             'sort',
-            'show' => 'radio',
+            'show' => array
+            (
+                'type' => 'radio',
+                'option'     => array
+                (
+                    1 => '展示',
+                    2 => '不展示',
+                ),
+            ),
         ),
         'check' => 'key',
         'control' => array

+ 1 - 0
table/manage/system.php

@@ -16,5 +16,6 @@ return array
             'name',
             'sort',
         ),
+        'check' => 'key',
     ),
 );

+ 7 - 0
table/menu.php

@@ -75,6 +75,7 @@ return array
             (
                 1 => '展示',
                 2 => '不展示',
+                3 => '隐藏',
             ),
         ),
         'func' => array
@@ -83,5 +84,11 @@ return array
             'type'      => 'tinyint(1)',
             'default'   => 2,
         ),
+        'level' => array
+        (
+            'name'      => '层级',
+            'type'      => 'tinyint(11)',
+            'default'   => '1',
+        ),
     ),
 );

+ 7 - 2
table/platform.php

@@ -11,6 +11,11 @@ return array
             'name'      => '平台名称',
             'type'      => 'varchar(200)',
         ),
+        'number' => array
+        (
+            'name'      => '集团号',
+            'type'      => 'varchar(60)',
+        ),
         'sort' => array
         (
             'name'      => '排序',
@@ -20,10 +25,10 @@ return array
     ),
     'default' => array
     (
-        'field' => 'id,name,sort,cdate',
+        'field' => 'id,name,number,sort,cdate',
         'value' => array
         (
-            '1,"默认平台",-100,' . DEVER_TIME,
+            '1,"默认平台","default",-100,' . DEVER_TIME,
         ),
         'num' => 1,
     ),