Files
SecMPS/api_sqlsugar/VolPro.WebApi/Controllers/Warehouse
g82tt a0a458bc34 V1.12.2: base_device getPageData 智能分流(支持 Filter)
【问题】
主人反馈: /api/base_device/getPageData 使用 filter: [{name:MapModelId, value:mh7b0xvof7p}] 查询时返回空

【根因】
base_deviceController.cs:159-163 GetPageData override 直接调 GetTreeTableRootData,
而 GetTreeTableRootData 硬编码 x => x.ParentDeviceId==0 || null (查顶层设备),
**完全忽略 options.Filter 条件**。
- 子设备(MapModelId 在子设备上)永远查不到
- 主人用 MapModelId 查设备详情场景完全失效

【修复】
base_deviceController.cs:154-197 GetPageData 智能分流:
1. options.Filter 或 options.Wheres 非空 → GetFilteredPageData → 调 _service.GetPageData(options)
   走框架默认实现(ServiceBase.GetPageData:318),自动处理 Filter/Wheres/Sort/分页
2. 都为空 → 保留原 GetTreeTableRootData 调用(treatable 组件兼容)
3. 新增 GetFilteredPageData 私有方法,统一返回 {total, rows} 结构

【验证】
dotnet build api_sqlsugar 0 错误 1 警告(Program.cs:244 与本次无关)

【效果】
- warehouse 大端 Filter.vue 按 MapModelId 查询设备能正常返回
- web.vite 管理端 tree-table 组件(无 filter 调用)行为不变
- 任意字段(DeviceName/AdapterCode/SourceId 等)都能作为 filter 查询
2026-07-24 05:56:16 +08:00
..