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 = `
名称 |
规格 |
单位 |
数量 |
单价 |
金额 | `
} else {
tableHeader = `名称 |
规格 |
批号 |
单位 |
数量 |
单价 |
金额 | `
}
let printContent = `
诸暨市新丝维化纤有限公司
销售出库单
单位名称:${unitName}
备注:${remark}出库日期: ${yy} 年 ${mm} 月 ${dd} 日
${tableHeader}
`;
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 += `
${productName} |
${productSpecifications} |
${lotNumber} |
${unit} |
${actualWeight} |
${productUnitPrice} |
${productAmounts} |
`
}
totalPrice = totalPrice.toFixed(2);
totalWeight = totalWeight.toFixed(2);
printContent += `
合计 |
|
${isRetail ? '' : ' | '}
|
${totalWeight} |
|
${totalPrice} |
`
printContent += `
制表人:${printUser}
`
document.body.innerHTML = document.getElementById(domId).innerHTML = printContent;
window.print(); //打印
window.location.reload();
return false;
}
export default oldOutBoundPrint