diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php index 845964b..2b99927 100644 --- a/app/admin/controller/Admin.php +++ b/app/admin/controller/Admin.php @@ -3,9 +3,11 @@ namespace app\admin\controller; use app\model\Admin as AppAdmin; +use app\model\AdminGroup; use app\model\AdminLog; use app\UploadFiles as AppUploadFiles; use think\facade\View; +use think\helper\Str; class Admin extends Common { @@ -80,12 +82,64 @@ class Admin extends Common public function create() { + + $admin_group_list = AdminGroup::select(); + + View::assign('group_list',$admin_group_list); + return View::fetch(); } public function save() { - + $post_data = $this->request->post(); + + $admin_model = AppAdmin::where('account',$post_data['account'])->find(); + + if(!empty($admin_model)){ + $this->error('管理员已存在'); + } + + if(empty($post_data['password'])){ + $post_data['password'] = '123456'; + } + + + $post_data['salt'] = Str::random(6); + + $post_data['password'] = md5($post_data['password'].$post_data['salt']); + + AppAdmin::create($post_data); + + $this->success('添加成功','index'); + + } + + public function editAccount($id) + { + $model_admin = AppAdmin::find($id); + $admin_group_list = AdminGroup::select(); + View::assign('group_list',$admin_group_list); + View::assign('admin',$model_admin); + return View::fetch(); + } + + public function updateAccount() + { + $post_data = $this->request->post(); + + if(!empty($post_data['password'])){ + $post_data['salt'] = Str::random(6); + + $post_data['password'] = md5($post_data['password'].$post_data['salt']); + }else{ + unset($post_data['password']); + } + + AppAdmin::update($post_data); + + $this->success('修改成功','index'); + } public function adminLog() @@ -97,4 +151,12 @@ class Admin extends Common return View::fetch(); } + + public function delete($id) + { + AppAdmin::destroy($id); + + + return json_message(); + } } diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php new file mode 100644 index 0000000..4a2b569 --- /dev/null +++ b/app/admin/controller/User.php @@ -0,0 +1,84 @@ +getData('group_id'))){ - return '未分组'; + return []; } + + return AdminGroup::where('id',$this->getData('group_id'))->cache(1)->find(); } + } diff --git a/app/model/User.php b/app/model/User.php new file mode 100644 index 0000000..85c8b87 --- /dev/null +++ b/app/model/User.php @@ -0,0 +1,13 @@ + + @@ -7,15 +8,16 @@ 基本资料 {include file="common/_require"} + - +
{include file="common/_header"} - + {include file="common/left_admin_manage"} - +
- +
@@ -27,25 +29,42 @@
- 管理员管理 + 添加管理员
登录账号
- +
昵称
- +
密码
- + +
+
+
+
管理组
+
+ +
+ 不设置分组,帐号拥有所有权限 +
@@ -55,7 +74,8 @@
上传
- +
@@ -71,36 +91,39 @@
- - + + {include file="common/_footer"}
+ \ No newline at end of file diff --git a/view/admin/admin/edit_account.html b/view/admin/admin/edit_account.html new file mode 100644 index 0000000..4d65524 --- /dev/null +++ b/view/admin/admin/edit_account.html @@ -0,0 +1,141 @@ + + + + + + + 应用管理 + {include file="common/_require"} + + + +
+ {include file="common/_header"} + + {include file="common/left_admin_manage"} + +
+ +
+ +
+
+
+
+ 添加管理员 +
+ + +
+
登录账号
+
+ +
+
+
+
昵称
+
+ +
+
+
+
密码
+
+ +
+ 留空不修改 +
+
+
+
+
管理组
+
+ +
+ 不设置分组,帐号拥有所有权限 +
+
+
+
+
头像
+
+
+
上传
+
+
+ {$admin.avatar} +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ + + {include file="common/_footer"} + + +
+ + \ No newline at end of file diff --git a/view/admin/admin/index.html b/view/admin/admin/index.html index 90474a1..fc7e99a 100644 --- a/view/admin/admin/index.html +++ b/view/admin/admin/index.html @@ -44,16 +44,16 @@ {volist name='$list' id='vo'} - + {$vo.id} {$vo.account} {$vo.nickname} - {$vo.group} + {$vo.group.name|default="未分组"}
- 编辑 -
+ 编辑 +
删除
@@ -74,6 +74,23 @@ {include file="common/_footer"} + +
diff --git a/view/admin/admin_group/edit.html b/view/admin/admin_group/edit.html index 5de9c59..1271c02 100644 --- a/view/admin/admin_group/edit.html +++ b/view/admin/admin_group/edit.html @@ -33,6 +33,7 @@
分组名称
+
@@ -40,7 +41,12 @@
分组权限
{volist name='permission_list' id='vo'} + {if condition="empty($vo->getData('name'))" } + + {else /} + + {/if} {/volist}
diff --git a/view/admin/login/index.html b/view/admin/login/index.html index 31a27ba..ff261fc 100644 --- a/view/admin/login/index.html +++ b/view/admin/login/index.html @@ -54,7 +54,7 @@
- +
@@ -91,6 +91,7 @@ location.href = '{:url("admin/Index/index")}' }, 1200); }else{ + $('.captcha').click() layer.msg(result.msg); } })