17 小时以前 35722562e9e13f0504acc15b740d042ecb810199
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
import type { PageParam, PageResult } from '@vben/request';
 
import { requestClient } from '#/api/request';
 
export namespace QcReportInstanceApi {
  /** 智能质检报告实例 */
  export interface Instance {
    id?: number; // 实例编号
    reportNo?: string; // 报告编号(业务唯一)
    templateId?: number; // 模板编号
    templateVersion?: string; // 生成时使用的模板版本号
    businessId?: string; // 业务单据编号
    businessType?: string; // 业务单据类型
    status?: number; // 报告状态:0生成中 1生成成功 2生成失败
    creator?: string; // 创建人
    createTime?: Date; // 创建时间
    updateTime?: Date; // 更新时间
  }
 
  /**
   * 实例详情。
   * <p>
   * 比列表多一个 {@link renderHtml}——那是出件时冻结下来的产物,用 iframe 直接渲染即为「预览」,
   * 不需要重新出件。数据快照不在这个接口里,要看得单独调 {@link QcReportInstanceApi.Instance} 的 snapshot。
   */
  export interface InstanceDetail extends Instance {
    renderHtml?: string; // 渲染产物 HTML
  }
 
  /** PDF 出件结果 */
  export interface PdfResult {
    id: number; // 实例编号
    reportNo: string; // 报告编号
    fileName: string; // PDF 文件名
    byteSize: number; // PDF 字节数
    blobId?: number; // 文件编号
    attachmentId?: number; // 附件关联编号
    previewURL?: string; // 预览地址(临时签名,会过期)
    downloadURL?: string; // 下载地址(临时签名,会过期)
    durationMs?: number; // 本次出件总耗时(毫秒)
    pdfDurationMs?: number; // 打印耗时(毫秒)
    browserStatus?: string; // 浏览器状态:READY / RESTARTED
  }
 
  /**
   * 由质检单出件的入参。
   * <p>
   * 这里刻意没有 context——数据全部由后端从 MES 质检单取,前端只负责选「哪张单据 + 哪张模板」。
   */
  export interface GenerateFromQcReq {
    qcType: number; // 质检类型:1 来料 2 过程 3 出货 4 退货
    qcId: number; // 质检单编号(四张表各自的主键)
    templateId: number; // 报告模板编号,其 reportType 必须与 qcType 一致
    version?: string; // 模板版本号,不传取模板 currentVersion
    reportNo?: string; // 报告编号,不传由后端按 QR+日期+流水 生成
  }
 
  /** 由质检单出件的结果 */
  export interface GenerateFromQcResult {
    id: number; // 报告实例编号,拿去跳详情/反查
    reportNo: string; // 最终生效的报告编号
    templateVersion: string; // 本次使用的模板版本号
    itemCount: number; // 写入报告的检验项条数(不等于质检单行数)
    undecidableCount: number; // 待判定项数,大于 0 必须提示用户
    warnings?: string[]; // 数据取舍的软提示:分组标题被跳过 / 指标已删 / 未录实测值 / 样品数过多
    errors?: string[]; // 渲染期数据缺口(模板绑定了但没数据的字段)
  }
}
 
/** 查询报告实例分页 */
export function getInstancePage(params: PageParam) {
  return requestClient.get<PageResult<QcReportInstanceApi.Instance>>(
    '/qc-report/instance/page',
    { params },
  );
}
 
/** 查询报告实例详情(含渲染产物 HTML,不含数据快照) */
export function getInstance(id: number) {
  return requestClient.get<QcReportInstanceApi.InstanceDetail>(
    `/qc-report/instance/get?id=${id}`,
  );
}
 
/** 查询报告实例冻结的数据快照 */
export function getInstanceSnapshot(id: number) {
  return requestClient.get<Record<string, unknown>>(
    `/qc-report/instance/snapshot?id=${id}`,
  );
}
 
/** 导出 PDF(打印实例已存的渲染产物并归档到附件库,可重复调用) */
export function exportInstancePdf(id: number) {
  return requestClient.post<QcReportInstanceApi.PdfResult>(
    `/qc-report/instance/pdf?id=${id}`,
  );
}
 
/** 删除报告实例 */
export function deleteInstance(id: number) {
  return requestClient.delete(`/qc-report/instance/delete?id=${id}`);
}
 
/**
 * 由质检单(IQC/IPQC/OQC/RQC)直接生成报告。
 * <p>
 * 数据由后端经 MesQcReportApi 从 MES 取,前端不拼 context。
 * 调用前五道校验按业务优先级只报第一处;失败都是「数据或选择不对」,重试无用,按报文改数据或换模板。
 */
export function generateInstanceFromQc(
  data: QcReportInstanceApi.GenerateFromQcReq,
) {
  return requestClient.post<QcReportInstanceApi.GenerateFromQcResult>(
    '/qc-report/instance/generate-from-qc',
    data,
  );
}