tudc 4 years ago
parent
commit
9a2b974251

+ 9 - 1
src/main/java/com/minpay/common/service/impl/ReportServiceImpl.java

@@ -671,7 +671,7 @@ public class ReportServiceImpl implements IReportService {
 		dataMap.put("sanciyishangNum", sanciyishangNum);
 		dataMap.put("sanciyishangNumDesc", sanciyishangNumDesc);
 		dataMap.put("huifu", huifu);
-		String descStr = "监测发现台区停电${tingdianNum}个,按单位分:${tingdianNumDesc}其中${monthNum}个月内重复停电${countNum}次及以上的台区${sanciyishangNum},按单位分:${sanciyishangNumDesc}截止今日${huifu}时已全部恢复送电。";
+		String descStr = "<p>监测发现台区停电${tingdianNum}个,按单位分:${tingdianNumDesc}其中${monthNum}个月内重复停电${countNum}次及以上的台区${sanciyishangNum},按单位分:${sanciyishangNumDesc}截止今日${huifu}时已全部恢复送电。</p>";
 		resMap.put("dataMap", dataMap);
 		resMap.put("descStr", descStr);
 		
@@ -1070,6 +1070,14 @@ public class ReportServiceImpl implements IReportService {
 		heji.add(totalMonthChongfuTaici);
 		heji.add(totalMonthChongfuTaishu);
 		
+		// 没有数据的区域数值为0
+		for (List<String> list : resList) {
+			if (list.size() == 6) {
+				list.add("0");
+				list.add("0");
+			}
+		}
+		
 		// 环比
 		String huanbi = "0";
 		String huanbiBeginTime = DateUtil.dateAddMonth(rangeArray[1], -4);	// 减四个月加一天

+ 96 - 3
src/main/java/com/minpay/dianwang/util/ReportExcelUtil.java

@@ -1,5 +1,13 @@
 package com.minpay.dianwang.util;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.math.BigInteger;
 import java.net.URLEncoder;
 import java.util.Collection;
 import java.util.Iterator;
@@ -14,6 +22,19 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
+import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.apache.poi.xwpf.usermodel.XWPFParagraph;
+import org.apache.poi.xwpf.usermodel.XWPFRun;
+import org.apache.poi.xwpf.usermodel.XWPFTable;
+import org.apache.poi.xwpf.usermodel.XWPFTableRow;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTShd;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STShd;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
 
 import com.minpay.common.util.CommonUtil;
 
@@ -34,7 +55,7 @@ public class ReportExcelUtil {
 	  * @throws Exception
 	  */
 	 public static <T> HSSFWorkbook export(HttpServletResponse response, String fileName,
-	   String dataListStr) throws Exception {
+			 List<List<String>> dataList, String reportDesc) throws Exception {
 		  // 设置请求
 		  response.setContentType("application/application/vnd.ms-excel");
 		  response.setHeader("Content-disposition",
@@ -44,9 +65,16 @@ public class ReportExcelUtil {
 		  // 在Workbook中添加一个sheet,对应Excel文件中的sheet
 		  HSSFSheet sheet = wb.createSheet(fileName);
 		  // 遍历集合数据,产生数据行
-		  JSONArray dataList = JSONArray.fromObject(dataListStr);
-		  
 		  int index = 0;
+		  if (!CommonUtil.isEmpty(reportDesc)) {
+			  HSSFRow row = sheet.createRow(index);
+			  row.setHeight((short)1000);
+			  HSSFCell dataCell = row.createCell(0);
+			  dataCell.setCellValue(reportDesc);
+			  CellRangeAddress region = new CellRangeAddress(0, 0, 0, dataList.get(0).size() - 1);
+			  sheet.addMergedRegion(region);
+			  index ++;
+		  }
 		  for (Object dataChild : dataList) {
 			  List<Object> dataChildList = (List<Object>)dataChild;
 			  
@@ -139,4 +167,69 @@ public class ReportExcelUtil {
 			  sheet.setColumnWidth(fieldArray.length, 20 * 256);
 			  return wb;
 		 }
+	 
+	 public static void write2Docx(HttpServletResponse response, String title, String content, String path, String fileName)throws Exception{
+	        XWPFDocument document= new XWPFDocument();
+	        //Write the Document in file system
+	        File saveFilePath = new File(path);
+	        if (!saveFilePath.exists()) {
+				saveFilePath.mkdirs();
+			}
+			
+			FileOutputStream out = null;
+
+			try {
+				out = new FileOutputStream(new File(path + "\\" + fileName));
+				 //添加标题
+		        XWPFParagraph titleParagraph = document.createParagraph();
+		        //设置段落居中
+		        titleParagraph.setAlignment(ParagraphAlignment.CENTER);
+
+		        XWPFRun titleParagraphRun = titleParagraph.createRun();
+
+		        titleParagraphRun.setText(title);
+		        titleParagraphRun.setColor("000000");
+		        titleParagraphRun.setFontSize(20);
+
+		        String[] paragraphs = content.split(System.getProperty("line.separator"));
+		        for (int i = 0; i < paragraphs.length; i ++) {
+			        //段落
+			        XWPFParagraph firstParagraph = document.createParagraph();
+			        XWPFRun run = firstParagraph.createRun();
+			        run.setText(paragraphs[i]);
+			        run.setColor("696969");
+			        run.setFontSize(16);
+		        }
+
+		        document.write(out);
+			} catch (Exception e) {
+				e.printStackTrace();
+			} finally {
+				out.close();
+			}
+			OutputStream toClient = null;
+			InputStream fis = null;
+			try {
+				fis = new BufferedInputStream(new FileInputStream(path + "\\" + fileName));
+				byte[] buffer = new byte[fis.available()];
+				fis.read(buffer);
+				   
+				// 清空response
+				response.reset();
+				// 设置response的Header
+				response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
+				toClient = new BufferedOutputStream(response.getOutputStream());
+				response.setContentType("application/octet-stream");
+				toClient.write(buffer);
+				toClient.flush();
+			} catch (Exception e) {
+				e.printStackTrace(); 
+			} finally {
+				fis.close();
+				toClient.close();
+			}
+			
+			// 操作成功后删除本地文件
+			new File(path + "\\" + fileName).delete();
+	    }
 }

+ 2 - 2
src/main/java/com/minpay/reportManage/action/JtfjtReportAction.java

@@ -384,7 +384,7 @@ public class JtfjtReportAction implements IMINAction {
     	DwReportData reportDataInf = db.selectByPrimaryKey(DwReportDataMapper.class, reportId);
     	
     	// excel类型
-    	if ("00".equals(branchReportType.getType())) {
+    	/*if ("00".equals(branchReportType.getType())) {
     		//导出Excel
     		OutputStream out=null;
     		try {
@@ -398,7 +398,7 @@ public class JtfjtReportAction implements IMINAction {
     		} catch (Exception e) {
     			e.printStackTrace();
     		}
-    	}
+    	}*/
     	
     	return response;
     }

+ 23 - 3
src/main/java/com/minpay/reportManage/action/ReportManageAction.java

@@ -11,6 +11,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Matcher;
 
 import javax.servlet.http.HttpServletResponse;
 
@@ -63,6 +64,7 @@ import com.startup.minpay.frame.target.MINComponent;
 import com.startup.minpay.frame.target.MINParam;
 
 import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 
 @MINComponent
 public class ReportManageAction implements IMINAction {
@@ -389,13 +391,13 @@ public class ReportManageAction implements IMINAction {
      * @param reportId
      * @param response
      * @return
-     * @throws MINBusinessException
+     * @throws Exception 
      */
     @MINAction(value = REPORT_DOWN_LOAD)
     public HttpServletResponse reportDownLoad(
     		@MINParam(key = "reportId") String reportId,
     		HttpServletResponse response
-    		) throws MINBusinessException {
+    		) throws Exception {
     	db = Service.lookup(IMINDataBaseService.class);
     	
     	DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
@@ -404,13 +406,29 @@ public class ReportManageAction implements IMINAction {
     	
     	DwReportData reportDataInf = db.selectByPrimaryKey(DwReportDataMapper.class, reportId);
     	
+    	Map<String, Object> dataJSONMap = JSONObject.fromObject(reportDataInf.getData());
+    	List<List<String>> dataList = (List<List<String>>)dataJSONMap.get("excelList");
+    	
+    	String descStr = (String)dataJSONMap.get("descStr");
+    	descStr = descStr.replaceAll("<p>", "");
+    	descStr = descStr.replaceAll("</p>", System.getProperty("line.separator"));
+    	if (dataJSONMap.get("dataMap") != null) {
+    		Map<String, Object> dataMap = (Map<String, Object>)dataJSONMap.get("dataMap");
+    		for(Map.Entry<String, Object> entry : dataMap.entrySet()){
+    		    String mapKey = entry.getKey();
+    		    Object mapValue = entry.getValue();
+    		    descStr = descStr.replaceAll("\\$\\{" + mapKey + "\\}", String.valueOf(mapValue));
+    		}
+    	}
+    	
+    	
     	// excel类型
     	if ("00".equals(branchReportType.getType())) {
     		//导出Excel
     		OutputStream out=null;
     		try {
     			out = response.getOutputStream();
-    			HSSFWorkbook wb = ReportExcelUtil.export(response, reportInf.getFileName(), reportDataInf.getData());
+    			HSSFWorkbook wb = ReportExcelUtil.export(response, reportInf.getFileName(), dataList, descStr);
     			if(wb != null){
     				wb.write(out);
     			}
@@ -419,6 +437,8 @@ public class ReportManageAction implements IMINAction {
     		} catch (Exception e) {
     			e.printStackTrace();
     		}
+    	} else {
+    		ReportExcelUtil.write2Docx(response, reportInf.getFileName(), descStr, "\\home\\temp", reportInf.getFileName() + ".docx");
     	}
     	
     	return response;

+ 8 - 2
src/main/webapp/admin/tqtd/reportManageDetailTqtd.html

@@ -9,12 +9,16 @@
 <body class="content">
 	<div class="shadow-content" style="margin:1.5rem; text-align: center;">
 		<p id = "reportTitle" style="margin:15px; font-size : 20px"></p>
-<!--     	<table id="reportTable" class="layui-table"></table> -->
     	<div id = "reportDiv" style = "margin : 20px; text-align : left;"></div>
     	<div id = "reportFujian" style = "margin : 20px; text-align : right;">
     		<a style = "color : red;" onclick = "downLoadFujian()">附件下载</a>
     	</div>
 	</div>
+	<div class="layui-form-item box-button display" style="justify-content: flex-end;-webkit-justify-content: flex-end;">
+         <div class="layui-input-block" id="goBack" onclick="goBack()">
+             <button class="layui-btn">返回</button>
+         </div>
+	</div>
     <script>
 	var pageId = getQueryString("pageId");
 	var reportId = getQueryString("reportId");		//报告id
@@ -42,6 +46,8 @@
 				var replaceStr = "${" + key + "}";
 				if (key == "totalCountTwice") {
 					reportDesc = reportDesc.replace(/\${totalCountTwice}/g, reportDataJson[key]);
+				}else if (key == "shejiNum") {
+					reportDesc = reportDesc.replace(/\${shejiNum}/g, reportDataJson[key]);
 				} else {
 					reportDesc = reportDesc.replace(replaceStr, reportDataJson[key]);
 				}
@@ -78,7 +84,7 @@
   	});
 	
 	function reportTable(excelList, typeId, isEdit) {
-		var html = '<table class="layui-table">';
+		var html = '<table class="layui-table" id = "tableId">';
 		for (var i = 0; i < excelList.length; i ++) {
 			html += '<tr>';
 			var excelChildList = excelList[i];

+ 2 - 4
src/main/webapp/admin/tqtd/reportManageTqtd.html

@@ -40,10 +40,8 @@
 	</div>
 	<script type="text/html" id="barDemo">
 		<a class="layui-btn layui-btn-xs" lay-event="detail">详情查看</a>
-		{{#  if(timeType == '00'){ }}
-			<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
-		{{#  } }}
-     	<!-- <a class="layui-btn layui-btn-xs" lay-event="downLoad">下载</a> -->
+		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
+     	<a class="layui-btn layui-btn-xs" lay-event="downLoad">下载</a>
 		<a class="layui-btn layui-btn-xs" lay-event="delete">删除</a>
    	</script>
 	<script type="text/html" id="algorithmBar">

+ 286 - 43
src/main/webapp/admin/tqtd/reportManageUpdateTqtd.html

@@ -5,72 +5,315 @@
     <meta charset="utf-8">
     <title>报告详情</title>
     <script src="../../js/min-loader-next.js"></script>
-    <script src="../../js/report.js"></script>
 </head>
 <body class="content">
 	<div class="shadow-content" style="margin:1.5rem; text-align: center;">
-		<p id = "reportTitle" style="margin:15px; font-size : 20px" contenteditable = "true"></p>
-    	<table id="reportTable" class="layui-table"></table>
+		<p id = "reportTitle" style="margin:15px; font-size : 20px" contenteditable = true></p>
+    	<div id = "reportDiv" style = "margin : 20px; text-align : left;"></div>
+    	<div id = "reportFujian" style = "margin : 20px; text-align : right;">
+    		<a style = "color : red;" onclick = "downLoadFujian()">附件下载</a>
+    	</div>
+	</div>
+	<div class="layui-form-item box-button display" style="justify-content: flex-end;-webkit-justify-content: flex-end;">
+		<div class="layui-input-block" onclick="save()">
+             <button class="layui-btn">保存</button>
+         </div>
+         <div class="layui-input-block" onclick="goBack()">
+             <button class="layui-btn">返回</button>
+         </div>
 	</div>
-	<div class="layui-form-item box-button" style="margin-top:50px">
-          <div class="layui-input-block">
-				<button class="layui-btn" onclick = "saveReport()">保存</button>
-          </div>
-    </div>
     <script>
 	var pageId = getQueryString("pageId");
 	var reportId = getQueryString("reportId");		//报告id
 	var fileName = chineseUrlDecodeURI(getQueryString("fileName"));	//报告名称
 	
-	var type = getQueryString("type");		//报告类型00:excel 01:word
-	var typeId = getQueryString("typeId");	//报告类型id
+	var type = getQueryString("type");				//报告类型00:excel 01:word
+	var typeId = getQueryString("typeId");			//报告类型id
+	var reportType = getQueryString("reportType");	//报告类型
 	
 	var cols = null;
 	
-	// excel
-	if ("00" == type) {
-		$("#reportTitle").html(fileName);
+	$("#reportTable").hide();
+	$("#reportTitle").html(fileName);
+	$.request({
+		action : 'ReportManageAction/reportInfDetail',
+		data : {
+			reportId : reportId
+		},
+		success : function(data) {
+			var resJSON = eval('(' + data.data.data + ')');
+			var reportDataJson = resJSON.dataMap;
+			var reportDesc = resJSON.descStr;
+			
+			if (!isEmpty(reportDataJson)) {
+				for(var key in reportDataJson){
+					var replaceStr = "${" + key + "}";
+					if (key == "totalCountTwice") {
+						reportDesc = reportDesc.replace(/\${totalCountTwice}/g, reportDataJson[key]);
+					} else {
+						reportDesc = reportDesc.replace(replaceStr, reportDataJson[key]);
+					}
+				}
+			}
+			$("#reportDiv").html(reportDesc);
+			$("#reportDiv").find("p").attr("contenteditable", true);
+			
+			var excelList = resJSON.excelList;
+			// 周报
+			if (reportType == "TQTDZB") {
+				var tableHtml = '<table class="layui-table" id = "tableId">';
+				for (var i = 0; i < excelList.length; i ++) {
+					tableHtml += '<tr>';
+					var childList = excelList[i];
+					for (var j = 0; j < childList.length; j ++) {
+						tableHtml += '<td onblur = "reportChange(this, \'' + typeId + '\',' + i + ', '+ j + ')" contenteditable = "true">' + childList[j] + '</td>';
+					}
+					tableHtml += '</tr>';
+				}
+				tableHtml += '</table>';
+				$("#reportDiv").append(tableHtml);
+			}
+			// 日报
+			if (reportType == "TQTDRB") {
+				reportTable(excelList, typeId);
+			}
+			// 不是月报
+			if (reportType != "TQTDYB") {
+				$("#reportFujian").hide();
+			}
+		},
+		error : function(data2) {
+			$.ErrorAlert(data2.MINErrorMessage);
+		}
+  	});
+	
+	function reportTable(excelList, typeId, isEdit) {
+		var html = '<table class="layui-table" id = "tableId">';
+		for (var i = 0; i < excelList.length; i ++) {
+			html += '<tr>';
+			var excelChildList = excelList[i];
+			for (var j = 0; j < excelChildList.length; j ++) {
+				// 合计列增加穿透
+				if ((j == excelChildList.length - 1)) {
+					// 台区停电次数
+					if (i == 2) {
+						html += '<td style="cursor: pointer;background-color: #f8d61a;" onclick="tqtd0()" title = "查看详情">' + excelChildList[j] + '</td>';
+					} else if (i == 3) {
+						html += '<td style="cursor: pointer;background-color: #f8d61a;" onclick="tqtd4()" title = "查看详情">' + excelChildList[j] + '</td>';
+					// 2个月停电3次及以上台区
+					} else if (i == 6) {
+						html += '<td style="cursor: pointer;background-color: #f8d61a;" onclick="tqtd1()" title = "查看详情">' + excelChildList[j] + '</td>';
+					// 2个月停电3次及以上台区且昨日停电
+					} else if (i == 7) {
+						html += '<td style="cursor: pointer;background-color: #f8d61a;" onclick="tqtd2()" title = "查看详情">' + excelChildList[j] + '</td>';
+					} else if (i == 8) {
+						html += '<td style="cursor: pointer;background-color: #f8d61a;" onclick="tqtd3()" title = "查看详情">' + excelChildList[j] + '</td>';
+					} else {
+						html += '<td onblur = "reportChange(this, \'' + typeId + '\',' + i + ', '+ j + ')" contenteditable = "true">' + excelChildList[j] + '</td>';
+					}
+				} else {
+					html += '<td onblur = "reportChange(this, \'' + typeId + '\',' + i + ', '+ j + ')" contenteditable = "true">' + excelChildList[j] + '</td>';
+				}
+			}
+			html += '</tr>';
+		}
+		html += '</table>';
+		$("#reportDiv").append(html);
+	}
+	
+	// 台区次数穿透
+	function tqtd0(){
+		var openPageId = pageId + "-01";
+		openMainTabPage(openPageId, "详情", "tqtd/reportManageDetailChuantou.html?pageId="+openPageId+"&reportId="+reportId+"&chuantouType=TQTD01", '', pageId, null);
+	}
+	// 2个月停电3次及以上台区穿透
+	function tqtd1(){
+		var openPageId = pageId + "-02";
+		openMainTabPage(openPageId, "详情", "tqtd/reportManageDetailChuantou.html?pageId="+openPageId+"&reportId="+reportId+"&chuantouType=TQTD02", '', pageId, null);
+	}
+	// month个月停电count次及以上台区且昨日停电穿透
+	function tqtd2(){
+		var openPageId = pageId + "-03";
+		openMainTabPage(openPageId, "详情", "tqtd/reportManageDetailChuantou.html?pageId="+openPageId+"&reportId="+reportId+"&chuantouType=TQTD03", '', pageId, null);
+	}
+	// 2个月停电1次及以上台区且昨日停电穿透
+	function tqtd3(){
+		var openPageId = pageId + "-04";
+		openMainTabPage(openPageId, "详情", "tqtd/reportManageDetailChuantou.html?pageId="+openPageId+"&reportId="+reportId+"&chuantouType=TQTD04", '', pageId, null);
+	}
+	function tqtd4(){
+		var openPageId = pageId + "-05";
+		openMainTabPage(openPageId, "详情", "tqtd/reportManageDetailChuantou.html?pageId="+openPageId+"&reportId="+reportId+"&chuantouType=TQTD05", '', pageId, null);
+	}
+	
+	function downLoadFujian() {
+		var data = {reportId : reportId};
+		exportExcel("../../TQTDReportAction/reportInfFujian",data);
+	}
+	
+	
+	/**
+	 * 报表变动公共方法
+	 * @param t
+	 * @param typeId
+	 * @param rowIndex
+	 * @param colIndex
+	 * @returns
+	 */
+	function reportChange(t, typeId, rowIndex, colIndex) {
+		if (typeId == "TQTDRB") {
+			tableCountTQTDRB(t, typeId, rowIndex, colIndex);
+		} else if (typeId == "TQTDZB") {
+			tableCountTQTDZB(t, typeId, rowIndex, colIndex);
+		}
+	}
+
+	/**
+	 * 台区停电日报表编辑
+	 * @param t
+	 * @param typeId
+	 * @param rowIndex
+	 * @param colIndex
+	 */
+	function tableCountTQTDRB(t, typeId, rowIndex, colIndex) {
+		var tableDom = $(t).parent().parent();
+		var trsDom = $(tableDom).find("tr");
+		// 台区数量行
+		var editNumTds = $($(trsDom)[1]).find("td");
+		// 停电次数行
+		var editCountTds = $($(trsDom)[2]).find("td");
+		// 停电率数行
+		var editlvTds = $($(trsDom)[4]).find("td");
+		// 停电三次以上
+		var sanciTds = $($(trsDom)[5]).find("td");
+		
+		if ((rowIndex == 1 || rowIndex == 2 ||  rowIndex == 4) && (colIndex != 0 && colIndex != 9)) {
+			// 修改台区数量
+			if (rowIndex == 1) {
+				var editNum = $(t).html().replace("<br>", "");
+				// 对应停电次数
+				var editCount = $(editCountTds[colIndex]).html().replace("<br>", "");
+				// 对应停电率
+				$(editlvTds[colIndex]).html(accMul(accDivFun(editCount, editNum, 4), 100, 2) + "%");
+				// 台区总数
+				var totalNum = "0";
+				for (var i = 1; i < (editNumTds.length - 1); i ++) {
+					totalNum = accAdd($(editNumTds[i]).html(), totalNum);
+				}
+				$(editNumTds[editNumTds.length - 1]).html(totalNum);
+				// 停电总次数
+				var totalCount = $(editCountTds[editCountTds.length - 1]).html().replace("<br>", "");
+				$(editlvTds[editlvTds.length - 1]).html(accMul(accDivFun(totalCount, totalNum, 4), 100, 2) + "%");
+			// 修改台区停电次数
+			} else if (rowIndex == 2) {
+				var editCount = $(t).html().replace("<br>", "");
+				// 对应台区数量
+				var editNum = $(editNumTds[colIndex]).html().replace("<br>", "");
+				// 对应停电率
+				$(editlvTds[colIndex]).html(accMul(accDivFun(editCount, editNum, 4), 100, 2) + "%");
+				// 台区总数
+				var totalNum = $(editNumTds[editNumTds.length - 1]).html().replace("<br>", "");
+				// 停电总次数
+				var totalCount = "0";
+				for (var i = 1; i < (editCountTds.length - 1); i ++) {
+					totalCount = accAdd($(editCountTds[i]).html().replace("<br>", ""), totalCount);
+				}
+				$(editCountTds[editCountTds.length-1]).html(totalCount);
+				$(editlvTds[editlvTds.length - 1]).html(accMul(accDivFun(totalCount, totalNum, 4), 100, 2) + "%");
+			} else if (rowIndex == 4) {
+				var sanciCount = "0";
+				for (var i = 1; i < (sanciTds.length - 1); i ++) {
+					sanciCount = accAdd($(sanciTds[i]).html().replace("<br>", ""), sanciCount);
+				}
+				$(sanciTds[sanciTds.length - 1]).html(sanciCount);
+			}
+		}
+	}
+	/**
+	 * 台区停电周报表编辑
+	 * @param t
+	 * @param typeId
+	 * @param rowIndex
+	 * @param colIndex
+	 */
+	function tableCountTQTDZB(t, typeId, rowIndex, colIndex) {
+		if (rowIndex == 0) {
+			return;
+		}
+		var tableDom = $(t).parent().parent();
+		var trsDom = $(tableDom).find("tr");
+
+		// 管理台区总数 、1个月内累计停电台次 、上月累计停电台次、去年同期累计停电台次 合计为相加值
+		if (colIndex == 1 || colIndex == 2 || colIndex == 3 || colIndex == 5) {
+			// 不是表头也不是合计,需要重新计算合计数
+			if (rowIndex != 0 && rowIndex != (trsDom.length - 1)) {
+				var heji = "0";
+				for (var i = 1; i < (trsDom.length - 1); i ++) {
+					var tdsDom = $(trsDom[i]).find("td");
+					var val = $(tdsDom[colIndex]).html();
+					heji = accAdd(heji, val, 2);
+				}
+				$($(trsDom[trsDom.length - 1]).find("td")[colIndex]).html(heji);
+			}
+			// 管理台区总数 、1个月内累计停电台次  改变会改变频次
+			if (colIndex == 1 || colIndex == 2) {
+				// 本身频次改变
+// 				var zongtaishu = $($(trsDom[rowIndex]).find("td")[1]).html();
+// 				var tingdiantaici = $($(trsDom[rowIndex]).find("td")[2]).html();
+// 				var pinci = accDivFun(tingdiantaici, zongtaishu, 2);
+// 				$($(trsDom[rowIndex]).find("td")[5]).html(pinci);
+				// 合计频次改变
+// 				var zongtaishu = $($(trsDom[trsDom.length - 1]).find("td")[1]).html();
+// 				var tingdiantaici = $($(trsDom[trsDom.length - 1]).find("td")[2]).html();
+// 				var pinci = accDivFun(tingdiantaici, zongtaishu, 2);
+// 				$($(trsDom[trsDom.length - 1]).find("td")[5]).html(pinci);
+			}
+		} 
+	}
+	
+	// 保存
+	function save() {
+		var excelList = getTableToArray("tableId");
+		$("#reportDiv").find("p").removeAttr("contenteditable");
+		var descStr = $("#reportDiv").html();
+		
+		var reportData = {};
+		if (!isEmpty(excelList)) {
+			reportData.excelList = excelList;
+		}
+		reportData.descStr = descStr;
 		$.request({
-			action : 'ReportManageAction/reportInfDetail',
+			action : 'ReportManageAction/reportInfUpdate',
 			data : {
-				reportId : reportId
+				reportId : reportId,
+				excelList : JSON.stringify(reportData),
+				reportName : $("#reportTitle").html()
 			},
 			success : function(data) {
-				var reportDataJsonStr = data.data.data;
-				var excelList = eval('(' + reportDataJsonStr + ')');
-				reportTable(excelList, typeId, true);
+				$.SuccAlert("保存成功!");
 			},
 			error : function(data2) {
 				$.ErrorAlert(data2.MINErrorMessage);
 			}
 	  	});
-	// word
-	} else {
-		
 	}
-
-	function saveReport() {
-		// excel
-		if ("00" == type) {
-			var excelList = getTableToArray("reportTable");
-			$.request({
-				action : 'ReportManageAction/reportInfUpdate',
-				data : {
-					reportId : reportId,
-					excelList : JSON.stringify(excelList),
-					reportName : $("#reportTitle").html()
-				},
-				success : function(data) {
-					$.SuccAlert("保存成功!");
-					setTimeout(function(){
-						deleteTabPageParent(pageId); 
-					}, 1500)
-				},
-				error : function(data2) {
-					$.ErrorAlert(data2.MINErrorMessage);
-				}
-		  	});
+	function goBack() {
+		deleteTabPageParent(pageId); 
+	}
+	
+	function getTableToArray(tableId) {
+		var excelList = new Array();
+		var tableDom = $("#" + tableId);
+		var trsDom = $(tableDom).find("tr");
+		for (var i = 0; i < trsDom.length; i ++) {
+			var excelChildList = new Array();
+			var tdsDom = $(trsDom[i]).find("td");
+			for (var j = 0; j < tdsDom.length; j ++) {
+				excelChildList.push($(tdsDom[j]).html());
+			}
+			excelList.push(excelChildList);
 		}
+		return excelList;
 	}
     </script>
 </body>