正在显示
9 个修改的文件
包含
59 行增加
和
27 行删除
@@ -148,17 +148,12 @@ class House extends Backend | @@ -148,17 +148,12 @@ class House extends Backend | ||
148 | 148 | ||
149 | //小区id | 149 | //小区id |
150 | $house_id = $this->model->getLastInsID(); | 150 | $house_id = $this->model->getLastInsID(); |
151 | - $data = Db::name('house')->where('id',$house_id)->find(); | ||
152 | -// $house_admin = Db::name('house_admin')->where('house_id',$house_id)->find(); | ||
153 | -// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$house_id]); | ||
154 | -// if($house_admin) { | ||
155 | -// Db::name('house_admin')->where('id',$house_admin['id'])->update(['house_id'=>'']); | ||
156 | -// } | ||
157 | - // 把修改后的管理员状态更新 | ||
158 | - Db::name('house_admin')->where('house_id',$house_id)->where('is_direct',1)->update(['house_id'=>'']); | ||
159 | - Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$house_id,'is_direct'=>1]); | ||
160 | - | ||
161 | -// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$house_id]); | 151 | + |
152 | +// $data = Db::name('house')->where('id',$house_id)->find(); | ||
153 | +// // 把修改后的管理员状态更新 | ||
154 | +// Db::name('house_admin')->where('house_id',$house_id)->where('is_direct',1)->update(['house_id'=>'']); | ||
155 | +// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$house_id,'is_direct'=>1]); | ||
156 | + | ||
162 | $url = request()->domain().'/index/index/hourse?id='.$house_id; | 157 | $url = request()->domain().'/index/index/hourse?id='.$house_id; |
163 | 158 | ||
164 | //生成二维码 | 159 | //生成二维码 |
@@ -236,15 +231,11 @@ class House extends Backend | @@ -236,15 +231,11 @@ class House extends Backend | ||
236 | $row->validateFailException(true)->validate($validate); | 231 | $row->validateFailException(true)->validate($validate); |
237 | } | 232 | } |
238 | $result = $row->allowField(true)->save($params); | 233 | $result = $row->allowField(true)->save($params); |
239 | - $data = Db::name('house')->where('id',$ids)->find(); | ||
240 | -// $house_admin = Db::name('house_admin')->where('house_id',$ids)->find(); | ||
241 | -// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$ids]); | ||
242 | -// if($house_admin) { | ||
243 | -// Db::name('house_admin')->where('id',$house_admin['id'])->update(['house_id'=>'']); | ||
244 | -// } | ||
245 | - // 把修改后的管理员状态更新 | ||
246 | - Db::name('house_admin')->where('house_id',$ids)->where('is_direct',1)->update(['house_id'=>'']); | ||
247 | - Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$ids,'is_direct'=>1]); | 234 | + |
235 | +// $data = Db::name('house')->where('id',$ids)->find(); | ||
236 | +// // 把修改后的管理员状态更新 | ||
237 | +// Db::name('house_admin')->where('house_id',$ids)->where('is_direct',1)->update(['house_id'=>'']); | ||
238 | +// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$ids,'is_direct'=>1]); | ||
248 | 239 | ||
249 | Db::commit(); | 240 | Db::commit(); |
250 | } catch (ValidateException $e) { | 241 | } catch (ValidateException $e) { |
@@ -50,7 +50,7 @@ class HouseAdmin extends Backend | @@ -50,7 +50,7 @@ class HouseAdmin extends Backend | ||
50 | 50 | ||
51 | // 城市或区县代理 | 51 | // 城市或区县代理 |
52 | $group_id_arr = array_column($this->auth->getGroups(), 'group_id'); | 52 | $group_id_arr = array_column($this->auth->getGroups(), 'group_id'); |
53 | - $where1 = []; | 53 | + $where1 = ['house_id' => $this->request->request('house_id')]; |
54 | if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr)){ | 54 | if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr)){ |
55 | $area_arr = \app\admin\model\AdminArea::where('admin_id',$this->auth->id)->column('area'); | 55 | $area_arr = \app\admin\model\AdminArea::where('admin_id',$this->auth->id)->column('area'); |
56 | foreach ($area_arr as $v) { | 56 | foreach ($area_arr as $v) { |
@@ -95,6 +95,7 @@ class HouseAdmin extends Backend | @@ -95,6 +95,7 @@ class HouseAdmin extends Backend | ||
95 | */ | 95 | */ |
96 | public function add() | 96 | public function add() |
97 | { | 97 | { |
98 | + $house_id = $this->request->request('house_id'); | ||
98 | if ($this->request->isPost()) { | 99 | if ($this->request->isPost()) { |
99 | $params = $this->request->post("row/a"); | 100 | $params = $this->request->post("row/a"); |
100 | if ($params) { | 101 | if ($params) { |
@@ -102,6 +103,14 @@ class HouseAdmin extends Backend | @@ -102,6 +103,14 @@ class HouseAdmin extends Backend | ||
102 | if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | 103 | if ($this->dataLimit && $this->dataLimitFieldAutoFill) { |
103 | $params[$this->dataLimitField] = $this->auth->id; | 104 | $params[$this->dataLimitField] = $this->auth->id; |
104 | } | 105 | } |
106 | + | ||
107 | + // 判断该用户已经是此小区的管理员了 | ||
108 | + if($this->model->get(['user_id'=>$params['user_id'],'house_id'=>$house_id])){ | ||
109 | + $this->error('该用户已经是此小区的管理员了'); | ||
110 | + } | ||
111 | + | ||
112 | + $params['house_id'] = $house_id; | ||
113 | + | ||
105 | $result = false; | 114 | $result = false; |
106 | Db::startTrans(); | 115 | Db::startTrans(); |
107 | try { | 116 | try { |
@@ -163,6 +172,10 @@ class HouseAdmin extends Backend | @@ -163,6 +172,10 @@ class HouseAdmin extends Backend | ||
163 | if ($params) { | 172 | if ($params) { |
164 | $params = $this->preExcludeFields($params); | 173 | $params = $this->preExcludeFields($params); |
165 | 174 | ||
175 | + // 判断该用户已经是此小区的管理员了 | ||
176 | + if($this->model->get(['user_id'=>$params['user_id'],'house_id'=>$row['house_id']]) && $params['user_id'] != $row['user_id']){ | ||
177 | + $this->error('该用户已经是此小区的管理员了'); | ||
178 | + } | ||
166 | 179 | ||
167 | $result = false; | 180 | $result = false; |
168 | Db::startTrans(); | 181 | Db::startTrans(); |
@@ -6,6 +6,9 @@ return [ | @@ -6,6 +6,9 @@ return [ | ||
6 | 'Nickname' => '管理员姓名', | 6 | 'Nickname' => '管理员姓名', |
7 | 'Mobile' => '管理员手机号', | 7 | 'Mobile' => '管理员手机号', |
8 | 'Image' => '管理员头像', | 8 | 'Image' => '管理员头像', |
9 | + 'Is_direct' => '是否为主管理员', | ||
10 | + 'Is_direct 1' => '是', | ||
11 | + 'Is_direct 2' => '否', | ||
9 | 'Createtime' => '创建时间', | 12 | 'Createtime' => '创建时间', |
10 | 'Updatetime' => '修改时间' | 13 | 'Updatetime' => '修改时间' |
11 | ]; | 14 | ]; |
1 | <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | 1 | <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> |
2 | 2 | ||
3 | - <div class="form-group"> | 3 | + <!--<div class="form-group"> |
4 | <label class="control-label col-xs-12 col-sm-2">{:__('Admin_user_id')}:</label> | 4 | <label class="control-label col-xs-12 col-sm-2">{:__('Admin_user_id')}:</label> |
5 | <div class="col-xs-12 col-sm-8"> | 5 | <div class="col-xs-12 col-sm-8"> |
6 | <input id="c-admin_user_id" data-rule="" data-source="house_admin/index" data-field="nickname" class="form-control selectpage" name="row[admin_user_id]" type="text" value=""> | 6 | <input id="c-admin_user_id" data-rule="" data-source="house_admin/index" data-field="nickname" class="form-control selectpage" name="row[admin_user_id]" type="text" value=""> |
7 | </div> | 7 | </div> |
8 | - </div> | 8 | + </div>--> |
9 | <div class="form-group"> | 9 | <div class="form-group"> |
10 | <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | 10 | <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> |
11 | <div class="col-xs-12 col-sm-8"> | 11 | <div class="col-xs-12 col-sm-8"> |
1 | <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | 1 | <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> |
2 | 2 | ||
3 | - <div class="form-group"> | 3 | + <!--<div class="form-group"> |
4 | <label class="control-label col-xs-12 col-sm-2">{:__('Admin_user_id')}:</label> | 4 | <label class="control-label col-xs-12 col-sm-2">{:__('Admin_user_id')}:</label> |
5 | <div class="col-xs-12 col-sm-8"> | 5 | <div class="col-xs-12 col-sm-8"> |
6 | <input id="c-admin_user_id" data-rule="" data-source="house_admin/index" data-field="nickname" class="form-control selectpage" name="row[admin_user_id]" type="text" value="{$row.admin_user_id|htmlentities}"> | 6 | <input id="c-admin_user_id" data-rule="" data-source="house_admin/index" data-field="nickname" class="form-control selectpage" name="row[admin_user_id]" type="text" value="{$row.admin_user_id|htmlentities}"> |
7 | </div> | 7 | </div> |
8 | - </div> | 8 | + </div>--> |
9 | <div class="form-group"> | 9 | <div class="form-group"> |
10 | <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | 10 | <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> |
11 | <div class="col-xs-12 col-sm-8"> | 11 | <div class="col-xs-12 col-sm-8"> |
@@ -24,6 +24,12 @@ | @@ -24,6 +24,12 @@ | ||
24 | <input id="c-mobile" class="form-control" data-rule="required;mobile" name="row[mobile]" type="text"> | 24 | <input id="c-mobile" class="form-control" data-rule="required;mobile" name="row[mobile]" type="text"> |
25 | </div> | 25 | </div> |
26 | </div> | 26 | </div> |
27 | + <div class="form-group"> | ||
28 | + <label class="control-label col-xs-12 col-sm-2">{:__('Is_direct')}:</label> | ||
29 | + <div class="col-xs-12 col-sm-8"> | ||
30 | + {:build_radios('row[is_direct]', [1=>__('Is_direct 1'), 2=>__('Is_direct 2')], 1)} | ||
31 | + </div> | ||
32 | + </div> | ||
27 | <!--<div class="form-group">--> | 33 | <!--<div class="form-group">--> |
28 | <!--<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>--> | 34 | <!--<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>--> |
29 | <!--<div class="col-xs-12 col-sm-8">--> | 35 | <!--<div class="col-xs-12 col-sm-8">--> |
@@ -18,6 +18,12 @@ | @@ -18,6 +18,12 @@ | ||
18 | <input id="c-mobile" class="form-control" data-rule="required;mobile" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}"> | 18 | <input id="c-mobile" class="form-control" data-rule="required;mobile" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}"> |
19 | </div> | 19 | </div> |
20 | </div> | 20 | </div> |
21 | + <div class="form-group"> | ||
22 | + <label class="control-label col-xs-12 col-sm-2">{:__('Is_direct')}:</label> | ||
23 | + <div class="col-xs-12 col-sm-8"> | ||
24 | + {:build_radios('row[is_direct]', [1=>__('Is_direct 1'), 2=>__('Is_direct 2')], $row['is_direct'])} | ||
25 | + </div> | ||
26 | + </div> | ||
21 | <div class="form-group layer-footer"> | 27 | <div class="form-group layer-footer"> |
22 | <label class="control-label col-xs-12 col-sm-2"></label> | 28 | <label class="control-label col-xs-12 col-sm-2"></label> |
23 | <div class="col-xs-12 col-sm-8"> | 29 | <div class="col-xs-12 col-sm-8"> |
@@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
26 | [ | 26 | [ |
27 | {checkbox: true}, | 27 | {checkbox: true}, |
28 | {field: 'id', title: __('Id'), operate:false}, | 28 | {field: 'id', title: __('Id'), operate:false}, |
29 | - {field: 'admin_user_id', title: __('Admin_user_id'), operate:false}, | 29 | + // {field: 'admin_user_id', title: __('Admin_user_id'), operate:false}, |
30 | {field: 'name', title: __('Name'), operate:'like'}, | 30 | {field: 'name', title: __('Name'), operate:'like'}, |
31 | // {field: 'image', title: __('Image'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image}, | 31 | // {field: 'image', title: __('Image'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image}, |
32 | {field: 'area', title: __('所在地区'), operate:false}, | 32 | {field: 'area', title: __('所在地区'), operate:false}, |
@@ -77,6 +77,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -77,6 +77,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
77 | ], operate:false, formatter: Table.api.formatter.buttons | 77 | ], operate:false, formatter: Table.api.formatter.buttons |
78 | }, | 78 | }, |
79 | 79 | ||
80 | + {field: 'id', title: __('管理员'), table: table, events: Table.api.events.operate, buttons: | ||
81 | + [ | ||
82 | + { | ||
83 | + text: '管理员', | ||
84 | + title: '管理员', | ||
85 | + icon: 'fa fa-list', | ||
86 | + classname: 'btn btn-xs btn-primary btn-dialog', | ||
87 | + url: 'house_admin/index?house_id={id}', | ||
88 | + extend: 'data-area=\'["80%","80%"]\'', | ||
89 | + } | ||
90 | + ], operate:false, formatter: Table.api.formatter.buttons | ||
91 | + }, | ||
92 | + | ||
80 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, | 93 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, |
81 | // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, | 94 | // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, |
82 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 95 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
@@ -6,7 +6,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -6,7 +6,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
6 | Table.api.init({ | 6 | Table.api.init({ |
7 | extend: { | 7 | extend: { |
8 | index_url: 'house_admin/index' + location.search, | 8 | index_url: 'house_admin/index' + location.search, |
9 | - add_url: 'house_admin/add', | 9 | + add_url: 'house_admin/add' + location.search, |
10 | edit_url: 'house_admin/edit', | 10 | edit_url: 'house_admin/edit', |
11 | del_url: 'house_admin/del', | 11 | del_url: 'house_admin/del', |
12 | multi_url: 'house_admin/multi', | 12 | multi_url: 'house_admin/multi', |
-
请 注册 或 登录 后发表评论