From fa9e5c48974f1bab02fb691d5a6399867843745b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Tue, 13 May 2025 15:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=81=E5=9F=9F=E6=93=8D=E7=9B=98=E6=89=8B?= =?UTF-8?q?=20-=20=E8=B0=83=E6=95=B4=E6=B5=81=E9=87=8F=E6=B1=A0=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6=E5=8F=8A?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cunkebao/app/traffic-pool/page.tsx | 27 ++++++++++++------- ...PotentialListWithInCompanyV1Controller.php | 17 +++++++++--- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Cunkebao/app/traffic-pool/page.tsx b/Cunkebao/app/traffic-pool/page.tsx index 13f7cd0df..209792776 100644 --- a/Cunkebao/app/traffic-pool/page.tsx +++ b/Cunkebao/app/traffic-pool/page.tsx @@ -151,16 +151,25 @@ export default function TrafficPoolPage() { const params = new URLSearchParams({ page: page.toString(), - limit: "30", - search: debouncedSearchQuery, - category: activeCategory, - source: sourceFilter !== "all" ? sourceFilter : "", - status: statusFilter === "all" ? "" : statusFilter, + limit: "30" }) - const sourceParam = searchParams?.get("source") - if (sourceParam) { - params.append("wechatSource", sourceParam) + // 只有在有搜索关键词时才添加 keyword 参数 + if (debouncedSearchQuery) { + params.append("keyword", debouncedSearchQuery) + } + + // 只有在选择了特定来源时才添加 fromd 参数 + if (sourceFilter !== "all") { + const selectedSource = sourceTypes.find(source => source.id.toString() === sourceFilter) + if (selectedSource) { + params.append("fromd", selectedSource.name) + } + } + + // 只有在选择了特定状态时才添加 status 参数 + if (statusFilter !== "all") { + params.append("status", statusFilter) } const response = await api.get>(`/v1/traffic/pool?${params.toString()}`, { @@ -216,7 +225,7 @@ export default function TrafficPoolPage() { setIsFetching(false) setLoading(false) } - }, [debouncedSearchQuery, activeCategory, sourceFilter, statusFilter, searchParams]) + }, [debouncedSearchQuery, sourceFilter, statusFilter, sourceTypes]) const fetchStatusTypes = useCallback(async () => { try { diff --git a/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php b/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php index 44513f041..945c75c11 100644 --- a/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php +++ b/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php @@ -20,11 +20,20 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController */ protected function makeWhere(array $params = []): array { - // 关键词搜索(同时搜索IMEI和备注) if (!empty($keyword = $this->request->param('keyword'))) { $where[] = ['exp', "p.identifier LIKE '%{$keyword}%'"]; } + // 状态筛选 + if ($status = $this->request->param('status')) { + $where['s.status'] = $status; + } + + // 来源的筛选 + if ($fromd = $this->request->param('fromd')) { + $where['s.fromd'] = $fromd; + } + $where['s.companyId'] = $this->getUserInfo('companyId'); return array_merge($where, $params); @@ -38,14 +47,14 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController */ protected function getPoolListByCompanyId(array $where): \think\Paginator { - $query = TrafficPoolModel::alias('t') + $query = TrafficPoolModel::alias('p') ->field( [ - 't.identifier nickname', 't.mobile', 't.wechatId', 't.identifier', + 'p.identifier nickname', 'p.mobile', 'p.wechatId', 'p.identifier', 's.id', 's.fromd', 's.status', 's.createTime' ] ) - ->join('traffic_source s', 't.identifier=s.identifier') + ->join('traffic_source s', 'p.identifier=s.identifier') ->order('s.id desc'); foreach ($where as $key => $value) {