reportProduceTqtd.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>导入</title>
  6. <script src="../../js/min-loader-next.js"></script>
  7. <script src="../../js/report.js"></script>
  8. <link rel="stylesheet" href="../../plugins/layui/lay/modules/steps/style.css"></link>
  9. <style>
  10. .layui-input {
  11. width : 200px;
  12. }
  13. .layui-upload-drag .layui-icon {
  14. font-size: 18px;
  15. color: #fff;
  16. }
  17. .layui-btn-sm {
  18. height: 22px;
  19. line-height: 22px;
  20. padding: 0 10px;
  21. font-size: 12px;
  22. }
  23. </style>
  24. </head>
  25. <body class="content">
  26. <div id="step_demo" class="step-body" style = "margin-top : 20px; margin-left: 10%;">
  27. <div class="step-header" style="width:80%;overflow: hidden;">
  28. <ul>
  29. <li>
  30. <span class="step-name">选择报告/报表</span>
  31. </li>
  32. <li>
  33. <span class="step-name">选择文件</span>
  34. </li>
  35. <li>
  36. <span class="step-name">数据预览</span>
  37. </li>
  38. <li>
  39. <span class="step-name">生成报告/报表</span>
  40. </li>
  41. </ul>
  42. </div>
  43. </div>
  44. <div class="order-body" style = "width: 80%; margin-left : 10%;height : 450px" name = "step">
  45. <form class="layui-form" style = "text-align : center;">
  46. <div class="order-select" id="content" style = "background: #FFFFFF;border-radius: 8px;padding: 16px 1.4rem;">
  47. <div class="layui-inline" style="margin-top: 150px;">
  48. <label class="f12-gray4">请选择文件类型:</label>
  49. <div id = "reportTypeDiv" class="layui-inline">
  50. </div>
  51. </div>
  52. <div style="margin-top : 200px;">
  53. <button type="button" class="layui-btn" style = "width : 214px" onclick = "goStep(2)">下一步</button>
  54. </div>
  55. </div>
  56. </form>
  57. </div>
  58. <div name = "step" style = "width: 80%; margin-left : 10%;height : 300px; display : none; text-align : center;">
  59. <div style = "width: 80%; margin-left : 0px; height : 200px" class = "layui-upload-drag" >
  60. <input type="text" style = "display : inline-block" class="layui-input" id="dayRange" placeholder="请选择报表日期">
  61. <input type="text" style = "display : inline-block" class="layui-input" id="dateRange" placeholder="请选择报表日期范围">
  62. <input type="text" style = "display : inline-block" class="layui-input" id="timeRange" placeholder="请选择报表时间段">
  63. <p name = "TQTDRB" style = "display : none;"><a id = "monthNum" style = "font-size: 18px; color: red;" onclick = "changeHtml(this)">2</a>个月内停电<a id = "countNum" style = "font-size: 18px; color: red;" onclick = "changeHtml(this)">3</a>次以上的台区数量</p>
  64. </div>
  65. <div style="margin-top : 50px;">
  66. <button type="button" class="layui-btn" style = "width : 214px" onclick = "tableYulan()">下一步</button>
  67. </div>
  68. </div>
  69. <div name = "step" style = "width: auto; height : 300px; display : none; text-align : center;">
  70. <div style = "width: auto; margin-left : 0px;" class = "layui-upload-drag" >
  71. <p id = "fileName" contenteditable="true">国网泰安供电公司2020年8月份配网运行分析月报</p>
  72. <table id = "reportTable" class="layui-table" style = "display : none">
  73. </table>
  74. <p id = "gongjubiao">报表关联的工具表为《<a id = "utilName" onclick = "goUtilDetail(this)">2020年6月底低电压月报工具表</a>》 关联的报表算法为《<a id = "algorithmName" onclick = "goAlgorithmDetail(this)">国网泰安供电公司2020年8月份配网运行分析月报</a>》 的算法</p>
  75. <div id = "reportDiv" style = "display : none;text-align : left;"></div>
  76. </div>
  77. <div style="margin-top : 50px;">
  78. <button type="button" class="layui-btn" style = "width : 214px" onclick = "goStep(4)">下一步</button>
  79. </div>
  80. </div>
  81. <div name = "step" style = "width: 80%; margin-left : 10%;height : 300px; display : none; text-align : center; margin-top : 50px;">
  82. <i class="layui-icon layui-icon-ok-circle" style="font-size: 100px; color: #009688;"></i>
  83. <p style = "font-weight: 700;font-size: 25px;">报表生成成功!</p>
  84. <p style = " color: #b2bbc2;">可在数据仓库-报表管理进行查看</p>
  85. <div style="margin-top : 100px;">
  86. <button type="button" class="layui-btn" style = "width : 214px" onclick = "finish()">完成</button>
  87. </div>
  88. </div>
  89. <script>
  90. var pageId = getQueryString("pageId");
  91. var timeType = getQueryString("timeType");// 00日报01周报02月报
  92. var reportType = getQueryString("reportType");// 00日报01周报02月报
  93. // 日报
  94. if (timeType == '00') {
  95. $("#dayRange").show();
  96. $("#dateRange").hide();
  97. // 周报和月报
  98. } else {
  99. $("#dayRange").hide();
  100. $("#dateRange").show();
  101. }
  102. var $step;
  103. layui.config({
  104. base: '../../plugins/layui/lay/modules/steps/'
  105. }).use(['steps','jquery'],function(){
  106. var $ = layui.$;
  107. $step = $("#step_demo").step();
  108. })
  109. layui.use('laydate', function(){
  110. var laydate = layui.laydate;
  111. // 报告日报日期选择
  112. laydate.render({
  113. elem : '#dayRange'
  114. ,format : 'yyyyMMdd'
  115. ,done: function(value, date, endDate){
  116. console.log(value); //得到日期生成的值,如:2017-08-18
  117. var fileName = $("#fileName").html();
  118. if (fileName.indexOf("-") != -1) {
  119. $("#fileName").html(fileName.split("-")[0]+value);
  120. } else {
  121. $("#fileName").html(fileName+"-" + value);
  122. }
  123. }
  124. });
  125. // 报告日期范围选择
  126. laydate.render({
  127. elem : '#dateRange'
  128. ,format : 'yyyyMMdd'
  129. ,range : true
  130. ,done: function(value, date, endDate){
  131. console.log(value); //得到日期生成的值,如:2017-08-18
  132. var fileName = $("#fileName").html();
  133. if (fileName.indexOf("-") != -1) {
  134. $("#fileName").html(fileName.split("-")[0]+value);
  135. } else {
  136. $("#fileName").html(fileName+"-" + value);
  137. }
  138. }
  139. });
  140. //时间范围
  141. laydate.render({
  142. elem : '#timeRange'
  143. ,type : 'time'
  144. ,format : 'HHmmss'
  145. ,value : '000000 - 235959'
  146. ,range : true
  147. });
  148. });
  149. // 范围类型
  150. layui.use('form', function(){
  151. var form = layui.form;
  152. $.request({
  153. action : 'BranchReportTypeAction/branchReportTypeQuery',
  154. data : {
  155. reportType : reportType
  156. },
  157. success : function(data) {
  158. var html = '<select id = "reportType" lay-filter="reportTypeFilter"><option value = "">请选择</option>';
  159. var fileTypeList = data.data;
  160. for (var i = 0; i < fileTypeList.length; i ++) {
  161. var fileTypeInf = fileTypeList[i];
  162. html += '<option value = "' + fileTypeInf.id + '_' + fileTypeInf.type + '_' + fileTypeInf.timeType + '">' + fileTypeInf.name + '</option>';
  163. }
  164. html += '</select>';
  165. $("#reportTypeDiv").html(html);
  166. form.render();
  167. },
  168. error : function(data2) {
  169. $.ErrorAlert(data2.MINErrorMessage);
  170. }
  171. });
  172. form.on('select(reportTypeFilter)', function(data){
  173. var value = data.value;
  174. if (!isEmpty(value)) {
  175. var reportTypeId = value.split("_")[0];
  176. $("#fileName").html(data.elem.selectedOptions[0].text);
  177. if (!isEmpty(reportTypeId)) {
  178. $.request({
  179. action : 'BranchReportTypeAction/fileTypeOfReportType',
  180. data : {
  181. reportTypeId : reportTypeId
  182. },
  183. success : function(data) {
  184. fileType = data.data;
  185. setTempVal("fileType", fileType);
  186. var utilDataInf = data.utilDataInf;
  187. if (!isEmpty(utilDataInf)) {
  188. $("#utilName").html(utilDataInf.fileName);
  189. $("#utilName").attr("fileName", utilDataInf.fileName);
  190. setTempVal("utilExcelDataDetail", utilDataInf.excelData);
  191. var algorithmInf = data.algorithmInf;
  192. if (!isEmpty(algorithmInf)) {
  193. $("#algorithmName").html(utilDataInf.fileName+"算法");
  194. $("#algorithmName").attr("reportTypeId", reportTypeId);
  195. }
  196. }
  197. },
  198. error : function(data2) {
  199. $.ErrorAlert(data2.MINErrorMessage);
  200. }
  201. });
  202. }
  203. }
  204. });
  205. })
  206. function goStep (step) {
  207. var reportInf = $("#reportTypeDiv").find("select option:selected").val();
  208. var dayRange = $("#dayRange").val();
  209. var dateRange = $("#dateRange").val();
  210. var timeRange = $("#timeRange").val();
  211. if (step == 2) {
  212. if (isEmpty(reportInf)) {
  213. $.ErrorAlert("请选择上传文件类型!");
  214. return;
  215. }
  216. var reportType = reportInf.split("_")[0];
  217. // 台区停电日报
  218. if ("TQTDRB" == reportType) {
  219. $("body").find("[name='TQTDRB']").show();
  220. }
  221. }
  222. if (step == 4) {
  223. var fileName = $("#fileName").html();
  224. var range = null;
  225. if (timeType == '00') {
  226. range = dayRange + "-" + dayRange;
  227. } else {
  228. range = dateRange;
  229. }
  230. var monthNum = $("#monthNum").html();
  231. var countNum = $("#countNum").html();
  232. $.request({
  233. action : 'ReportManageAction/fileInfReportSubmit',
  234. data : {
  235. reportData : JSON.stringify(resJsonStr),
  236. reportInf : reportInf,
  237. fileName : fileName,
  238. range : range,
  239. timeRange : timeRange,
  240. monthNum : monthNum,
  241. countNum : countNum
  242. },
  243. success : function(data) {
  244. if (data.code == 0) {
  245. $step.goStep(step);
  246. var stepDiv = $("div[name = 'step']");
  247. for (var i = 0; i < stepDiv.length; i ++) {
  248. if (step == (i + 1)) {
  249. $(stepDiv[i]).show();
  250. } else {
  251. $(stepDiv[i]).hide();
  252. }
  253. }
  254. } else {
  255. $.ErrorAlert(res.MINErrorMessage);
  256. }
  257. },
  258. error : function(data2) {
  259. $.ErrorAlert(data2.MINErrorMessage);
  260. }
  261. });
  262. return;
  263. }
  264. $step.goStep(step);
  265. var stepDiv = $("div[name = 'step']");
  266. for (var i = 0; i < stepDiv.length; i ++) {
  267. if (step == (i + 1)) {
  268. $(stepDiv[i]).show();
  269. } else {
  270. $(stepDiv[i]).hide();
  271. }
  272. }
  273. }
  274. function finish() {
  275. deleteTabPageParent(pageId);
  276. }
  277. // 查看工具表详情
  278. function goUtilDetail(t) {
  279. var fileName = $(t).attr("fileName");
  280. var openPageId = pageId + "-01";
  281. openMainTabPage(openPageId, "详情查看", "reprotManage/utilExcelDetail.html?pageId="+openPageId+"&fileName="+chineseUrlEncode(fileName), '', pageId, null);
  282. }
  283. // 查看算法详情
  284. function goAlgorithmDetail(t) {
  285. var reportTypeId = $(t).attr("reportTypeId");
  286. var openPageId = pageId + "-02";
  287. openMainTabPage(openPageId, "详情查看", "reprotManage/reportAlgorithm.html?pageId="+openPageId+"&reportTypeId="+reportTypeId, '', pageId, null);
  288. }
  289. // 报表返回数据
  290. var resJsonStr = null;
  291. // 预览
  292. function tableYulan() {
  293. var reportInf = $("#reportTypeDiv").find("select option:selected").val();
  294. var dayRange = $("#dayRange").val();
  295. var dateRange = $("#dateRange").val();
  296. var timeRange = $("#timeRange").val();
  297. // 日报
  298. if (timeType == '00') {
  299. if (isEmpty(dayRange)) {
  300. $.ErrorAlert("请选择报表日期!");
  301. return;
  302. }
  303. } else {
  304. if (isEmpty(dateRange)) {
  305. $.ErrorAlert("请选择报表日期范围!");
  306. return;
  307. }
  308. }
  309. // 日报
  310. var range = null;
  311. if (timeType == '00') {
  312. range = dayRange + "-" + dayRange;
  313. } else {
  314. range = dateRange;
  315. }
  316. var monthNum = $("#monthNum").html();
  317. var countNum = $("#countNum").html();
  318. // 查询符合条件的明细数据,生成预览数据
  319. $.request({
  320. action : 'ReportManageAction/reportNeedDataDetail',
  321. data : {
  322. range : range,
  323. timeRange : timeRange,
  324. reportInf : reportInf,
  325. monthNum : monthNum,
  326. countNum : countNum
  327. },
  328. success : function(data) {
  329. if (data.code == 0) {
  330. // 日报
  331. if (timeType == '00') {
  332. resJsonStr = data.data.resList;
  333. $("#reportDiv").hide();
  334. $("#reportTable").show();
  335. $("#gongjubiao").show();
  336. initExcelData(resJsonStr, "reportTable", false);
  337. goStep(3);
  338. // 月报 或 周报
  339. } else if (timeType == '02' || timeType == '01') {
  340. $("#reportTable").hide();
  341. $("#gongjubiao").hide();
  342. $("#reportDiv").show();
  343. resJsonStr = data.data;
  344. var dataMap = data.data.dataMap;
  345. var descStr = data.data.descStr;
  346. console.log(dataMap);
  347. console.log(descStr);
  348. for(var key in dataMap){
  349. var replaceStr = "${" + key + "}";
  350. if (key == "totalCountTwice") {
  351. descStr = descStr.replace(/\${totalCountTwice}/g, dataMap[key]);
  352. } else {
  353. descStr = descStr.replace(replaceStr, dataMap[key]);
  354. }
  355. }
  356. $("#reportDiv").html(descStr);
  357. var tableHtml = '<table class="layui-table">';
  358. // 周报
  359. if (timeType == '01') {
  360. var excelList = data.data.excelList;
  361. for (var i = 0; i < excelList.length; i ++) {
  362. tableHtml += '<tr>';
  363. var childList = excelList[i];
  364. for (var j = 0; j < childList.length; j ++) {
  365. tableHtml += '<td>' + childList[j] + '</td>';
  366. }
  367. tableHtml += '</tr>';
  368. }
  369. }
  370. tableHtml += '</table>';
  371. $("#reportDiv").append(tableHtml);
  372. goStep(3);
  373. }
  374. } else {
  375. $.ErrorAlert(res.MINErrorMessage);
  376. }
  377. },
  378. error : function(data2) {
  379. $.ErrorAlert(data2.MINErrorMessage);
  380. }
  381. });
  382. }
  383. function changeHtml(t) {
  384. var initValue = $(t).html();
  385. layer.prompt({
  386. formType: 2,
  387. value: initValue,
  388. title: '请输入',
  389. area: ['200px', '33px'] //自定义文本域宽高
  390. },
  391. function(value, index, elem){
  392. $(t).html(value);
  393. layer.close(index);
  394. }
  395. );
  396. }
  397. </script>
  398. </body>
  399. </html>