rabin 1 rok pred
rodič
commit
67b7240e85
7 zmenil súbory, kde vykonal 84 pridanie a 6 odobranie
  1. 1 1
      api/Admin.php
  2. 3 3
      api/Login.php
  3. 3 1
      lib/Group.php
  4. 11 0
      lib/Page.php
  5. 60 0
      lib/System.php
  6. 5 0
      table/manage/admin.php
  7. 1 1
      table/manage/group_manage.php

+ 1 - 1
api/Admin.php

@@ -6,7 +6,7 @@ class Admin extends Auth
     public function info()
     {
         $this->user['module']['show'] = true;
-        $this->user['module']['id'] = $this->user['select']['module_id'];
+        $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';

+ 3 - 3
api/Login.php

@@ -47,7 +47,7 @@ class Login
                 $insert['name'] = Str::hide($where['mobile']);
                 $insert['mobile'] = $where['mobile'];
                 $insert['role'] = 1;
-                $insert += Dever::load('common')->createPwd($password);
+                $insert += Dever::load('common', 'manage')->createPwd($password);
                 $id = $db->insert($insert);
                 $admin = $db->find($id);
             } else {
@@ -60,7 +60,7 @@ class Login
         if ($admin['status'] == 2) {
             Dever::error('登录失败,账户已被封禁');
         }
-        if (Dever::load('common')->hash($password, $admin['salt']) != $admin['password']) {
+        if (Dever::load('common', 'manage')->hash($password, $admin['salt']) != $admin['password']) {
             Dever::error('登录失败,账户密码无效');
         }
         # 根据角色获取module_id
@@ -104,7 +104,7 @@ class Login
         if (!$module_id || !$data_id) {
             Dever::error('登录失败,账户无效');
         }
-        return Dever::load('common')->token($admin['id'], $admin['mobile'], $system['partition'], $system['id'], $info['id'], $module_id, $data_id);
+        return Dever::load('common', 'manage')->token($admin['id'], $admin['mobile'], $system['partition'], $system['id'], $info['id'], $module_id, $data_id);
     }
     private function checkCode()
     {

+ 3 - 1
lib/Group.php

@@ -16,6 +16,7 @@ class Group extends Auth
         return $result;
     }
 
+    # 后续废弃,转移到system中
     public function update($data)
     {
         if ($data['mobile']) {
@@ -35,7 +36,8 @@ class Group extends Auth
             }
         }
     }
-
+    
+    # 后续废弃,转移到system中
     # 创建账户
     public function createUser($module, $data_id, $name, $mobile, $password, $state = false)
     {

+ 11 - 0
lib/Page.php

@@ -210,6 +210,10 @@ class Page extends Auth
                 }
             }
             if ($field) {
+                if (is_string($field) && (strstr($field, '{') || strstr($field, '%7B'))) {
+                    $field = htmlspecialchars_decode($field);
+                    $field = Dever::json_decode($field);
+                }
                 if (is_array($field)) {
                     if (isset($field['param'])) {
                         if (isset($field['param']['set'])) {
@@ -272,6 +276,9 @@ class Page extends Auth
                 $value['remote'] = Dever::url($value['remote']);
             }
             if ($type == 'show') {
+                if (!isset($value['tip'])) {
+                    $value['tip'] = true;
+                }
                 $in = array('switch', 'select', 'input');
                 if (in_array($value['type'], $in)) {
                     $value['func'] = $this->getFunc('list_edit_' . $value['key'], '列表更新-' . $value['name'], 104);
@@ -329,6 +336,7 @@ class Page extends Auth
         if (isset($value['upload']) && Dever::project('upload')) {
             $value['url'] = Dever::url('upload/save.act', array('id' => $value['upload']));
             $value['config'] = Dever::load('save', 'upload')->get($value['upload']);
+            $value['set'] = Dever::url('image/manage.set', array('id' => $value['upload'], 'wh' => $value['wh'] ?? '500*500'));
             if (isset($value['multiple']) && $value['multiple']) {
                 $value['limit'] = 10;
             } else {
@@ -390,6 +398,9 @@ class Page extends Auth
             if ($value['type'] == 'text') {
                 $value['type'] = 'select';
             }
+            if (!is_array($value['value']) && $value['value']) {
+                $value['value'] = (float) $value['value'];
+            }
         }
     }
 

+ 60 - 0
lib/System.php

@@ -1,6 +1,7 @@
 <?php namespace Manage\Lib;
 use Dever;
 use Dever\Project;
+use Dever\Helper\Str;
 class System extends Auth
 {
     public function getTree()
@@ -15,4 +16,63 @@ class System extends Auth
         );
         return $result;
     }
+
+    # 创建管理员
+    public function update($data)
+    {
+        if (isset($data['mobile']) && $data['mobile']) {
+            $system = Dever::db('system', 'manage')->find(array('key' => $data['system']));
+            $data['system_id'] = $system['id'];
+            $data['info_id'] = $data['id'];
+            $data['partition'] = $system['partition'];
+            $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($data));
+            $info = $db->find(1);
+            if (!$info) {
+                $password = '123456';
+                $insert['name'] = Str::hide($data['mobile']);
+                $insert['mobile'] = $data['mobile'];
+                $insert['role'] = 1;
+                $insert += Dever::load('common', 'manage')->createPwd($password);
+                $db->insert($insert);
+            }
+        }
+    }
+
+    # 创建账户
+    public function createUser($data, $state = true)
+    {
+        if (isset($data['mobile']) && $data['mobile'] && isset($data['password']) && $data['password']) {
+            $info = Dever::db($data['table'])->find($data['id']);
+            if ($info) {
+                $system = Dever::db('system', 'manage')->find(array('key' => $data['system']));
+                $set['system_id'] = $system['id'];
+                $set['info_id'] = 1;
+                $set['partition'] = $system['partition'];
+                $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($set));
+
+                $user = $db->find(array('mobile' => $data['mobile']));
+                if ($state && $user) {
+                    Dever::error('手机号' . $data['mobile'] . '已存在,请更换手机号');
+                }
+
+                $module = Dever::db('system_module', 'manage')->find(array('key' => $data['module'], 'system' => 'group'));
+                $insert['name'] = $info['name'];
+                $insert['mobile'] = $data['mobile'];
+                $insert['role'] = 2;
+                $insert['module_data'] = $module['id'] . '-' . $info['id'];
+                $insert += Dever::load('common', 'manage')->createPwd($data['password']);
+                if (!$user) {
+                    $db->insert($insert);
+                } else {
+                    $module_data = $insert['module_data'];
+                    unset($insert['module_data']);
+                    if (!strstr($user['module_data'], $module_data)) {
+                        $insert['module_data'] = $module_data . ',' . $user['module_data'];
+                    }
+                    $db->update($user['id'], $insert);
+                }
+            }
+        }
+        return $data;
+    }
 }

+ 5 - 0
table/manage/admin.php

@@ -279,6 +279,7 @@ return array
 
             password:文本密码框
             textarea:多行文本
+            autosize:true 高度是否自适应,也可以传入数组,array('minRows' => 2, 'maxRows' => 6)
             rows:多行文本的行数,默认为2
             editor:编辑器
 
@@ -466,6 +467,10 @@ return array
                 'multiple' => false,
                 # 提示
                 'tip' => '',
+                # 展示类型 默认为list 列表 input 可输入地址 pic图片模式
+                'style' => 'input',
+                # 上传后影响的字段 这个目前仅有name字段
+                'upload_name' => 'name',
             ),*/
         ),
 

+ 1 - 1
table/manage/group_manage.php

@@ -65,6 +65,6 @@ return array
             'status' => 'radio',
         ),
         'check' => 'key',
-        'end' => 'group.update',
+        'end' => 'manage/system.update?system=group',
     ),
 );