1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import type { PageParam, PageResult } from '@vben/request';
 
import { requestClient } from '#/api/request';
 
export namespace SrmStatisticsApi {
  export interface TenderStatisticsVO {
    totalTenderCount?: number;
    totalTenderAmount?: number;
    totalAwardAmount?: number;
    savedAmount?: number;
    winRate?: number;
    supplierCount?: number;
    period?: string;
  }
 
  /** 报价明细项 */
  export interface CostQuoteItem {
    supplierId?: number;
    supplierName?: string;
    quotePrice?: number;
    taxRate?: number;
    deliveryCycle?: number;
    quoteTime?: string;
  }
 
  /** 物料成本分析行 */
  export interface CostAnalysis {
    productId?: number;
    productCode?: string;
    productName?: string;
    productSpec?: string;
    unit?: string;
    totalQuantity?: number;
    quoteCount?: number;
    supplierCount?: number;
    weightedAvgPrice?: number;
    minPrice?: number;
    maxPrice?: number;
    estimatedPrice?: number;
    deviationRate?: number;
    lastQuoteTime?: string;
    priceChange?: number;
    quotes?: CostQuoteItem[];
  }
 
  /** 价格趋势点 */
  export interface CostTrendPoint {
    month?: string;
    avgPrice?: number;
    count?: number;
  }
}
 
/** 获取招标统计 */
export function getTenderStatistics(year: string) {
  return requestClient.get<SrmStatisticsApi.TenderStatisticsVO>(
    '/srm/statistics/tender',
    { params: { year } },
  );
}
 
/** 采购成本分析(基于招标需求量与供应商报价,不依赖 ERP) */
export function getCostAnalysis(
  params: PageParam & { productName?: string },
) {
  return requestClient.get<PageResult<SrmStatisticsApi.CostAnalysis>>(
    '/srm/statistics/cost-analysis',
    { params },
  );
}
 
/** 物料价格趋势 */
export function getCostTrend(productId: number) {
  return requestClient.get<SrmStatisticsApi.CostTrendPoint[]>(
    '/srm/statistics/cost-trend',
    { params: { productId } },
  );
}