+ `;
+
+ moduleList.forEach((module) => {
+ const config = module.config;
+
+ if (module.type === "title") {
+ htmlString += `
+
+
+ ${config.title || ""}
+
+
+ `;
+ }
+
+ if (module.type === "dealerInfo") {
+ htmlString += `
+
+
+ `;
+
+ if (config.showDealerName || config.showWatermelonGrade) {
+ htmlString += `
+
+ ${
+ config.showWatermelonGrade
+ ? `${config.dealerName || ""}-${config.watermelonGrade || ""}`
+ : config.dealerName || ""
+ }
+
+ `;
+ } else {
+ htmlString += `
`;
+ }
+
+ if (config.showDestination || config.showVehicleNumber) {
+ htmlString += `
+
+ ${config.destination || ""} ${config.vehicleNumber || ""}
+
+ `;
+ } else {
+ htmlString += `
`;
+ }
+
+ htmlString += `
+
+
+ `;
+ }
+
+ if (module.type === "shippingInfo") {
+ htmlString += `
`;
+
+ if (config.showShippingFrom) {
+ htmlString += `
+
发货地:
+
+ ${config.shippingFrom || ""}
+
+ `;
+ }
+
+ if (config.showDate) {
+ htmlString += `
+
日期:
+
+ ${config.date || ""}
+
+ `;
+ }
+
+ htmlString += `
`;
+ }
+
+ if (module.type === "weightInfo") {
+ if (config.data) {
+ config.data.forEach((item: any) => {
+ htmlString += `
`;
+
+ if (config.showNetWeight) {
+ htmlString += `
+
+
净重:
+
+ ${item.netWeight || ""}
+
+
+ ${config.netWeightUnit === "1" ? "斤" : "公斤"}
+
+
+ `;
+ }
+
+ if (config.showBoxWeight) {
+ htmlString += `
+
+
箱重:
+
+ ${item.boxWeight || ""}
+
+
+ ${config.boxWeightUnit === "1" ? "斤" : "公斤"}
+
+
+ `;
+ }
+
+ if (config.showGrossWeight) {
+ htmlString += `
+
+
毛重:
+
+ ${item.grossWeight || ""}
+
+
+ ${config.grossWeightUnit === "1" ? "斤" : "公斤"}
+
+
+ `;
+ }
+
+ if (config.showUnitPrice) {
+ htmlString += `
+
+
单价:
+
+ ${item.unitPrice || ""}
+
+
+ ${config.unitPriceUnit === "1" ? "元/斤" : "元/公斤"}
+
+
+ `;
+ }
+
+ if (config.showAmount) {
+ htmlString += `
+
+
金额:
+
+ ${item.totalAmount || ""}
+
+
元
+
+ `;
+ }
+
+ if (config.showGrade) {
+ htmlString += `
+
+
品级:
+
+ ${item.watermelonGrade || ""}
+
+
+ `;
+ }
+
+ htmlString += `
`;
+ });
+ }
+
+ htmlString += `
`;
+
+ if (config.showAccountCompany) {
+ htmlString += `
+
+
入账公司:
+
+ ${config.accountCompany || ""}
+
+
+ `;
+ }
+
+ if (config.showSumAmount) {
+ htmlString += `
+
+
总计:
+
+ ${config.sumAmount || ""}
+
+
元
+
+ `;
+ }
+
+ htmlString += `
`;
+ }
+
+ if (module.type === "packingSpec") {
+ htmlString += `
`;
+ // 计算需要显示的列数
+ const visibleColumnCount =
+ [
+ config.showBoxType,
+ config.showQuantity,
+ config.showUnitPrice,
+ config.showAmount,
+ config.showUnitWeight,
+ config.showWeight,
+ ].filter(Boolean).length + 1; // +1 是因为"规格:"列总是显示
+
+ const gridClass = `grid w-full gap-0 text-base grid-cols-${visibleColumnCount}`;
+
+ htmlString += `
+
+ `;
+
+ htmlString += `
`;
+
+ if (config.columns) {
+ config.columns.forEach((column: any, index: number) => {
+ if (index === 0) {
+ htmlString += `
`;
+ return;
+ }
+
+ if (
+ (column.dataIndex === "boxType" && config.showBoxType) ||
+ (column.dataIndex === "quantity" && config.showQuantity) ||
+ (column.dataIndex === "unitPrice" && config.showUnitPrice) ||
+ (column.dataIndex === "amount" && config.showAmount) ||
+ (column.dataIndex === "unitWeight" && config.showUnitWeight) ||
+ (column.dataIndex === "weight" && config.showWeight)
+ ) {
+ htmlString += `
+
${column.title || ""}
+ `;
+ }
+ });
+ }
+
+ htmlString += `
`;
+ htmlString += `
`;
+
+ if (config.data) {
+ config.data.forEach((item: any, index: number) => {
+ htmlString += `
+
+
+ ${
+ item.boxCategory === "FOUR_GRAIN"
+ ? "4粒装"
+ : item.boxCategory === "TWO_GRAIN"
+ ? "2粒装"
+ : "未知"
+ }
+
+ `;
+
+ htmlString += `
+
${item.boxType || ""}
+ `;
+
+ if (config.showQuantity) {
+ htmlString += `
+
${item.quantity || ""}
+ `;
+ }
+
+ if (config.showUnitPrice) {
+ htmlString += `
+
${item.unitPrice || ""}
+ `;
+ }
+
+ if (config.showAmount) {
+ htmlString += `
+
${item.amount || ""}
+ `;
+ }
+
+ if (config.showUnitWeight) {
+ htmlString += `
+
${item.unitWeight || ""}
+ `;
+ }
+
+ if (config.showWeight) {
+ htmlString += `
+
${item.weight || ""}
+ `;
+ }
+
+ htmlString += `
`;
+ });
+ }
+
+ htmlString += `
+
+
总件数
+ `;
+
+ if (config.showQuantity) {
+ htmlString += `
+
+ ${
+ config.data?.reduce(
+ (acc: any, cur: any) => acc + Number(cur.quantity || 0),
+ 0,
+ ) || 0
+ }
+
+ `;
+ }
+
+ if (config.showUnitPrice) {
+ htmlString += `
+
+
+ `;
+ }
+
+ if (config.showAmount) {
+ htmlString += `
+
+ ${
+ config.data?.reduce(
+ (acc: any, cur: any) => acc + Number(cur.amount || 0),
+ 0,
+ ) || 0
+ }
+
+ `;
+ }
+
+ if (config.showUnitWeight) {
+ htmlString += `
+
+
+ `;
+ }
+
+ if (config.showWeight) {
+ htmlString += `
+
+ ${
+ config.data?.reduce(
+ (acc: any, cur: any) => acc + Number(cur.weight || 0),
+ 0,
+ ) || 0
+ }
+
+ `;
+ }
+
+ htmlString += `
+
+
+ `;
+ htmlString += `
`;
+ }
+
+ if (module.type === "vehicleInfo") {
+ htmlString += `
`;
+
+ if (config.showDriverPhone) {
+ htmlString += `
+
司机号码:
+
+ ${config.driverPhone || ""}
+
+ `;
+ }
+
+ if (config.showLicensePlate) {
+ htmlString += `
+
车牌:
+
+ ${config.licensePlate || ""}
+
+ `;
+ }
+
+ if (config.showEstimatedArrivalTime) {
+ htmlString += `
+
预计到仓时间:
+
+ ${config.estimatedArrivalTime || ""}
+
+ `;
+ }
+
+ if (config.showRemarks) {
+ htmlString += `
+
备注:
+
+ ${config.remarks || ""}
+
+ `;
+ }
+
+ if (config.showFreightDebt) {
+ htmlString += `
+
+ ${config.freightDebtTitle || "运费欠"}:
+
+
+ ${config.freightDebt || ""}
+
+ `;
+ }
+
+ if (config.showStrawMatDebt) {
+ htmlString += `
+
草帘欠:
+
+ ${config.strawMatDebt || ""}
+
+ `;
+ }
+
+ htmlString += `
`;
+ }
+
+ if (module.type === "otherFees") {
+ htmlString += `
`;
+
+ if (config.feeItems) {
+ config.feeItems.forEach((feeType: any) => {
+ htmlString += `
+
+ ${(config.feeLabels && config.feeLabels[feeType]) || ""}:
+
+
+ ${config[feeType] || ""}元
+
+ `;
+ });
+ }
+
+ htmlString += `
`;
+ }
+
+ if (module.type === "totalAmount") {
+ htmlString += `
`;
+
+ if (config.showTotalAmount) {
+ htmlString += `
+
+ ${config.sumTitle || "合计金额"}:
+
+
+ ${config.amount || ""}
+
+
元
+ `;
+ }
+
+ if (config.showFarmer) {
+ htmlString += `
+
瓜农:
+
+ ${config.farmer || ""}
+
+ `;
+ }
+
+ htmlString += `
`;
+ }
+
+ if (module.type === "otherInfo") {
+ htmlString += `
+
+
产地:
+
+ ${config.origin || ""}
+
+
供应商:
+
+ ${config.supplier || ""}
+
+
发车时间:
+
+ ${config.departureTime || ""}
+
+
到达时间:
+
+ ${config.arrivalTime || ""}
+
+
产品名称:
+
+ ${config.productName || ""}
+
+
+ `;
+ }
+ });
+
+ htmlString += `