正在显示
4 个修改的文件
包含
71 行增加
和
0 行删除
@@ -3,6 +3,9 @@ | @@ -3,6 +3,9 @@ | ||
3 | namespace app\admin\controller\user; | 3 | namespace app\admin\controller\user; |
4 | 4 | ||
5 | use app\admin\library\Auth; | 5 | use app\admin\library\Auth; |
6 | +use app\admin\model\AuthGroup; | ||
7 | +use app\admin\model\ThirdExam; | ||
8 | +use app\admin\model\ThirdStudy; | ||
6 | use app\common\controller\Backend; | 9 | use app\common\controller\Backend; |
7 | use app\common\model\User as UserModel; | 10 | use app\common\model\User as UserModel; |
8 | use Exception; | 11 | use Exception; |
@@ -591,4 +594,40 @@ class User extends Backend | @@ -591,4 +594,40 @@ class User extends Backend | ||
591 | 594 | ||
592 | $this->success(); | 595 | $this->success(); |
593 | } | 596 | } |
597 | + | ||
598 | + /** | ||
599 | + * 分配组织 | ||
600 | + */ | ||
601 | + public function fporganization($ids = null) | ||
602 | + { | ||
603 | + if ($this->request->isPost()) { | ||
604 | + empty($ids) && $this->error('请选择用户'); | ||
605 | + $organization_id = $this->request->post("organization_id"); | ||
606 | + empty($organization_id) && $this->error('请选择组织'); | ||
607 | + $update_data = ['organization_id'=>$organization_id]; | ||
608 | + Db::startTrans(); | ||
609 | + try { | ||
610 | + | ||
611 | + $this->model->where('id','in',$ids)->update($update_data); | ||
612 | + ThirdStudy::where('third_id','in',$ids)->update($update_data); | ||
613 | + ThirdExam::where('user_id','in',$ids)->update($update_data); | ||
614 | + | ||
615 | + Db::commit(); | ||
616 | + } catch (ValidateException $e) { | ||
617 | + Db::rollback(); | ||
618 | + $this->error($e->getMessage()); | ||
619 | + } catch (PDOException $e) { | ||
620 | + Db::rollback(); | ||
621 | + $this->error($e->getMessage()); | ||
622 | + } catch (Exception $e) { | ||
623 | + Db::rollback(); | ||
624 | + $this->error($e->getMessage()); | ||
625 | + } | ||
626 | + $this->success(); | ||
627 | + } | ||
628 | + $this->getOrganizationId() > 0 && $this->error(__('You have no permission')); | ||
629 | + $organizationList = AuthGroup::where('is_organization','1')->column('name','id'); | ||
630 | + $this->view->assign('organizationList',$organizationList); | ||
631 | + return $this->view->fetch(); | ||
632 | + } | ||
594 | } | 633 | } |
1 | +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | ||
2 | + | ||
3 | + | ||
4 | + <div class="form-group"> | ||
5 | + <label class="control-label col-xs-12 col-sm-2">{:__('组织')}:</label> | ||
6 | + <div class="col-xs-12 col-sm-8"> | ||
7 | + <select id="c-organization_id" data-rule="required" class="form-control selectpicker" name="organization_id"> | ||
8 | + {foreach name="organizationList" item="vo"} | ||
9 | + <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option> | ||
10 | + {/foreach} | ||
11 | + </select> | ||
12 | + </div> | ||
13 | + </div> | ||
14 | + <div class="form-group layer-footer"> | ||
15 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
16 | + <div class="col-xs-12 col-sm-8"> | ||
17 | + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> | ||
18 | + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | ||
19 | + </div> | ||
20 | + </div> | ||
21 | +</form> |
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | <!--</div>--> | 16 | <!--</div>--> |
17 | <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('user/user/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> | 17 | <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('user/user/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> |
18 | <a href="/assets/import_moudle/用户数据导入.xlsx" class="btn btn-danger {:$auth->check('user/user/import')?'':'hide'}" title="{:__('导入模板')}"> {:__('导入模板')}</a> | 18 | <a href="/assets/import_moudle/用户数据导入.xlsx" class="btn btn-danger {:$auth->check('user/user/import')?'':'hide'}" title="{:__('导入模板')}"> {:__('导入模板')}</a> |
19 | + <a href="javascript:;" class="btn btn-info btn-disabled disabled {:$auth->check('user/user/fpOrganization')?'':'hide'}" title="分配组织" id="btn-fp-organization">分配组织</a> | ||
19 | <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;"> | 20 | <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;"> |
20 | <span class="extend"> | 21 | <span class="extend"> |
21 | 用户数量:<span id="total">0</span> | 22 | 用户数量:<span id="total">0</span> |
@@ -94,6 +94,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -94,6 +94,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
94 | 94 | ||
95 | // 为表格绑定事件 | 95 | // 为表格绑定事件 |
96 | Table.api.bindevent(table); | 96 | Table.api.bindevent(table); |
97 | + | ||
98 | + //分配组织 | ||
99 | + $(document).on('click','#btn-fp-organization',function (){ | ||
100 | + var ids = Table.api.selectedids(table); | ||
101 | + Fast.api.open('user/user/fporganization?ids=' + ids, '分配组织'); | ||
102 | + return false; | ||
103 | + }) | ||
97 | }, | 104 | }, |
98 | add: function () { | 105 | add: function () { |
99 | Controller.api.bindevent(); | 106 | Controller.api.bindevent(); |
@@ -101,6 +108,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -101,6 +108,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
101 | edit: function () { | 108 | edit: function () { |
102 | Controller.api.bindevent(); | 109 | Controller.api.bindevent(); |
103 | }, | 110 | }, |
111 | + fporganization: function () { | ||
112 | + Form.api.bindevent($("form[role=form]")); | ||
113 | + }, | ||
104 | api: { | 114 | api: { |
105 | bindevent: function () { | 115 | bindevent: function () { |
106 | Form.api.bindevent($("form[role=form]")); | 116 | Form.api.bindevent($("form[role=form]")); |
-
请 注册 或 登录 后发表评论