|
@@ -144,7 +144,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div slot="footer">
|
|
<div slot="footer">
|
|
|
- <el-button type="primary" @click="isPrintPrice ? exportExcel() : exportExcelWithoutPrice()">导出</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" @click="handleExport">导出</el-button>
|
|
|
<el-button @click="print">打印预览</el-button>
|
|
<el-button @click="print">打印预览</el-button>
|
|
|
<el-button @click="close">关闭</el-button>
|
|
<el-button @click="close">关闭</el-button>
|
|
|
</div>
|
|
</div>
|
|
@@ -178,7 +178,6 @@
|
|
|
this.formData = await getSendSaleOrderrecordDetailSplit(id);
|
|
this.formData = await getSendSaleOrderrecordDetailSplit(id);
|
|
|
this.QRvisible = true;
|
|
this.QRvisible = true;
|
|
|
this.isPrintPrice = isPrintPrice;
|
|
this.isPrintPrice = isPrintPrice;
|
|
|
- //包装维度
|
|
|
|
|
},
|
|
},
|
|
|
close() {
|
|
close() {
|
|
|
this.QRvisible = false;
|
|
this.QRvisible = false;
|
|
@@ -198,7 +197,6 @@
|
|
|
},
|
|
},
|
|
|
print() {
|
|
print() {
|
|
|
const printSection = document.getElementById('printSection');
|
|
const printSection = document.getElementById('printSection');
|
|
|
- // 创建打印任务
|
|
|
|
|
const printWindow = window.open('', '_blank');
|
|
const printWindow = window.open('', '_blank');
|
|
|
printWindow.document.open();
|
|
printWindow.document.open();
|
|
|
printWindow.document.write('<html><head><title>打印预览</title>');
|
|
printWindow.document.write('<html><head><title>打印预览</title>');
|
|
@@ -213,250 +211,220 @@
|
|
|
printWindow.print();
|
|
printWindow.print();
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
- exportExcel() {
|
|
|
|
|
- const list = this.formData.productList || [];
|
|
|
|
|
- const totalCount = this.getTotalValue('saleCount', 2);
|
|
|
|
|
- const totalPrice = this.getTotalValue('totalPrice', 2);
|
|
|
|
|
- const totalChinese = convertToChinese(totalPrice);
|
|
|
|
|
-
|
|
|
|
|
- const border =
|
|
|
|
|
- 'border-top:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000;border-left:1px solid #000;';
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取Excel样式配置
|
|
|
|
|
+ */
|
|
|
|
|
+ getExcelStyles() {
|
|
|
|
|
+ const border = 'border-top:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000;border-left:1px solid #000;';
|
|
|
const cellBase = `${border}padding:4px;mso-number-format:"\\@";vertical-align:middle;text-align:center;mso-horizontal-align:center;`;
|
|
const cellBase = `${border}padding:4px;mso-number-format:"\\@";vertical-align:middle;text-align:center;mso-horizontal-align:center;`;
|
|
|
- const th = `${cellBase}font-weight:bold;font-family:'宋体';font-size:12pt;`;
|
|
|
|
|
- const td = `${cellBase}font-family:'宋体';font-size:11pt;`;
|
|
|
|
|
- const label = td;
|
|
|
|
|
- const labelLeft = `${border}padding:4px;mso-number-format:"\\@";vertical-align:middle;text-align:left;mso-horizontal-align:left;font-family:'宋体';font-size:11pt;`;
|
|
|
|
|
-
|
|
|
|
|
- const colWidths = [55, 170, 55, 70, 75, 65, 90, 70, 110];
|
|
|
|
|
- const colGroup = colWidths
|
|
|
|
|
- .map((w) => `<col width="${w}" style="width:${w}pt;" />`)
|
|
|
|
|
- .join('');
|
|
|
|
|
-
|
|
|
|
|
- const rows = list
|
|
|
|
|
- .map(
|
|
|
|
|
- (item, index) => `
|
|
|
|
|
- <tr height="24" style="height:24pt;">
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${index + 1}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.modelType || ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.saleUnit || ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.saleCount ?? ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.singlePrice ?? ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${
|
|
|
|
|
- item.taxRate ? item.taxRate + '%' : '0%'
|
|
|
|
|
- }</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.totalPrice ?? ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.colorKey || ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.remark || ''}</td>
|
|
|
|
|
- </tr>`
|
|
|
|
|
- )
|
|
|
|
|
- .join('');
|
|
|
|
|
-
|
|
|
|
|
- const title = `${this.groupName || ''}${ this.isPrintPrice ? '货物销售单' : '货物签收单' }`;
|
|
|
|
|
- const table = `
|
|
|
|
|
- <table border="1" cellspacing="0" cellpadding="0" align="center"
|
|
|
|
|
- style="border-collapse:collapse;border:1px solid #000;mso-border-alt:solid #000 0.5pt;font-family:'宋体';font-size:11pt;text-align:center;">
|
|
|
|
|
- <colgroup>${colGroup}</colgroup>
|
|
|
|
|
- <tr height="40" style="height:40pt;">
|
|
|
|
|
- <td colspan="9" align="center" valign="middle" style="${border}padding:6px;text-align:center;font-family:'宋体';font-size:22pt;font-weight:bold;">${title}</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr height="26" style="height:26pt;">
|
|
|
|
|
- <td colspan="6" align="left" valign="middle" style="${labelLeft}">客户:${
|
|
|
|
|
- this.formData.contactName || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- <td colspan="3" align="left" valign="middle" style="${labelLeft}">单据编码:${
|
|
|
|
|
- this.formData.docNo || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr height="26" style="height:26pt;">
|
|
|
|
|
- <td colspan="6" align="left" valign="middle" style="${labelLeft}">项目:${
|
|
|
|
|
- this.formData.projectName || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- <td colspan="3" align="left" valign="middle" style="${labelLeft}">单据日期:${
|
|
|
|
|
- this.formData.createTime ? this.formData.createTime.split(' ')[0] : ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
-
|
|
|
|
|
- <tr height="28" style="height:28pt;">
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">序号</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">规格型号</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">单位</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">数量</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">单价</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">税率</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">金额</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">颜色</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">备注</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- ${rows}
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ border,
|
|
|
|
|
+ th: `${cellBase}font-weight:bold;font-family:'宋体';font-size:12pt;`,
|
|
|
|
|
+ td: `${cellBase}font-family:'宋体';font-size:11pt;`,
|
|
|
|
|
+ labelLeft: `${border}padding:4px;mso-number-format:"\\@";vertical-align:middle;text-align:left;mso-horizontal-align:left;font-family:'宋体';font-size:11pt;`
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取列配置
|
|
|
|
|
+ * @param {boolean} includePrice - 是否包含价格列
|
|
|
|
|
+ */
|
|
|
|
|
+ getColumnConfig(includePrice) {
|
|
|
|
|
+ if (includePrice) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ widths: [55, 170, 55, 70, 75, 65, 90, 70, 110],
|
|
|
|
|
+ headers: ['序号', '规格型号', '单位', '数量', '单价', '税率', '金额', '颜色', '备注'],
|
|
|
|
|
+ colspan: 9,
|
|
|
|
|
+ infoColspan: { left: 6, right: 3 },
|
|
|
|
|
+ footer: { salesman: 2, maker: 2, checker: 3, sender: 2, address: 5, signature: 4 }
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ return {
|
|
|
|
|
+ widths: [55, 170, 55, 70, 70, 110],
|
|
|
|
|
+ headers: ['序号', '规格型号', '单位', '数量', '颜色', '备注'],
|
|
|
|
|
+ colspan: 6,
|
|
|
|
|
+ infoColspan: { left: 4, right: 2 },
|
|
|
|
|
+ footer: { salesman: 2, maker: 1, checker: 1, sender: 2, address: 3, signature: 3 }
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成数据行
|
|
|
|
|
+ * @param {Array} list - 产品列表
|
|
|
|
|
+ * @param {boolean} includePrice - 是否包含价格
|
|
|
|
|
+ * @param {string} tdStyle - TD样式
|
|
|
|
|
+ */
|
|
|
|
|
+ generateRows(list, includePrice, tdStyle) {
|
|
|
|
|
+ return list.map((item, index) => {
|
|
|
|
|
+ const cells = [];
|
|
|
|
|
+ cells.push(`<td align="center" valign="middle" style="${tdStyle}">${index + 1}</td>`);
|
|
|
|
|
+ cells.push(`<td align="center" valign="middle" style="${tdStyle}">${item.modelType || ''}</td>`);
|
|
|
|
|
+ cells.push(`<td align="center" valign="middle" style="${tdStyle}">${item.saleUnit || ''}</td>`);
|
|
|
|
|
+ cells.push(`<td align="center" valign="middle" style="${tdStyle}">${item.saleCount ?? ''}</td>`);
|
|
|
|
|
+
|
|
|
|
|
+ if (includePrice) {
|
|
|
|
|
+ cells.push(`<td align="center" valign="middle" style="${tdStyle}">${item.singlePrice ?? ''}</td>`);
|
|
|
|
|
+ cells.push(`<td align="center" valign="middle" style="${tdStyle}">${item.taxRate ? item.taxRate + '%' : '0%'}</td>`);
|
|
|
|
|
+ cells.push(`<td align="center" valign="middle" style="${tdStyle}">${item.totalPrice ?? ''}</td>`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ cells.push(`<td align="center" valign="middle" style="${tdStyle}">${item.colorKey || ''}</td>`);
|
|
|
|
|
+ cells.push(`<td align="center" valign="middle" style="${tdStyle}">${item.remark || ''}</td>`);
|
|
|
|
|
+
|
|
|
|
|
+ return `<tr height="24" style="height:24pt;">${cells.join('')}</tr>`;
|
|
|
|
|
+ }).join('');
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成合计行
|
|
|
|
|
+ */
|
|
|
|
|
+ generateTotalRow(includePrice, tdStyle, totalCount, totalPrice, totalChinese) {
|
|
|
|
|
+ if (includePrice) {
|
|
|
|
|
+ return `
|
|
|
<tr height="26" style="height:26pt;">
|
|
<tr height="26" style="height:26pt;">
|
|
|
- <td align="center" valign="middle" style="${td};font-weight:bold;">合计</td>
|
|
|
|
|
- <td colspan="2" align="center" valign="middle" style="${td};font-weight:bold;">${totalChinese}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td};font-weight:bold;">${totalCount}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}"></td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}"></td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td};font-weight:bold;">
|
|
|
|
|
- ${totalPrice}
|
|
|
|
|
- </td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}"></td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}"></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr height="28" style="height:28pt;">
|
|
|
|
|
- <td colspan="2" align="left" valign="middle" style="${labelLeft}">业务员:${
|
|
|
|
|
- this.formData.salesmanName || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- <td colspan="2" align="left" valign="middle" style="${labelLeft}">制单人:${
|
|
|
|
|
- this.formData.makerName || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- <td colspan="3" align="left" valign="middle" style="${labelLeft}">核对人:</td>
|
|
|
|
|
- <td colspan="2" align="left" valign="middle" style="${labelLeft}">发货人:</td>
|
|
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle};font-weight:bold;">合计</td>
|
|
|
|
|
+ <td colspan="2" align="center" valign="middle" style="${tdStyle};font-weight:bold;">${totalChinese}</td>
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle};font-weight:bold;">${totalCount}</td>
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle}"></td>
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle}"></td>
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle};font-weight:bold;">${totalPrice}</td>
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle}"></td>
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle}"></td>
|
|
|
</tr>
|
|
</tr>
|
|
|
- <tr height="28" style="height:28pt;">
|
|
|
|
|
- <td colspan="5" align="left" valign="middle" style="${labelLeft}">地址:湖南湘江新区宁乡夏铎铺机械工业园</td>
|
|
|
|
|
- <td colspan="4" align="left" valign="middle" style="${labelLeft}">客户签字:</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- </table>`;
|
|
|
|
|
-
|
|
|
|
|
- const html = `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
|
|
|
|
|
- <head>
|
|
|
|
|
- <meta charset="UTF-8" />
|
|
|
|
|
- <style>
|
|
|
|
|
- br { mso-data-placement: same-cell; }
|
|
|
|
|
- table { mso-displayed-decimal-separator:"."; mso-displayed-thousand-separator:","; }
|
|
|
|
|
- td { mso-ignore:padding; }
|
|
|
|
|
- </style>
|
|
|
|
|
- <!--[if gte mso 9]><xml>
|
|
|
|
|
- <x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
|
|
|
|
|
- <x:Name>${title}</x:Name>
|
|
|
|
|
- <x:WorksheetOptions>
|
|
|
|
|
- <x:DefaultRowHeight>260</x:DefaultRowHeight>
|
|
|
|
|
- <x:Print><x:ValidPrinterInfo/><x:HorizontalResolution>600</x:HorizontalResolution><x:VerticalResolution>600</x:VerticalResolution></x:Print>
|
|
|
|
|
- <x:Selected/>
|
|
|
|
|
- <x:DoNotDisplayGridlines/>
|
|
|
|
|
- </x:WorksheetOptions>
|
|
|
|
|
- </x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook>
|
|
|
|
|
- </xml><![endif]-->
|
|
|
|
|
- </head>
|
|
|
|
|
- <body>${table}</body></html>`;
|
|
|
|
|
-
|
|
|
|
|
- const blob = new Blob(['' + html], {
|
|
|
|
|
|
|
+ `;
|
|
|
|
|
+ }
|
|
|
|
|
+ return `
|
|
|
|
|
+ <tr height="26" style="height:26pt;">
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle};font-weight:bold;">合计</td>
|
|
|
|
|
+ <td colspan="2" align="center" valign="middle" style="${tdStyle};font-weight:bold;"></td>
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle};font-weight:bold;">${totalCount}</td>
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle}"></td>
|
|
|
|
|
+ <td align="center" valign="middle" style="${tdStyle}"></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ `;
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成底部信息行
|
|
|
|
|
+ */
|
|
|
|
|
+ generateFooterRows(includePrice, labelLeftStyle, config) {
|
|
|
|
|
+ let html = `
|
|
|
|
|
+ <tr height="28" style="height:28pt;">
|
|
|
|
|
+ <td colspan="${config.footer.salesman}" align="left" valign="middle" style="${labelLeftStyle}">业务员:${this.formData.salesmanName || ''}</td>
|
|
|
|
|
+ <td colspan="${config.footer.maker}" align="left" valign="middle" style="${labelLeftStyle}">制单人:${this.formData.makerName || ''}</td>
|
|
|
|
|
+ <td colspan="${config.footer.checker}" align="left" valign="middle" style="${labelLeftStyle}">核对人:</td>
|
|
|
|
|
+ <td colspan="${config.footer.sender}" align="left" valign="middle" style="${labelLeftStyle}">发货人:</td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr height="28" style="height:28pt;">
|
|
|
|
|
+ <td colspan="${config.footer.address}" align="left" valign="middle" style="${labelLeftStyle}">地址:湖南湘江新区宁乡夏铎铺机械工业园</td>
|
|
|
|
|
+ <td colspan="${config.footer.signature}" align="left" valign="middle" style="${labelLeftStyle}">客户签字:</td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ `;
|
|
|
|
|
+
|
|
|
|
|
+ return html;
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成完整的Excel HTML结构
|
|
|
|
|
+ */
|
|
|
|
|
+ generateExcelHtml(table, title) {
|
|
|
|
|
+ return `
|
|
|
|
|
+ <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
|
|
|
|
|
+ <head>
|
|
|
|
|
+ <meta charset="UTF-8" />
|
|
|
|
|
+ <style>
|
|
|
|
|
+ br { mso-data-placement: same-cell; }
|
|
|
|
|
+ table { mso-displayed-decimal-separator:"."; mso-displayed-thousand-separator:","; }
|
|
|
|
|
+ td { mso-ignore:padding; }
|
|
|
|
|
+ </style>
|
|
|
|
|
+ <!--[if gte mso 9]><xml>
|
|
|
|
|
+ <x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
|
|
|
|
|
+ <x:Name>${title}</x:Name>
|
|
|
|
|
+ <x:WorksheetOptions>
|
|
|
|
|
+ <x:DefaultRowHeight>260</x:DefaultRowHeight>
|
|
|
|
|
+ <x:Print><x:ValidPrinterInfo/><x:HorizontalResolution>600</x:HorizontalResolution><x:VerticalResolution>600</x:VerticalResolution></x:Print>
|
|
|
|
|
+ <x:Selected/>
|
|
|
|
|
+ <x:DoNotDisplayGridlines/>
|
|
|
|
|
+ </x:WorksheetOptions>
|
|
|
|
|
+ </x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook>
|
|
|
|
|
+ </xml><![endif]-->
|
|
|
|
|
+ </head>
|
|
|
|
|
+ <body>${table}</body></html>
|
|
|
|
|
+ `;
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 下载Excel文件
|
|
|
|
|
+ */
|
|
|
|
|
+ downloadExcel(html, title) {
|
|
|
|
|
+ const blob = new Blob(['\ufeff' + html], {
|
|
|
type: 'application/vnd.ms-excel;charset=utf-8'
|
|
type: 'application/vnd.ms-excel;charset=utf-8'
|
|
|
});
|
|
});
|
|
|
saveAs(blob, `${title}_${this.formData.orderNo || ''}.xls`);
|
|
saveAs(blob, `${title}_${this.formData.orderNo || ''}.xls`);
|
|
|
},
|
|
},
|
|
|
- // 不打印价格的导出Excel方法
|
|
|
|
|
- exportExcelWithoutPrice() {
|
|
|
|
|
- const list = this.formData.productList || [];
|
|
|
|
|
- const totalCount = this.getTotalValue('saleCount', 2);
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 统一导出Excel方法
|
|
|
|
|
+ * @param {boolean} includePrice - 是否包含价格
|
|
|
|
|
+ */
|
|
|
|
|
+ exportExcel(includePrice = true) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const list = this.formData.productList || [];
|
|
|
|
|
+ const totalCount = this.getTotalValue('saleCount', 2);
|
|
|
|
|
+ const totalPrice = includePrice ? this.getTotalValue('totalPrice', 2) : 0;
|
|
|
|
|
+ const totalChinese = includePrice ? convertToChinese(totalPrice) : '';
|
|
|
|
|
|
|
|
- const border =
|
|
|
|
|
- 'border-top:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000;border-left:1px solid #000;';
|
|
|
|
|
- const cellBase = `${border}padding:4px;mso-number-format:"\\@";vertical-align:middle;text-align:center;mso-horizontal-align:center;`;
|
|
|
|
|
- const th = `${cellBase}font-weight:bold;font-family:'宋体';font-size:12pt;`;
|
|
|
|
|
- const td = `${cellBase}font-family:'宋体';font-size:11pt;`;
|
|
|
|
|
- const labelLeft = `${border}padding:4px;mso-number-format:"\\@";vertical-align:middle;text-align:left;mso-horizontal-align:left;font-family:'宋体';font-size:11pt;`;
|
|
|
|
|
|
|
+ const styles = this.getExcelStyles();
|
|
|
|
|
+ const config = this.getColumnConfig(includePrice);
|
|
|
|
|
+
|
|
|
|
|
+ // 生成列定义
|
|
|
|
|
+ const colGroup = config.widths
|
|
|
|
|
+ .map(w => `<col width="${w}" style="width:${w}pt;" />`)
|
|
|
|
|
+ .join('');
|
|
|
|
|
|
|
|
- // 不包含价格列的列宽配置
|
|
|
|
|
- const colWidths = [55, 170, 55, 70, 70, 110];
|
|
|
|
|
- const colGroup = colWidths
|
|
|
|
|
- .map((w) => `<col width="${w}" style="width:${w}pt;" />`)
|
|
|
|
|
- .join('');
|
|
|
|
|
|
|
+ // 生成数据行
|
|
|
|
|
+ const rows = this.generateRows(list, includePrice, styles.td);
|
|
|
|
|
|
|
|
- const rows = list
|
|
|
|
|
- .map(
|
|
|
|
|
- (item, index) => `
|
|
|
|
|
- <tr height="24" style="height:24pt;">
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${index + 1}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.modelType || ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.saleUnit || ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.saleCount ?? ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.colorKey || ''}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}">${item.remark || ''}</td>
|
|
|
|
|
- </tr>`
|
|
|
|
|
- )
|
|
|
|
|
- .join('');
|
|
|
|
|
|
|
+ // 生成标题
|
|
|
|
|
+ const title = `${this.groupName || ''}${includePrice ? '货物销售单' : '货物签收单'}`;
|
|
|
|
|
|
|
|
- const title = `${this.groupName || ''}货物签收单`;
|
|
|
|
|
- const table = `
|
|
|
|
|
- <table border="1" cellspacing="0" cellpadding="0" align="center"
|
|
|
|
|
- style="border-collapse:collapse;border:1px solid #000;mso-border-alt:solid #000 0.5pt;font-family:'宋体';font-size:11pt;text-align:center;">
|
|
|
|
|
- <colgroup>${colGroup}</colgroup>
|
|
|
|
|
- <tr height="40" style="height:40pt;">
|
|
|
|
|
- <td colspan="6" align="center" valign="middle" style="${border}padding:6px;text-align:center;font-family:'宋体';font-size:22pt;font-weight:bold;">${title}</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr height="26" style="height:26pt;">
|
|
|
|
|
- <td colspan="4" align="left" valign="middle" style="${labelLeft}">客户:${
|
|
|
|
|
- this.formData.contactName || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- <td colspan="2" align="left" valign="middle" style="${labelLeft}">单据编码:${
|
|
|
|
|
- this.formData.docNo || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr height="26" style="height:26pt;">
|
|
|
|
|
- <td colspan="4" align="left" valign="middle" style="${labelLeft}">项目:${
|
|
|
|
|
- this.formData.projectName || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- <td colspan="2" align="left" valign="middle" style="${labelLeft}">单据日期:${
|
|
|
|
|
- this.formData.createTime ? this.formData.createTime.split(' ')[0] : ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
-
|
|
|
|
|
- <tr height="28" style="height:28pt;">
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">序号</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">规格型号</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">单位</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">数量</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">颜色</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${th}">备注</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- ${rows}
|
|
|
|
|
- <tr height="26" style="height:26pt;">
|
|
|
|
|
- <td align="center" valign="middle" style="${td};font-weight:bold;">合计</td>
|
|
|
|
|
- <td colspan="2" align="center" valign="middle" style="${td};font-weight:bold;"></td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td};font-weight:bold;">${totalCount}</td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}"></td>
|
|
|
|
|
- <td align="center" valign="middle" style="${td}"></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr height="28" style="height:28pt;">
|
|
|
|
|
- <td colspan="2" align="left" valign="middle" style="${labelLeft}">业务员:${
|
|
|
|
|
- this.formData.salesmanName || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- <td colspan="2" align="left" valign="middle" style="${labelLeft}">制单人:${
|
|
|
|
|
- this.formData.makerName || ''
|
|
|
|
|
- }</td>
|
|
|
|
|
- <td colspan="2" align="left" valign="middle" style="${labelLeft}">发货人:</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr height="28" style="height:28pt;">
|
|
|
|
|
- <td colspan="3" align="left" valign="middle" style="${labelLeft}">地址:湖南湘江新区宁乡夏铎铺机械工业园</td>
|
|
|
|
|
- <td colspan="3" align="left" valign="middle" style="${labelLeft}">客户签字:</td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- </table>`;
|
|
|
|
|
|
|
+ // 生成表头
|
|
|
|
|
+ const headers = config.headers.map(
|
|
|
|
|
+ header => `<td align="center" valign="middle" style="${styles.th}">${header}</td>`
|
|
|
|
|
+ ).join('');
|
|
|
|
|
|
|
|
- const html = `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
|
|
|
|
|
- <head>
|
|
|
|
|
- <meta charset="UTF-8" />
|
|
|
|
|
- <style>
|
|
|
|
|
- br { mso-data-placement: same-cell; }
|
|
|
|
|
- table { mso-displayed-decimal-separator:"."; mso-displayed-thousand-separator:","; }
|
|
|
|
|
- td { mso-ignore:padding; }
|
|
|
|
|
- </style>
|
|
|
|
|
- <!--[if gte mso 9]><xml>
|
|
|
|
|
- <x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
|
|
|
|
|
- <x:Name>${title}</x:Name>
|
|
|
|
|
- <x:WorksheetOptions>
|
|
|
|
|
- <x:DefaultRowHeight>260</x:DefaultRowHeight>
|
|
|
|
|
- <x:Print><x:ValidPrinterInfo/><x:HorizontalResolution>600</x:HorizontalResolution><x:VerticalResolution>600</x:VerticalResolution></x:Print>
|
|
|
|
|
- <x:Selected/>
|
|
|
|
|
- <x:DoNotDisplayGridlines/>
|
|
|
|
|
- </x:WorksheetOptions>
|
|
|
|
|
- </x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook>
|
|
|
|
|
- </xml><![endif]-->
|
|
|
|
|
- </head>
|
|
|
|
|
- <body>${table}</body></html>`;
|
|
|
|
|
|
|
+ // 生成表格
|
|
|
|
|
+ const table = `
|
|
|
|
|
+ <table border="1" cellspacing="0" cellpadding="0" align="center"
|
|
|
|
|
+ style="border-collapse:collapse;border:1px solid #000;mso-border-alt:solid #000 0.5pt;font-family:'宋体';font-size:11pt;text-align:center;">
|
|
|
|
|
+ <colgroup>${colGroup}</colgroup>
|
|
|
|
|
+ <tr height="40" style="height:40pt;">
|
|
|
|
|
+ <td colspan="${config.colspan}" align="center" valign="middle" style="${styles.border}padding:6px;text-align:center;font-family:'宋体';font-size:22pt;font-weight:bold;">${title}</td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr height="26" style="height:26pt;">
|
|
|
|
|
+ <td colspan="${config.infoColspan.left}" align="left" valign="middle" style="${styles.labelLeft}">客户:${this.formData.contactName || ''}</td>
|
|
|
|
|
+ <td colspan="${config.infoColspan.right}" align="left" valign="middle" style="${styles.labelLeft}">单据编码:${this.formData.docNo || ''}</td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr height="26" style="height:26pt;">
|
|
|
|
|
+ <td colspan="${config.infoColspan.left}" align="left" valign="middle" style="${styles.labelLeft}">项目:${this.formData.projectName || ''}</td>
|
|
|
|
|
+ <td colspan="${config.infoColspan.right}" align="left" valign="middle" style="${styles.labelLeft}">单据日期:${this.formData.createTime ? this.formData.createTime.split(' ')[0] : ''}</td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr height="28" style="height:28pt;">${headers}</tr>
|
|
|
|
|
+ ${rows}
|
|
|
|
|
+ ${this.generateTotalRow(includePrice, styles.td, totalCount, totalPrice, totalChinese)}
|
|
|
|
|
+ ${this.generateFooterRows(includePrice, styles.labelLeft, config)}
|
|
|
|
|
+ </table>
|
|
|
|
|
+ `;
|
|
|
|
|
|
|
|
- const blob = new Blob(['' + html], {
|
|
|
|
|
- type: 'application/vnd.ms-excel;charset=utf-8'
|
|
|
|
|
- });
|
|
|
|
|
- saveAs(blob, `${title}_${this.formData.orderNo || ''}.xls`);
|
|
|
|
|
|
|
+ // 生成完整HTML
|
|
|
|
|
+ const html = this.generateExcelHtml(table, title);
|
|
|
|
|
+
|
|
|
|
|
+ // 导出文件
|
|
|
|
|
+ this.downloadExcel(html, title);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('导出Excel失败:', error);
|
|
|
|
|
+ this.$message.error('导出Excel失败,请重试');
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据isPrintPrice自动选择导出方式
|
|
|
|
|
+ */
|
|
|
|
|
+ handleExport() {
|
|
|
|
|
+ this.exportExcel(this.isPrintPrice);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|