Commit fa1595cd by 宁成龙

修复权限

parent ac4c8093
......@@ -19,16 +19,16 @@ class UserAssignAction extends BatchAction
protected $action;
protected $htmlClasses = ['btn btn-primary btn-sm btn-mini'];
// 注意action的构造方法参数一定要给默认值
public function __construct()
// 注意action的构造方法参数一定要给默认值 1指派,2转让
public function __construct($action=1)
{
$this->title = "";
$this->action = 1;
$this->action = $action;
}
public function render()
{
$form = AssignUserHandle::make();
$form = AssignUserHandle::make(['action' => $this->action]);
$buttonName = trans('user.labels.assign');
return Modal::make()->lg()->title($this->title)->body($form->payload([]))->onLoad($this->getModalScript())->button('<button class="btn btn-primary">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline" style="margin-left: 5px">' . $buttonName . '</span>
......
......@@ -43,7 +43,7 @@ class AssignUserHandle extends Form implements LazyRenderable
{
$this->disableResetButton();
$this->hidden('id')->attribute('id', 'id');
$this->select('sale_id')->options(CmsUser::pluck('name', 'userId')->toArray())->default(0)->required();
$this->select('sale_id')->options(CmsUser::getUserList())->default(0)->required();
}
/**
......
......@@ -2,6 +2,7 @@
namespace App\Admin\Forms\User;
use App\Admin\Service\PermService;
use App\Admin\Service\UserService;
use App\Models\Cms\CmsUser;
use App\Models\Inquiry;
......@@ -36,6 +37,43 @@ class TransferUserHandle extends Form implements LazyRenderable
}
}
public function getCmsUserList()
{
CmsUser::getUserList();
$where = [];
$where[] = [
function ($query) {
$viewList = User::$ruleViewList;
$adminUser = "userId";
$nowSaleId = getAdminUserId();
if ($nowSaleId == 1000) {
return $query;
}
//查看所有
if (checkPerm($viewList[0])) {
return $query;
}
//查看下级
if (checkPerm($viewList[1])) { //查看下级的权限//获取用户部门下的所有用户
$userIds = PermService::getSubUserId($nowSaleId);
if (!empty($userIds)) {
return $query->whereIn($adminUser, $userIds);
}
}
//查看同组
$user_info = CmsUser::getInfoByUserId($nowSaleId);
if (empty($user_info) || !$user_info['department_id']) {
return $query->where($adminUser, $nowSaleId);
}
// 获取下级部门的人员
$sub_user_ids = CmsUser::getUserIdsByDepartmentIds([$user_info['department_id']]);
return $query->whereIn($adminUser, $sub_user_ids);
}
];
return CmsUser::where($where)->pluck('name', 'userId')->toArray();
}
/**
* Build a form here.
*/
......@@ -43,7 +81,7 @@ class TransferUserHandle extends Form implements LazyRenderable
{
$this->disableResetButton();
$this->hidden('id')->attribute('id', 'id');
$this->select('sale_id')->options(CmsUser::getUserList())->default(0)->required();
$this->select('sale_id')->options($this->getCmsUserList())->default(0)->required();
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment