refactor: 移动 CategoryInferenceService 到 product-category 模块,修复循环依赖

- 移动 category-inference.service.ts 从 lead/ 到 product-category/
- 修复所有 import 路径
- InquiryPage 品类筛选改为动态 API 加载
This commit is contained in:
Sisyphus 2026-07-01 02:38:30 +08:00
parent 58ac140802
commit f625dd0de1
4 changed files with 10 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import { Injectable, NotFoundException, Logger, ServiceUnavailableException } fr
import { PrismaService } from '../prisma/prisma.service'
import { IntegrationService } from '../integration/integration.service'
import { ProductCategoryService } from '../product-category/product-category.service'
import { CategoryInferenceService } from './category-inference.service'
import { CategoryInferenceService } from '../product-category/category-inference.service'
@Injectable()
export class LeadService {

View File

@ -2,7 +2,7 @@ import { Module } from '@nestjs/common'
import { PrismaModule } from '../prisma/prisma.module'
import { ProductCategoryService } from './product-category.service'
import { ProductCategoryController } from './product-category.controller'
import { CategoryInferenceService } from '../lead/category-inference.service'
import { CategoryInferenceService } from './category-inference.service'
@Module({
imports: [PrismaModule],

View File

@ -59,7 +59,6 @@ function mapLead(raw: any): Lead {
const STATUS_OPTIONS = ['全部状态', '待复核', '待跟进', '跟进中', '已转询价', '已转协同', '已成交', '无效线索']
const LEVEL_OPTIONS = ['全部级别', 'S级', 'A级', 'B级', 'C级', 'D级']
const CAT_OPTIONS = ['全部品类', '防火门', '配电箱', '电线电缆', '阀门', '钢材', '涂料', '混凝土', '变压器', '水泵', '风机', '管材', '开关', '灯具', '仪表', '电机']
const SOURCE_OPTIONS = ['全部来源', '中电建', '新矿集团', '中核集团']
const PERSON_OPTIONS = ['全部人员', '郑钊', '赵主任', '运营管理员', '未分配']
@ -115,6 +114,7 @@ export default function InquiryPage({ onLeadDetail }: { onLeadDetail?: (id: stri
const [fStatus, setFStatus] = useState('全部状态')
const [fLevel, setFLevel] = useState('全部级别')
const [fCat, setFCat] = useState('全部品类')
const [catOptions, setCatOptions] = useState<string[]>(['全部品类'])
const [fSource, setFSource] = useState('全部来源')
const [fPerson, setFPerson] = useState('全部人员')
@ -145,6 +145,12 @@ export default function InquiryPage({ onLeadDetail }: { onLeadDetail?: (id: stri
setLoading(false)
}, [])
useEffect(() => {
fetch(`${API_BASE}/api/categories`).then(r => r.json()).then((data: any[]) => {
setCatOptions(['全部品类', ...data.map((c: any) => c.name)])
}).catch(() => {})
}, [])
useEffect(() => { loadLeads(fStar, fStatus, fLevel, fCat, fSource, fPerson, fTime) }, [loadLeads, fStar, fStatus, fLevel, fCat, fSource, fPerson, fTime])
const refreshLeads = async () => {
@ -396,7 +402,7 @@ export default function InquiryPage({ onLeadDetail }: { onLeadDetail?: (id: stri
{ label: '公告日期', value: fTime, set: setFTime, opts: ['全部日期', '今天', '昨天', '本周', '本月'] },
{ label: '星级', value: fStar, set: setFStar, opts: ['全部星级', '5星', '4星', '3星', '2星及以下'] },
{ label: '甲方级别', value: fLevel, set: setFLevel, opts: LEVEL_OPTIONS },
{ label: '品类', value: fCat, set: setFCat, opts: CAT_OPTIONS },
{ label: '品类', value: fCat, set: setFCat, opts: catOptions },
{ label: '来源平台', value: fSource, set: setFSource, opts: SOURCE_OPTIONS },
{ label: '负责人', value: fPerson, set: setFPerson, opts: PERSON_OPTIONS },
].map(f => (