...
|
...
|
@@ -66,7 +66,7 @@ class Company extends Backend |
|
|
foreach ($list as $row) {
|
|
|
$row->visible(['id','user_id','name','address','license','legal_person','invite_code','status']);
|
|
|
$row->visible(['user']);
|
|
|
$row->getRelation('user')->visible(['nickname']);
|
|
|
$row->getRelation('user')->visible(['group_id','nickname']);
|
|
|
}
|
|
|
$list = collection($list)->toArray();
|
|
|
$result = array("total" => $total, "rows" => $list);
|
...
|
...
|
@@ -143,4 +143,53 @@ class Company extends Backend |
|
|
$this->success($msg);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置角色
|
|
|
*/
|
|
|
public function setgroup($ids = null)
|
|
|
{
|
|
|
if($ids) {
|
|
|
$row = $this->model->get($ids);
|
|
|
if (!$row) {
|
|
|
$this->error(__('No Results were found'));
|
|
|
}
|
|
|
$adminIds = $this->getDataLimitAdminIds();
|
|
|
if (is_array($adminIds)) {
|
|
|
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
$this->error(__('You have no permission'));
|
|
|
}
|
|
|
}
|
|
|
$params = $this->request->param();
|
|
|
if ($params['group_id'] == 1) {
|
|
|
if ($row->user->group_id == 1) {
|
|
|
$this->error('该用户已经是企业管理员了');
|
|
|
}
|
|
|
}
|
|
|
if ($params['group_id'] == 0) {
|
|
|
if ($row->user->group_id == 0) {
|
|
|
$this->error('该企业管理员已经是普通用户了');
|
|
|
}
|
|
|
}
|
|
|
$row->user->group_id = $params['group_id'];
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$result = $row->user->save();
|
|
|
Db::commit();
|
|
|
} catch (ValidateException $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (\think\Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if(!$result) {
|
|
|
$this->error('操作失败');
|
|
|
}
|
|
|
$this->success('操作成功');
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|