From d4deb8855ecae27888e6e6ba0bc2c79e007884a8 Mon Sep 17 00:00:00 2001 From: mzl Date: Wed, 2 Sep 2026 10:10:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=A1=E6=89=B9=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=94=AF=E6=8C=81PI=E5=8F=B7=E7=AD=9B=E9=80=89=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E5=A4=8D=E5=8E=9F=E6=90=9C=E7=B4=A2=E6=A1=86?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E6=9C=AA=E5=AE=9E=E7=8E=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 pi_no 参数:模糊匹配备货单 pi_no -> 单id -> 审批实例biz_id (whereHas,todo/history 场景通用) - 顺带修复:历史页一直发送的 keyword 参数后端从未处理(搜索框是摆设), 现按 单号/PI号/客户名称 任一模糊匹配;与 pi_no 同传时取交集 Co-Authored-By: Claude --- app/common/service/ApprovalRecordsService.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/common/service/ApprovalRecordsService.php b/app/common/service/ApprovalRecordsService.php index f0e33b1..6af6a56 100644 --- a/app/common/service/ApprovalRecordsService.php +++ b/app/common/service/ApprovalRecordsService.php @@ -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'] = [