fix: 修复页面间状态丢失问题并优化选择页面
- 修复选择审批人后再选择抄送人导致状态丢失的问题 - 使用独立的 sessionStorage key (selectedApprovers, selectedCc) - 组件每次挂载时从 sessionStorage 恢复状态 - 只在提交/保存成功后清除 sessionStorage - 优化人员选择页面布局和样式 - 更新 CLAUDE.md 文档记录问题和解决方案 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Model\User;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
|
||||
class UserController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
public function info(Request $request): Response
|
||||
{
|
||||
$userId = $this->getUserId($request);
|
||||
$user = User::find($userId);
|
||||
|
||||
if (!$user) {
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
|
||||
return $this->success($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户菜单权限
|
||||
*/
|
||||
public function menu(Request $request): Response
|
||||
{
|
||||
// TODO: 根据用户权限返回菜单
|
||||
return $this->success([
|
||||
['id' => 1, 'name' => '首页', 'path' => '/dashboard'],
|
||||
['id' => 2, 'name' => '出差审批', 'path' => '/business-trip'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户可切换的公司列表
|
||||
*/
|
||||
public function companies(Request $request): Response
|
||||
{
|
||||
$userId = $this->getUserId($request);
|
||||
|
||||
// TODO: 从数据库获取用户关联的公司列表
|
||||
return $this->success([
|
||||
['id' => 1, 'name' => '公司A'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换当前公司
|
||||
*/
|
||||
public function switchCompany(Request $request): Response
|
||||
{
|
||||
$companyId = $request->post('company_id');
|
||||
|
||||
// TODO: 更新用户当前公司
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表(用于选择审批人等)
|
||||
*/
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
$userId = $this->getUserId($request);
|
||||
$keyword = $request->get('keyword', '');
|
||||
$page = (int) $request->get('page', 1);
|
||||
$pageSize = (int) $request->get('page_size', 50);
|
||||
|
||||
$query = User::active();
|
||||
|
||||
if ($keyword) {
|
||||
$query->search($keyword);
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
$list = $query->orderBy('id')
|
||||
->offset(($page - 1) * $pageSize)
|
||||
->limit($pageSize)
|
||||
->get();
|
||||
|
||||
return $this->success([
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
'page_size' => $pageSize,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user