fix: 全链路运行时修复 — 登录/路由/菜单/门店CRUD

登录流程:
- login() 不再设置 userInfo,由 router guard 触发 getInfo() + 路由生成
- validate() 从 callback 改为 Promise 式,修复异步链断裂
- getInfo() 适配 /auth/me 扁平响应结构

动态路由:
- import.meta.glob 替代 Vite 不支持的多级动态 import
- 目录菜单检测: !component || 'Layout' 而非仅 'Layout'
- resolveComponent 支持多种 key 格式 + 后缀匹配兜底

侧边栏:
- menu.title → menu.name (匹配后端字段)
- 空 path 目录节点加 fallback index

门店管理:
- StoreController: region_id 改 nullable, 新增 contact/capacity/description 验证
- has('status') → filled('status') 修复空字符串导致列表为空
- capacity null → 0 兜底,避免 NOT NULL 约束报错
- 前端: capacity 初始值 '' → 1, handleSubmit 过滤冗余字段
- region 列渲染 region.name 而非 [object Object]
- 新增 stores 表迁移: contact/capacity/description 列

种子数据:
- DatabaseSeeder 改用 InitSeeder
- createMenus() 补全 52 个叶子页面菜单 (13 模块)
- 目录菜单添加 path 属性

其他:
- vite proxy 端口 8000 → 8001
- request.js 添加 Accept: application/json
- UserStatus 枚举值对齐 (Active=1, Disabled=0)
- 新增 positions/index.vue 页面
This commit is contained in:
li
2026-03-13 23:53:30 +08:00
parent 058ee507fa
commit 4a68855a88
14 changed files with 478 additions and 93 deletions
+2 -11
View File
@@ -4,16 +4,7 @@ namespace App\Enums;
enum UserStatus: int
{
case Pending = 0;
case Active = 1;
case Disabled = 2;
public function label(): string
{
return match ($this) {
self::Pending => '待审核',
self::Active => '正常',
self::Disabled => '禁用',
};
}
case Disabled = 0;
case Pending = 2;
}
@@ -16,7 +16,7 @@ class StoreController extends Controller
if ($request->keyword) {
$query->where('name', 'like', "%{$request->keyword}%");
}
if ($request->has('status')) {
if ($request->filled('status')) {
$query->where('status', $request->status);
}
@@ -29,14 +29,20 @@ class StoreController extends Controller
public function store(Request $request): JsonResponse
{
$data = $request->validate([
'region_id' => 'required|exists:regions,id',
'region_id' => 'nullable|exists:regions,id',
'name' => 'required|string|max:100',
'code' => 'nullable|string|max:20|unique:stores,code',
'address' => 'nullable|string|max:255',
'phone' => 'nullable|string|max:20',
'contact' => 'nullable|string|max:50',
'capacity' => 'nullable|integer|min:0|max:9999',
'description' => 'nullable|string|max:500',
'status' => 'in:0,1',
]);
// capacity 列有 NOT NULL + default(0),空值时用默认值
$data['capacity'] = $data['capacity'] ?? 0;
$store = Store::create($data);
return $this->success($store, '创建成功');
}
@@ -50,14 +56,21 @@ class StoreController extends Controller
public function update(Request $request, Store $store): JsonResponse
{
$data = $request->validate([
'region_id' => 'exists:regions,id',
'region_id' => 'nullable|exists:regions,id',
'name' => 'string|max:100',
'code' => 'nullable|string|max:20|unique:stores,code,' . $store->id,
'address' => 'nullable|string|max:255',
'phone' => 'nullable|string|max:20',
'contact' => 'nullable|string|max:50',
'capacity' => 'nullable|integer|min:0|max:9999',
'description' => 'nullable|string|max:500',
'status' => 'in:0,1',
]);
if (array_key_exists('capacity', $data) && $data['capacity'] === null) {
$data['capacity'] = 0;
}
$store->update($data);
return $this->success($store, '更新成功');
}
+2 -1
View File
@@ -9,7 +9,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
class Store extends Model
{
protected $fillable = [
'region_id', 'name', 'code', 'address', 'phone', 'logo', 'status',
'region_id', 'name', 'code', 'address', 'phone', 'logo',
'contact', 'capacity', 'description', 'status',
];
protected $casts = [