正在显示
14 个修改的文件
包含
492 行增加
和
2 行删除
application/admin/controller/AdminArea.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | +use think\Db; | ||
7 | + | ||
8 | +/** | ||
9 | + * 代理地区管理 | ||
10 | + * | ||
11 | + * @icon fa fa-circle-o | ||
12 | + */ | ||
13 | +class AdminArea extends Backend | ||
14 | +{ | ||
15 | + | ||
16 | + /** | ||
17 | + * AdminArea模型对象 | ||
18 | + * @var \app\admin\model\AdminArea | ||
19 | + */ | ||
20 | + protected $model = null; | ||
21 | + | ||
22 | + public function _initialize() | ||
23 | + { | ||
24 | + parent::_initialize(); | ||
25 | + $this->model = new \app\admin\model\AdminArea; | ||
26 | + | ||
27 | + } | ||
28 | + | ||
29 | + /** | ||
30 | + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | ||
31 | + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||
32 | + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||
33 | + */ | ||
34 | + | ||
35 | + | ||
36 | + /** | ||
37 | + * 查看 | ||
38 | + */ | ||
39 | + public function index() | ||
40 | + { | ||
41 | + //当前是否为关联查询 | ||
42 | + $this->relationSearch = false; | ||
43 | + //设置过滤方法 | ||
44 | + $this->request->filter(['strip_tags', 'trim']); | ||
45 | + if ($this->request->isAjax()) | ||
46 | + { | ||
47 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
48 | + if ($this->request->request('keyField')) | ||
49 | + { | ||
50 | + return $this->selectpage(); | ||
51 | + } | ||
52 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
53 | + $total = $this->model | ||
54 | + ->where('admin_id',$this->request->request('admin_id')) | ||
55 | + ->where($where) | ||
56 | + ->order($sort, $order) | ||
57 | + ->count(); | ||
58 | + | ||
59 | + $list = $this->model | ||
60 | + ->where('admin_id',$this->request->request('admin_id')) | ||
61 | + ->where($where) | ||
62 | + ->order($sort, $order) | ||
63 | + ->limit($offset, $limit) | ||
64 | + ->select(); | ||
65 | + | ||
66 | + foreach ($list as $row) { | ||
67 | + $row->visible(['id','area']); | ||
68 | + | ||
69 | + } | ||
70 | + $list = collection($list)->toArray(); | ||
71 | + $result = array("total" => $total, "rows" => $list); | ||
72 | + | ||
73 | + return json($result); | ||
74 | + } | ||
75 | + return $this->view->fetch(); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * 添加 | ||
80 | + */ | ||
81 | + public function add() | ||
82 | + { | ||
83 | + $admin_id = $this->request->request('admin_id'); | ||
84 | + if ($this->request->isPost()) { | ||
85 | + $params = $this->request->post("row/a"); | ||
86 | + if ($params) { | ||
87 | + $params = $this->preExcludeFields($params); | ||
88 | + | ||
89 | + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | ||
90 | + $params[$this->dataLimitField] = $this->auth->id; | ||
91 | + } | ||
92 | + // 当前账号的角色组ID数组 | ||
93 | + $group_id_arr = Db::name('auth_group_access')->where('uid',$admin_id)->column('group_id'); | ||
94 | + // 地区ID | ||
95 | + $area_name = strrpos($params['area'], '/') === false ? $params['area'] : substr($params['area'],strrpos($params['area'], '/')+1); | ||
96 | + $area = \app\admin\model\Area::getByname($area_name); | ||
97 | + if(in_array(6,$group_id_arr) && $area['level'] != 2){ | ||
98 | + $this->error('城市代理只能选择城市'); | ||
99 | + } | ||
100 | + if(in_array(7,$group_id_arr) && $area['level'] != 3){ | ||
101 | + $this->error('区县代理只能选择区县'); | ||
102 | + } | ||
103 | + $params['area_id'] = $area['id']; | ||
104 | + $params['admin_id'] = $admin_id; | ||
105 | + | ||
106 | + $result = false; | ||
107 | + Db::startTrans(); | ||
108 | + try { | ||
109 | + //是否采用模型验证 | ||
110 | + if ($this->modelValidate) { | ||
111 | + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | ||
112 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | ||
113 | + $this->model->validateFailException(true)->validate($validate); | ||
114 | + } | ||
115 | + $result = $this->model->allowField(true)->save($params); | ||
116 | + Db::commit(); | ||
117 | + } catch (ValidateException $e) { | ||
118 | + Db::rollback(); | ||
119 | + $this->error($e->getMessage()); | ||
120 | + } catch (PDOException $e) { | ||
121 | + Db::rollback(); | ||
122 | + $this->error($e->getMessage()); | ||
123 | + } catch (Exception $e) { | ||
124 | + Db::rollback(); | ||
125 | + $this->error($e->getMessage()); | ||
126 | + } | ||
127 | + if ($result !== false) { | ||
128 | + $this->success(); | ||
129 | + } else { | ||
130 | + $this->error(__('No rows were inserted')); | ||
131 | + } | ||
132 | + } | ||
133 | + $this->error(__('Parameter %s can not be empty', '')); | ||
134 | + } | ||
135 | + return $this->view->fetch(); | ||
136 | + } | ||
137 | + | ||
138 | + /** | ||
139 | + * 编辑 | ||
140 | + */ | ||
141 | + public function edit($ids = null) | ||
142 | + { | ||
143 | + $row = $this->model->get($ids); | ||
144 | + if (!$row) { | ||
145 | + $this->error(__('No Results were found')); | ||
146 | + } | ||
147 | + $adminIds = $this->getDataLimitAdminIds(); | ||
148 | + if (is_array($adminIds)) { | ||
149 | + if (!in_array($row[$this->dataLimitField], $adminIds)) { | ||
150 | + $this->error(__('You have no permission')); | ||
151 | + } | ||
152 | + } | ||
153 | + if ($this->request->isPost()) { | ||
154 | + $params = $this->request->post("row/a"); | ||
155 | + if ($params) { | ||
156 | + $params = $this->preExcludeFields($params); | ||
157 | + // 当前账号的角色组ID数组 | ||
158 | + $group_id_arr = Db::name('auth_group_access')->where('uid',$row['admin_id'])->column('group_id'); | ||
159 | + // 地区ID | ||
160 | + $area_name = strrpos($params['area'], '/') === false ? $params['area'] : substr($params['area'],strrpos($params['area'], '/')+1); | ||
161 | + $area = \app\admin\model\Area::getByname($area_name); | ||
162 | + if(in_array(6,$group_id_arr) && $area['level'] != 2){ | ||
163 | + $this->error('城市代理只能选择城市'); | ||
164 | + } | ||
165 | + if(in_array(7,$group_id_arr) && $area['level'] != 3){ | ||
166 | + $this->error('区县代理只能选择区县'); | ||
167 | + } | ||
168 | + $params['area_id'] = $area['id']; | ||
169 | + | ||
170 | + $result = false; | ||
171 | + Db::startTrans(); | ||
172 | + try { | ||
173 | + //是否采用模型验证 | ||
174 | + if ($this->modelValidate) { | ||
175 | + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | ||
176 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; | ||
177 | + $row->validateFailException(true)->validate($validate); | ||
178 | + } | ||
179 | + $result = $row->allowField(true)->save($params); | ||
180 | + Db::commit(); | ||
181 | + } catch (ValidateException $e) { | ||
182 | + Db::rollback(); | ||
183 | + $this->error($e->getMessage()); | ||
184 | + } catch (PDOException $e) { | ||
185 | + Db::rollback(); | ||
186 | + $this->error($e->getMessage()); | ||
187 | + } catch (Exception $e) { | ||
188 | + Db::rollback(); | ||
189 | + $this->error($e->getMessage()); | ||
190 | + } | ||
191 | + if ($result !== false) { | ||
192 | + $this->success(); | ||
193 | + } else { | ||
194 | + $this->error(__('No rows were updated')); | ||
195 | + } | ||
196 | + } | ||
197 | + $this->error(__('Parameter %s can not be empty', '')); | ||
198 | + } | ||
199 | + $this->view->assign("row", $row); | ||
200 | + return $this->view->fetch(); | ||
201 | + } | ||
202 | +} |
@@ -89,7 +89,26 @@ class House extends Backend | @@ -89,7 +89,26 @@ class House extends Backend | ||
89 | if ($params) { | 89 | if ($params) { |
90 | $params = $this->preExcludeFields($params); | 90 | $params = $this->preExcludeFields($params); |
91 | 91 | ||
92 | + // 当前账号的角色组ID数组 | ||
93 | + $group_id_arr = array_column($this->auth->getGroups(), 'group_id'); | ||
94 | + // 城市或区县代理 | ||
95 | + if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr)){ | ||
96 | + // 地区 | ||
97 | + $area_name = strrpos($params['area'], '/') === false ? $params['area'] : substr($params['area'],strrpos($params['area'], '/')+1); | ||
98 | + $area = \app\admin\model\Area::getByname($area_name); | ||
99 | + // 代理地区 | ||
100 | + if($area['level'] == 3 && in_array(6,$group_id_arr)){ | ||
101 | + $admin_area_name = substr($params['area'],0,strrpos($params['area'], '/')); | ||
102 | + }else{ | ||
103 | + $admin_area_name = $params['area']; | ||
104 | + } | ||
105 | + $admin_area = \app\admin\model\AdminArea::getByArea($admin_area_name); | ||
106 | + if(!$admin_area){ | ||
107 | + $this->error('抱歉,您不能开发其他区域的小区'); | ||
108 | + } | ||
109 | + } | ||
92 | 110 | ||
111 | + // 小区编号 | ||
93 | $data = Db::name('house') | 112 | $data = Db::name('house') |
94 | ->field('max(com_number) as num') | 113 | ->field('max(com_number) as num') |
95 | ->find(); | 114 | ->find(); |
@@ -170,6 +189,26 @@ class House extends Backend | @@ -170,6 +189,26 @@ class House extends Backend | ||
170 | $params = $this->request->post("row/a"); | 189 | $params = $this->request->post("row/a"); |
171 | if ($params) { | 190 | if ($params) { |
172 | $params = $this->preExcludeFields($params); | 191 | $params = $this->preExcludeFields($params); |
192 | + | ||
193 | + // 当前账号的角色组ID数组 | ||
194 | + $group_id_arr = array_column($this->auth->getGroups(), 'group_id'); | ||
195 | + // 城市或区县代理 | ||
196 | + if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr)){ | ||
197 | + // 地区 | ||
198 | + $area_name = strrpos($params['area'], '/') === false ? $params['area'] : substr($params['area'],strrpos($params['area'], '/')+1); | ||
199 | + $area = \app\admin\model\Area::getByname($area_name); | ||
200 | + // 代理地区 | ||
201 | + if($area['level'] == 3 && in_array(6,$group_id_arr)){ | ||
202 | + $admin_area_name = substr($params['area'],0,strrpos($params['area'], '/')); | ||
203 | + }else{ | ||
204 | + $admin_area_name = $params['area']; | ||
205 | + } | ||
206 | + $admin_area = \app\admin\model\AdminArea::getByArea($admin_area_name); | ||
207 | + if(!$admin_area){ | ||
208 | + $this->error('抱歉,您不能开发其他区域的小区'); | ||
209 | + } | ||
210 | + } | ||
211 | + | ||
173 | $result = false; | 212 | $result = false; |
174 | Db::startTrans(); | 213 | Db::startTrans(); |
175 | try { | 214 | try { |
@@ -82,6 +82,15 @@ class Store extends Backend | @@ -82,6 +82,15 @@ class Store extends Backend | ||
82 | 82 | ||
83 | return json($result); | 83 | return json($result); |
84 | } | 84 | } |
85 | + // 城市或区县代理 | ||
86 | + $have_store_num = 0; | ||
87 | + $group_id_arr = array_column($this->auth->getGroups(), 'group_id'); | ||
88 | + if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr)){ | ||
89 | + $have_store_num = 1; | ||
90 | + } | ||
91 | + $store_num = Admin::where('id',$this->auth->id)->value('store_num'); | ||
92 | + $this->view->assign('have_store_num',$have_store_num); | ||
93 | + $this->view->assign('store_num',$store_num); | ||
85 | return $this->view->fetch(); | 94 | return $this->view->fetch(); |
86 | } | 95 | } |
87 | 96 | ||
@@ -169,6 +178,12 @@ class Store extends Backend | @@ -169,6 +178,12 @@ class Store extends Backend | ||
169 | $openid = Db::name('third')->where('user_id',$row->user_id)->value('openid'); | 178 | $openid = Db::name('third')->where('user_id',$row->user_id)->value('openid'); |
170 | $url = 'http://community.t.brotop.cn/admininfo.php'; | 179 | $url = 'http://community.t.brotop.cn/admininfo.php'; |
171 | $this->wxsendmessage($openid,$send_data,config('option.template')['store_pass'],$url); | 180 | $this->wxsendmessage($openid,$send_data,config('option.template')['store_pass'],$url); |
181 | + // 城市或区县代理,可审核商铺数量减一 | ||
182 | + $group_id_arr = array_column($this->auth->getGroups(), 'group_id'); | ||
183 | + $admin = Admin::get($this->auth->id); | ||
184 | + if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr) && $admin['store_num'] > 0){ | ||
185 | + $admin->setDec('store_num'); | ||
186 | + } | ||
172 | } | 187 | } |
173 | if($params['status'] == 4) { | 188 | if($params['status'] == 4) { |
174 | // 审核不通过,执行退款操作 | 189 | // 审核不通过,执行退款操作 |
application/admin/lang/zh-cn/admin_area.php
0 → 100644
application/admin/model/AdminArea.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\model; | ||
4 | + | ||
5 | +use think\Model; | ||
6 | + | ||
7 | + | ||
8 | +class AdminArea extends Model | ||
9 | +{ | ||
10 | + | ||
11 | + | ||
12 | + | ||
13 | + | ||
14 | + | ||
15 | + // 表名 | ||
16 | + protected $name = 'admin_area'; | ||
17 | + | ||
18 | + // 自动写入时间戳字段 | ||
19 | + protected $autoWriteTimestamp = 'int'; | ||
20 | + | ||
21 | + // 定义时间戳字段名 | ||
22 | + protected $createTime = 'createtime'; | ||
23 | + protected $updateTime = 'updatetime'; | ||
24 | + protected $deleteTime = false; | ||
25 | + | ||
26 | + // 追加属性 | ||
27 | + protected $append = [ | ||
28 | + | ||
29 | + ]; | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | + | ||
34 | + | ||
35 | + | ||
36 | + | ||
37 | + | ||
38 | + | ||
39 | + | ||
40 | +} |
application/admin/validate/AdminArea.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\validate; | ||
4 | + | ||
5 | +use think\Validate; | ||
6 | + | ||
7 | +class AdminArea extends Validate | ||
8 | +{ | ||
9 | + /** | ||
10 | + * 验证规则 | ||
11 | + */ | ||
12 | + protected $rule = [ | ||
13 | + ]; | ||
14 | + /** | ||
15 | + * 提示消息 | ||
16 | + */ | ||
17 | + protected $message = [ | ||
18 | + ]; | ||
19 | + /** | ||
20 | + * 验证场景 | ||
21 | + */ | ||
22 | + protected $scene = [ | ||
23 | + 'add' => [], | ||
24 | + 'edit' => [], | ||
25 | + ]; | ||
26 | + | ||
27 | +} |
application/admin/view/admin_area/add.html
0 → 100644
1 | +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | ||
2 | + | ||
3 | + <div class="form-group"> | ||
4 | + <label class="control-label col-xs-12 col-sm-2">{:__('Area')}:</label> | ||
5 | + <div class="col-xs-12 col-sm-8"> | ||
6 | + <input id="c-area" data-rule="required" class="form-control" name="row[area]" type="text" value="" data-toggle="city-picker"> | ||
7 | + </div> | ||
8 | + </div> | ||
9 | + <div class="form-group layer-footer"> | ||
10 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
11 | + <div class="col-xs-12 col-sm-8"> | ||
12 | + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> | ||
13 | + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | ||
14 | + </div> | ||
15 | + </div> | ||
16 | +</form> |
application/admin/view/admin_area/edit.html
0 → 100644
1 | +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | ||
2 | + | ||
3 | + <div class="form-group"> | ||
4 | + <label class="control-label col-xs-12 col-sm-2">{:__('Area')}:</label> | ||
5 | + <div class="col-xs-12 col-sm-8"> | ||
6 | + <input id="c-area" data-rule="required" class="form-control" name="row[area]" type="text" value="{$row.area|htmlentities}" data-toggle="city-picker"> | ||
7 | + </div> | ||
8 | + </div> | ||
9 | + <div class="form-group layer-footer"> | ||
10 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
11 | + <div class="col-xs-12 col-sm-8"> | ||
12 | + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> | ||
13 | + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | ||
14 | + </div> | ||
15 | + </div> | ||
16 | +</form> |
application/admin/view/admin_area/index.html
0 → 100644
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> | ||
10 | + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('admin_area/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> | ||
11 | + <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('admin_area/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> | ||
12 | + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('admin_area/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> | ||
13 | + | ||
14 | + | ||
15 | + </div> | ||
16 | + <table id="table" class="table table-striped table-bordered table-hover table-nowrap" | ||
17 | + data-operate-edit="{:$auth->check('admin_area/edit')}" | ||
18 | + data-operate-del="{:$auth->check('admin_area/del')}" | ||
19 | + width="100%"> | ||
20 | + </table> | ||
21 | + </div> | ||
22 | + </div> | ||
23 | + | ||
24 | + </div> | ||
25 | + </div> | ||
26 | +</div> |
@@ -36,6 +36,12 @@ | @@ -36,6 +36,12 @@ | ||
36 | {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')])} | 36 | {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')])} |
37 | </div> | 37 | </div> |
38 | </div> | 38 | </div> |
39 | + <div class="form-group" id="store_num" style="display: none"> | ||
40 | + <label class="control-label col-xs-12 col-sm-2">{:__('可审核商铺数量')}:</label> | ||
41 | + <div class="col-xs-12 col-sm-8"> | ||
42 | + <input id="c-store_num" class="form-control form-control" name="row[store_num]" type="number" value="0"> | ||
43 | + </div> | ||
44 | + </div> | ||
39 | <div class="form-group hidden layer-footer"> | 45 | <div class="form-group hidden layer-footer"> |
40 | <label class="control-label col-xs-12 col-sm-2"></label> | 46 | <label class="control-label col-xs-12 col-sm-2"></label> |
41 | <div class="col-xs-12 col-sm-8"> | 47 | <div class="col-xs-12 col-sm-8"> |
@@ -42,6 +42,12 @@ | @@ -42,6 +42,12 @@ | ||
42 | {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])} | 42 | {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])} |
43 | </div> | 43 | </div> |
44 | </div> | 44 | </div> |
45 | + <div class="form-group" id="store_num" style="display: none"> | ||
46 | + <label class="control-label col-xs-12 col-sm-2">{:__('可审核商铺数量')}:</label> | ||
47 | + <div class="col-xs-12 col-sm-8"> | ||
48 | + <input id="c-store_num" class="form-control form-control" name="row[store_num]" type="number" value="{$row.store_num}"> | ||
49 | + </div> | ||
50 | + </div> | ||
45 | <div class="form-group hidden layer-footer"> | 51 | <div class="form-group hidden layer-footer"> |
46 | <label class="control-label col-xs-12 col-sm-2"></label> | 52 | <label class="control-label col-xs-12 col-sm-2"></label> |
47 | <div class="col-xs-12 col-sm-8"> | 53 | <div class="col-xs-12 col-sm-8"> |
@@ -17,6 +17,9 @@ | @@ -17,6 +17,9 @@ | ||
17 | <div class="widget-body no-padding"> | 17 | <div class="widget-body no-padding"> |
18 | <div id="toolbar" class="toolbar"> | 18 | <div id="toolbar" class="toolbar"> |
19 | <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> | 19 | <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> |
20 | + {eq name="have_store_num" value="1"} | ||
21 | + <span style="color: red">可审核商铺数量:{$store_num}</span> | ||
22 | + {/eq} | ||
20 | <!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('store/store/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>--> | 23 | <!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('store/store/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>--> |
21 | <!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('store/store/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>--> | 24 | <!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('store/store/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>--> |
22 | <!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('store/store/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>--> | 25 | <!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('store/store/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>--> |
public/assets/js/backend/admin_area.js
0 → 100644
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'admin_area/index' + location.search, | ||
9 | + add_url: 'admin_area/add' + location.search, | ||
10 | + edit_url: 'admin_area/edit', | ||
11 | + del_url: 'admin_area/del', | ||
12 | + multi_url: 'admin_area/multi', | ||
13 | + table: 'admin_area', | ||
14 | + } | ||
15 | + }); | ||
16 | + | ||
17 | + var table = $("#table"); | ||
18 | + | ||
19 | + // 初始化表格 | ||
20 | + table.bootstrapTable({ | ||
21 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
22 | + pk: 'id', | ||
23 | + sortName: 'id', | ||
24 | + columns: [ | ||
25 | + [ | ||
26 | + {checkbox: true}, | ||
27 | + {field: 'id', title: __('Id')}, | ||
28 | + {field: 'area', title: __('Area')}, | ||
29 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
30 | + ] | ||
31 | + ] | ||
32 | + }); | ||
33 | + | ||
34 | + // 为表格绑定事件 | ||
35 | + Table.api.bindevent(table); | ||
36 | + }, | ||
37 | + add: function () { | ||
38 | + Controller.api.bindevent(); | ||
39 | + }, | ||
40 | + edit: function () { | ||
41 | + Controller.api.bindevent(); | ||
42 | + }, | ||
43 | + api: { | ||
44 | + bindevent: function () { | ||
45 | + Form.api.bindevent($("form[role=form]")); | ||
46 | + } | ||
47 | + } | ||
48 | + }; | ||
49 | + return Controller; | ||
50 | +}); |
@@ -37,7 +37,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -37,7 +37,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
37 | {field: 'email', title: __('Email')}, | 37 | {field: 'email', title: __('Email')}, |
38 | {field: 'status', title: __("Status"), formatter: Table.api.formatter.status}, | 38 | {field: 'status', title: __("Status"), formatter: Table.api.formatter.status}, |
39 | {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | 39 | {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, |
40 | - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { | 40 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons: |
41 | + [ | ||
42 | + { | ||
43 | + text: '代理地区', | ||
44 | + title: '代理地区', | ||
45 | + icon: 'fa fa-list', | ||
46 | + classname: 'btn btn-xs btn-primary btn-dialog', | ||
47 | + url: 'admin_area/index?admin_id={id}', | ||
48 | + extend: 'data-area=\'["80%","80%"]\'', | ||
49 | + visible: function(row){ | ||
50 | + var group = row.groups.split(','); | ||
51 | + if($.inArray("1", group) === -1 && $.inArray("6", group) !== -1 || $.inArray("7", group) !== -1){ | ||
52 | + return true; | ||
53 | + } | ||
54 | + } | ||
55 | + } | ||
56 | + ],formatter: function (value, row, index) { | ||
41 | if(row.id == Config.admin.id){ | 57 | if(row.id == Config.admin.id){ |
42 | return ''; | 58 | return ''; |
43 | } | 59 | } |
@@ -52,10 +68,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -52,10 +68,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
52 | }, | 68 | }, |
53 | add: function () { | 69 | add: function () { |
54 | Form.api.bindevent($("form[role=form]")); | 70 | Form.api.bindevent($("form[role=form]")); |
71 | + Controller.api.change(); | ||
55 | }, | 72 | }, |
56 | edit: function () { | 73 | edit: function () { |
57 | Form.api.bindevent($("form[role=form]")); | 74 | Form.api.bindevent($("form[role=form]")); |
58 | - } | 75 | + Controller.api.change(); |
76 | + setTimeout(function () { | ||
77 | + $('select[name="group[]"]').trigger("change"); | ||
78 | + }, 100); | ||
79 | + }, | ||
80 | + api: { | ||
81 | + change: function () { | ||
82 | + $('select[name="group[]"]').change(function () { | ||
83 | + var group = $(this).val(); | ||
84 | + if($.inArray("1", group) === -1 && $.inArray("6", group) !== -1 || $.inArray("7", group) !== -1){ | ||
85 | + $('#store_num').show(); | ||
86 | + $("form[role=form]").validator("setField", "#c-store_num", "required;"); | ||
87 | + }else{ | ||
88 | + $('#store_num').hide(); | ||
89 | + $("form[role=form]").validator("setField", "#c-store_num", null); | ||
90 | + } | ||
91 | + }) | ||
92 | + } | ||
93 | + } | ||
59 | }; | 94 | }; |
60 | return Controller; | 95 | return Controller; |
61 | }); | 96 | }); |
-
请 注册 或 登录 后发表评论