diff --git a/Cunkebao/app/traffic-pool/page.tsx b/Cunkebao/app/traffic-pool/page.tsx index 13f7cd0d..20979277 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 44513f04..945c75c1 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) {