You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
simple-yewu/frontend/web/js/expElePrint1.js

446 lines
14 KiB

5 years ago
$("#startDate").click(function() {
WdatePicker({
dateFmt : 'yyyy-MM-dd HH:mm',
maxDate : '#F{$dp.$D(\'endDate\')}',
isShowClear : true,
readOnly : true
});
});
$("#endDate").click(function() {
WdatePicker({
dateFmt : 'yyyy-MM-dd HH:mm',
minDate : '#F{$dp.$D(\'startDate\')}',
isShowClear : true,
readOnly : true
});
});
/**
* 弹框报文详情
*/
$(function() {
// $("#detailInfo").dialog({
// autoOpen : false,
// width : 600,
// modal : true,
// resizable : false
// })
$(".selectAllPrint").click(function() {
if (!$(this).prop('checked')) {
$(".selectItem").prop("checked", false);
}
else {
$(".selectItem").prop("checked", true);
}
})
})
/**
* 查看报文详情
*
* @param obj
*/
function queryDetailInfo(obj) {
var $td = $(obj).parent("td");
var requestParam = $td.find("span").eq(0).html();
var responseParam = $td.find("span").eq(1).html();
$("#requestParam").val(requestParam);
$("#responseParam").val(responseParam);
// $("#detailInfo").dialog("open");
}
/**
* 分页查询提交
*
* @param formId
* @param currentPage
*/
function page_nav(formId, currentPage) {
var waybillNo = $("textarea[name = 'waybillNo']").val();
var beginDate = $("#startDate").val();
var endDate = $("#endDate").val();
var endtimestamp = new Date(endDate).getTime();
var begintimestamp = new Date(beginDate).getTime();
var queryTime = endtimestamp - begintimestamp;
if (waybillNo.split(',').length>200){
$.myAlert('运单号查询批次maxsize为200', '提示');
return;
} else if(queryTime>604800000){
$.myAlert("查询时间范围必须在一个星期之内");
return;
}
$("#page").val(currentPage);
$("#" + formId).submit();
}
$("#flagFour").click(function() {
window.location.href = '/help/helpFour.do?flag=four';
})
$(function() {
$("textarea[name = 'waybillNo']").val($("#querywaybillNo").val());
$("textarea[name = 'acceptDeptId']").val($("#queryacceptDeptId").val());
$("textarea[name = 'channelNumber']").val($("#querychannelNumber").val());
$("textarea[name = 'shipperName']").val($("#queryshipperName").val());
$("textarea[name = 'shipperNumber']").val($("#queryshipperNumber").val());
})
function PrintTable() {
var billList=[];
for(var i=0;i<allway.length;i++){
if($("#"+allway[i].waybillNumber+"_selectEle").prop('checked')){
billList.push(allway[i]);
}
}
for ( var i = 0; i < billList.length; i++) {
var printOrders = billList[i];
// printOrders.isHideDeliveryCustomerInfo = isHideDeliveryCustomerInfo;
// printOrders.isHideBillWeight = isHideBillWeight;
// printOrders.isHideTransportFee = isHideTransportFee;
// printOrders.isHideTotalFee = isHideTotalFee;
// printOrders.isHideWareHouse = isHideWareHouse;
//如果原发货人,电话不为空,显示原发货人信息,否则现在发货人信息
if (printOrders.shipperCompanyName != null
&& printOrders.shipperCompanyName != ''
&& printOrders.shipperCompanyPhone != null
&& printOrders.shipperCompanyPhone != '') {
printOrders.shipperTel = printOrders.shipperCompanyPhone;
printOrders.shipperName = printOrders.shipperCompanyName;
printOrders.saddress = printOrders.shipperCompanyAddress;
printOrders.shipperPhone = '';
}
}
var len = $(".waybillNum").length;
var wayNum = "";
for ( var i = 0; i < len; i++) {
wayNum += $(".waybillNum")[i].innerText + ",";
}
wayNum = wayNum.substring(0, wayNum.length - 1);
//newPrintWayBill(billList, wayNum); //打印
lodopPrintTable(billList, wayNum); //打印
}
//当前打印模板
var htmlTemplateObj = null;
/**
* lodop打印
* @param billList
* @param wayNum
*/
function lodopPrintTable(billList, wayNum){
htmlTemplateObj = $("#printContext");
// console.log(htmlTemplateObj);
// alert(htmlTemplateObj);
//return ;
var LODOP = null;
try{
LODOP=getLodop();
//console.log(LODOP)
//alert(300000);
if ((LODOP!=null)&&(typeof(LODOP.VERSION)!="undefined")){
$("#lodopTips").hide();
//alert(2323232);
}
else{
$("#lodopTips").show();
//alert(11116);
return;
}
}catch(err){
$("#lodopTips").show();
return;
}
//return;
// alert(232)
// console.log(LODOP);
// return;
//打印
print(billList, wayNum);
}
// lodopPrintTable();
//打印模板
function templateDataProcess(data, index){
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
var printHtml = null;
if(data==undefined || data == null || data== ""){
return printHtml;
}
htmlTemplateObj.find("span.conPhone").text(data.conPhone);
htmlTemplateObj.find("span.conTel").text(data.conTel);
htmlTemplateObj.find("span.shipperTel").text(data.shipperTel);
htmlTemplateObj.find("span.shipperName").text(data.shipperName);
htmlTemplateObj.find("span.shipperPhone").text(data.shipperPhone);
htmlTemplateObj.find("span.conName").text(data.conName);
if(data.caddress.length>42){
$('#conMsg').attr('style','border-right:0mm;font-size:8pt;width:90mm;font-family:黑体;font-weight:bold;text-align:left; ');
$('#conMsg2').attr('style','font-family:黑体;text-align:left; font-size:8px;font-weight:bold; ');
}else{
$('#conMsg').attr('style','border-right:0mm;font-size:10pt;width:90mm;font-family:黑体;font-weight:bold;text-align:left; ');
$('#conMsg2').attr('style','font-family:黑体;text-align:left; font-size:10px;font-weight:bold; ');
}
htmlTemplateObj.find("span.caddress").text(data.caddress);
htmlTemplateObj.find("span.saddress").text(data.saddress);
htmlTemplateObj.find("span.cargoName").text(data.cargoName);
htmlTemplateObj.find("span.cargoWeight").text(data.cargoWeight);
htmlTemplateObj.find("span.refundPayment").text(data.refundPayment);
if (data.refundPayment > 0) {
$("#refundPaymentId").text("代收货款");
$('#refundPaymentId').attr('style','border-top:0mm;background:#000000;line-height:72px;font-weight:bold; text-align:center; color:#FFFFFF; font-size:20px;');
} else {
$("#refundPaymentId").text("");
$('#refundPaymentId').attr('style','border-top:0mm;background:#000000;line-height:72px; text-align:center; color:#FFFFFF;');
}
if (data.payType.length > 2) {
$('#payTypeId').attr('style','border-top:0mm;background:#000000;line-height:72px;font-weight:bold; text-align:center; color:#FFFFFF; font-size:10px;');
} else {
$('#payTypeId').attr('style','border-top:0mm;background:#000000;line-height:72px;font-weight:bold; text-align:center; color:#FFFFFF; font-size:20px;');
}
$("#payTypeId").text(data.payType);
if ("" == data.transType) {
$('#transTypeId').attr('style','border-top:0mm;background:#FFFFFF;line-height:72px;font-weight:bold; text-align:center; color:#000000; font-size:13px;');
htmlTemplateObj.find("span.transType").text("无法匹配");
} else {
if (data.transType.length > 4) {
$('#transTypeId').attr('style','border-top:0mm;background:#FFFFFF;line-height:72px;font-weight:bold; text-align:center; color:#000000; font-size:8px;');
} else {
$('#transTypeId').attr('style','border-top:0mm;background:#FFFFFF;line-height:72px;font-weight:bold; text-align:center; color:#000000; font-size:13px;');
}
htmlTemplateObj.find("span.transType").text(data.transType);
}
htmlTemplateObj.find("span.destination").text(data.destination);
htmlTemplateObj.find("span.billWeight").text(data.billWeight);
htmlTemplateObj.find("span.transportCharge").text(data.transportCharge);
htmlTemplateObj.find("span.totalCharge").text(data.totalCharge);
htmlTemplateObj.find("span.insuranceMoney").text(data.insuranceMoney);
htmlTemplateObj.find("span.signSheet").text(data.signSheet);
htmlTemplateObj.find("span.outerField1").text(data.outerField1);
htmlTemplateObj.find("span.lastOutLoadOrgName").text(data.lastOutLoadOrgName);
htmlTemplateObj.find("span.departCityName").text(data.departCityName);
htmlTemplateObj.find("span.departCityName").text(data.departCityName);
htmlTemplateObj.find("span.secondLoadOrgName").text(data.secondLoadOrgName);
htmlTemplateObj.find("span.stationNumber").text(data.stationNumber);
htmlTemplateObj.find("span.custOrderLine").text(data.custOrderLine);
htmlTemplateObj.find("span.transNote").text(data.transNote);
if ("" == data.markerPen) {
$('#markerPen').attr('style','text-align: center; line-height: 13mm; vertical-align: middle;font-size: 35px; font-weight: bold; margin: 0px; padding: 0px;');
$("#refundPaymentId").text("无大头笔信息");
} else {
if (data.markerPen.length > 10) {
$('#markerPen').attr('style','text-align: center; line-height: 13mm; vertical-align: middle;font-size: 18px; font-weight: bold; margin: 0px; padding: 0px;');
$("#markerPen").text(data.markerPen);
} else {
$('#markerPen').attr('style','text-align: center; line-height: 13mm; vertical-align: middle;font-size: 35px; font-weight: bold; margin: 0px; padding: 0px;');
$("#markerPen").text(data.markerPen);
}
}
// htmlTemplateObj.find("span.markerPen").text(data.markerPen);
htmlTemplateObj.find("span.orderNumber").text(data.orderNumber);
htmlTemplateObj.find("span.printTime").text(new Date().Format("yyyyMMdd HH:mm:ss"));
htmlTemplateObj.find("span.billTime").text(data.billTime.substring(0,10));
var cargoCount = data.cargoCount;
if(data.cargoCount>1){
cargoCount += "-" + (index+1);
}
htmlTemplateObj.find("span.cargoCount").text(cargoCount);
//代收账号
var account = data.reciveLoanAccount;
if (account != null && account != '') {
account = account.substring(0, 3) + "*"
+ account.substring(account.length - 4, account.length);
} else {
account = "";
}
htmlTemplateObj.find("span.reciveLoanAccount").text(account);
if (data.conTel != '' && data.conTel != null) {
if (data.conPhone != '' && data.conPhone != null) {
htmlTemplateObj.find("span.conTel").text(data.conTel + "/");
}
}
if (data.shipperTel != '' && data.shipperTel != null) {
if (data.shipperPhone != ''
&& data.shipperPhone != null) {
htmlTemplateObj.find("span.shipperTel").text(data.shipperTel + "/");
}
}
// return htmlTemplateObj.html();
}
/**
* 打印
* @param list
*/
function print(billList, wayNum){
// alert(1111);
// for(var i=0; i<billList.length; i++){
// var data = billList[i];
// data.cargoCount = 1;
// for(var j=0; j<data.cargoCount; j++){
// var serialNo = data.printSerialNos;
// if(data.cargoCount>1){
// serialNo = data.printSerialNos.split(",")[j];
// }
// //条码
// var barcode = data.waybillNumber + serialNo + data.stationNumber;
// var isHideWareHouse = data.isHideWareHouse;
// //模板数据处理
// templateDataProcess(data, j);
// //打印电子运单1
// //打印仓库分拣单
// // if("N"==isHideWareHouse){
// // printWareHouseWaybill(data, serialNo, barcode);
// // }
// }
printEWaybill(billList, 0, 0, wayNum);
// }
// if(billList.length>0){
// $.myAlert("本次共打印"+billList.length+"张,已成功添加到打印列表!");
// }else {
// $.myAlert('请先勾选需要打印的面单');
// }
}
/**
* 打印电子运单
* @param data
* @param serialNo
*/
function printEWaybill(data, serialNo, barcode, wayNum){
//打印内容
var printHtml = htmlTemplateObj.find("div#expressPrintArea").html();
// alert(9999);
// console.log(LODOP);
// return ;
LODOP.PRINT_INIT("二级模板");
LODOP.SET_PRINT_PAGESIZE(0,"110mm","180mm","CreateCustomPage");
// LODOP.ADD_PRINT_TEXT(130,30,150,130,'8888');
// LODOP.ADD_PRINT_TEXT(130,30,150,130,"河南郑州");
LODOP.SET_SHOW_MODE("BKIMG_WIDTH","100mm");
LODOP.SET_SHOW_MODE("BKIMG_HEIGHT","180mm");
LODOP.ADD_PRINT_TABLE("2mm","0.6mm","95mm","177mm",printHtml);
//运单号
LODOP.ADD_PRINT_BARCODE("73mm","10mm","84mm","15mm","128C",data);
//运单号
LODOP.ADD_PRINT_BARCODE("112mm","45mm","50mm","8mm","128C",data);
//运单号
LODOP.ADD_PRINT_BARCODE("145mm","45mm","50mm","8mm","128C",data);
//打印
//LODOP.PREVIEW();
LODOP.PRINT();
// LODOP.PRINT_DESIGN();
//记录打印日志
// try {
// printLogses(data);
// } catch (e) {
// }
}
// printEWaybill();
/**
* 打印仓库分拣单
*/
// function printWareHouseWaybill(data, serialNo, barcode){
// //打印内容
// var printHtml = htmlTemplateObj.find("div#warehousePrintArea").html();
// LODOP.PRINT_INIT("二级模板-仓库分拣单");
// LODOP.SET_PRINT_PAGESIZE(0,"100mm","180mm","CreateCustomPage");
// LODOP.ADD_PRINT_TABLE("1.7mm","0mm","98mm","148mm",printHtml);
// LODOP.ADD_PRINT_BARCODE("3.5mm","52mm","42mm","13mm","128C", data.waybillNumber);
// LODOP.ADD_PRINT_BARCODE("94.5mm","52mm","42mm","12mm","128C", data.waybillNumber);
// //打印
// // LODOP.PREVIEW();
// LODOP.PRINT();
// // try{
// // //记录打印日志
// // printLog();
// // }catch (e) { }
// }
// function printLogses(content) {
// $.post("/sandBox/writerPrintLog.do", {"printContent": JSON.stringify(content)}, function (data) {
// //console.log(content);
// });
// }