实现报销材料连续预览(07-27-yang-jun-reimbursement-readiness)
这个提交包含在:
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户