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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import type { PageParam, PageResult } from '@vben/request';
 
import { requestClient } from '#/api/request';
 
export namespace MesQcIndicatorResultApi {
  /** 平行测量批次明细(同一指标的一次测量) */
  export interface Measure {
    detailId?: number; // 明细编号
    resultId?: number; // 关联检验结果 ID
    measureNo?: number; // 测量批次号(从 1 开始)
    value?: string; // 检测值
    remark?: string; // 备注
  }
 
  /** MES 检验结果明细(树形:分组项下挂子项;平行测量放入 measures) */
  export interface IndicatorResultDetail {
    id?: number; // 编号(第一批明细 ID,兼容旧字段)
    resultId?: number; // 关联检验结果 ID
    indicatorId?: number; // 检测指标 ID
    value?: string; // 检测值(第一批,兼容旧字段)
    valueNumber?: number; // UI 数值绑定(提交前转字符串)
    measureNo?: number; // 测量批次号(提交用,默认 1)
    remark?: string; // 备注
    // 关联查询字段(来自 indicator)
    indicatorName?: string; // 检测指标名称
    valueType?: number; // 质检值类型
    valueSpecification?: string; // 值属性
    parentId?: number; // 父指标编号(0=顶级)
    itemType?: number; // 条目类型:1=录入项,2=分组项
    formulaText?: string; // 公式展示文本
    unitText?: string; // 单位文本
    sortOrder?: number; // 同级排序号
    measures?: Measure[]; // 平行测量批次列表(按 measureNo 升序)
    children?: IndicatorResultDetail[]; // 子项列表(分组项下挂)
  }
 
  /** MES 检验结果 */
  export interface IndicatorResult {
    id?: number; // 编号
    code?: string; // 样品编号
    qcId?: number; // 关联质检单 ID
    qcType?: number; // 质检类型
    itemId?: number; // 产品物料 ID
    sn?: string; // 物资 SN
    remark?: string; // 备注
    createTime?: Date; // 创建时间
    items?: IndicatorResultDetail[]; // 检验结果明细列表
  }
}
 
/** 查询检验结果分页 */
export function getIndicatorResultPage(
  params: PageParam & { qcId?: number; qcType?: number },
) {
  return requestClient.get<PageResult<MesQcIndicatorResultApi.IndicatorResult>>(
    '/mes/qc/indicator-result/page',
    { params },
  );
}
 
/** 查询检验结果明细(含检测项模板):编辑传 id,新增不传 */
export function getIndicatorResultDetail(
  qcId: number,
  qcType: number,
  id?: number,
) {
  return requestClient.get<MesQcIndicatorResultApi.IndicatorResult>(
    '/mes/qc/indicator-result/get-detail',
    { params: { id, qcId, qcType } },
  );
}
 
/** 新增检验结果 */
export function createIndicatorResult(
  data: MesQcIndicatorResultApi.IndicatorResult,
) {
  return requestClient.post('/mes/qc/indicator-result/create', data);
}
 
/** 修改检验结果 */
export function updateIndicatorResult(
  data: MesQcIndicatorResultApi.IndicatorResult,
) {
  return requestClient.put('/mes/qc/indicator-result/update', data);
}
 
/** 删除检验结果 */
export function deleteIndicatorResult(id: number) {
  return requestClient.delete(`/mes/qc/indicator-result/delete?id=${id}`);
}
 
// ==================== 检验报告单(打印数据) ====================
 
export namespace MesQcReportApi {
  /** 报告测量值 */
  export interface ReportMeasure {
    measureNo?: number; // 测量批次号
    value?: string; // 检测值
    remark?: string; // 备注
  }
 
  /** 报告检验项(树形) */
  export interface ReportItem {
    indicatorId?: number;
    indicatorCode?: string;
    indicatorName?: string;
    parentId?: number;
    itemType?: number; // 1=录入项,2=分组项
    formulaText?: string;
    unitText?: string;
    sortOrder?: number;
    checkMethod?: string; // 检测方法
    standardValue?: string; // 标准值
    thresholdMin?: string; // 阈值下限
    thresholdMax?: string; // 阈值上限
    measures?: ReportMeasure[];
    children?: ReportItem[];
  }
 
  /** 检验报告单 */
  export interface QcReport {
    qcType?: number;
    docCode?: string;
    docName?: string;
    itemCode?: string;
    itemName?: string;
    itemSpecification?: string;
    batchNo?: string;
    samplingLocation?: string;
    certificateNo?: string;
    executeStandard?: string;
    samplingTime?: Date;
    batchQuantity?: number;
    checkResult?: number;
    checkResultText?: string; // 检测结果文案(后端按质检类型字典解析,用于判定结论)
    inspectorUserId?: number;
    inspectorName?: string;
    auditUserId?: number;
    auditName?: string;
    approveUserId?: number;
    approveName?: string;
    remark?: string;
    measureNos?: number[]; // 列头:测量批次号列表
    items?: ReportItem[];
  }
}
 
/** 查询检验报告单数据(打印用) */
export function getQcReport(qcId: number, qcType: number, resultId?: number) {
  return requestClient.get<MesQcReportApi.QcReport>('/mes/qc/indicator-result/report', {
    params: { qcId, qcType, resultId },
  });
}
 
/** 导出产品检验单 Word(纸质检验单版式,返回 Blob) */
export function exportProductWord(qcId: number, qcType: number, resultId?: number) {
  return requestClient.download('/mes/qc/indicator-result/export-product-word', {
    params: { qcId, qcType, resultId },
  });
}