设置角色组
This commit is contained in:
@@ -84,6 +84,33 @@ class User extends Backend
|
||||
return parent::edit($ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角色组
|
||||
*/
|
||||
public function group($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post('row/a');
|
||||
$groupId = isset($params['group_id']) ? intval($params['group_id']) : 0;
|
||||
if (!$groupId || !\app\admin\model\UserGroup::get($groupId)) {
|
||||
$this->error('请选择角色组');
|
||||
}
|
||||
$result = $row->allowField(['group_id'])->save(['group_id' => $groupId]);
|
||||
if ($result === false) {
|
||||
$this->error('角色组保存失败');
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
$this->view->assign('row', $row);
|
||||
$this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<form id="group-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
{:token()}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Nickname')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input class="form-control" type="text" value="{$row.nickname|htmlentities}" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Group')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
{$groupList}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-3"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -18,6 +18,7 @@
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
data-operate-edit="{:$auth->check('user/user/edit')}"
|
||||
data-operate-del="{:$auth->check('user/user/del')}"
|
||||
data-operate-group="{:$auth->check('user/user/group')}"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -33,6 +33,7 @@ class Profile extends Api
|
||||
public function userCenter()
|
||||
{
|
||||
$userInfo = $this->auth->getUserinfo();
|
||||
$group = $this->auth->getUser()->group;
|
||||
$userInfo = [
|
||||
'id' => $userInfo['id'],
|
||||
'avatarUrl' => $userInfo['avatar'] ?: $this->request->domain() . '/uploads/avatar/default.png',
|
||||
@@ -40,6 +41,7 @@ class Profile extends Api
|
||||
'phoneNumber' => '',
|
||||
'gender' => $userInfo['gender'],
|
||||
'role' => $userInfo['role'],
|
||||
'group_name' => $group ? trim((string)$group['name']) : '',
|
||||
];
|
||||
$publishCount = DemandService::where('user_id', $userInfo['id'])->count();
|
||||
$quoteCount = DemandBiddingService::where(['user_id' => $userInfo['id']])->count();
|
||||
|
||||
@@ -547,7 +547,7 @@ if (!function_exists('convert_keys_to_camelcase')) {
|
||||
if (!function_exists('generate_order_sn')) {
|
||||
function generate_order_sn($prefix = '', $digits = 10)
|
||||
{
|
||||
$sn = date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, $digits);
|
||||
$sn = date('Ymd') . substr(implode('', array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, $digits);
|
||||
return strtoupper($prefix) . $sn;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user