作者 何书鹏
1 个管道 的构建 通过 耗费 2 秒

合并分支 'heshupeng' 到 'master'

社区管理员优化



查看合并请求 !412
... ... @@ -148,17 +148,12 @@ class House extends Backend
//小区id
$house_id = $this->model->getLastInsID();
$data = Db::name('house')->where('id',$house_id)->find();
// $house_admin = Db::name('house_admin')->where('house_id',$house_id)->find();
// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$house_id]);
// if($house_admin) {
// Db::name('house_admin')->where('id',$house_admin['id'])->update(['house_id'=>'']);
// }
// 把修改后的管理员状态更新
Db::name('house_admin')->where('house_id',$house_id)->where('is_direct',1)->update(['house_id'=>'']);
Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$house_id,'is_direct'=>1]);
// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$house_id]);
// $data = Db::name('house')->where('id',$house_id)->find();
// // 把修改后的管理员状态更新
// Db::name('house_admin')->where('house_id',$house_id)->where('is_direct',1)->update(['house_id'=>'']);
// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$house_id,'is_direct'=>1]);
$url = request()->domain().'/index/index/hourse?id='.$house_id;
//生成二维码
... ... @@ -236,15 +231,11 @@ class House extends Backend
$row->validateFailException(true)->validate($validate);
}
$result = $row->allowField(true)->save($params);
$data = Db::name('house')->where('id',$ids)->find();
// $house_admin = Db::name('house_admin')->where('house_id',$ids)->find();
// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$ids]);
// if($house_admin) {
// Db::name('house_admin')->where('id',$house_admin['id'])->update(['house_id'=>'']);
// }
// 把修改后的管理员状态更新
Db::name('house_admin')->where('house_id',$ids)->where('is_direct',1)->update(['house_id'=>'']);
Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$ids,'is_direct'=>1]);
// $data = Db::name('house')->where('id',$ids)->find();
// // 把修改后的管理员状态更新
// Db::name('house_admin')->where('house_id',$ids)->where('is_direct',1)->update(['house_id'=>'']);
// Db::name('house_admin')->where('id',$data['admin_user_id'])->update(['house_id'=>$ids,'is_direct'=>1]);
Db::commit();
} catch (ValidateException $e) {
... ...
... ... @@ -50,7 +50,7 @@ class HouseAdmin extends Backend
// 城市或区县代理
$group_id_arr = array_column($this->auth->getGroups(), 'group_id');
$where1 = [];
$where1 = ['house_id' => $this->request->request('house_id')];
if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr)){
$area_arr = \app\admin\model\AdminArea::where('admin_id',$this->auth->id)->column('area');
foreach ($area_arr as $v) {
... ... @@ -95,6 +95,7 @@ class HouseAdmin extends Backend
*/
public function add()
{
$house_id = $this->request->request('house_id');
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
... ... @@ -102,6 +103,14 @@ class HouseAdmin extends Backend
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
// 判断该用户已经是此小区的管理员了
if($this->model->get(['user_id'=>$params['user_id'],'house_id'=>$house_id])){
$this->error('该用户已经是此小区的管理员了');
}
$params['house_id'] = $house_id;
$result = false;
Db::startTrans();
try {
... ... @@ -163,6 +172,10 @@ class HouseAdmin extends Backend
if ($params) {
$params = $this->preExcludeFields($params);
// 判断该用户已经是此小区的管理员了
if($this->model->get(['user_id'=>$params['user_id'],'house_id'=>$row['house_id']]) && $params['user_id'] != $row['user_id']){
$this->error('该用户已经是此小区的管理员了');
}
$result = false;
Db::startTrans();
... ...
... ... @@ -6,6 +6,9 @@ return [
'Nickname' => '管理员姓名',
'Mobile' => '管理员手机号',
'Image' => '管理员头像',
'Is_direct' => '是否为主管理员',
'Is_direct 1' => '是',
'Is_direct 2' => '否',
'Createtime' => '创建时间',
'Updatetime' => '修改时间'
];
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<!--<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Admin_user_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<!--<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Admin_user_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -24,6 +24,12 @@
<input id="c-mobile" class="form-control" data-rule="required;mobile" name="row[mobile]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Is_direct')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_radios('row[is_direct]', [1=>__('Is_direct 1'), 2=>__('Is_direct 2')], 1)}
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
... ...
... ... @@ -18,6 +18,12 @@
<input id="c-mobile" class="form-control" data-rule="required;mobile" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Is_direct')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_radios('row[is_direct]', [1=>__('Is_direct 1'), 2=>__('Is_direct 2')], $row['is_direct'])}
</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">
... ...
... ... @@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id'), operate:false},
{field: 'admin_user_id', title: __('Admin_user_id'), operate:false},
// {field: 'admin_user_id', title: __('Admin_user_id'), operate:false},
{field: 'name', title: __('Name'), operate:'like'},
// {field: 'image', title: __('Image'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'area', title: __('所在地区'), operate:false},
... ... @@ -77,6 +77,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
], operate:false, formatter: Table.api.formatter.buttons
},
{field: 'id', title: __('管理员'), table: table, events: Table.api.events.operate, buttons:
[
{
text: '管理员',
title: '管理员',
icon: 'fa fa-list',
classname: 'btn btn-xs btn-primary btn-dialog',
url: 'house_admin/index?house_id={id}',
extend: 'data-area=\'["80%","80%"]\'',
}
], operate:false, formatter: Table.api.formatter.buttons
},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{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
Table.api.init({
extend: {
index_url: 'house_admin/index' + location.search,
add_url: 'house_admin/add',
add_url: 'house_admin/add' + location.search,
edit_url: 'house_admin/edit',
del_url: 'house_admin/del',
multi_url: 'house_admin/multi',
... ...