zhangwencui
昨天 388b07c38e88e618c4332f07b96994516dc04207
src/views/salesManagement/salesLedger/components/processCardPrint.js
@@ -52,15 +52,28 @@
  return columns || '<td class="route-col"></td>';
};
const renderItems = (items, startIndex, routeNodes, totalCols) => {
const renderItems = (
  items,
  startIndex,
  routeNodes,
  totalCols,
  previousProductName,
  fallbackProductName
) => {
  const list = Array.isArray(items) ? items : [];
  if (list.length === 0) {
    return `<tr><td colspan="${totalCols}" style="text-align:center;">暂无明细</td></tr>`;
  }
  const routeEmptyCells = renderRouteEmptyCells(routeNodes);
  let lastProductName = String(previousProductName ?? "").trim();
  return list
    .map(
      (item, index) => `
    .map((item, index) => {
      const currentProductName =
        String(item?.productDescription ?? "").trim() || fallbackProductName;
      const shouldRenderProductRow = currentProductName !== lastProductName;
      lastProductName = currentProductName;
      return `
      ${shouldRenderProductRow ? `<tr><td colspan="${totalCols}" class="section-title">产品名称:${escapeHtml(currentProductName)}</td></tr>` : ""}
      <tr>
        <td>${startIndex + index + 1}</td>
        <td class="no-wrap">${escapeHtml(item?.floorCode)}</td>
@@ -70,8 +83,8 @@
        <td class="no-wrap">${escapeHtml(item?.processRequirement)}</td>
        ${routeEmptyCells}
      </tr>
    `
    )
    `;
    })
    .join("");
};
@@ -89,8 +102,7 @@
  const data = cardData ?? {};
  const routeNodes = Array.isArray(data.routeNodes) ? data.routeNodes : [];
  const items = Array.isArray(data.items) ? data.items : [];
  const firstItem = items[0] ?? {};
  const productName = firstItem.productDescription || "";
  const fallbackProductName = String(data?.productName ?? "").trim();
  const totalCols = 6 + Math.max(routeNodes.length, 1);
  const signLabelCols = 2;
  const signBlankCols = Math.max(totalCols - 5 - signLabelCols, 1);
@@ -187,9 +199,15 @@
      .map((pageItems, pageIndex) => {
        const isLastPage = pageIndex === totalPages - 1;
        const startIndex = pageIndex * pageSize;
        const previousProductName =
          startIndex > 0
            ? String(items[startIndex - 1]?.productDescription ?? "").trim() ||
              fallbackProductName
            : "";
        return `
    <div class="page">
      <div class="header">
        <div class="title">鹤壁天沐钢化玻璃厂<br /><span class="sub-title">生产流程卡(成品)</span></div>
        ${
          qrDataUrl
            ? `<div class="qr-block">
@@ -197,7 +215,6 @@
        </div>`
            : ""
        }
        <div class="title">鹤壁天沐钢化玻璃厂<br /><span class="sub-title">生产流程卡(成品)</span></div>
      </div>
      <div class="table-wrap">
      <div class="page-mark">第${pageIndex + 1}页,共${totalPages}页</div>
@@ -223,10 +240,14 @@
          <tr>${renderRouteRow(routeNodes)}</tr>
        </thead>
        <tbody>
          <tr>
            <td colspan="${totalCols}" class="section-title">产品名称:${escapeHtml(productName)}</td>
          </tr>
          ${renderItems(pageItems, startIndex, routeNodes, totalCols)}
          ${renderItems(
            pageItems,
            startIndex,
            routeNodes,
            totalCols,
            previousProductName,
            fallbackProductName
          )}
          ${
            isLastPage
              ? `<tr>