/**
|
* 根据气体信息生成打印模版
|
*
|
* @param depotData
|
* 仓库基本信息
|
* @param grainData
|
* 粮情数据信息
|
*/
|
builderModel = function(curData,dept) {
|
var depotData = curData.depotData;
|
var listPoint = curData.listPoint;
|
|
var model = "<!DOCTYPE html><html lang=\"zh-cn\">\n"
|
+ "<head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"><title>气体报表模版</title>"
|
+ " <style>\n"
|
+ " table,table tr th,table tr td{border:1px solid #0d1021}table{width:100%;line-height:23px;text-align:center;font-size:14px}.table-2{border-top:0px solid #0d1021 !important}.table-2 tr{border-top:0px solid #0d1021 !important}.table-2 td{border-top:0px solid #0d1021 !important}.table-row-tr{border-left:0px !important;border-right:0px !important;border-top:0px !important}.table-row-fz{border:0px !important}.link-top{width:100%;border-top:solid #0d1021 1px}</style>\n"
|
+ "</head><body>";
|
|
model += "<div style=\"text-align: center\">\n"
|
+ "<span style=\"font-size: 26px; font-weight: bold;\">\n";
|
if(dept){
|
model += dept.name;
|
}else{
|
model += "--XXX--粮库"
|
}
|
model += "</span><div class=\"link-top\"></div><div class=\"link-top\"></div>\n";
|
model += "<span style=\"font-size: 18px; \">";
|
model += depotData.name;
|
model += " 气体报表</span>\n";
|
model += "</div><div style=\"margin-top: 5px;\"><span style=\"float: left;\">";
|
model += " 方向:东</span><span style=\"float: right;\">检测时间:";
|
model += curData.receiveDate;
|
model += "</span></div>";
|
|
// 动态配置
|
model += "<table cellspacing=\"0\" cellpadding=\"0\">";
|
model += "<tr><td>采集位</td><td>CO2</td><td>O2</td><td>PH3</td><td>N2</td><td>采集位</td><td>CO2</td><td>O2</td><td>PH3</td><td>N2</td></tr>";
|
|
var num = Math.ceil(listPoint.length / 2);
|
var index = 1;
|
var point;
|
for (var i = 0; i < num; i++) {
|
point = listPoint[index - 1];
|
model += "<tr>";
|
|
model += "<td class=\"table-row-fz\">采集位 " + point.passCode + "</td>";
|
model += "<td class=\"table-row-fz\">"
|
+ attrPoint(point, curData, "CO2") + "</td>";
|
model += "<td class=\"table-row-fz\">"
|
+ attrPoint(point, curData, "O2") + "</td>";
|
model += "<td class=\"table-row-fz\">"
|
+ attrPoint(point, curData, "PH3") + "</td>";
|
model += "<td class=\"table-row-fz\">"
|
+ attrPoint(point, curData, "N2") + "</td>";
|
|
index++;
|
|
if (index > listPoint.length) {
|
model += "<td class=\"table-row-fz\"></td>";
|
model += "<td class=\"table-row-fz\"></td>";
|
model += "<td class=\"table-row-fz\"></td>";
|
model += "<td class=\"table-row-fz\"></td>";
|
model += "<td class=\"table-row-fz\"></td>";
|
} else {
|
point = listPoint[index - 1];
|
model += "<td class=\"table-row-fz\">采集位 " + point.passCode + "</td>";
|
model += "<td class=\"table-row-fz\">"
|
+ attrPoint(point, curData, "CO2") + "</td>";
|
model += "<td class=\"table-row-fz\">"
|
+ attrPoint(point, curData, "O2") + "</td>";
|
model += "<td class=\"table-row-fz\">"
|
+ attrPoint(point, curData, "PH3") + "</td>";
|
model += "<td class=\"table-row-fz\">"
|
+ attrPoint(point, curData, "N2") + "</td>";
|
|
index++;
|
}
|
model += "</tr>";
|
}
|
model += "</table>";
|
// <!--下面表格开始-->
|
model += "<table cellspacing=\"0\" cellpadding=\"0\" class=\"table-2\">";
|
model += "<tr><td width=\"20%\">检测分析:</td>";
|
model += "<td colspan=4>" + (curData.remark == null ? "/" : curData.remark) + "</td></tr>";
|
model += "<tr><td width=\"20%\"></td><td width=\"20%\">最高</td><td width=\"20%\">最低</td><td width=\"20%\">平均</td><td width=\"20%\">备注</td></tr>";
|
|
// 气体整体信息
|
model += "<tr> <td>CO2(PPM)</td><td>" + curData.perCo2Max + "</td>";
|
model += "<td>" + curData.perCo2Min + "</td>";
|
model += "<td>" + curData.perCo2 + "</td>";
|
model += "<td></td></tr>";
|
|
model += "<tr> <td>O2(%)</td><td>" + curData.perO2Max + "</td>";
|
model += "<td>" + curData.perO2Min + "</td>";
|
model += "<td>" + curData.perO2 + "</td>";
|
model += "<td></td></tr>";
|
|
model += "<tr> <td>PH3(PPM)</td><td>" + curData.perPh3Max + "</td>";
|
model += "<td>" + curData.perPh3Min + "</td>";
|
model += "<td>" + curData.perPh3 + "</td>";
|
model += "<td></td></tr>";
|
|
model += "<tr> <td>N2(%)</td><td>" + curData.perN2Max + "</td>";
|
model += "<td>" + curData.perN2Min + "</td>";
|
model += "<td>" + curData.perN2 + "</td>";
|
model += "<td></td></tr>";
|
|
// 仓库信息
|
model += "<tr><td>仓房类型</td><td>" + depotData.depotTypeName + "</td>";
|
model += "<td>入仓日期</td><td>" + (depotData.storeDate == null ? "/" : depotData.storeDate) + "</td><td ></td></tr>";
|
|
model += "<tr><td>粮食品种</td><td>" + depotData.foodVarietyName + "</td>";
|
model += "<td>实际储量(吨)</td><td>" + (depotData.storageReal == null ? "/" : (Number(depotData.storageReal)/1000).toFixed(2))
|
+ "</td><td ></td></tr>";
|
|
model += "<tr><td>入仓水分(%)</td><td>" + (depotData.perWet == null ? "/" : depotData.perWet) + "</td>";
|
model += "<td>当前水分(%)</td><td>" + (depotData.perWet == null ? "/" : depotData.perWet) + "</td><td ></td></tr>";
|
|
model += "<tr><td>出糙率(%)</td><td>" + (depotData.rough == null ? "/" : depotData.rough) + "</td>";
|
model += "<td>粮食产地</td><td>" + (depotData.foodLocation == null ? "/" : depotData.foodLocation)
|
+ "</td><td ></td></tr>";
|
|
model += "<tr><td>容重(kg/m3)</td><td>" + (depotData.bulkWeight == null ? "/" : depotData.bulkWeight) + "</td>";
|
model += "<td>面筋持水率(%)</td><td>" + (depotData.waterGluten == null ? "/" : depotData.waterGluten) + "</td><td></td></tr>";
|
|
model += "<tr><td>杂质(%)</td><td>" + (depotData.perImpurity == null ? "/" : depotData.perImpurity) + "</td>";
|
model += "<td>不完善粒(%)</td><td>" + (depotData.broken == null ? "/" : depotData.broken) + "</td><td ></td></tr>";
|
|
model += "<tr><td>检测人</td><td>" + curData.checkUser + "</td>";
|
model += "<td>保管员</td><td>" + (depotData.storeKeeperName == null ? "/" : depotData.storeKeeperName)
|
+ "</td><td ></td></tr>";
|
|
model += "</table>";
|
|
// 添加尾部信息
|
model += "<div style=\"margin-top: 5px;\">";
|
model += "<span style=\"float: left;\">注:#表示最低 *表示最高</span>";
|
model += "<span style=\"float: right;\">制表时间:" + curData.sysDate
|
+ "</span></div>";
|
model += "</div></body></html>";
|
|
return model;
|
};
|
|
// 根据采集点赋值,注意数据库生成的坐标是从0开始的
|
attrPoint = function(point, curData, type) {
|
if (type == "CO2") {
|
if (-100.0 == point.perCo2) {
|
return "备用";
|
}
|
if (curData.perCo2Max == point.perCo2) {
|
return point.perCo2 + "*";
|
}
|
if (curData.perCo2Min == point.perCo2) {
|
return point.perCo2 + "#";
|
}
|
}
|
|
if (type == "O2") {
|
if (-100.0 == point.perO2) {
|
return "备用";
|
}
|
if (curData.perO2Max == point.perO2) {
|
return point.perO2 + "*";
|
}
|
if (curData.perO2Min == point.perO2) {
|
return point.perO2 + "#";
|
}
|
}
|
|
if (type == "PH3") {
|
if (-100.0 == point.perPh3) {
|
return "备用";
|
}
|
if (curData.perPh3Max == point.perPh3) {
|
return point.perPh3 + "*";
|
}
|
if (curData.perPh3Min == point.perPh3) {
|
return point.perPh3 + "#";
|
}
|
}
|
|
if (type == "N2") {
|
if (-100.0 == point.perN2) {
|
return "备用";
|
}
|
if (curData.perN2Max == point.perN2) {
|
return point.perN2 + "*";
|
}
|
if (curData.perN2Min == point.perN2) {
|
return point.perN2 + "#";
|
}
|
}
|
|
return "";
|
};
|
|
/**
|
* 根据HTML模版打印为A4
|
*
|
* @param strHtml
|
*/
|
previewA4 = function(strHtml) {
|
var LODOP = getLodop();
|
LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
|
LODOP.PRINT_INIT("气体报表");
|
LODOP.ADD_PRINT_HTM(30, 40, "180mm", "100%", strHtml);
|
LODOP.PREVIEW();
|
};
|