Browse Source

增加预结算单

xuefy 1 year ago
parent
commit
556c49f54b

+ 207 - 0
adm/src/main/java/com/minpay/guomao/ordermanage/action/ExcelSomeJieSuanAction.java

@@ -60,6 +60,9 @@ public class ExcelSomeJieSuanAction implements IMINAction {
 	/** 直发结算单数据 */
 	public final static String	ZHIFA_JIESUAN		= "zhifaJiesuan";
 	
+	/**订单预结算单导出*/
+	public final static String	EXCEL_PRE_SETTLEMENT		= "excelPreSettlement";
+	
 	
 	/***
 	 * 订单结算单批量导出
@@ -340,6 +343,210 @@ public class ExcelSomeJieSuanAction implements IMINAction {
 			return res;
 	}
 	
+	
+	/**
+	 * 订单预结算单导出
+	 * @param message
+	 * @param response
+	 * @return
+	 * @throws MINBusinessException
+	 */
+	@MINAction(value = EXCEL_PRE_SETTLEMENT)
+	public MINActionResult excelPreSettlement(
+			@MINParam(key = "message") String message,
+			HttpServletResponse response) throws MINBusinessException {
+		
+			MINActionResult res = new MINActionResult();
+			
+			Map messageMap = (Map<String, Object>)JSONObject.fromObject(message);
+			
+			String exportExcel = "交货区域#region,交货日期#entryTime,交货数量(吨)#weight,临时付款单价(元)#predictPrice,已付款金额(元)#totalPriceI,预结算价(元)#realPrice,预结算金额(元)#totalPriceII";
+			String[] excelHeader = exportExcel.split(",");
+			String dateTime = DateUtil.getCurrentDateTimeString();
+			String daTime = dateTime.substring(0, 8);
+			//导出Excel
+			OutputStream out=null;
+			try {
+				out = response.getOutputStream();
+				String name = daTime+"预交货结算单";
+				
+				response.setContentType("application/application/vnd.ms-excel");
+				response.setHeader("Content-disposition","attachment;filename=" + URLEncoder.encode(name + ".xls", "UTF-8"));
+				// 创建一个Workbook,对应一个Excel文件
+				HSSFWorkbook wb = new HSSFWorkbook();
+				// 设置标题样式
+				HSSFCellStyle titleStyle = wb.createCellStyle();
+				// 设置单元格边框样式
+				titleStyle.setBorderTop(BorderStyle.THIN);// 上边框 细边线
+				titleStyle.setBorderBottom(BorderStyle.THIN);// 下边框 细边线
+				titleStyle.setBorderLeft(BorderStyle.THIN);// 左边框 细边线
+				titleStyle.setBorderRight(BorderStyle.THIN);// 右边框 细边线
+				// 设置单元格对齐方式
+				titleStyle.setAlignment(HorizontalAlignment.CENTER); // 水平居中
+				titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
+				//titleStyle.setWrapText(true);//自动换行
+				// 设置字体样式
+				Font titleFont = wb.createFont();
+				titleFont.setFontHeightInPoints((short) 15); // 字体高度
+				titleFont.setFontName("黑体"); // 字体样式
+				titleStyle.setFont(titleFont);
+				
+				// 设置标题样式
+				HSSFCellStyle Style = wb.createCellStyle();
+				
+				// 设置单元格对齐方式
+				Style.setAlignment(HorizontalAlignment.CENTER); // 水平居中
+				Style.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
+				// 设置字体样式
+				Font StyleFont = wb.createFont();
+				StyleFont.setFontHeightInPoints((short) 15); // 字体高度
+				StyleFont.setFontName("黑体"); // 字体样式
+				Style.setFont(StyleFont);
+				
+				// 设置标题样式
+				HSSFCellStyle style2 = wb.createCellStyle();
+				// 设置单元格对齐方式
+				style2.setAlignment(HorizontalAlignment.LEFT); // 水平居中
+				style2.setVerticalAlignment(VerticalAlignment.TOP); // 垂直居中
+				style2.setFont(StyleFont);
+				style2.setWrapText(true);//自动换行
+				
+				// 设置标题样式
+				HSSFCellStyle style3 = wb.createCellStyle();
+				// 设置单元格对齐方式
+				style3.setAlignment(HorizontalAlignment.RIGHT); // 水平居中
+				style3.setVerticalAlignment(VerticalAlignment.TOP); // 垂直居中
+				style3.setFont(StyleFont);
+				style3.setWrapText(true);//自动换行
+				
+				// 在Workbook中添加一个sheet,对应Excel文件中的sheet
+				HSSFSheet sheet = wb.createSheet(name);
+				// 标题数组
+				String[] titleArray = new String[excelHeader.length];
+				// 字段名数组
+				String[] fieldArray = new String[excelHeader.length];
+				for (int i = 0; i < excelHeader.length; i++) {
+					String[] tempArray = excelHeader[i].split("#");// 临时数组 分割#
+					titleArray[i] = tempArray[0];
+					fieldArray[i] = tempArray[1];
+				}
+				// 在sheet中添加标题行
+				//标题
+				CellRangeAddress region1 = new CellRangeAddress(0, 0, (short) 0, (short) excelHeader.length); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列 
+				sheet.addMergedRegion(region1);
+				HSSFRow row4 = sheet.createRow((int) 0);// 行数从0开始
+				HSSFCell sequenceCell = row4.createCell(0);// cell列 从0开始 第一列添加序号
+				sequenceCell.setCellValue("预交货结算单");
+				sequenceCell.setCellStyle(Style);
+				sheet.autoSizeColumn(0);// 自动设置宽度
+				//编号
+				CellRangeAddress region2 = new CellRangeAddress(1, 1, (short) 0, (short)4); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列 
+				sheet.addMergedRegion(region2);
+				HSSFRow row1 = sheet.createRow((int) 1);// 行数从0开始
+				HSSFCell sequenceCell1 = row1.createCell(0);// cell列 从0开始 第一列添加序号
+				sequenceCell1.setCellValue(CommonUtil.objToString(messageMap.get("bianhao")));
+				sequenceCell1.setCellStyle(style2);
+				//结算日期
+				CellRangeAddress region3 = new CellRangeAddress(1, 1, (short) 6, (short) 8); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列 
+				sheet.addMergedRegion(region3);
+				HSSFCell sequenceCell2 = row1.createCell(6);// cell列 从0开始 第一列添加序号
+				sequenceCell2.setCellValue(CommonUtil.objToString(messageMap.get("jiesuanriqi")));
+				sequenceCell2.setCellStyle(style3);
+				sheet.autoSizeColumn(1);
+
+				//描述
+				CellRangeAddress region4 = new CellRangeAddress(2, 3, (short) 0, (short) excelHeader.length); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列 
+				sheet.addMergedRegion(region4);
+				HSSFRow row3 = sheet.createRow((int) 2);// 行数从0开始
+				row3.setHeight((short)500);
+				HSSFCell sequenceCell3 = row3.createCell(0);// cell列 从0开始 第一列添加序号
+				sequenceCell3.setCellValue(CommonUtil.objToString(messageMap.get("jianjie")));
+				sequenceCell3.setCellStyle(style2);
+				sheet.autoSizeColumn(2);
+				HSSFRow row = sheet.createRow((int) 4);// 行数从0开始
+				HSSFCell sequenceCell4 = row.createCell(0);// cell列 从0开始 第一列添加序号
+				sequenceCell4.setCellValue("序号");
+				sequenceCell4.setCellStyle(titleStyle);
+				// 为标题行赋值
+				for (int i = 0; i < titleArray.length; i++) {
+					HSSFCell titleCell = row.createCell(i + 1);// 0号位被序号占用,所以需+1
+					titleCell.setCellValue(titleArray[i]);
+					titleCell.setCellStyle(titleStyle);
+					sheet.autoSizeColumn(i + 1);// 0号位被序号占用,所以需+1
+				}
+				// 数据样式 因为标题和数据样式不同 需要分开设置 不然会覆盖
+				HSSFCellStyle dataStyle = wb.createCellStyle();
+				// 设置数据边框
+				dataStyle.setBorderBottom(BorderStyle.THIN);
+				dataStyle.setBorderTop(BorderStyle.THIN);
+				dataStyle.setBorderLeft(BorderStyle.THIN);
+				dataStyle.setBorderRight(BorderStyle.THIN);
+				// 设置居中样式
+				dataStyle.setAlignment(HorizontalAlignment.CENTER); // 水平居中
+				dataStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
+				// 设置数据字体
+				Font dataFont = wb.createFont();
+				dataFont.setFontHeightInPoints((short) 12); // 字体高度
+				dataFont.setFontName("宋体"); // 字体
+				dataStyle.setFont(dataFont);
+				// 遍历集合数据,产生数据行
+				int index = 0;
+				int rowIndex = 4;
+				
+				List<Map<String, String>> dataList = (List<Map<String, String>>)messageMap.get("tableData");
+				for(Map<String, String> maps : dataList){
+					index++; 
+					rowIndex++;
+					row = sheet.createRow(rowIndex);
+					HSSFCell sequenceCellValue = row.createCell(0);// 序号值永远是第0列
+					sequenceCellValue.setCellValue(index);
+					sequenceCellValue.setCellStyle(dataStyle);
+					HSSFCell dataCell = null;
+					for (int i = 0; i < fieldArray.length; i++) {
+						dataCell = row.createCell(i + 1);
+						dataCell.setCellStyle(dataStyle);
+						String fieldName = fieldArray[i];
+						String value = CommonUtil.objToString(maps.get(fieldName));
+						if (CommonUtil.isEmpty(value)) {
+							dataCell.setCellValue("");					// 为当前列赋值
+						} else {
+							dataCell.setCellValue(CommonUtil.objToString(value));// 为当前列赋值
+						}
+					}
+				}
+				
+				CellRangeAddress region5 = new CellRangeAddress(rowIndex+3, rowIndex+4, (short) 0, (short) excelHeader.length); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列 
+				sheet.addMergedRegion(region5);
+				HSSFRow row6 = sheet.createRow((int) rowIndex+3);// 行数从0开始
+				row6.setHeight((short)500);
+				HSSFCell sequenceCell13 = row6.createCell(0);// cell列 从0开始 第一列添加序号
+				sequenceCell13.setCellValue(CommonUtil.objToString(messageMap.get("jianjie1")));
+				sequenceCell13.setCellStyle(style2);
+				//卖方
+				CellRangeAddress region6 = new CellRangeAddress(rowIndex+5, rowIndex+5, (short) 0, (short) 4); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列 
+				sheet.addMergedRegion(region6);
+				HSSFRow row7 = sheet.createRow((int) rowIndex+5);// 行数从0开始
+				HSSFCell sequenceCell18 = row7.createCell(0);// cell列 从0开始 第一列添加序号
+				sequenceCell18.setCellValue("卖方:"+messageMap.get("sell"));
+				sequenceCell18.setCellStyle(style2);
+				//买方
+				CellRangeAddress region7 = new CellRangeAddress(rowIndex+5, rowIndex+5, (short) 6, (short) 8); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列 
+				sheet.addMergedRegion(region7);
+				HSSFCell sequenceCell19 = row7.createCell(6);// cell列 从0开始 第一列添加序号
+				sequenceCell19.setCellValue("买方:"+messageMap.get("buy"));
+				sequenceCell19.setCellStyle(style3);
+				
+				if(wb != null){
+					wb.write(out);
+				}
+				out.flush();
+				out.close();
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+			return res;
+	}
+	
 	@MINAction(value = ZHIFA_JIESUAN)
 	public MINActionResult zhifaJiesuan(
 			@MINParam(key = "jieSunDetail") String jieSunDetail,

+ 457 - 0
adm/src/main/webapp/admin/orderManage/preSettlementPt.html

@@ -0,0 +1,457 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <title>预结算单</title>
+    <script src="../../js/min-loader-next.js"></script>
+    <script src="../../js/jquery.jqprint-0.3.js"></script>
+    <script src="http://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script>
+    <style>
+	    .layui-table-cell {
+		    height: 28px;
+		    line-height: 28px;
+		    padding: 0 0px;
+		    position: relative;
+		    box-sizing: border-box;
+		    overflow: visible !important;
+		    text-overflow: !important;
+		    white-space: nowrap !important;
+		}
+    </style>
+</head>
+
+<body class="body-content">
+	<form class="layui-form" action="javascript:void(0)"  id = "formName" >
+	</form>
+	<div class="shadow-content"  >
+		<div class="gray-title demoTable" id = "buttonForm">
+			 <button class="layui-btn left-bnt1 in-b" id="printBtn" >
+ 				打印
+			 </button>
+			 <button class="layui-btn left-bnt1 in-b" id="exportFile" >
+ 				导出
+			 </button>
+		</div>
+		<div id="big">
+			<div id="DivHead" style="margin-bottom: 24px;">
+				<div style="margin: 0;width: 100%;">
+					<div style="font-size: 18px;font-weight: 600;text-align: center;margin: 0;">
+						<span id="title">预交货结算单</span>
+					</div>
+					<div style="font-size:18px;font-weight: 600;text-align: center;margin: 0;">
+						<span id="bianhao" style="float:left" contenteditable="true">编号:</span>
+						<span id="jiesuanriqi" contenteditable="true">结算日期:</span>
+					</div>
+					<br>
+					<div style="font-size: 18px;font-weight: 600;text-align: left;margin: 0;">
+						<span id="jianjie" contenteditable="true"></span>
+					</div>
+					<div style = "width:980px;margin-top: 20px;">
+						<table id="tableTest" lay-filter="tableFilter"></table>
+						<table id="tableTestPrint"  style="display: none;width: 100%;" class="printChuku">
+							<thead style = "padding-left:24px;padding-right:24px;">
+							<tr>
+								<th>交货区域</th>
+								<th>交货日期</th>
+								<th>交货数量(吨)</th>
+								<th id = "dongzuoThLs">临时付款单价(元)</th>
+								<th id = "dongzuoTh">已付款金额(元)</th>
+								<th>预结算价(元)</th>
+								<th>预结算金额(元)</th>
+								<!-- <th>差额</th> -->
+							</tr>
+							</thead>
+							<tbody id ="small" style = "padding-left:24px;padding-right:24px;">
+							</tbody>
+						</table>
+					</div>
+				</div>		
+			</div>
+			<div id="DivFoot" style="margin: 0;padding-bottom: 24px;">
+				<div style="font-size: 18px;font-weight: 600;text-align: left;margin: 0;">
+						<span id="jianjie1"contenteditable="true"></span>
+				</div>
+				<br>
+				<div style="margin: 0;width: 100%;">
+					<div class="display5" style="font-size: 18px;font-weight: 600;float:left">
+						<div>卖方:</div>
+						<div id="sell" style="padding-right:200px;font-size: 18px;font-weight: 600;" contenteditable="true"></div>
+						<div>买方:</div>
+						<div id="buy" contenteditable="true"></div>
+					</div>
+				</div>
+			</div>
+		</div>
+	</div> 
+<script>
+	var datas =  getTempVal('jieSuanInfo');
+	var conType = getQueryString("conType");
+	var tabPageId = getQueryString("tabPageId");
+	// 采购
+	var dongzuo = "";
+	var dongzuoThHtml = "";
+	if (conType == '00') {
+		dongzuo = "付款";
+		$("#dongzuoThLs").html("临时付款单价(元)");
+		$("#dongzuoTh").html("已付款金额(元)");
+		dongzuoThHtml = "付";
+	} else {
+		dongzuo = "收款";
+		$("#dongzuoThLs").html("临时收款单价(元)");
+		$("#dongzuoTh").html("已收款金额(元)");
+		dongzuoThHtml = "收";
+	}
+	
+	var table;
+	$.request({
+		action : 'ExcelSomeJieSuanAction/excelSomeJiesuans',
+		loading : false,
+		data : {MINView:"JSON", jieSunDetail:JSON.stringify(datas),conType:conType,type:"00"}, 
+		success : function(res) {
+			var mesList = res.data;
+			tableData = heji(mesList);
+		    //新增
+			layui.use('table', function(){
+				//创建一行参数
+				table = layui.table;
+				table.render({
+					id : 'tableTest'
+					,elem: '#tableTest'
+					,data : mesList
+					,limit:1000
+					,size: 'sm' //小尺寸的表格
+					,cols : [[ //表头
+// 		 		        {type:'numbers',title:  '序号'}
+						{field : 'region', title: '交货区域',edit: 'text'}
+						,{field : 'entryTime', title: '交货日期',edit: 'text'}
+						,{field : 'detailWeight', title: '交货数量(吨)', edit: 'text',templet : function (d) {
+							if (isEmpty(d.detailWeight)) {
+								return d.weight;
+							} else {
+								return d.detailWeight;
+							}
+						}}
+						,{field : 'predictPrice', title: '临时'+dongzuoThHtml+'款单价(元)', edit: 'text'}
+						,{field : 'totalPriceI', title: '已'+dongzuoThHtml+'款金额(元)', edit: 'text',templet : function (d) {
+							if (isEmpty(d.totalPriceI)) {
+								var weight = isEmpty(d.weight)?0:d.weight;
+								var predictPrice = isEmpty(d.predictPrice)?0:d.predictPrice;
+								return accMul(weight, predictPrice, 2);
+							} else {
+								return d.totalPriceI;
+							}
+						}}
+						,{field : 'realPrice', title: '预结算价(元)',edit: 'text'}
+						,{field : 'totalPriceII', title: '预结算金额(元)', edit: 'text',templet : function (d) {
+							if (isEmpty(d.totalPriceII)) {
+								var detailWeight = isEmpty(d.detailWeight)?0:d.detailWeight;
+								var realPrice = isEmpty(d.realPrice)?0:d.realPrice;
+								return accMul(detailWeight, realPrice, 2);
+							} else {
+								return d.totalPriceII;
+							}
+						}}
+					/* 	,{field : 'chae', title: '差额',edit: 'text',templet : function (d) {
+							if (isEmpty(d.chae)) {
+								var weight = isEmpty(d.weight)?0:d.weight;
+								var predictPrice = isEmpty(d.predictPrice)?0:d.predictPrice;
+								var detailWeight = isEmpty(d.detailWeight)?0:d.detailWeight;
+								var realPrice = isEmpty(d.realPrice)?0:d.realPrice;
+								var totalPriceI = isEmpty(d.totalPriceI)?accMul(weight, predictPrice):d.totalPriceI;
+								var totalPriceII = isEmpty(d.totalPriceII)?accMul(detailWeight, realPrice):d.totalPriceII;
+								if(conType == '01'){//销售
+									return accSub(totalPriceI, totalPriceII, 2);
+								}else if(conType == '00'){//采购
+									return accSub(totalPriceII, totalPriceI, 2);
+								}
+							} else {
+								return d.chae;
+							}
+						} 
+						}*/
+					]]
+					,page: false
+					,done: function(res, curr, count){
+						// 处理合计行
+						var trs = $("tbody").find("tr");
+						// 最后一个tr的div
+						var divs = $(trs[trs.length - 1]).find("div");
+						$(divs[0]).html("合计");
+						
+						$('#bianhao').html("编号:"+datas[0].contractNo);
+						$('#buy').html(datas[0].buyerNameAll+"(盖章)");
+						$('#sell').html(datas[0].sellerNameAll+"(盖章)");
+						var htYueDesc = datas[0].htYueDesc;
+						var riqi = htYueDesc.substr(0, 2);
+						riqi = accAdd(riqi, 1);
+						if (riqi == '13') {
+							riqi = '1';
+						}
+						$('#jianjie').html("根据"+datas[0].contractNo+"号长单合同的约定,第"+riqi+"个交货月("+htYueDesc+")期间卖方向买方交付铝锭货物,现双方确认预结算单价如下:");
+						var jiesrq = htYueDesc.substr(5, 4);
+						jiesrq = new Date().getFullYear() + "年" + jiesrq.substr(0,2) + "月" + jiesrq.substr(2,2) + "日";
+						$('#jiesuanriqi').html("结算日期:"+jiesrq);
+
+						var caeDesc = "";
+						/* if((parseFloat(tableData[tableData.length - 1].chae) < 0 && conType == '01') || (parseFloat(tableData[tableData.length - 1].chae) > 0 && conType == '00')){
+							caeDesc = "买方应补货款" + (Math.abs(tableData[tableData.length - 1].chae))+"元,";
+						} else if((parseFloat(tableData[tableData.length - 1].chae) > 0 && conType == '01') || (parseFloat(tableData[tableData.length - 1].chae) < 0 && conType == '00')){
+							caeDesc = "卖方应退货款" + (Math.abs(tableData[tableData.length - 1].chae))+"元,";
+						} else {
+							caeDesc = "";
+						} */
+						$('#jianjie1').html(riqi+"月合同执行量"+tableData[tableData.length - 1].detailWeight+"吨,已" + dongzuo + "金额"+tableData[tableData.length - 1].totalPriceI+"元,"+/* 实际结算金额"+tableData[tableData.length - 1].totalPriceII+"元, "+caeDesc */"卖方于"+riqi+"月26日前开具当月全额增值税发票。");
+					}
+				});
+				table.on('edit(tableFilter)', function(obj){ //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值"
+					var index = obj.data.LAY_TABLE_INDEX;
+					
+					var tableData = table.cache['tableTest'];
+					// 不是合计数据
+					if (index != (tableData.length - 1)) {
+						// 交货吨数
+						if (obj.field == 'weight') {
+							tableData[index].totalPriceI = null;
+							tableData.splice(tableData.length - 1);
+							tableData = heji(tableData);
+							table.reload('tableTest',{  
+					  			data : tableData  
+					        }); 
+						} else if (obj.field == 'predictPrice') {
+							tableData[index].totalPriceI = null;
+							tableData.splice(tableData.length - 1);
+							tableData = heji(tableData);
+							table.reload('tableTest',{  
+					  			data : tableData  
+					        });
+						// 合计金额
+						} else if (obj.field == 'totalPriceI') {
+							tableData.splice(tableData.length - 1);
+							tableData = heji(tableData);
+							table.reload('tableTest',{  
+					  			data : tableData  
+					        });
+						} else if (obj.field == 'detailWeight') {
+							tableData[index].totalPriceII = null;
+							tableData.splice(tableData.length - 1);
+							tableData = heji(tableData);
+							table.reload('tableTest',{  
+					  			data : tableData  
+					        });
+						} else if (obj.field == 'realPrice') {
+							tableData[index].totalPriceII = null;
+							tableData.splice(tableData.length - 1);
+							tableData = heji(tableData);
+							table.reload('tableTest',{  
+					  			data : tableData  
+					        });
+						// 合计金额
+						} else if (obj.field == 'totalPriceII') {
+							tableData.splice(tableData.length - 1);
+							tableData = heji(tableData);
+							table.reload('tableTest',{  
+					  			data : tableData  
+					        });
+						// 差额 暂不做处理
+						} else if (obj.field == 'chae') {
+							
+						}
+					}
+				});
+			})
+		},
+		error : function(data) {
+			 layer.alert('操作失败!', {
+				icon: 5,
+				title: "提示"
+			}); 
+		}
+	}); 
+	
+	function heji(tableData) {
+		// 总重量
+		var totalWeight = 0;
+		// 总 已付款金额
+		var totalPriceI = 0;
+		// 总 结算量
+		var totalDetailWeight = 0;
+		// 总结算金额
+		var totalPriceII = 0;
+		for (var i = 0; i < tableData.length; i ++) {
+			var d = tableData[i];
+			var weight = isEmpty(d.weight)?0:d.weight;
+			var predictPrice = isEmpty(d.predictPrice)?0:d.predictPrice;
+			var detailWeight = isEmpty(d.detailWeight)?0:d.detailWeight;
+			var realPrice = isEmpty(d.realPrice)?0:d.realPrice;
+			
+			// 总重量
+			totalWeight = accAdd(totalWeight, weight);
+			// 总 已付款金额
+			if (isEmpty(d.totalPriceI)) {
+				totalPriceI = accAdd(totalPriceI,accMul(weight, predictPrice,2));
+			} else {
+				totalPriceI = accAdd(d.totalPriceI, totalPriceI);
+			}
+			// 总 结算量
+			totalDetailWeight = accAdd(totalDetailWeight, detailWeight);
+			// 总结算金额
+			if (isEmpty(d.totalPriceII)) {
+				totalPriceII = accAdd(totalPriceII,accMul(detailWeight, realPrice));
+			} else {
+				totalPriceII = accAdd(d.totalPriceII, totalPriceII);
+			}
+		}
+		
+		var hejiMap = {};
+		hejiMap.weight = fomatFloat(totalWeight,4);
+		hejiMap.totalPriceI = fomatFloat(totalPriceI,2);
+		hejiMap.detailWeight = fomatFloat(totalDetailWeight,4);
+		hejiMap.totalPriceII = fomatFloat(totalPriceII,2);
+		if(conType == '01'){//销售
+			hejiMap.chae = fomatFloat(accSub(totalPriceI,totalPriceII),2);
+		}else if(conType == '00'){//采购
+			hejiMap.chae = fomatFloat(accSub(totalPriceII,totalPriceI),2);
+		}
+		tableData.push(hejiMap);
+        return tableData;
+		
+	}
+
+	//打印
+  	$(document).on('click','#printBtn',function(){
+  		var tableData = table.cache['tableTest'];
+  		for (var i = 0; i < tableData.length; i ++) {
+  			var d = tableData[i];
+  			if (isEmpty(d.totalPriceI)) {
+				var weight = isEmpty(d.weight)?0:d.weight;
+				var predictPrice = isEmpty(d.predictPrice)?0:d.predictPrice;
+				d.totalPriceI = accMul(weight, predictPrice, 2);
+			}
+  			
+  			if (isEmpty(d.totalPriceII)) {
+				var detailWeight = isEmpty(d.detailWeight)?0:d.detailWeight;
+				var realPrice = isEmpty(d.realPrice)?0:d.realPrice;
+				d.totalPriceII = accMul(detailWeight, realPrice, 2);
+			}
+  			
+  			/* if (isEmpty(d.chae)) {
+				var weight = isEmpty(d.weight)?0:d.weight;
+				var predictPrice = isEmpty(d.predictPrice)?0:d.predictPrice;
+				var detailWeight = isEmpty(d.detailWeight)?0:d.detailWeight;
+				var realPrice = isEmpty(d.realPrice)?0:d.realPrice;
+				var totalPriceI = isEmpty(d.totalPriceI)?accMul(weight, predictPrice):d.totalPriceI;
+				var totalPriceII = isEmpty(d.totalPriceII)?accMul(detailWeight, realPrice):d.totalPriceII;
+				d.chae = accSub(totalPriceII, totalPriceI, 2);
+			} */
+  			// 最后一条数据
+  			if (i == (tableData.length - 1)) {
+  				d.region = "合计";
+  			}
+  		}
+  		
+		var printTableHtml = '';
+  		for (var i = 0; i < tableData.length; i ++) {
+  			var inf = tableData[i];
+  			inf.region = (isEmpty(inf.region)?'':inf.region);
+  			inf.entryTime = (isEmpty(inf.entryTime)?'':inf.entryTime);
+  			inf.predictPrice = (isEmpty(inf.predictPrice)?'':inf.predictPrice);
+  			inf.totalPriceI = (isEmpty(inf.totalPriceI)?'':inf.totalPriceI);
+  			inf.detailWeight = (isEmpty(inf.detailWeight)?'':inf.detailWeight);
+  			inf.realPrice = (isEmpty(inf.realPrice)?'':inf.realPrice);
+  			inf.totalPriceII = (isEmpty(inf.totalPriceII)?'':inf.totalPriceII);
+  			inf.chae = (isEmpty(inf.chae)?'':inf.chae);
+  			printTableHtml += '<tr><td>' + (inf.region) + '</td><td>' + (inf.entryTime) + '</td><td>' + (inf.weight) + '</td><td>' + ($.toCashWithCommaAndDot(inf.predictPrice)) + '</td><td>' + ($.toCashWithCommaAndDot(inf.totalPriceI)) + '</td><td>' + ($.toCashWithCommaAndDot(inf.realPrice)) + '</td><td>' + ($.toCashWithCommaAndDot(inf.totalPriceII)) + '</td>'+/* <td>' + ($.toCashWithCommaAndDot(inf.chae)) + '</td> */+'</tr>';
+  		}
+  		$("#small").html(printTableHtml);
+  		
+  		$(".layui-table-view").hide();
+  		$("#tableTestPrint").show();
+	    $("#big").jqprint();
+		$("#tableTestPrint").hide();
+		$(".layui-table-view").show();
+	});
+	
+	//打印
+  	$(document).on('click','#exportFile',function(){
+  		var tableData = table.cache['tableTest'];
+  		for (var i = 0; i < tableData.length; i ++) {
+  			var d = tableData[i];
+  			if (isEmpty(d.totalPriceI)) {
+				var weight = isEmpty(d.weight)?0:d.weight;
+				var predictPrice = isEmpty(d.predictPrice)?0:d.predictPrice;
+				d.totalPriceI = accMul(weight, predictPrice, 2);
+			}
+  			
+  			if (isEmpty(d.totalPriceII)) {
+				var detailWeight = isEmpty(d.detailWeight)?0:d.detailWeight;
+				var realPrice = isEmpty(d.realPrice)?0:d.realPrice;
+				d.totalPriceII = accMul(detailWeight, realPrice, 2);
+			}
+  			
+  			if (isEmpty(d.chae)) {
+				var weight = isEmpty(d.weight)?0:d.weight;
+				var predictPrice = isEmpty(d.predictPrice)?0:d.predictPrice;
+				var detailWeight = isEmpty(d.detailWeight)?0:d.detailWeight;
+				var realPrice = isEmpty(d.realPrice)?0:d.realPrice;
+				var totalPriceI = isEmpty(d.totalPriceI)?accMul(weight, predictPrice):d.totalPriceI;
+				var totalPriceII = isEmpty(d.totalPriceII)?accMul(detailWeight, realPrice):d.totalPriceII;
+				d.chae = accSub(totalPriceI, totalPriceII, 2);
+			}
+  			// 最后一条数据
+  			if (i == (tableData.length - 1)) {
+  				d.region = "合计";
+  			}
+  		}
+  		
+  		var message = {};
+  		message.title = $("#title").html();
+  		message.bianhao = $("#bianhao").html();
+  		message.jiesuanriqi = $("#jiesuanriqi").html();
+  		message.jianjie = $("#jianjie").html();
+  		message.jianjie1 = $("#jianjie1").html();
+  		message.sell = $("#sell").html();
+  		message.buy = $("#buy").html();
+  		message.tableData = tableData;
+  		openPostWindow("../../ExcelSomeJieSuanAction/excelPreSettlement", JSON.stringify(message), "message");
+	});
+	
+	//预结算
+  	$(document).on('click','#preSettlement',function(){
+  		openMainTabPageParent(tabPageId+'-01', '打印预结算', 'orderManage/someOutPrintCd.html?&tabPageId='+tabPageId+'-01&conType='+conType,'',tabPageId,null);
+ 
+	});
+	
+  	/**
+  	 * 使用post方式打开画面,解决self.open传输数据get方法的传输数据量限制
+  	 */
+  	function openPostWindow(url, data, name){     
+  	     var tempForm = document.createElement("form");     
+  	     tempForm.id="tempForm1";     
+  	     tempForm.method="post";     
+  	     tempForm.action=url;     
+  	     tempForm.target=name;     
+  	     var hideInput = document.createElement("input");     
+  	     hideInput.type="hidden";     
+  	     hideInput.name= name;  
+  	     hideInput.value= data;   
+  	     tempForm.appendChild(hideInput);      
+  	     tempForm.addEventListener("onsubmit",function(){ openWindow(url,name); });   
+  	     document.body.appendChild(tempForm);     
+  	     tempForm.submit();   
+  	     document.body.removeChild(tempForm);   
+  	}  
+  	/**
+  	 * 打开画面
+  	 */
+  	function openWindow(url,name){     
+  	     self.open(url,name,'height=400, width=400, top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes');      
+  	} 
+
+</script>
+     
+  
+  
+</body>
+
+</html>

+ 180 - 0
adm/src/main/webapp/admin/orderManage/preSettlementZf.html

@@ -0,0 +1,180 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <title>预交货结算单</title>
+    <script src="../../js/min-loader-next.js"></script>
+    <script src="../../js/jquery.jqprint-0.3.js"></script>
+    <script src="http://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script>
+    <style>
+	    .layui-table-cell {
+		    height: 28px;
+		    line-height: 28px;
+		    padding: 0 0px;
+		    position: relative;
+		    box-sizing: border-box;
+		    overflow: visible !important;
+		    text-overflow: !important;
+		    white-space: nowrap !important;
+		}
+    </style>
+</head>
+
+<body class="body-content">
+	<form class="layui-form" action="javascript:void(0)"  id = "formName" >
+	</form>
+	<div class="shadow-content"  >
+		<div class="gray-title demoTable" id = "buttonForm">
+			 <button class="layui-btn left-bnt1 in-b" id="printBtn" >
+ 				打印
+			 </button>
+		</div>
+		<div id="big">
+			<div id="DivHead" style="margin-bottom: 24px;">
+				<div style="margin: 0;width: 100%;">
+					<div style="font-size: 18px;font-weight: 600;text-align: center;margin: 0;">
+						<span id="title">预交货结算单</span>
+					</div>
+					<div style="font-size:18px;font-weight: 600;text-align: center;margin: 0;">
+						<span id="bianhao" style="float:left" contenteditable="true">编号:</span>
+						<span id="jiesuanriqi" contenteditable="true">结算日期:</span>
+					</div>
+					<br>
+					<div style="font-size: 18px;font-weight: 600;text-align: left;margin: 0;">
+						<span id="jianjie" contenteditable="true"></span>
+					</div>
+					<div style = "width:980px;margin-top: 20px;">
+						<table id="tableTestPrint"  style="width: 100%;" class="printChuku">
+							<thead style = "padding-left:24px;padding-right:24px;">
+							<tr>
+								<th colspan = "7" contenteditable="true">国家电投集团铝业国际贸易有效公司铝锭出库单</th>
+							</tr>
+							<tr>
+								<th contenteditable="true">客户名称</th>
+								<th colspan = "6" id = "customerName" contenteditable="true"></th>
+							</tr>
+							<tr>
+								<th contenteditable="true">票号</th>
+								<th colspan = "6" contenteditable="true"></th>
+							</tr>
+							<tr>
+								<th contenteditable="true">出库日期</th>
+								<th colspan = "6" id = "date" contenteditable="true"></th>
+							</tr>
+							<tr>
+								<th contenteditable="true">备注</th>
+								<th colspan = "6" contenteditable="true"></th>
+							</tr>
+							<tr>
+								<th>日期</th>
+								<th>货源单位</th>
+								<th>仓库名称</th>
+								<th>品位</th>
+								<th>重量</th>
+								<th>单价</th>
+								<th>货款金额</th>
+							</tr>
+							</thead>
+							<tbody id ="small" style = "padding-left:24px;padding-right:24px;">
+							</tbody>
+						</table>
+					</div>
+				</div>		
+			</div>
+			<div id="DivFoot" style="margin: 0;padding-bottom: 24px;">
+				<div style="font-size: 18px;font-weight: 600;text-align: left;margin: 0;">
+						<span id="jianjie1"contenteditable="true"></span>
+				</div>
+				<br>
+				<div style="margin: 0;width: 100%;">
+					<div class="display5" style="font-size: 18px;font-weight: 600;float:left">
+						<div>卖方:</div>
+						<div id="sell" style="padding-right:200px;font-size: 18px;font-weight: 600;" contenteditable="true"></div>
+						<div>买方:</div>
+						<div id="buy" contenteditable="true"></div>
+					</div>
+				</div>
+			</div>
+		</div>
+	</div> 
+<script>
+	var datas =  getTempVal('jieSuanInfo');
+	var conType = getQueryString("conType");
+	// 采购
+	var dongzuo = "";
+	var dongzuoThHtml = "";
+	if (conType == '00') {
+		dongzuo = "付款";
+		$("#dongzuoThLs").html("临时付款单价(元)");
+		$("#dongzuoTh").html("已付款金额(元)");
+		dongzuoThHtml = "付";
+	} else {
+		dongzuo = "收款";
+		$("#dongzuoThLs").html("临时收款单价(元)");
+		$("#dongzuoTh").html("已收款金额(元)");
+		dongzuoThHtml = "收";
+	}
+	
+	$("#customerName").html(datas[0].buyerNameAll);
+	$('#bianhao').html("编号:"+datas[0].contractNo);
+	$('#buy').html(datas[0].buyerNameAll+"(盖章)");
+	$('#sell').html(datas[0].sellerNameAll+"(盖章)");
+	
+	var htYueDesc = datas[0].htYueDesc;
+	var riqi = htYueDesc.substr(0, 2);
+	riqi = accAdd(riqi, 1);
+	if (riqi == '13') {
+		riqi = '1';
+	}
+	$('#jianjie').html("根据"+datas[0].contractNo+"号长单合同的约定,第"+riqi+"个交货月("+htYueDesc+")期间卖方向买方交付铝锭货物,现双方确认预结算单价如下:");
+	var jiesrq = htYueDesc.substr(5, 4);
+	jiesrq = new Date().getFullYear() + "年" + jiesrq.substr(0,2) + "月" + jiesrq.substr(2,2) + "日";
+	$('#jiesuanriqi').html("结算日期:"+jiesrq);
+	$("#date").html(new Date().getFullYear() + "-" + htYueDesc.substr(5, 4).substr(0,2) + "-" + htYueDesc.substr(5, 4).substr(2,2));
+	
+	var table;
+	$.request({
+		action : 'ExcelSomeJieSuanAction/zhifaJiesuan',
+		loading : false,
+		data : {MINView:"JSON", jieSunDetail:JSON.stringify(datas)}, 
+		success : function(res) {
+			var mesList = res.data;
+			console.log(mesList);
+			
+			var html = "";
+			
+			var totalWeight = "0.0000";
+			var totalAmt = "0.0000";
+			for (var i = 0; i < mesList.length; i ++) {
+				var resData = mesList[i];
+				var detailWeight = isEmpty(resData.detailWeight)?'0.0000':resData.detailWeight;
+				var realPrice = isEmpty(resData.realPrice)?'0.00':resData.realPrice;
+				html += '<tr><td>' + resData.entryTime + '</td><td>' + resData.shortName + '</td><td>' + resData.wareName + '</td><td>' + resData.specName + '</td><td>' + detailWeight + '</td><td>' + realPrice + '</td><td>' + accMul(detailWeight, realPrice, 2) + '</td></tr>';
+				totalWeight = accAdd(totalWeight, detailWeight, 4);
+				totalAmt = accAdd(totalAmt, accMul(detailWeight, realPrice, 2), 2);
+			}
+			html += '<tr><td>小计</td><td></td><td></td><td></td><td>' + totalWeight + '</td><td></td><td>' + totalAmt + '</td></tr>';
+			html += '<tr><td>合计</td><td></td><td></td><td></td><td>' + totalWeight + '</td><td></td><td>' + totalAmt + '</td></tr>';
+			$("#small").html(html);
+		},
+		error : function(data) {
+			 layer.alert('操作失败!', {
+				icon: 5,
+				title: "提示"
+			}); 
+		}
+	}); 
+
+	//打印
+  	$(document).on('click','#printBtn',function(){
+	    $("#big").jqprint();
+	});
+
+</script>
+     
+  
+  
+</body>
+
+</html>

+ 16 - 1
adm/src/main/webapp/admin/orderManage/someOutPrintCd.html

@@ -32,6 +32,9 @@
 			 <button class="layui-btn left-bnt1 in-b" id="exportFile" >
  				导出
 			 </button>
+			 <button class="layui-btn left-bnt1 in-b" id="preSettlement" >
+ 				预结算单
+			 </button>
 		</div>
 		<div id="big">
 			<div id="DivHead" style="margin-bottom: 24px;">
@@ -87,6 +90,7 @@
 <script>
 	var datas =  getTempVal('jieSuanInfo');
 	var conType = getQueryString("conType");
+	var tabPageId = getQueryString("tabPageId");
 	// 采购
 	var dongzuo = "";
 	var dongzuoThHtml = "";
@@ -124,7 +128,13 @@
 // 		 		        {type:'numbers',title:  '序号'}
 						{field : 'region', title: '交货区域',edit: 'text'}
 						,{field : 'entryTime', title: '交货日期',edit: 'text'}
-						,{field : 'detailWeight', title: '实际交货数量(吨)', edit: 'text'}
+						,{field : 'detailWeight', title: '实际交货数量(吨)', edit: 'text',templet : function (d) {
+							if (isEmpty(d.detailWeight)) {
+								return d.weight;
+							} else {
+								return d.detailWeight;
+							}
+						}}
 						,{field : 'predictPrice', title: '临时'+dongzuoThHtml+'款单价(元)', edit: 'text'}
 						,{field : 'totalPriceI', title: '已'+dongzuoThHtml+'款金额(元)', edit: 'text',templet : function (d) {
 							if (isEmpty(d.totalPriceI)) {
@@ -408,6 +418,11 @@
   		openPostWindow("../../ExcelSomeJieSuanAction/excelJiesuans", JSON.stringify(message), "message");
 	});
 	
+	//预结算
+  	$(document).on('click','#preSettlement',function(){
+  		openMainTabPageParent(tabPageId+'-01', '预交货结算单', 'orderManage/preSettlementPt.html?&tabPageId='+tabPageId+'-01&conType='+conType,'',tabPageId,null);
+ 
+	});
 	
   	/**
   	 * 使用post方式打开画面,解决self.open传输数据get方法的传输数据量限制

+ 9 - 0
adm/src/main/webapp/admin/orderManage/someOutPrintZF.html

@@ -29,6 +29,9 @@
 			 <button class="layui-btn left-bnt1 in-b" id="printBtn" >
  				打印
 			 </button>
+			 <button class="layui-btn left-bnt1 in-b" id="preSettlement" >
+ 				预交货结算单
+			 </button>
 		</div>
 		<div id="big">
 			<div id="DivHead" style="margin-bottom: 24px;">
@@ -101,6 +104,7 @@
 <script>
 	var datas =  getTempVal('jieSuanInfo');
 	var conType = getQueryString("conType");
+	var tabPageId = getQueryString("tabPageId");
 	// 采购
 	var dongzuo = "";
 	var dongzuoThHtml = "";
@@ -171,6 +175,11 @@
 	    $("#big").jqprint();
 	});
 
+  //预交货结算
+  	$(document).on('click','#preSettlement',function(){
+  		openMainTabPageParent(tabPageId+'-01', '预交货结算单', 'orderManage/preSettlementZf.html?&tabPageId='+tabPageId+'-01&conType='+conType,'',tabPageId,null);
+ 
+	});
 </script>