|
@@ -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>
|