feat: 审批历史支持PI号筛选,并修复原搜索框后端未实现的问题
- 新增 pi_no 参数:模糊匹配备货单 pi_no -> 单id -> 审批实例biz_id (whereHas,todo/history 场景通用) - 顺带修复:历史页一直发送的 keyword 参数后端从未处理(搜索框是摆设), 现按 单号/PI号/客户名称 任一模糊匹配;与 pi_no 同传时取交集 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ namespace app\common\service;
|
||||
|
||||
use app\common\model\User;
|
||||
use app\common\model\UserGroupMembers;
|
||||
use support\Db;
|
||||
use app\common\validate\ApprovalRecordsValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\ApprovalRecords;
|
||||
@@ -118,6 +119,31 @@ class ApprovalRecordsService
|
||||
$config['where']['status'] = ['!=', 'pending'];
|
||||
}
|
||||
|
||||
// 业务筛选:pi_no 精确到PI号;keyword 匹配 单号/PI号(历史页原有搜索框此前后端未实现)
|
||||
// 两个条件同时传时取交集
|
||||
$bizIdFilter = null;
|
||||
if (!empty($p['pi_no'])) {
|
||||
$ids = Db::table('stock_orders')
|
||||
->where('pi_no', 'like', '%' . trim((string)$p['pi_no']) . '%')
|
||||
->pluck('id')->toArray();
|
||||
$bizIdFilter = $ids ?: [0];
|
||||
}
|
||||
if (!empty($p['keyword'])) {
|
||||
$kw = '%' . trim((string)$p['keyword']) . '%';
|
||||
$ids = Db::table('stock_orders')
|
||||
->where(function ($q) use ($kw) {
|
||||
$q->where('order_no', 'like', $kw)
|
||||
->orWhere('pi_no', 'like', $kw)
|
||||
->orWhere('customer_snapshot', 'like', $kw);
|
||||
})
|
||||
->pluck('id')->toArray();
|
||||
$ids = $ids ?: [0];
|
||||
$bizIdFilter = $bizIdFilter === null ? $ids : array_values(array_intersect($bizIdFilter, $ids));
|
||||
}
|
||||
if ($bizIdFilter !== null) {
|
||||
$config['where']['instance.biz_id'] = ['in', $bizIdFilter];
|
||||
}
|
||||
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
$config['with'] = [
|
||||
|
||||
Reference in New Issue
Block a user