Browse Source

用户邀请用户添加

zhangxiaobin 1 year ago
parent
commit
bee34d4b57

+ 179 - 0
application/admin/controller/UserInvite.php

@@ -0,0 +1,179 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+use think\Db;
+
+/**
+ * 用户邀请管理
+ *
+ * @icon fa fa-circle-o
+ */
+class UserInvite extends Backend
+{
+    
+    /**
+     * UserInvite模型对象
+     * @var \app\admin\model\UserInvite
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\UserInvite;
+
+    }
+
+    public function import()
+    {
+        parent::import();
+    }
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = true;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                    ->with(['user','inviteuser'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                
+                $row->getRelation('user')->visible(['nickname']);
+                $row->getRelation('inviteuser')->visible(['nickname']);
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
+    /**
+     * 添加
+     */
+    public function add()
+    {
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            $params = $this->preExcludeFields($params);
+            if (!$params) {
+                $this->error(__('Parameter %s can not be empty', ''));
+            }
+            Db::startTrans();
+            try {
+                //是否采用模型验证
+                if ($this->modelValidate) {
+                    $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                    $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
+                    $this->model->validateFailException(true)->validate($validate);
+                }
+                if ($params['invite_user_id'] == $params['user_id']) {
+                    throw new Exception('不能邀请自己');
+                }
+                if (!empty($params['invite_user_id'])) {
+                    $userWhere['id'] = $params['invite_user_id'];
+                    $user = Db::name('user')->where($userWhere)->find();
+                    if ($user['pre_userid'] != 0) {
+                        throw new Exception('该用户已被邀请');
+                    }
+                    $userRes = Db::name('user_id')->where($userWhere)->update(['pre_userid'=>$params['user_id']]);
+                    if (!$userRes) {
+                        throw new Exception('更新用户邀请信息失败');
+                    }
+                }
+                $result = $this->model->allowField(true)->save($params);
+                if ($result == false) {
+                    throw new Exception(__('No rows were inserted'));
+                }
+                Db::commit();
+                $this->success();
+            } catch (ValidateException|PDOException|Exception $e) {
+                Db::rollback();
+                $this->error($e->getMessage());
+            }
+        }
+        return $this->view->fetch();
+    }
+
+    /**
+     * 编辑
+     */
+    public function edit($ids = null)
+    {
+        $row = $this->model->get($ids);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        $adminIds = $this->getDataLimitAdminIds();
+        if (is_array($adminIds)) {
+            if (!in_array($row[$this->dataLimitField], $adminIds)) {
+                $this->error(__('You have no permission'));
+            }
+        }
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            if (!$params) {
+                $this->error(__('Parameter %s can not be empty', ''));
+            }
+            $params = $this->preExcludeFields($params);
+            Db::startTrans();
+            try {
+                //是否采用模型验证
+                if ($this->modelValidate) {
+                    $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                    $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+                    $row->validateFailException(true)->validate($validate);
+                }
+                if ($params['invite_user_id'] == $params['user_id']) {
+                    throw new Exception('不能邀请自己');
+                }
+                if (!empty($params['invite_user_id'])) {
+                    $userWhere['id'] = $params['invite_user_id'];
+                    $user = Db::name('user')->where($userWhere)->find();
+                    if ($user['pre_userid'] != $params['user_id']) {
+                        $userRes = Db::name('user_id')->where($userWhere)->update(['pre_userid'=>$params['user_id']]);
+                        if (!$userRes) {
+                            throw new Exception('更新用户邀请信息失败');
+                        }
+                    }
+                }
+                $result = $row->allowField(true)->save($params);
+                if ($result == false) {
+                    throw new Exception(__('No rows were inserted'));
+                }
+                Db::commit();
+                $this->success();
+            } catch (ValidateException|PDOException|Exception $e) {
+                Db::rollback();
+                $this->error($e->getMessage());
+            }
+        }
+        $this->view->assign("row", $row);
+        return $this->view->fetch();
+    }
+}

+ 102 - 7
application/admin/controller/user/User.php

@@ -3,8 +3,14 @@
 namespace app\admin\controller\user;
 
 use app\admin\model\Message;
+use app\admin\model\UserPower;
 use app\common\controller\Backend;
 use app\common\library\Auth;
+use fast\Random;
+use think\Db;
+use think\Exception;
+use think\exception\PDOException;
+use think\exception\ValidateException;
 
 /**
  * 会员管理
@@ -27,6 +33,7 @@ class User extends Backend
         parent::_initialize();
         $this->model = model('User');
         $typeList = [
+            'genderList' => $this->model->getGenderList(),
             'isCoolList' => $this->model->getIsCoolList(),
             'isManagerList' => $this->model->getIsManagerList(),
         ];
@@ -68,12 +75,60 @@ class User extends Backend
     /**
      * 添加
      */
+    /**
+     * 添加
+     */
     public function add()
     {
         if ($this->request->isPost()) {
-            $this->token();
+            $params = $this->request->post("row/a");
+            $params = $this->preExcludeFields($params);
+            if (!$params) {
+                $this->error(__('Parameter %s can not be empty', ''));
+            }
+            $result = false;
+            Db::startTrans();
+            try {
+                //是否采用模型验证
+                if ($this->modelValidate) {
+                    $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                    $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
+                    $this->model->validateFailException(true)->validate($validate);
+                }
+                if (empty($params['avatar'])) {
+                    $params['avatar'] = '/assets/img/default_avatar.png';
+                }
+                $ids = $this->model->column("u_id");
+                $invite_no = $this->model->column("invite_no");
+                $params['u_id'] = $this->model->getUinqueId(8, [$ids]);
+                $params['invite_no'] = $this->model->getUinqueNo(8, $invite_no);
+                if (empty($params['nickname'])) {
+                    $params['nickname'] = 'gg_'.$params['u_id'];
+                }
+                $params['image'] = '/assets/img/default_avatar.png';
+                $params['username'] = $params['mobile'];
+                $params['status'] = 'normal';
+                $params['salt'] = Random::alnum();
+                $params['has_info'] = 1;
+                $result = $this->model->allowField(true)->save($params);
+                $userId = $this->model->id;
+                $userPower = new UserPower();
+                $userPowerData['user_id'] = $userId;
+                $userPowerRes = $userPower->insertGetId($userPowerData);
+                if (!$userPowerRes) {
+                    throw new Exception('创建用户权限失败');
+                }
+            } catch (ValidateException|PDOException|Exception $e) {
+                Db::rollback();
+                $this->error($e->getMessage());
+            }
+            if ($result == false) {
+               $this->error(__('No rows were inserted'));
+            }
+            Db::commit();
+            $this->success();
         }
-        return parent::add();
+        return $this->view->fetch();
     }
 
     /**
@@ -81,15 +136,55 @@ class User extends Backend
      */
     public function edit($ids = null)
     {
-        if ($this->request->isPost()) {
-            $this->token();
-        }
         $row = $this->model->get($ids);
-        $this->modelValidate = true;
         if (!$row) {
             $this->error(__('No Results were found'));
         }
-        return parent::edit($ids);
+        $adminIds = $this->getDataLimitAdminIds();
+        if (is_array($adminIds)) {
+            if (!in_array($row[$this->dataLimitField], $adminIds)) {
+                $this->error(__('You have no permission'));
+            }
+        }
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            if (!$params) {
+                $this->error(__('Parameter %s can not be empty', ''));
+            }
+            $params = $this->preExcludeFields($params);
+            $result = false;
+            try {
+                //是否采用模型验证
+                if ($this->modelValidate) {
+                    $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                    $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+                    $row->validateFailException(true)->validate($validate);
+                }
+                if (!empty($params['u_id'])) {
+                    $userWhere['u_id'] = $params['u_id'];
+                    $user = $this->model->where($userWhere)->find();
+                    if (!empty($user)) {
+                        throw new Exception('前端用户ID已存在');
+                    }
+                }
+                if (!empty($params['mobile'])) {
+                    $userWhere['mobile'] = $params['mobile'];
+                    $user = $this->model->where($userWhere)->find();
+                    if (!empty($user)) {
+                        throw new Exception('手机号已存在');
+                    }
+                }
+                $result = $row->allowField(true)->save($params);
+            } catch (ValidateException|PDOException|Exception $e) {
+                $this->error($e->getMessage());
+            }
+            if ($result == false) {
+                $this->error(__('No rows were updated'));
+            }
+            $this->success();
+        }
+        $this->view->assign("row", $row);
+        return $this->view->fetch();
     }
 
     /**

+ 11 - 0
application/admin/lang/zh-cn/user_invite.php

@@ -0,0 +1,11 @@
+<?php
+
+return [
+    'Id'             => '主键ID',
+    'User_id'        => '用户ID',
+    'Invite_user_id' => '被邀请的用户ID',
+    'Createtime'     => '创建时间',
+    'Updatetime'     => '更新时间',
+    'User.nickname'  => '邀请用户昵称',
+    'Inviteuser.nickname'  => '被邀请用户昵称',
+];

+ 22 - 0
application/admin/model/User.php

@@ -3,6 +3,7 @@
 namespace app\admin\model;
 
 use app\common\model\ScoreLog;
+use fast\Random;
 use think\Model;
 
 class User extends Model
@@ -149,4 +150,25 @@ class User extends Model
     {
         return $this->belongsTo('app\admin\model\Constellation', 'constellation_id', 'id', [], 'LEFT')->setEagerlyType(0);
     }
+
+    public function getUinqueId($length = 8, $ids = [])
+    {
+        $newid = Random::build("nozero", $length);
+        if (in_array($newid, $ids)) {
+            $newid = $this->getUinqueId($length, $ids);
+        }
+        return $newid;
+    }
+
+    /**
+     * 生成不重复的随机数字字母组合
+     */
+    function getUinqueNo($length = 8, $nos = [])
+    {
+        $newid = Random::build("alnum", $length);
+        if (in_array($newid, $nos)) {
+            $newid = $this->getUinqueNo($length, $nos);
+        }
+        return $newid;
+    }
 }

+ 49 - 0
application/admin/model/UserInvite.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class UserInvite extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'user_invite';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+    public function user()
+    {
+        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
+
+    public function inviteuser()
+    {
+        return $this->belongsTo('User', 'invite_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
+}

+ 27 - 0
application/admin/validate/UserInvite.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class UserInvite extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 63 - 0
application/admin/view/user/user/add.html

@@ -0,0 +1,63 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    {:token()}
+    <div class="form-group">
+        <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-mobile" data-rule="required" class="form-control" name="row[mobile]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-nickname" data-rule="" class="form-control" name="row[nickname]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-avatar" class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="input-group">
+                <input id="c-avatar" data-rule="" class="form-control" size="50" name="row[avatar]" type="text" value="">
+                <div class="input-group-addon no-border no-padding">
+                    <span><button type="button" id="faupload-avatar" class="btn btn-danger faupload" data-input-id="c-avatar" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-avatar"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
+                    <span><button type="button" id="fachoose-avatar" class="btn btn-primary fachoose" data-input-id="c-avatar" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
+                </div>
+                <span class="msg-box n-right" for="c-avatar"></span>
+            </div>
+            <ul class="row list-inline faupload-preview" id="p-avatar"></ul>
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-gender" class="control-label col-xs-12 col-sm-2">{:__('Gender')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="radio">
+                {foreach name="genderList" item="vo"}
+                <label for="row[gender]-{$key}"><input id="row[gender]-{$key}" name="row[gender]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label>
+                {/foreach}
+            </div>
+        </div>
+    </div>
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Age_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-age_id" data-rule="required" data-source="age/index" class="form-control selectpage" name="row[age_id]" type="text" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_manager')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <select id="c-is_manager" data-rule="required" class="form-control selectpicker" name="row[is_manager]">
+                {foreach name="isManagerList" item="vo"}
+                <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 1 - 1
application/admin/view/user/user/index.html

@@ -6,7 +6,7 @@
             <div class="tab-pane fade active in" id="one">
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
-                        {:build_toolbar('refresh,edit')}
+                        {:build_toolbar('refresh,add,edit')}
                         <div class="dropdown btn-group {:$auth->check('user/user/multi')?'':'hide'}">
                             <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
                             <ul class="dropdown-menu text-left" role="menu">

+ 22 - 0
application/admin/view/user_invite/add.html

@@ -0,0 +1,22 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Invite_user_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-invite_user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[invite_user_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 22 - 0
application/admin/view/user_invite/edit.html

@@ -0,0 +1,22 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Invite_user_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-invite_user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[invite_user_id]" type="text" value="{$row.invite_user_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 35 - 0
application/admin/view/user_invite/index.html

@@ -0,0 +1,35 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('user_invite/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('user_invite/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('user_invite/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('user_invite/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
+
+                        <div class="dropdown btn-group {:$auth->check('user_invite/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('user_invite/edit')}" 
+                           data-operate-del="{:$auth->check('user_invite/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 1 - 1
application/common/library/Auth.php

@@ -181,7 +181,7 @@ class Auth
             'mobile'    => $mobile,
             'level'     => 0,
             'score'     => 0,
-            'avatar'    => isset($extend["avatar"]) ? $extend["avatar"] : cdnurl('/assets/img/default_avatar.png'),
+            'avatar'    => isset($extend["avatar"]) ? $extend["avatar"] : '/assets/img/default_avatar.png',
             'image'     => '/assets/img/default_avatar.png',
         ];
         //https://bansheng-1304213176.cos.ap-guangzhou.myqcloud.com/

+ 1 - 0
public/assets/js/backend/user/user.js

@@ -6,6 +6,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             Table.api.init({
                 extend: {
                     index_url: 'user/user/index',
+                    add_url: 'user/user/add',
                     edit_url: 'user/user/edit',
                     multi_url: 'user/user/multi',
                     infocheck_url: 'user/user/infocheck',

+ 56 - 0
public/assets/js/backend/user_invite.js

@@ -0,0 +1,56 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'user_invite/index' + location.search,
+                    add_url: 'user_invite/add',
+                    edit_url: 'user_invite/edit',
+                    del_url: 'user_invite/del',
+                    multi_url: 'user_invite/multi',
+                    import_url: 'user_invite/import',
+                    table: 'user_invite',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'user_id', title: __('User_id')},
+                        {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
+                        {field: 'invite_user_id', title: __('Invite_user_id')},
+                        {field: 'inviteuser.nickname', title: __('Inviteuser.nickname'), operate: 'LIKE'},
+                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});