实现报销材料连续预览(07-27-yang-jun-reimbursement-readiness)
ci-e2e / e2e (push) Canceled after 0s
ci-minimal / check-minimal (push) Canceled after 0s

这个提交包含在:
2026-08-01 00:17:54 +08:00
父节点 b6485a278e
当前提交 8a9279efce
共修改 26 个文件,包含 1211 行新增和 178 行删除
+30 -3
查看文件
@@ -7,6 +7,8 @@ type InvoiceDisplayLike = {
invoiceNumber?: string | null;
invoiceDate?: string | null;
sellerName?: string | null;
buyerName?: string | null;
documentCategory?: string | null;
originalName?: string | null;
unavailableReason?: string | null;
unavailableMessage?: string | null;
@@ -18,6 +20,26 @@ type InvoiceDisplayLike = {
ocrLastError?: string | null;
};
const INVOICE_CATEGORY_LABELS: Record<string, string> = {
vat_invoice: "增值税发票",
full_vat_invoice: "数电发票",
electronic_train_ticket: "电子火车票",
};
export function resolveInvoiceTypeLabel(invoice: InvoiceDisplayLike | null | undefined) {
return invoice?.documentCategory && INVOICE_CATEGORY_LABELS[invoice.documentCategory]
? INVOICE_CATEGORY_LABELS[invoice.documentCategory]
: "发票";
}
export function resolveInvoicePartyText(invoice: InvoiceDisplayLike | null | undefined) {
if (!invoice) return "";
if (invoice.documentCategory === "electronic_train_ticket") {
return invoice.buyerName ? `购买方:${invoice.buyerName}` : "";
}
return invoice.sellerName ? `销售方:${invoice.sellerName}` : "";
}
const INVOICE_STATUS_LABELS: Record<InvoicePoolStatus, string> = {
pending_ocr: "识别中",
ocr_failed: "识别失败",
@@ -37,11 +59,16 @@ export function formatInvoiceDisplayTitle(invoice: InvoiceDisplayLike | null | u
return "未识别发票";
}
if (invoice.invoiceCode || invoice.invoiceNumber) {
return `${invoice.invoiceCode || "无代码"}-${invoice.invoiceNumber || "无号码"}`;
const typeLabel = resolveInvoiceTypeLabel(invoice);
if (invoice.invoiceCode && invoice.invoiceNumber) {
return `${typeLabel} · ${invoice.invoiceCode}-${invoice.invoiceNumber}`;
}
return invoice.sellerName || invoice.originalName || "未识别发票";
if (invoice.invoiceNumber || invoice.invoiceCode) {
return `${typeLabel} · ${invoice.invoiceNumber || invoice.invoiceCode}`;
}
return invoice.sellerName || invoice.originalName || typeLabel;
}
function looksLikeMachineMessage(message: string) {
+14 -1
查看文件
@@ -24,7 +24,7 @@ async function configuredWecomSdk() {
}
ww.register({
corpId: config.corpId,
jsApiList: ["previewFile"],
jsApiList: ["previewFile", "previewImage"],
async getConfigSignature(url) {
const signed = await fetchWecomJsSdkSignature(url || currentPageUrl());
return {
@@ -58,6 +58,19 @@ export async function previewFileInWecom(file: NativePreviewFile) {
return true;
}
export async function previewImagesInWecom(urls: string[], current = urls[0]) {
if (!isWecomWebView()) {
return false;
}
const normalized = urls.map((url) => url.trim()).filter(Boolean);
if (!normalized.length || !current || !normalized.includes(current)) {
throw new Error("图片预览信息不完整");
}
const ww = await configuredWecomSdk();
await ww.previewImage({ current, urls: normalized });
return true;
}
export function openFileInBrowser(url: string) {
window.open(url, "_blank", "noopener,noreferrer");
}