12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- function oldOutBoundPrint(data, domId, isRetail = false) {
- console.log(data);
- let { outStockDate, remark, unitName, printUser } = data.form
- let { tableData } = data
- let date = new Date(outStockDate)
- console.log(date);
- let yy = date.getFullYear();
- let mm = date.getMonth() + 1;
- if (mm < 10) {
- mm = "0" + mm;
- }
- let dd = date.getDate();
- if (dd < 10) {
- dd = "0" + dd;
- }
- let tableHeader = ``
- if (isRetail) { //零售
- tableHeader = `<td style="width: 100px;">名称</td>
- <td style="width: 100px;">规格</td>
- <td style="width: 100px;">单位</td>
- <td style="width: 100px;">数量</td>
- <td style="width: 100px;">单价</td>
- <td style="width: 100px;">金额</td>`
- } else {
- tableHeader = `<td style="width: 100px;">名称</td>
- <td style="width: 100px;">规格</td>
- <td style="width: 100px;">批号</td>
- <td style="width: 100px;">单位</td>
- <td style="width: 100px;">数量</td>
- <td style="width: 100px;">单价</td>
- <td style="width: 100px;">金额</td>`
- }
- let printContent = `<div style="width: 700px;position: relative;">
- <div
- style="width: 100%;position: relative;text-align: center;display: flex;flex-direction: column;margin-bottom: 10px;">
- <span style="font-size: 24px;font-weight: 500;">诸暨市新丝维化纤有限公司</span>
- <span>销售出库单</span>
- </div>
- <div>
- <div style="margin-bottom: 3px; padding: 0 10px;"><span>单位名称:${unitName}</span></div>
- <div style="display: flex;justify-content: space-between;padding: 0 20px;">
- <span>备注:${remark}</span><span>出库日期: ${yy} 年 ${mm} 月 ${dd} 日</span>
- </div>
- </div>
- <table style="width: 100%;border-collapse:collapse;" cellpadding="10" border="1">
- <tr style="text-align: center;">
- ${tableHeader}
- </tr>`;
- let totalPrice = 0, totalWeight = 0;
- for (let i = 0; i < tableData.length; i++) {
- let item = tableData[i];
- let { productName, productSpecifications, lotNumber, unit, productNumber, productUnitPrice, productAmounts, actualWeight } = item
- if (Number(productAmounts)) {
- totalPrice += Number(productAmounts);
- }
- if (Number(actualWeight)) {
- totalWeight += Number(actualWeight);
- }
- printContent += `<tr style="text-align: center;">
- <td>${productName}</td>
- <td>${productSpecifications}</td>
- <td>${lotNumber}</td>
- <td>${unit}</td>
- <td>${actualWeight}</td>
- <td>${productUnitPrice}</td>
- <td>${productAmounts}</td>
- </tr>`
- }
- totalPrice = totalPrice.toFixed(2);
- totalWeight = totalWeight.toFixed(2);
- printContent += `<tr style="text-align: center;border: none;">
- <td style="width: 100px;">合计</td>
- <td style="width: 100px;"></td>
- ${isRetail ? '' : '<td style="width: 100px;"></td>'}
- <td style="width: 100px;"></td>
- <td style="width: 100px;">${totalWeight}</td>
- <td style="width: 100px;"></td>
- <td style="width: 100px;">${totalPrice}</td>
- </tr>`
- printContent += `</table>
- <div><span>制表人:${printUser}</span></div>
- </div>`
- document.body.innerHTML = document.getElementById(domId).innerHTML = printContent;
- window.print(); //打印
- window.location.reload();
- return false;
- }
- export default oldOutBoundPrint
|