rabin há 5 horas atrás
pai
commit
859637b719
14 ficheiros alterados com 1 adições e 1713 exclusões
  1. 0 143
      api/Admin.php
  2. 0 167
      api/Console.php
  3. 0 25
      api/Cron.php
  4. 0 18
      api/Icon.php
  5. 0 134
      api/Login.php
  6. 0 105
      api/Menu.php
  7. 0 170
      api/Page/Data.php
  8. 0 29
      api/Page/Diy.php
  9. 0 107
      api/Page/Oper.php
  10. 0 34
      api/Page/Pdf.php
  11. 0 11
      api/Page/Stat.php
  12. 0 748
      api/Page/Update.php
  13. 0 21
      api/Page/View.php
  14. 1 1
      index.php

+ 0 - 143
api/Admin.php

@@ -1,143 +0,0 @@
-<?php namespace Manage\Api;
-use Dever;
-use Manage\Lib\Auth;
-class Admin extends Auth
-{
-    public function info()
-    {
-        $this->user['module']['show'] = true;
-        $this->user['module']['id'] = (int) $this->user['select']['module_id'];
-        $this->user['module']['name'] = '当前模块';
-        $this->user['module']['list'] = $this->module();
-        $this->user['module']['login'] = 'login';
-        $this->user['module']['uri'] = ['system' => $this->system['key'], 'number' => $this->system_info['number']];
-        return $this->user;
-    }
-
-    # 获取当前的模块列表
-    public function module()
-    {
-        $where = [];
-        if ($this->user['auth']['module']) {
-            $where['id'] = ['in', $this->user['auth']['module']];
-        } else {
-            $where['system'] = $this->system['key'];
-        }
-        $result = [];
-        $module = Dever::db('system_module', 'manage')->select($where);
-        $i = 0;
-        foreach ($module as $k => $v) {
-            $data_where = $v['data_where'];
-            if ($data_where) {
-                if (strstr($data_where, '{uid}')) {
-                    $data_where = str_replace('{uid}', $this->user['id'], $data_where);
-                }
-                $data_where = Dever::json_decode($data_where);
-            } else {
-                $data_where = [];
-            }
-            $child = Dever::db($v['data_table'])->select($data_where);
-            
-            if ($child) {
-                $data = [];
-                foreach ($child as $k1 => $v1) {
-                    $v1['select'] = false;
-                    if ($v['id'] == $this->user['select']['module_id'] && $v1['id'] == $this->user['select']['data_id']) {
-                        $this->user['module']['name'] = $v1['name'];
-                        $v1['select'] = true;
-                    }
-                    $key = $v['id'] . '-' . $v1['id'];
-                    if ($this->user['module_data']) {
-                        if (strstr($this->user['module_data'], $key)) {
-                            $data[] = $v1;
-                        }
-                    } else {
-                        $data[] = $v1;
-                    }
-                }
-                if ($data) {
-                    $result[$i] = $v;
-                    $result[$i]['child'] = $data;
-                    $i++;
-                }
-            }
-        }
-        if ($i <= 1) {
-            $this->user['module']['show'] = false;
-        }
-        return $result;
-    }
-
-    # 根据角色获取模块下的数据
-    public function getModuleData($value = false)
-    {
-        if (!$value) {
-            $result['module_data']['option'] = [];
-            return $result;
-        }
-        $result = [];
-        $role = Dever::db($this->system['role_table'])->select(array('id' => ['in', $value]));
-        if ($role) {
-            $info = $module = [];
-            foreach ($role as $k => $v) {
-                if ($v['module']) {
-                    $child = Dever::db('system_module', 'manage')->select(array('id' => ['in', $v['module']]));
-                    if ($child) {
-                        foreach ($child as $k1 => $v1) {
-                            if (isset($info[$v1['id']])) {
-                                continue;
-                            }
-                            $info[$v1['id']] = true;
-                            $v1['value'] = 's-' . $v1['id'];
-                            $v1['label'] = $v1['name'];
-                            $v1['children'] = [];
-                            $data = Dever::db($v1['data_table'])->select([], array('col' => 'concat('.$v1['id'].', "-", id) as value, name as label'));
-                            if ($data) {
-                                $v1['children'] = array_merge($v1['children'], $data);
-                            }
-                            $module[] = $v1;
-                        }
-                    }
-                }
-            }
-            $result['module_data']['option'] = $module;
-        }
-        
-        return $result;
-    }
-
-    # 切换模块
-    public function setModule()
-    {
-        $module_id = Dever::input('module_id');
-        $this->checkModule($this->user['select']['module_id']);
-        $data_id = Dever::input('data_id');
-        if ($this->user['module_data'] && !strstr($this->user['module_data'], $module_id . '-' . $data_id)) {
-            Dever::error('无模块权限');
-        }
-        $result = Dever::load('util', 'manage')->token($this->user['id'], $this->user['mobile'], $this->user['select']['partition'], $this->user['select']['system_key'], $this->user['select']['system_id'], $this->user['select']['info_id'], $module_id, $data_id);
-        return $result;
-    }
-
-    # 修改资料
-    public function setInfo()
-    {
-        $username = Dever::input('username');
-        $password = Dever::input('password');
-        $data = [];
-        if ($username) {
-            $data['name'] = $username;
-        }
-        if ($password) {
-            $data += Dever::load('util', 'manage')->createPwd($password);
-        }
-        $state = false;
-        if ($data) {
-            $state = Dever::db($this->system['user_table'])->update($this->uid, $data);
-        }
-        if (!$state) {
-            Dever::error('修改失败');
-        }
-        return 'yes';
-    }
-}

+ 0 - 167
api/Console.php

@@ -1,167 +0,0 @@
-<?php namespace Manage\Api;
-use Dever;
-use Manage\Lib\Auth;
-class Console extends Auth
-{
-    # 控制台首页
-    public function index()
-    {
-        $config = Dever::config('manage');
-        $data['layout'] = [
-            [
-                'tip' => 24,
-            ],
-        ];
-        $data['tip'] = [
-            'type' => 'tip',
-            'name' => $this->getMsg($this->user['name']),
-            'content' => '您正在使用{title},请通过左侧导航栏选择需要操作的模块。祝你工作愉快!',
-        ];
-        if (isset($config['console']) && $config['console']) {
-            $data = Dever::call($config['console'], [$data]);
-        }
-        return $data;
-    }
-
-    # 问候语
-    private function getMsg($username, $lang = 'zh')
-    {
-        $hour = date('H');
-        if ($hour < 8) {
-            $period = 'morning_early';
-        } elseif ($hour <= 11) {
-            $period = 'morning';
-        } elseif ($hour <= 13) {
-            $period = 'noon';
-        } elseif ($hour < 18) {
-            $period = 'afternoon';
-        } else {
-            $period = 'evening';
-        }
-
-        $greetings = [
-            'zh' => [
-                'morning_early' => [
-                    "新的一天开始啦,{username},愿你充满能量与好心情 🌅",
-                    "早上好,{username}!今天也要元气满满地出发 ☀️",
-                    "又是充满希望的一天,{username},愿你元气满满 ✨",
-                    "清晨的阳光最温柔,祝你一天好心情,{username} 🌞",
-                    "清晨的努力,是成功的开始,加油,{username}!",
-                    "起这么早,是被梦想叫醒的,还是被闹钟吓醒的?⏰,{username}",
-                    "早安,{username},太阳都羡慕你勤劳 🌞",
-                    "日出东方,一切皆静,{username} 🌄",
-                    "时间不语,却回答一切,{username} 🧘",
-                    "越努力,越幸运,新的一天,加油,{username} 💪",
-                    "今天做的每一件小事,都是未来的伏笔,{username} 📝",
-                    "美好的一天从早晨开始,{username},加油!",
-                    "黎明的第一缕光,送给勤奋的你,{username}。",
-                ],
-                'morning' => [
-                    "上午好,{username}!看到你上线真开心 😄",
-                    "今天也要高效完成每一项任务,加油,{username} 💪",
-                    "专注的你,最有魅力,{username} 🧠",
-                    "把事情做到最好,是你的风格,{username} 🔧",
-                    "保持节奏,每一天都值得记录,{username} 📅",
-                    "上午好,{username}!今天也要继续摸鱼计划 🐟",
-                    "再摸一会鱼,就到中午了,加油,{username} ✊",
-                    "你走你的路,花自开,{username} 🌸",
-                    "心静则清,行稳则远,{username} 🌿",
-                    "你正在书写属于你自己的不凡人生,{username} 📖",
-                    "相信自己,你比想象中更强大,{username} ✨",
-                    "每个上午都是新的开始,{username},抓住机会!",
-                    "专注且坚定,{username},你值得赞扬!",
-                ],
-                'noon' => [
-                    "中午好,{username}!记得按时吃饭补充能量 🍱",
-                    "工作再忙,也别忘了照顾自己,{username} ❤️",
-                    "好好吃饭,下午才有力气继续冲,{username} 💼",
-                    "中场休息,补充体力,{username} 🌯",
-                    "饭不吃饱,哪有力气摸鱼,{username} 🐠",
-                    "中午不休息,下午徒伤悲,{username} 😵",
-                    "饭要好好吃,觉要好好睡,{username} 🌿",
-                    "坐看云起时,不争一时高下,{username} ☁️",
-                    "每一次坚持,都是积累能量,{username} 🔋",
-                    "中午短暂放松,是为了更好出发,{username} 🚀",
-                    "阳光正好,{username},午饭别忘了吃饱哦!",
-                    "充能中,{username},下午继续加油!",
-                ],
-                'afternoon' => [
-                    "下午好,{username}!来杯咖啡提提神 ☕",
-                    "再坚持一会儿,胜利就在眼前,{username} 🏁",
-                    "保持专注,继续向前,{username} 💼",
-                    "喝口水,伸个懒腰,继续冲,{username} 💨",
-                    "摸鱼也需要节奏,别太张扬,{username} 😏",
-                    "困了就看老板照片提神,{username} 🧃",
-                    "一花一世界,一念一清净,{username} 🪷",
-                    "茶要慢饮,事要缓做,{username} 🍵",
-                    "你所付出的努力,终将照亮前路,{username} 💡",
-                    "不怕慢,只怕站,坚持走就对了,{username} 🛤️",
-                    "努力的下午,{username},胜利不远了!",
-                    "冲刺时间到,{username},继续燃烧吧!",
-                ],
-                'evening' => [
-                    "晚上好,{username}!愿你天黑有灯,下雨有伞 🌙",
-                    "今天也辛苦啦,好好休息,{username} 🛏️",
-                    "收工啦,放松一下,明天继续努力,{username} ✨",
-                    "一天结束了,给自己点个赞,{username} 👍",
-                    "打卡下班是对生活最基本的尊重,{username} 📤",
-                    "今天摸鱼圆满成功,记得下次继续,{username} 🐳",
-                    "夜深人静时,心要平,{username} 💭",
-                    "万事随心,内心清明,{username} ✨",
-                    "收获不在今天,也会在明天到来,{username} 🌟",
-                    "夜晚是沉淀的时刻,也是蓄力的开始,{username} 🌌",
-                    "星空很美,{username},别忘了好好休息!",
-                    "忙碌一天,{username},放松自己,明天更好!",
-                ],
-            ],
-            'en' => [
-                'morning_early' => [
-                    "Good morning {username}! A new day, a new beginning ☀️",
-                    "Wake up, {username}! The sun is shining just for you 🌞",
-                    "Early bird {username}, you’re catching all the worms! 🐦",
-                    "Rise and shine, {username}! Let's seize the day! ✨",
-                    "Morning, {username}! The world awaits your greatness!",
-                ],
-                'morning' => [
-                    "Good morning {username}! Let's make today productive 💪",
-                    "Hey {username}, rise and grind! ☕",
-                    "Keep pushing forward, {username}. Success awaits! 🚀",
-                    "Stay focused, {username}, and make it happen! 🧠",
-                    "Morning hustle, {username}! Keep that energy high!",
-                    "Seize the morning, {username}! Make it count!",
-                ],
-                'noon' => [
-                    "Hi {username}, don't forget to grab some lunch 🍱",
-                    "Take a break, {username}, recharge your energy! ⚡",
-                    "Refuel well, {username}, the afternoon awaits! 🌟",
-                    "Lunch time, {username}! Enjoy your meal 🍔",
-                    "Midday break, {username}! Stay refreshed!",
-                    "Keep up the great work, {username}! Almost halfway!",
-                ],
-                'afternoon' => [
-                    "Afternoon vibes, {username}! Keep going strong 💼",
-                    "Almost there, {username}! Keep up the great work 🏆",
-                    "Stay hydrated, {username}, and keep focused! 💧",
-                    "You’re doing great, {username}! Keep pushing! 🔥",
-                    "Keep the momentum, {username}! Afternoon grind!",
-                    "Push through, {username}! The finish line is near!",
-                ],
-                'evening' => [
-                    "Good evening {username}! Time to wind down 🌙",
-                    "Relax and recharge, {username}, you earned it 🛏️",
-                    "Well done today, {username}! See you tomorrow 👋",
-                    "Evenings are for rest, {username}. Take care! 🌌",
-                    "Night falls, {username}. Rest well and dream big!",
-                    "Time to relax, {username}. Tomorrow is a new chance!",
-                ],
-            ],
-        ];
-
-        $langGroup = $greetings[$lang] ?? $greetings['zh'];
-        $lines = $langGroup[$period] ?? $langGroup['morning_early'];
-
-        $template = $lines[array_rand($lines)];
-
-        return str_replace('{username}', $username, $template);
-    }
-}

+ 0 - 25
api/Cron.php

@@ -1,25 +0,0 @@
-<?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' => ['<=', $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);
-            }
-        }
-    }
-}

+ 0 - 18
api/Icon.php

@@ -1,18 +0,0 @@
-<?php namespace Manage\Api;
-use Dever;
-use Manage\Lib\Auth;
-class Icon extends Auth
-{
-    public function list()
-    {
-        $set['num'] = Dever::input('pgnum', '', '', 16);
-        $key = Dever::input('title');
-        $where = [];
-        if ($key) {
-            $where['key'] = ['like', $key];
-        }
-        $data['list'] = Dever::db('icon', 'manage')->select($where, $set);
-        $data['total'] = Dever::page('total');
-        return $data;
-    }
-}

+ 0 - 134
api/Login.php

@@ -1,134 +0,0 @@
-<?php namespace Manage\Api;
-use Dever;
-use Dever\Helper\Str;
-use Dever\Helper\Code;
-class Login
-{
-    # 获取系统信息
-    public function getSystem()
-    {
-        $system = Dever::input('system', 'is_string', '系统', 'platform');
-        $system = Dever::db('system', 'manage')->find(['key' => $system]);
-        if (!$system) {
-            Dever::error('当前系统不存在');
-        }
-        $system['placeholder'] = '请输入' . $system['name'] . '号';
-        return $system;
-    }
-
-    # 登录
-    public function act()
-    {
-        //$this->checkCode();
-        $system = $this->getSystem();
-        $number = Dever::input('number', '', $system['name'] . '号', 'default');
-        $info = Dever::db($system['info_table'])->find(['number' => $number]);
-        if (!$info) {
-            Dever::error('登录失败,当前' . $system['name'] . '号错误');
-        }
-        if ($system['partition'] == 'no') {
-            # 不分库
-            $db = Dever::db($system['user_table']);
-            $role_db = Dever::db($system['role_table']);
-        } else {
-            # 分库
-            $info['info_id'] = $info['id'];
-            $info['partition'] = $system['partition'];
-            $info['system_key'] = $system['key'];
-            $info['system_id'] = $system['id'];
-            $partition = Dever::load('util', 'manage')->system($info);
-            $db = Dever::db($system['user_table'], '', true, 'default', $partition);
-            $role_db = Dever::db($system['role_table'], '', true, 'default', $partition);
-        }
-        $where['mobile'] = Dever::input('mobile', Dever::rule('mobile'), '手机号');
-        $password = Dever::input('password', 'is_string', '密码');
-        $admin = $db->find($where);
-        if (!$admin) {
-            $total = $db->find(1);
-            if (!$total) {
-                $insert['name'] = Str::hide($where['mobile']);
-                $insert['mobile'] = $where['mobile'];
-                $insert['role'] = 1;
-                $insert += Dever::load('util', 'manage')->createPwd($password);
-                $id = $db->insert($insert);
-                $admin = $db->find($id);
-            } else {
-                Dever::error('登录失败');
-            }
-        }
-        if (!$admin) {
-            Dever::error('登录失败,管理员信息无效');
-        }
-        if ($admin['status'] == 2) {
-            Dever::error('登录失败,账户已被封禁');
-        }
-        if (Dever::load('util', 'manage')->hash($password, $admin['salt']) != $admin['password']) {
-            Dever::error('登录失败,账户密码无效');
-        }
-        # 根据角色获取module_id
-        $system_user = Dever::db('system_user', 'manage')->find(['uid' => $admin['id'], 'system_id' => $system['id'], 'info_id' => $info['id']]);
-        $module_id = $data_id = 0;
-        if ($system_user) {
-            $module_id = $system_user['module_id'];
-            $data_id = $system_user['data_id'];
-        } elseif ($admin['role']) {
-            $module = '';
-            $role = $role_db->select(array('id' => ['in', $admin['role']]));
-            foreach ($role as $k => $v) {
-                if ($v['module']) {
-                    $module .= $v['module'] . ',';
-                }
-            }
-            if ($module) {
-                $where['id'] = ['in', $module];
-            } else {
-                $where['system'] = $system['key'];
-            }
-            $module = Dever::db('system_module', 'manage')->select($where);
-            if ($module) {
-                $module_id = $module[0]['id'];
-                $child = Dever::db($module[0]['data_table'])->select([]);
-                if ($child) {
-                    if ($admin['module_data']) {
-                        foreach ($child as $k => $v) {
-                            $key = $module_id . '-' . $v['id'];
-                            if (strstr($admin['module_data'], $key)) {
-                                $data_id = $v['id'];
-                                break;
-                            }
-                        }
-                    } else {
-                        $data_id = $child[0]['id'];
-                    }
-                }
-            }
-        }
-        if (!$module_id || !$data_id) {
-            Dever::error('登录失败,账户无效');
-        }
-        return Dever::load('util', 'manage')->token($admin['id'], $admin['mobile'], $system['partition'], $system['key'], $system['id'], $info['id'], $module_id, $data_id);
-    }
-    private function checkCode()
-    {
-        $code = Dever::input('verificationCode');
-        if (!$code) {
-            Dever::error('请输入验证码');
-        }
-        $save = Dever::session('code');
-        if ($code != $save) {
-            Dever::error('验证码错误');
-        }
-    }
-    public function code()
-    {
-        echo Dever::session('code', Code::create(), 3600);die;
-    }
-    public function out()
-    {
-        return 'ok';
-    }
-    public function loadMenu()
-    {
-        return Dever::load('menu', 'manage')->init();
-    }
-}

+ 0 - 105
api/Menu.php

@@ -1,105 +0,0 @@
-<?php namespace Manage\Api;
-use Dever;
-use Manage\Lib\Auth;
-class Menu extends Auth
-{
-    protected $top;
-    protected $opened;
-    public function info()
-    {
-        # 如果后续增加Root,就要这里置为false
-        $this->top = true;
-        $top = Dever::db('menu', 'manage')->select(['parent_id' => '0', 'module_id' => $this->user['select']['module_id']]);
-        $result = $menu = [];
-        $result[] = array
-        (
-            'path' => '/',
-            'name' => 'Root',
-            'component' => 'Layout',
-            'meta' => [
-                'title' => '首页',
-                'icon' => 'home-2-line',
-                'breadcrumbHidden' => true,
-            ],
-            'children' => array
-            (
-                array
-                (
-                    'path' => 'index',
-                    'name' => 'Index',
-                    'component' => '@/dever/index/index',
-                    'meta' => [
-                        'title' => '控制台',
-                        'icon' => 'home-2-line',
-                        'noClosable' => true,
-                    ]
-                ),
-            )
-        );
-        $this->opened = [];
-        foreach ($top as $v) {
-            $v = $this->getMenu($v, '');
-            if ($v) {
-                $result[] = $v;
-            }
-        }
-        return ['list' => $result, 'opened' => $this->opened];
-    }
-    private function getMenu($v, $parent = '')
-    {
-        $info = array
-        (
-            'path' => $parent ? '/' . $parent . '/' . $v['key'] : $v['key'],
-            'name' => $parent ? $parent . '_' . $v['key'] : $v['key'],
-            'meta' => [
-                'title' => $v['name'],
-                'icon' => $v['icon'],
-                //'noClosable' => true,
-                'breadcrumbHidden' => false,
-                'dynamicNewTab' => true,
-            ]
-        );
-        if ($v['show'] > 1) {
-            $info['meta']['hidden'] = true;
-        }
-        if (isset($v['active']) && $v['active']) {
-            $info['meta']['activeMenu'] = $v['active'];
-        }
-        if ($v['parent_id'] <= 0) {
-            if ($this->top) {
-                $info['path'] = '/' . $v['key'];
-            } else {
-                $this->top = true;
-                $info['path'] = '/';
-            }
-            $info['component'] = 'Layout';
-        }
-        $where = ['parent_id' => $v['id'], 'module_id' => $this->user['select']['module_id']];
-        $child = Dever::db('menu', 'manage')->select($where);
-        if ($child) {
-            foreach ($child as $v1) {
-                if ($v1['level'] == 3 && $v1['show'] <= 2 && $this->checkMenu($v1['id'])) {
-                    continue;
-                }
-                if (!$parent) {
-                    $this->opened[] = '/' . $v['key'] . '/' . $v1['key'];
-                }
-                $children = $this->getMenu($v1, $v['key']);
-                if ($children) {
-                    $info['children'][] = $children;
-                }
-            }
-            if (empty($info['children'])) {
-                return [];
-            }
-        } elseif ($v['path']) {
-            $info['component'] = '@/dever/page/' . $v['path'];
-        }
-        if (!$child) {
-            if ($v['level'] == 3 && $v['show'] <= 2 && $this->checkMenu($v['id'])) {
-                return false;
-            }
-        }
-        return $info;
-    }
-}

+ 0 - 170
api/Page/Data.php

@@ -1,170 +0,0 @@
-<?php namespace Manage\Api\Page;
-use Dever;
-use Manage\Lib\Page;
-# 数据获取
-class Data extends Page
-{
-    private $expand = false;
-    public function __construct($load = '')
-    {
-        parent::__construct('list', $load);
-    }
-    public function list()
-    {
-        if ($this->menu && $this->menu['show'] == 1 && !$this->getFunc('list', '列表', 1)) {
-            Dever::error('无访问权限');
-        }
-        $data['title'] = $this->config['title'] ?? '';
-        $data['button'] = $this->button();
-        $data['recycler'] = $this->recycler;
-        $data = array_merge($data, $this->out());
-        $data['total'] = Dever::page('total');
-        $data['height'] = $this->config['height'] ?? '100%';
-        $data['type'] = $this->config['type'] ?? 'table';
-        $data['desc'] = $this->config['desc'] ?? '';
-        $data['layout'] = $this->config['layout'] ?? [];
-        $data['exportButton'] = $this->export();
-        $data['show'] = [
-            'selection' => $this->config['selection'] ?? false,
-            'expand' => $this->expand,
-            'index' => $this->config['index'] ?? false,
-        ];
-        $this->column($data);
-        return $data;
-    }
-    public function out()
-    {
-        $where = $this->config['where'] ?? [];
-        $set = $this->config['set'] ?? [];
-        $data['field'] = $data['head'] = [];
-        $data['search'] = $this->search($where);
-        $ids = Dever::input('ids');
-        if ($ids) {
-            $where['id'] = ['in', $ids];
-        }
-        $set['num'] = Dever::input('pgnum', '', '', 10);
-        $order_col = Dever::input('order_col');
-        if ($order_col) {
-            $order_value = Dever::input('order_value');
-            if ($order_value) {
-                $set['order'] = $order_col . ' ' . $order_value . ', id desc';
-            }
-        }
-        $data['filter'] = [];
-        if (isset($this->config['filter'])) {
-            $data['filter'] = Dever::call($this->config['filter'], [$where]);
-            if ($data['filter']) {
-                $filter = Dever::input('filter', '', '', 0);
-                if (isset($data['filter'][$filter])) {
-                    $where = array_merge($where, $data['filter'][$filter]['where']);
-                }
-            }
-        }
-
-        if (isset($this->config['data'])) {
-            $result = Dever::call($this->config['data'], [$where, $set]);
-            $data = array_merge($data, $result);
-        } else {
-            $data['field'] = $this->setting('field', $data['head'], true, 'show');
-            $data['body'] = $this->data($where, $set);
-        }
-        $method = Dever::input('method');
-        if ($method && strstr($method, '.')) {
-            $result = Dever::call($method, [$data]);
-            unset($data);
-            $data['field'] = $result['head'];
-            $data['body'] = $result['body'];
-        }
-        $data['stat'] = [];
-        if (isset($this->config['stat'])) {
-            $data['stat'] = Dever::call($this->config['stat'], [$where]);
-        }
-        
-        $data['bodyButton'] = (isset($this->config['data_button']) && $this->config['data_button']) || isset($this->config['data_button_list']) ? true : false;
-        return $data;
-    }
-
-    private function data($where, $set = [])
-    {
-        if (isset($this->config['tree'])) {
-            return $this->db->tree($where, $this->config['tree'], [$this, 'handleData']);
-        }
-        $data = $this->db->select($where, $set);
-        $result = [];
-        if ($data) {
-            foreach ($data as $k => $v) {
-                $result[$k] = $this->handleData($k, $v);
-            }
-        }
-        return $result;
-    }
-
-    public function handleData($k, $v)
-    {
-        $result = $v;
-        $result['index'] = $k+1*Dever::input('pg', '', '', 1);
-        $button = $this->button('data_button', $v);
-        if ($button) {
-            $result['button'] = $button;
-        }
-        $button = $this->button('data_button_list', $v, false);
-        if ($button) {
-            $result['button_list'] = $button;
-        }
-        
-        # 是否保留html代码,1是保留,2是不保留
-        $html = Dever::input('html', '', '', 1);
-        if (isset($v['_id'])) {
-            $result['id'] = $v['_id'];
-        } elseif (isset($v['id'])) {
-            $result['id'] = $v['id'];
-        }
-        $result['cdate'] = $v['cdate'];
-        foreach ($this->field as $value) {
-            $key = $value['key'];
-            if (isset($v[$key])) {
-                $result[$key] = $this->getValue($key, $v[$key], $v, $value);
-            } elseif (strpos($key, '/')) {
-                $other = $this->getOther($key, $value, $v);
-                if ($other) {
-                    $otherName = [];
-                    foreach ($other as $k1 => $v1) {
-                        if (isset($v1['name'])) {
-                            $otherName[] = $v1['name'];
-                        }
-                    }
-                    if ($otherName) {
-                        $result[$key] = implode('、', $otherName);
-                    } else {
-                        $result[$key] = $other;
-                    }
-                }
-            } elseif (isset($value['show'])) {
-                $result[$key] = $this->getShow($value['show'], $v);
-            }
-            if ($html == 2 && is_string($result[$key])) {
-                $result[$key] = strip_tags($result[$key]);
-            }
-        }
-        if (isset($this->config['expand']) && $this->config['expand']) {
-            $result['expand'] = Dever::call($this->config['expand'], [$v]);
-            $this->expand = true;
-        }
-        return $result;
-    }
-
-    private function export()
-    {
-        $result = false;
-        if (isset($this->config['export']) && $this->config['export']) {
-            $result = [];
-            foreach ($this->config['export'] as $k => $v) {
-                $func = $this->getFunc($k, $v, 300);
-                if ($func) {
-                    $result[$k] = $v;
-                }
-            }
-        }
-        return $result;
-    }
-}

+ 0 - 29
api/Page/Diy.php

@@ -1,29 +0,0 @@
-<?php namespace Manage\Api\Page;
-use Dever;
-use Manage\Lib\Page;
-# 自定义页面
-class Diy extends Page
-{
-    public function __construct($load = '', $input = true, $id = false)
-    {
-        parent::__construct('diy', $load, $input);
-    }
-    public function get()
-    {
-        $this->checkFunc();
-        if (is_string($this->config)) {
-            $data = Dever::call($this->config, [$this->info]);
-        } else {
-            $data = $this->config;
-        }
-        $where = $this->config['where'] ?? [];
-        if (isset($data['search'])) {
-            $data['search'] = $this->search($where);
-            $data['search']['type'] = 'search';
-        }
-        if (isset($data['data']) && $data['data']) {
-            $data = Dever::call($data['data'], [$where, $data]);
-        }
-        return $data;
-    }
-}

+ 0 - 107
api/Page/Oper.php

@@ -1,107 +0,0 @@
-<?php namespace Manage\Api\Page;
-use Dever;
-use Manage\Lib\Page;
-# 操作
-class Oper extends Page
-{
-    public function __construct()
-    {
-        parent::__construct('oper');
-        $this->id = Dever::input('id');
-        if (!$this->id) {
-            Dever::error('无效数据');
-        }
-        $this->checkFunc();
-    }
-
-    # 更改某个字段的值
-    public function up_commit(){}
-    public function up()
-    {
-        $input = Dever::input();
-        $field = Dever::input('field');
-        if (is_array($field)) {
-            $field = $field['field'];
-        }
-        $field = explode(',', $field);
-        foreach ($field as $k => $v) {
-            if (isset($input[$v]) && $value = $input[$v]) {
-                if (is_array($value)) {
-                    $value = implode(',', $value);
-                }
-                $data[$v] = $value;
-            }
-        }
-        if (isset($this->config['up_start']) && $this->config['up_start']) {
-            list($this->id, $data) = Dever::call($this->config['up_start'], [$this->id, $data]);
-        }
-        $where['id'] = ['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'], [$this->id, $data]);
-            }
-            return ['msg' => '操作成功', 'upAdmin' => false];
-        } else {
-            Dever::error('操作失败');
-        }
-    }
-
-    # 删除 删除到回收站
-    public function recycle_commit(){}
-    public function recycle()
-    {
-        $where['id'] = ['in', $this->id];
-        $data = $this->db->select($where);
-        if ($data) {
-            foreach ($data as $k => $v) {
-                $insert['table'] = $this->db->config['load'];
-                $insert['table_id'] = $v['id'];
-                $insert['content'] = Dever::json_encode($v);
-                $state = Dever::db('manage/recycler')->insert($insert);
-                if (!$state) {
-                    Dever::error('删除失败,请重试');
-                }
-                $state = $this->db->delete($v['id']);
-                if (!$state) {
-                    Dever::error('删除失败,请重试');
-                }
-            }
-        }
-        return '操作成功';
-    }
-
-    # 从回收站恢复
-    public function recover_commit(){}
-    public function recover()
-    {
-        $where['id'] = ['in', $this->id];
-        $data = $this->db->select($where);
-        if ($data) {
-            foreach ($data as $k => $v) {
-                $v['content'] = Dever::json_decode($v['content']);
-                $state = Dever::db($v['table'])->insert($v['content']);
-                if (!$state) {
-                    Dever::error('恢复失败,请重试');
-                }
-                $state = $this->db->delete($v['id']);
-                if (!$state) {
-                    Dever::error('恢复失败,请重试');
-                }
-            }
-        }
-        return '操作成功';
-    }
-
-    # 直接删除
-    public function delete_commit(){}
-    public function delete()
-    {
-        $where['id'] = ['in', $this->id];
-        $state = $this->db->delete($where);
-        if (!$state) {
-            Dever::error('删除失败,请重试');
-        }
-        return '操作成功';
-    }
-}

+ 0 - 34
api/Page/Pdf.php

@@ -1,34 +0,0 @@
-<?php namespace Manage\Api\Page;
-use Dever;
-use Manage\Lib\Page;
-# pdf编辑器
-class Pdf extends Page
-{
-    public function __construct($load = '', $input = true, $id = false)
-    {
-        parent::__construct('pdf', $load, $input);
-    }
-    public function get()
-    {
-        $this->checkFunc();
-        if (is_string($this->config)) {
-            $data = Dever::call($this->config, [$this->info]);
-        } else {
-            $data = $this->config;
-        }
-        if (isset($data['upload'])) {
-            $upload = $this->getUpload($data['upload']);
-            if (is_array($data['upload'])) {
-                $upload += $data['upload'];
-            } else {
-                $upload += ['id' => $data['upload']];
-            }
-            if (empty($upload['id'])) {
-                Dever::error('上传配置错误');
-            }
-            $upload['wh'] = '500*500';
-            $data['upload'] = ['set' => Dever::url('image/manage.set', $upload, true)];
-        }
-        return $data;
-    }
-}

+ 0 - 11
api/Page/Stat.php

@@ -1,11 +0,0 @@
-<?php namespace Manage\Api;
-use Dever;
-use Manage\Lib\Page;
-# 统计页
-class Stat extends Page
-{
-    public function get()
-    {
-        
-    }
-}

+ 0 - 748
api/Page/Update.php

@@ -1,748 +0,0 @@
-<?php namespace Manage\Api\Page;
-use Dever;
-use Manage\Lib\Page;
-ini_set("memory_limit", -1);
-set_time_limit(0);
-# 更新页 项目着急上线 以后优化并封装
-class Update extends Page
-{
-    public function __construct($load = '', $input = true)
-    {
-        parent::__construct('update', $load, $input);
-    }
-    public function get(&$value = [], &$option = [])
-    {
-        $func = $this->checkFunc();
-        $remote = $show = $spec = $source = $default = [];
-        $data['update'] = $data['field'] = $data['option'] = [];
-        $this->setting('field', $data['update'], true, 'text');
-        foreach ($data['update'] as $k => $v) {
-            if ($v['type'] == 'tree' || $v['type'] == 'upload' || $v['type'] == 'cascader' || $v['type'] == 'checkbox' || isset($v['multiple'])) {
-                if (isset($v['value']) && $v['value']) {
-                    $v['value'] = explode(',', $v['value']);
-                    foreach ($v['value'] as $k1 => $v1) {
-                        if (is_numeric($v1)) {
-                            $v['value'][$k1] = (float) $v1;
-                        }
-                    }
-                } else {
-                    $v['value'] = [];
-                }
-            }
-            if (isset($v['source'])) {
-                $source[$v['key']] = $v['source'];
-            }
-            if (isset($v['remote'])) {
-                $remote[$v['key']] = [$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']] = [$k, $v['spec_data'], $v['key'] . '_spec', $v['spec'], $v['spec_field'], $v['spec_template'] ?? ''];
-            }
-            if (isset($v['show']) && is_string($v['show'])) {
-                $show[$v['key']] = [$k, $v['show']];
-            }
-            if (isset($v['default']) && is_string($v['default']) && strstr($v['default'], '{')) {
-                $default[$v['key']] = [$k, $v['default']];
-            }
-            $data['field'][$v['key']] = $v['value'];
-            if ($v['type'] == 'sku') {
-                $data['field'][$v['key'] . '_spec'] = [];
-            }
-            if (isset($v['option'])) {
-                $data['option'][$v['key']] = $v['option'];
-                unset($data['update'][$k]['option']);
-            }
-        }
-        $active = $this->column($data);
-        $data['info_id'] = false;
-        if (!$this->info && $active) {
-            $this->info = $this->db->find($active);
-            if ($this->info) {
-                $data['info_id'] = $this->info['id'];
-                if (!$func) {
-                    $func = $this->getFunc('edit', '编辑', 1);
-                    if (!$func && $this->menu && $this->menu['show'] == 1) {
-                        Dever::error('无操作权限');
-                    }
-                }
-            }
-        } elseif (!$func) {
-            $func = $this->getFunc('update', '更新', 1);
-            if (!$func && $this->menu && $this->menu['show'] == 1) {
-                Dever::error('无操作权限');
-            }
-        }
-        if ($this->info) {
-            $info = $this->info;
-            $this->setInfo($info, $data, $remote, $show, $source, $default, 1, $this->config['field']);
-            if ($spec) {
-                foreach ($spec as $k => $v) {
-                    $data['update'][$v[0]]['remote'] = Dever::url($v[1], ['value' => '', 'table' => $this->db->config['load'], 'id' => false]);
-                    $result = Dever::call($v[1], [$v[3], $v[4], $this->info['id']]);
-                    if ($result) {
-                        $data['field'][$v[2]] = $result;
-                    }
-                }
-            }
-        } elseif ($value) {
-            $field = [];
-            if (isset($this->config['field']) && $this->config['field']) {
-                foreach ($this->config['field'] as $k => $v) {
-                    if (isset($v['field'])) {
-                        $field[$v['field']] = $v;
-                        if (!isset($field[$v['field']]['index'])) {
-                            $field[$v['field']]['index'][] = $k;
-                        }
-                    } else {
-                        $field[$k] = $v;
-                    }
-                }
-            }
-            foreach ($value as $k => &$v) {
-                $this->setInfo($v, $data, $remote, $show, $source, $default, 2, $field);
-                $option[$k] = $data['option'];
-            }
-            if (isset($data['reset'])) {
-                foreach ($data['reset'] as $k1 => $v1) {
-                    if (isset($data['option'][$k1])) {
-                        unset($data['option'][$k1]);
-                        $data['field'][$k1] = $v1;
-                    }
-                }
-            }
-        } else {
-            if ($remote) {
-                $info = [];
-                foreach ($remote as $k => $v) {
-                    $data['update'][$v[0]]['remote'] = Dever::url($v[1], ['value' => '', 'table' => $this->db->config['load'], 'id' => false]);
-                    if (isset($v[2]) && isset($data['option'][$v[2]]) && $data['option'][$v[2]] && $m = Dever::issets($data['option'][$v[2]][0], 'id')) {
-                        $path = 'api';
-                        if (strstr($v[1], 'mapi')) $path = 'manage';
-                        $result = Dever::call($v[1], [$m, $this->db->config['load'], false], $path);
-                        if ($result) {
-                            $this->setUpdate($info, $data, $result);
-                        }
-                    }
-                }
-            }
-            if ($show) {
-                foreach ($show as $k => $v) {
-                    $data['update'][$v[0]]['show'] = true;
-                }
-            }
-        }
-        
-        $data['desc'] = $this->config['desc'] ?? '';
-        $data['drag'] = $this->config['drag'] ?? false;
-        $this->layout($data);
-        $data['control'] = $this->control($data);
-        $this->tab($data, 'step');
-        if (!$data['step']) {
-            $this->tab($data);
-        }
-        return $data;
-    }
-
-    private function setInfo(&$info, &$data, $remote, $show, $source, $default, $type = 1, $field = [])
-    {
-        if ($source) {
-            foreach ($source as $k => $v) {
-                $t = [];
-                foreach ($v as $v1) {
-                    $t[] = $info[$v1] ?? '';
-                }
-                $info[$k] = implode(',', $t);
-            }
-        }
-        foreach ($info as $k => $v) {
-            if ($v === null) {
-                $v = '';
-            }
-            if (isset($data['field'][$k])) {
-                if (is_array($data['field'][$k])) {
-                    if ($v) {
-                        $v = explode(',', $v);
-                        foreach ($v as $k1 => $v1) {
-                            if (is_numeric($v1)) {
-                                $v[$k1] = (float) $v1;
-                            }
-                        }
-                    } else {
-                        $v = [];
-                    }
-                    $info[$k] = $v;
-                }
-                # 处理一下select,后续优化
-                if (isset($field[$k]) && isset($field[$k]['type']) && $field[$k]['type'] == 'select' && !$v) {
-                    $v = $info[$k] = '';
-                }
-
-                if (isset($field[$k]) && isset($field[$k]['update'])) {
-                    $v = $field[$k]['update'];
-                }
-                if ($k == 'cdate') {
-                   $field[$k]['type'] = 'date';
-                }
-                if (isset($field[$k]) && isset($field[$k]['type']) && $field[$k]['type'] == 'date' && $v) {
-                    $v = date('Y-m-d H:i:s', $v);
-                }
-                if ($type == 1) {
-                    $data['field'][$k] = $v;
-                }
-                if (isset($remote[$k])) {
-                    $data['update'][$remote[$k][0]]['remote'] = Dever::url($remote[$k][1], ['value' => '', 'table' => $this->db->config['load'], 'id' => false]);
-                    if ($field[$k]['type'] == 'cascader' && !isset($field[$k]['option'])) {
-                        
-                    } else {
-                        $path = 'api';
-                        if (strstr($remote[$k][1], 'mapi')) $path = 'manage';
-                        $result = Dever::call($remote[$k][1], [$v, $this->db->config['load'], $info['id'] ?? false], $path);
-                        if ($result) {
-                            $this->setUpdate($info, $data, $result);
-                        }
-                    }
-                }
-                if (isset($show[$k])) {
-                    $data['update'][$show[$k][0]]['show'] = $this->getShow($show[$k][1], $info);
-                    $info[$k] = $data['update'][$show[$k][0]]['show'];
-                }
-            }
-            if (isset($field[$k]) && isset($field[$k]['index'])) {
-                foreach ($field[$k]['index'] as $v1) {
-                    $info[$v1] = $v;
-                }
-            }
-        }
-        if ($default) {
-            foreach ($default as $k => $v) {
-                $data['update'][$v[0]]['value'] = $this->getShow($v[1], $info);
-                $info[$k] = $data['field'][$k] = $data['update'][$v[0]]['value'];
-            }
-        }
-    }
-
-    private function setUpdate(&$info, &$data, $result, $remote = [])
-    {
-        foreach ($data['update'] as $k => $v) {
-            if (isset($result[$v['key']])) {
-                # 批量更新时,默认数据需要重置
-                if (!isset($data['reset'][$v['key']])) {
-                    $data['reset'][$v['key']] = $data['field'][$v['key']];
-                }
-                if (isset($result[$v['key']]['option'])) {
-                    $data['option'][$v['key']] = $result[$v['key']]['option'];
-                    unset($result[$v['key']]['option']);
-                }
-                if (empty($data['field'][$v['key']]) && isset($result[$v['key']]['value'])) {
-                    if (is_array($data['field'][$v['key']]) && !is_array($result[$v['key']]['value'])) {
-                        $data['field'][$v['key']] = explode(',', $result[$v['key']]['value']);
-                    } else {
-                        $data['field'][$v['key']] = $result[$v['key']]['value'];
-                    }
-                }
-                if (isset($result[$v['key']]['set']) && $info) {
-                    $info = array_merge($info, $result[$v['key']]['set']);
-                }
-                $data['update'][$k] = array_merge($data['update'][$k], $result[$v['key']]);
-            }
-        }
-    }
-
-    private function control(&$data)
-    {
-        $result = [];
-        if (isset($this->config['control']) && $this->config['control']) {
-            foreach ($this->config['control'] as $k => $v) {
-                if (is_string($v)) {
-                    parse_str($v, $v);
-                }
-                if (strstr($k, ',')) {
-                    $k = explode(',', $k);
-                    foreach ($k as $k2) {
-                        if (isset($data['update'])) $this->controlShow($data, $k2, $v);
-                        $result[$k2] = $v;
-                    }
-                } else {
-                    if (isset($data['update'])) $this->controlShow($data, $k, $v);
-                    $result[$k] = $v;
-                }
-            }
-        }
-        return $result;
-    }
-
-    private function controlShow(&$data, $k, $v)
-    {
-        foreach ($data['update'] as $k1 => $v1) {
-            if ($v1['key'] == $k) {
-                $show = true;
-                foreach ($v as $k2 => $v2) {
-                    if (is_array($v2)) {
-                        $temp = false;
-                        foreach ($v2 as $k3 => $v3) {
-                            if (is_array($data['field'][$k2]) && in_array($v3, $data['field'][$k2])) {
-                                $temp = true;
-                            } elseif ($data['field'][$k2] == $v3) {
-                                $temp = true;
-                            }
-                        }
-                        $show = $temp;
-                    } else {
-                        if (is_array($data['field'][$k2]) && !in_array($v2, $data['field'][$k2])) {
-                            $show = false;
-                        } elseif ($data['field'][$k2] != $v2) {
-                            $show = false;
-                        }
-                    }
-                }
-                $data['update'][$k1]['show'] = $show;
-                if ($show == false && isset($data['update'][$k1]['field'])) {
-                    # 对重新命名的字段删除
-                    if ($data['update'][$k1]['type'] == 'editor') {
-                        $data['field'][$v1['key']] = '';
-                    } else {
-                        unset($data['field'][$v1['key']]);
-                    }
-                }
-            }
-        }
-    }
-
-    private function tab(&$data, $type = 'tab')
-    {
-        $field = $this->input('field', '');
-        $data[$type] = [];
-        //if (empty($data['layout']) && !$field && isset($this->config[$type])) {
-        if (empty($data['layout']) && isset($this->config[$type])) {
-            foreach ($this->config[$type] as $k => $v) {
-                if (is_string($v)) {
-                    $field = [];
-                    $data[$type][] = array
-                    (
-                        'name' => $k,
-                        'update' => $this->getUpdate($v, $data['update'], $field),
-                        'field' => $field,
-                    );
-                } else {
-                    $field = [];
-                    $result = [];
-                    $result['name'] = $k;
-                    foreach ($v as $v1) {
-                        $result['layout'][] = $this->getUpdate($v1, $data['update'], $field);
-                    }
-                    $result['field'] = $field;
-                    $data[$type][] = $result;
-                }
-            }
-            $data['update'] = [];
-        }
-    }
-
-    private function layout(&$data)
-    {
-        $field = $this->input('field', '');
-        $data['layout'] = [];
-        if (isset($this->config['layout'])) {
-            foreach ($this->config['layout'] as $k => $v) {
-                $field = [];
-                $data['layout'][] = $this->getUpdate($v, $data['update'], $field, '100%');
-            }
-            $data['update'] = [];
-        }
-    }
-
-    private function getUpdate($set, $update, &$field, $width = '')
-    {
-        $result = [];
-        if (is_string($set)) {
-            $set = explode(',', $set);
-            foreach ($set as $k => $v) {
-                foreach ($update as $value) {
-                    if ($value['key'] == $v) {
-                        $width && $value['width'] = $width;
-                        $result[] = $value;
-                        $field[] = $v;
-                    }
-                }
-            }
-        } else {
-            foreach ($set as $k => $v) {
-                foreach ($update as $value) {
-                    if ($value['key'] == $k) {
-                        $width && $value['width'] = $width;
-                        $result[] = array('span' => $v, 'update' => [$value]);
-                        $field[] = $k;
-                    }
-                }
-            }
-        }
-        return $result;
-    }
-
-    public function do_commit(){}
-    public function do()
-    {
-        $this->checkFunc();
-        $update = [];
-        $this->setting('field', $update, true, 'text');
-        if (empty($this->config['upAdmin'])) {
-            $this->config['upAdmin'] = false;
-        }
-        if ($update) {
-            $data = $other = $sku = [];
-            $input = Dever::input();
-            $id = false;
-            if (isset($input['id']) && $input['id'] > 0) {
-                $id = $input['id'];
-            }
-            $control = $this->control($data);
-            foreach ($update as $k => $v) {
-                if (isset($input[$v['key']])) {
-                    if (isset($v['rules'])) {
-                        $this->checkRules($v, $input[$v['key']]);
-                    }
-                    if ($v['type'] == 'sku') {
-                        if (isset($input[$v['key'] . '_spec']) && isset($input[$v['key']])) {
-                            $sku[$v['key']] = [$v['where'], $v['content']['field'], $v['spec'], $v['spec_field'], $input[$v['key'] . '_spec'], $input[$v['key']]];
-                        }
-                        
-                    } elseif (strpos($v['key'], '/') && $v['type'] != 'hidden') {
-                        if (isset($v['field'])) {
-                            $value = $input[$v['key']] ?? false;
-                            if (strpos($v['key'], '#')) {
-                                $v['key'] = str_replace('#', '', $v['key']);
-                            }
-                            $other_id = $input[$v['key'] . '_id'] ?? 0;
-                            $value = array
-                            (
-                                0 => ['id' => $other_id, $v['field'] => $value]
-                            );
-                            if (isset($other[$v['key']])) {
-                                $other[$v['key']][3][0] += $value[0];
-                            } else {
-                                $other[$v['key']] = [$v['where'], false, false, $value];
-                            }
-                        } else {
-                            $other[$v['key']] = [$v['where'], $v['content']['field'], $v['content']['drag'], $input[$v['key']]];
-                        }
-                    } else {
-                        $this->doData($data, $v['key'], $input[$v['key']], $this->config['field'], $control);
-                    }
-                } elseif ($id) {
-                    $data[$v['key']] = '';
-                }
-                if (isset($data[$v['key']]) && !$data[$v['key']] && isset($v['empty']) && !$v['empty']) {
-                    unset($data[$v['key']]);
-                }
-            }
-            if (!$data && !$other && !$sku) {
-                Dever::error('无效数据');
-            }
-            if ($data) {
-                if (isset($this->config['check']) && $this->config['check']) {
-                    $this->exists($this->db, $this->config['check'], $id, $data, $this->config['field']);
-                }
-                $result = $this->start($id, $data);
-                if ($result == 'end') {
-                    return ['msg' => '操作成功', 'upAdmin' => $this->config['upAdmin']];
-                }
-                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 {
-                    $id = $this->db->insert($data);
-                }
-            }
-            if (!$id) {
-                Dever::error('操作失败');
-            }
-            $this->other($id, $data, $other);
-            $this->sku($id, $data, $sku);
-            $this->end($id, $data);
-            return ['msg' => '操作成功', 'upAdmin' => $this->config['upAdmin']];
-        }
-    }
-
-    private function doData(&$data, $key, $value, $field = [], $control = [])
-    {
-        if (is_array($value)) {
-            # 用最傻的办法做,往往是最好的。。
-            if (isset($value[0]) && !is_array($value[0])) {
-                $value = implode(',', $value);
-            } else {
-                $value = Dever::json_encode($value);
-            }
-        }
-        if (isset($field[$key]) && isset($field[$key]['field'])) {
-            if ($control && isset($control[$key])) {
-                # 如果有重命名字段并且是控制项,需要单独设置
-                $state = true;
-                foreach ($control[$key] as $k => $v) {
-                    if ($data[$k] != $v) {
-                        $state = false;
-                    }
-                }
-                if ($state) {
-                    $key = $field[$key]['field'];
-                }
-            } else {
-                $key = $field[$key]['field'];
-            }
-        }
-        if ($value && isset($field[$key]) && $handle = Dever::issets($field[$key], 'handle')) {
-            $value = Dever::call($handle, [$value]);
-            if (is_array($value) && isset($value[$key])) {
-                foreach ($value as $k => $v) {
-                    $data[$k] = trim($v);
-                }
-                return;
-            }
-        } elseif (isset($field[$key]) && isset($field[$key]['type']) && $field[$key]['type'] == 'date' && $value) {
-            $value = \Dever\Helper\Date::mktime($value);
-        }
-        /*
-        if (empty($data[$key])) {
-            $data[$key] = trim($value);
-        }
-        */
-        $data[$key] = trim($value);
-    }
-
-    private function exists($db, $check, $id, $data, $field)
-    {
-        $check = explode(',', $check);
-        $where = [];
-        $name = [];
-        foreach ($check as $k => $v) {
-            if (isset($data[$v]) && $data[$v]) {
-                if (isset($field[$v]) && isset($field[$v]['name'])) {
-                    $n = $field[$v]['name'];
-                } elseif (isset($db->config['struct'][$v])) {
-                    $n = $db->config['struct'][$v]['name'];
-                } else {
-                    $n = $v;
-                }
-                $where[$v] = $data[$v];
-                $name[] = $n;
-            }
-        }
-        if ($where) {
-            if ($id) {
-                $where['id'] = ['!=', $id];
-            }
-            $info = $db->find($where);
-            if ($info) {
-                $name = implode('、', $name);
-                Dever::error($name . '已存在');
-            }
-        }
-    }
-
-    private function start($id, &$data)
-    {
-        if (isset($this->config['start']) && $this->config['start']) {
-            $data['id'] = $id;
-            if (is_array($this->config['start'])) {
-                $result = $data;
-                foreach ($this->config['start'] as $k => $v) {
-                    $result = Dever::call($v, [$this->db, $result]);
-                }
-            } else {
-                $result = Dever::call($this->config['start'], [$this->db, $data]);
-            }
-            if ($result) {
-                if ($result == 'end') {
-                    return $result;
-                }
-                if (is_object($result)) {
-                    $this->db = $result;
-                } else {
-                    $data = $result;
-                }
-            }
-        }
-    }
-
-    private function end($id, $data)
-    {
-        if (isset($this->config['end']) && $this->config['end']) {
-            $data['id'] = $id;
-            if (is_array($this->config['end'])) {
-                foreach ($this->config['end'] as $k => $v) {
-                    Dever::call($v, [$this->db, $data]);
-                }
-            } else {
-                Dever::call($this->config['end'], [$this->db, $data]);
-            }
-        }
-    }
-
-    private function other($rid, $data, $other)
-    {
-        if ($other) {
-            foreach ($other as $k => $v) {
-                if (strpos($k, '#')) {
-                    $k = str_replace('#', '', $k);
-                }
-                $set = new Update($k, false);
-                $common = $v[0];
-                $update = $v[1];
-                $drag = $v[2];
-                $input = $v[3];
-                $value = [];
-                foreach ($input as $k1 => $v1) {
-                    if (isset($v1['id']) && $v1['id']) {
-                        $value['id'] = $v1['id'];
-                    }
-                    foreach ($common as $k2 => $v2) {
-                        if (!is_array($v2)) {
-                            if ($v2 == 'id') {
-                                $value[$k2] = $rid;
-                            } elseif (isset($data[$v2])) {
-                                $value[$k2] = $data[$v2];
-                            } else {
-                                $value[$k2] = $v2;
-                            }
-                        }
-                    }
-                    if ($update) {
-                        foreach ($update as $k2 => $v2) {
-                            if (isset($v1[$k2])) {
-                                $this->doData($value, $k2, $v1[$k2], $set->config['field']);
-                            } else {
-                                $value[$k2] = '';
-                            }
-                        }
-                    } else {
-                        $value += $v1;
-                    }
-                    if ($drag) {
-                        $value[$drag] = $k1+1;
-                    }
-                    $db = Dever::db($k);
-                    if (isset($db->config['manage']['update']['check'])) {
-                        $this->exists($db, $db->config['manage']['update']['check'], $value['id'], $value, $db->config['manage']['update']['field']);
-                    }
-                    if (isset($value['id']) && $value['id'] > 0) {
-                        $id = $value['id'];
-                        unset($value['id']);
-                        $db->update($id, $value);
-                    } else {
-                        $db->insert($value);
-                    }
-                }
-            }
-        }
-    }
-
-    private function sku($rid, $data, $sku)
-    {
-        if ($sku) {
-            if (isset($data['spec_type']) && $data['spec_type'] <= 2) {
-                return;
-            }
-            foreach ($sku as $k => $v) {
-                if (strpos($k, '#')) {
-                    $k = str_replace('#', '', $k);
-                }
-                $common = $v[0];
-                $update = $v[1];
-                $spec_table = $v[2];
-                $spec_value_table = $spec_table . '_value';
-                $spec_field = $v[3];
-                $spec = $v[4];
-                $input = $v[5];
-                $spec_value = [];
-                Dever::db($spec_table)->update([$spec_field => $rid], ['state' => 2]);
-                Dever::db($spec_value_table)->update([$spec_field => $rid], ['state' => 2]);
-                foreach ($spec as $k1 => &$v1) {
-                    $spec_data = [];
-                    $spec_data['state'] = 1;
-                    $spec_data[$spec_field] = $rid;
-                    $spec_data['name'] = $v1['name'];
-                    $spec_data['sort'] = $k1+1;
-                    if (isset($v1['id']) && $v1['id']) {
-                        Dever::db($spec_table)->update($v1['id'], $spec_data);
-                    } else {
-                        $v1['id'] = Dever::db($spec_table)->insert($spec_data);
-                    }
-                    if ($v1['id']) {
-                        foreach ($v1['value'] as $k2 => &$v2) {
-                            $spec_value_data = [];
-                            $spec_value_data['state'] = 1;
-                            $spec_value_data[$spec_field] = $rid;
-                            $spec_value_data['spec_id'] = $v1['id'];
-                            $spec_value_data['value'] = $v2['value'] ?? $v2['name'];
-                            $spec_value_data['pic'] = $v2['pic'] ?? '';
-                            $spec_value_data['sort'] = $k2+1;
-                            $spec_value_data['is_checked'] = $v2['checked'] == 'true' ? 1 : 2;
-                            if (isset($v2['id']) && $v2['id']) {
-                                Dever::db($spec_value_table)->update($v2['id'], $spec_value_data);
-                            } else {
-                                $v2['id'] = Dever::db($spec_value_table)->insert($spec_value_data);
-                            }
-                            $spec_value[$v1['key']][$spec_value_data['value']] = [$v2['id'], $spec_data['sort']];
-                        }
-                    }
-                }
-                Dever::db($spec_table)->delete([$spec_field => $rid, 'state' => 2]);
-                Dever::db($spec_value_table)->delete([$spec_field => $rid, 'state' => 2]);
-                Dever::db($k)->update([$spec_field => $rid], ['state' => 2]);
-                foreach ($input as $k1 => $v1) {
-                    $value = [];
-                    if (isset($v1['id'])) {
-                        $value['id'] = $v1['id'];
-                    }
-                    foreach ($common as $k2 => $v2) {
-                        if (!is_array($v2)) {
-                            if ($v2 == 'id') {
-                                $value[$k2] = $rid;
-                            } elseif (isset($data[$v2])) {
-                                $value[$k2] = $data[$v2];
-                            } else {
-                                $value[$k2] = $v2;
-                            }
-                        }
-                    }
-                    foreach ($update as $k2 => $v2) {
-                        if (isset($v1[$k2])) {
-                            if (is_array($v1[$k2])) {
-                                $v1[$k2] = implode(',', $v1[$k2]);
-                            }
-                            $value[$k2] = $v1[$k2];
-                        }
-                    }
-                    $value['key'] = [];
-                    foreach ($v1 as $k2 => $v2) {
-                        if (isset($spec_value[$k2]) && isset($spec_value[$k2][$v2])) {
-                            $value['key'][$spec_value[$k2][$v2][1]] = $spec_value[$k2][$v2][0];
-                        }
-                    }
-                    if ($value['key']) {
-                        $value['key'] = implode(',' , $value['key']);
-                    }
-                    $value['state'] = 1;
-                    if (isset($value['id']) && $value['id'] > 0) {
-                        $id = $value['id'];
-                        unset($value['id']);
-                        Dever::db($k)->update($id, $value);
-                    } else {
-                        Dever::db($k)->insert($value);
-                    }
-                }
-                Dever::db($k)->delete([$spec_field => $rid, 'state' => 2]);
-            }
-        }
-    }
-}

+ 0 - 21
api/Page/View.php

@@ -1,21 +0,0 @@
-<?php namespace Manage\Api\Page;
-use Dever;
-use Manage\Lib\Page;
-# 详情页
-class View extends Page
-{
-    public function __construct($load = '', $input = true, $id = false)
-    {
-        parent::__construct('view', $load, $input);
-    }
-    public function get()
-    {
-        $this->checkFunc();
-        if (is_string($this->config)) {
-            $data = Dever::call($this->config, [$this->info]);
-        } else {
-            $data = $this->config;
-        }
-        return $data;
-    }
-}

+ 1 - 1
index.php

@@ -1,5 +1,5 @@
 <?php
-define('DEVER_APP_NAME', 'manage');
+define('DEVER_APP_NAME', 'Manage');
 define('DEVER_APP_LANG', '管理平台');
 define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
 include(DEVER_APP_PATH . '../../boot.php');