From 33603d89b3d2e2523eed00bb7685a626071f03a4 Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Fri, 11 Nov 2016 12:07:36 +0800 Subject: [PATCH] =?UTF-8?q?added=20=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9=E5=92=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/User.php | 78 +++++++++++++++++++++--- application/admin/view/public/base.html | 1 + application/config.php | 2 +- public/admin/static/js/template/form.js | 25 ++++++++ public/admin/static/js/template/table.js | 2 +- 5 files changed, 99 insertions(+), 9 deletions(-) diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index 9264da8..60a4341 100644 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -17,10 +17,17 @@ class User extends Base { $dataObj = \app\admin\model\User::all(); foreach ( $dataObj as $value ){ $userInfo = $value->toArray(); - $userData = UserData::get(['uid' => $userInfo[$this->primaryKey]])->toArray(); - $userInfo['loginTimes'] = $userData['loginTimes']; - $userInfo['lastLoginTime'] = $userData['lastLoginTime']; - $userInfo['lastLoginIp'] = $userData['lastLoginIp']; + $userData = UserData::get(['uid' => $userInfo[$this->primaryKey]]); + if( !is_null($userData) ){ + $userData->toArray(); + $userInfo['loginTimes'] = $userData['loginTimes']; + $userInfo['lastLoginTime'] = $userData['lastLoginTime']; + $userInfo['lastLoginIp'] = $userData['lastLoginIp']; + }else{ + $userInfo['loginTimes'] = 0; + $userInfo['lastLoginTime'] = 0; + $userInfo['lastLoginIp'] = 0; + } $data[] = $userInfo; } $table = [ @@ -128,7 +135,7 @@ class User extends Base { }else{ $userObj->status = 1; $userObj->save(); - $this->success('操作成功', url($this->url)); + $this->success('操作成功', url('User/index')); } } } @@ -142,7 +149,7 @@ class User extends Base { }else{ $userObj->status = 0; $userObj->save(); - $this->success('操作成功', url($this->url)); + $this->success('操作成功', url('User/index')); } } } @@ -196,6 +203,63 @@ class User extends Base { } public function add(){ - + if( $this->request->isPost() ){ + $menuModel = new \app\admin\model\User(); + $result = $menuModel->allowField(true)->validate( + [ + 'username' => 'require', + ],[ + 'username.require' => '用户名不能为空', + ] + )->save($this->request->post()); + if(false === $result){ + $this->error($menuModel->getError()); + }else{ + $this->success('操作成功!', url('User/index')); + } + }else{ + $form = [ + 'formTitle' => $this->menuInfo['name'], + 'tempType' => 'add', + 'formAttr' => [ + 'target' => url('User/add'), + 'formId' => 'add-user-form', + 'backUrl' => url('User/index'), + ], + 'formList' => [ + [ + 'module' => 'text', + 'description' => '', + 'info' => '用户名称:', + 'attr' => [ + 'name' => 'username', + 'value' => '', + 'placeholder' => '' + ] + ], + [ + 'module' => 'text', + 'description' => '', + 'info' => '用户昵称:', + 'attr' => [ + 'name' => 'nickname', + 'value' => '', + 'placeholder' => '' + ] + ], + [ + 'module' => 'password', + 'description' => '', + 'info' => '用户密码[默认:123123]:', + 'attr' => [ + 'name' => 'password', + 'value' => '123123', + 'placeholder' => '' + ] + ] + ] + ]; + $this->result($form, ReturnCode::GET_TEMPLATE_SUCCESS); + } } } \ No newline at end of file diff --git a/application/admin/view/public/base.html b/application/admin/view/public/base.html index fb34cc1..ba3fc46 100644 --- a/application/admin/view/public/base.html +++ b/application/admin/view/public/base.html @@ -148,6 +148,7 @@ var STATIC_PATH = '__STATIC__'; var IMG_PATH = '__IMG__'; var PLUGIN_PATH = '__PLUGIN__'; + var COMPANY_NAME = '{:config("COMPANY_NAME")}'; /** * 自动适配面包屑导航 diff --git a/application/config.php b/application/config.php index 077ab52..29e09a2 100644 --- a/application/config.php +++ b/application/config.php @@ -13,7 +13,7 @@ return [ 'PRODUCT_VERSION' => 'V0.9.0', //项目版本 'PRODUCT_NAME' => '7d-vision', //产品名称 'WEBSITE_DOMAIN' => 'http://www.7d-vision.com', //官方网址 - 'COMPANY_NAME' => '七维视觉科技有限公司', //公司名称 + 'COMPANY_NAME' => '北京七维视觉科技有限公司', //公司名称 'SQL_PRIMARY_KEY' => 'id', // +---------------------------------------------------------------------- diff --git a/public/admin/static/js/template/form.js b/public/admin/static/js/template/form.js index b245684..d92e6da 100644 --- a/public/admin/static/js/template/form.js +++ b/public/admin/static/js/template/form.js @@ -48,6 +48,9 @@ case 'checkbox': formHtml += buildCheckbox(value); break; + case 'password': + formHtml += buildPassword(value); + break; } }); formHtml += '