GoldenDayMonthReportShow.js 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  1. StartTime = "";
  2. EndTime = "";
  3. ReportType = "";
  4. var isExporting = false;
  5. var exportTaskList = new Array();
  6. var batchExportTimer;
  7. function CreateDayMonthReportShow(x, y, width, height, pageHeight, jsonFileNameData, jsonFileNameFunc,
  8. ReportFileName, dayMonth, paneStyle)
  9. {
  10. var toolBarHeight = 66 * ratio.ratioY;
  11. var toolBar2Height = 12 * ratio.ratioY;
  12. var buttonLabelFont = 18*ratio.ratioY+'px "苹方 粗体"';
  13. var timeLabelFont = 18 * ratio.ratioY +'px "苹方 粗体"';//时间选择
  14. var timeTextLabelFont = 18 * ratio.ratioY +'px "苹方 粗体"';//开始时间,结束时间
  15. var listViewLabelFont = 18 * ratio.ratioY + 'px "苹方 粗体"';
  16. var transparentColor = 'rgba(0,0,0,0)';
  17. var toolBarBackColor = transparentColor;//"00000000";//"#0005194B";
  18. var range = width - 100 * ratio.ratioX;//底部 两个按钮的间矩
  19. var openStartTime = new Date();
  20. var borderPaneRealNode = new ht.HtmlNode();
  21. ReportType = dayMonth;
  22. //布局控件
  23. borderPaneDayReport = new ht.widget.BorderPane();
  24. var innerPane = new ht.widget.BorderPane();
  25. //开始补帛
  26. var startReculate=false;
  27. var listViewWidth = 140 * ratio.ratioX;
  28. var listViewHeight = 44 * ratio.ratioY;
  29. ReportFileName1 = ReportFileName;
  30. //表格控件
  31. var ReportDiv = document.createElement("div");
  32. //ReportDiv.style.backgroundColor=paneStyle.paneBackColor;
  33. var ReportDivChild = document.createElement("div");
  34. //ReportDivChild.style.backgroundColor=paneStyle.paneBackColor;
  35. ReportDiv.appendChild(ReportDivChild);
  36. ReportDivChild.className = "sample-turtorial";
  37. var reportWidth = width - listViewWidth;
  38. var reportHeight = (height) - toolBarHeight - toolBar2Height + 1;
  39. ReportDivChild.style = 'width:' + reportWidth + 'px; height:' + reportHeight + 'px;border: 1px solid gray;';
  40. //ReportDivChild.style = 'width:100%; height:100%;border: 1px solid gray;';
  41. ReportSpread = new GC.Spread.Sheets.Workbook(ReportDivChild,
  42. {
  43. sheetCount: 1
  44. });
  45. ReportDivChild.style.border = "1px solid " + toolBarBackColor;
  46. ChangeScrollBarStyle();
  47. //页面缩放报表要自适应
  48. var resizeTimer = 0;
  49. //window.onresize = function () {
  50. $(window).on('resizeOver', function (e) {
  51. clearTimeout(resizeTimer);
  52. resizeTimer = setTimeout(function () {
  53. console.log(ReportDiv.style.height);
  54. ReportDivChild.style.height = ReportDiv.style.height;
  55. ReportSpread.refresh();
  56. ChangeScrollBarStyle();
  57. range = toolbar2.getWidth()-300;
  58. var botRange=toolbar2.getItemById("botRange");
  59. if (botRange)
  60. botRange.textField.width=range;
  61. }, 500);
  62. });
  63. //表格加入布局
  64. //borderPaneDayReport.setRightView(ReportDiv,width-180);
  65. borderPaneDayReport.setCenterView(ReportDiv);
  66. var NodeStartTimeDiv = document.createElement("input");
  67. NodeStartTimeDiv.style.color = '#DADBAC';// paneStyle.DialogTitleFontColor;
  68. NodeStartTimeDiv.style.font=timeLabelFont;
  69. NodeStartTimeDiv.style.backgroundColor =transparentColor;
  70. NodeStartTimeDiv.className="back-size100";
  71. NodeStartTimeDiv.style.width = 163*ratio.ratioX+'px';
  72. NodeStartTimeDiv.style.height = 36*ratio.ratioY+'px';
  73. NodeStartTimeDiv.style.border='none';
  74. document.body.appendChild(NodeStartTimeDiv);
  75. NodeStartTimeDiv.style.background = "url(" + PAGEROOTDIR +"/script/image/date.png)";
  76. NodeStartTimeDiv.style.padding =8* ratio.ratioY+'px '+15* ratio.ratioX+'px';
  77. var NodeEndTimeDiv = document.createElement("input");
  78. NodeEndTimeDiv.style.color = '#DADBAC';
  79. NodeEndTimeDiv.style.backgroundColor = toolBarBackColor;// paneStyle.paneBackColor;
  80. NodeEndTimeDiv.style.font=timeLabelFont;
  81. NodeEndTimeDiv.className = "back-size100";
  82. NodeEndTimeDiv.style.width = 164*ratio.ratioX+'px';
  83. NodeEndTimeDiv.style.height = 36*ratio.ratioY+'px';
  84. NodeEndTimeDiv.style.border='none';
  85. NodeEndTimeDiv.style.background = "url(" + PAGEROOTDIR +"/script/image/date.png)";
  86. NodeEndTimeDiv.style.padding = 8 * ratio.ratioY + 'px ' + 15 * ratio.ratioX + 'px';
  87. document.body.appendChild(NodeEndTimeDiv);
  88. //时间选择控件 初始化时间
  89. if (ReportType == "DayReport") {
  90. var tempDate = new Date();
  91. //昨天
  92. tempDate.setDate(tempDate.getDate() - 1);
  93. tempDate.setHours(0);
  94. tempDate.setMinutes(0);
  95. tempDate.setSeconds(0);
  96. StartTime = tempDate.toDateString() + " " + tempDate.toTimeString(); //初始化起始时间
  97. //30天前
  98. tempDate = new Date();
  99. tempDate.setDate(tempDate.getDate() - 30);
  100. tempDate.setHours(0);
  101. tempDate.setMinutes(0);
  102. tempDate.setSeconds(0);
  103. SetTimeSelectDivValue(NodeStartTimeDiv, tempDate, 'date');
  104. //今天0点
  105. tempDate = new Date();
  106. tempDate.setHours(0);
  107. tempDate.setMinutes(0);
  108. tempDate.setSeconds(0);
  109. SetTimeSelectDivValue(NodeEndTimeDiv, tempDate, 'date');
  110. EndTime = tempDate.toDateString() + " " + tempDate.toTimeString();
  111. }
  112. else if (ReportType == "MonthReport") {
  113. var tempDate = new Date();
  114. //上月一号
  115. tempDate.setMonth(tempDate.getMonth() - 1);
  116. tempDate.setDate(1);
  117. tempDate.setHours(0);
  118. tempDate.setMinutes(0);
  119. tempDate.setSeconds(0);
  120. StartTime = tempDate.toDateString() + " " + tempDate.toTimeString();
  121. //12月前一号
  122. tempDate = new Date();
  123. tempDate.setMonth(tempDate.getMonth() - 12);
  124. tempDate.setDate(1);
  125. tempDate.setHours(0);
  126. tempDate.setMinutes(0);
  127. tempDate.setSeconds(0);
  128. SetTimeSelectDivValue(NodeStartTimeDiv, tempDate, 'month');
  129. //本月一号
  130. tempDate = new Date();
  131. tempDate.setDate(1);
  132. tempDate.setHours(0);
  133. tempDate.setMinutes(0);
  134. tempDate.setSeconds(0);
  135. SetTimeSelectDivValue(NodeEndTimeDiv, tempDate, 'month');
  136. EndTime = tempDate.toDateString() + " " + tempDate.toTimeString();
  137. }
  138. else //自定义报表
  139. {
  140. var tempDate = new Date();
  141. //昨天
  142. tempDate.setDate(tempDate.getDate() - 1);
  143. tempDate.setHours(0);
  144. tempDate.setMinutes(0);
  145. tempDate.setSeconds(0);
  146. StartTime = tempDate.toDateString() + " " + tempDate.toTimeString(); //初始化起始时间
  147. //30天前
  148. tempDate = new Date();
  149. tempDate.setDate(tempDate.getDate() - 30);
  150. tempDate.setHours(0);
  151. tempDate.setMinutes(0);
  152. tempDate.setSeconds(0);
  153. SetTimeSelectDivValue(NodeStartTimeDiv, tempDate, 'date');
  154. //今天0点
  155. tempDate = new Date();
  156. tempDate.setHours(0);
  157. tempDate.setMinutes(0);
  158. tempDate.setSeconds(0);
  159. SetTimeSelectDivValue(NodeEndTimeDiv, tempDate, 'date');
  160. EndTime = tempDate.toDateString() + " " + tempDate.toTimeString();
  161. }
  162. var beforeImportTime = new Date();
  163. console.log("before import use time:" + (beforeImportTime - openStartTime));
  164. //初始化报表
  165. if (ReportType != "OwnerReport") {
  166. //网格线不显示, 此项耗时约50ms
  167. importJSON(ReportSpread, jsonFileNameData);
  168. var activeSheet = ReportSpread.getActiveSheet();
  169. FreshReport(ReportSpread, "", paneStyle.ExportWhiteBackBlackFont, jsonFileNameFunc);
  170. //延迟执行,否则影响速度
  171. setTimeout(function () {
  172. ReportSpread.suspendPaint();
  173. var rowNum = activeSheet.getRowCount();
  174. var colNum = activeSheet.getColumnCount();
  175. ReportSpread.options.backColor = paneStyle.paneBackColor;
  176. ReportSpread.options.grayAreaBackColor=paneStyle.paneBackColor;
  177. activeSheet.options.gridline = { color: "#FF2235", showVerticalGridline: false, showHorizontalGridline: false };
  178. for(var i=0;i<rowNum;i++)
  179. {
  180. for(var k=0;k<colNum;k++)
  181. {
  182. var cell = activeSheet.getCell(i, k, GC.Spread.Sheets.SheetArea.viewport);
  183. var color= cell.backColor();
  184. if(!color)
  185. {
  186. cell.backColor(paneStyle.paneBackColor);
  187. }
  188. else
  189. {
  190. if (paneStyle.paneBackColorOpacity)
  191. color += paneStyle.paneBackColorOpacity;
  192. cell.backColor(color);
  193. }
  194. }
  195. }
  196. ReportSpread.resumePaint();
  197. ChangeScrollBarStyle();
  198. }, 50);
  199. var importDoneTime = new Date();
  200. console.log("done import use time:" + (importDoneTime - openStartTime));
  201. }
  202. else {
  203. resetSpread(ReportSpread);
  204. ReportSpread.options.backColor = paneStyle.paneBackColor;
  205. ReportSpread.options.grayAreaBackColor = paneStyle.paneBackColor;
  206. ReportSpread.getActiveSheet().options.selectionBorderColor = 'gray';
  207. }
  208. //顶部工具栏
  209. toolbar = new ht.widget.Toolbar();
  210. borderPaneDayReport.setTopView(toolbar);
  211. toolbar.setHeight(toolBarHeight);
  212. $(toolbar.getView()).css({
  213. borderBottom:"10px solid rgba(0,0,0,0)"
  214. })
  215. //底部工具栏
  216. toolbar2 = new ht.widget.Toolbar();
  217. borderPaneDayReport.setBottomView(toolbar2);
  218. toolbar2.setHeight(toolBar2Height);
  219. //按钮
  220. //报表查看 此按钮已隐藏
  221. lookButton1 = new ht.widget.Button();
  222. lookButton1.setWidth(40);
  223. lookButton1.setHeight(29);
  224. lookButton1.setLabel("查看");
  225. lookButton1.setDisabled();
  226. lookButton1.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  227. lookButton1.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  228. lookButton1.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnBackColor);
  229. //报表直接导出 此按钮已隐藏
  230. downloadButton1 = new ht.widget.Button();
  231. downloadButton1.setWidth(40);
  232. downloadButton1.setHeight(29);
  233. downloadButton1.setLabel("导出");
  234. downloadButton1.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  235. downloadButton1.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  236. downloadButton1.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnBackColor);
  237. //报表查询 通过时间段筛选时间列表
  238. lookButton2 = new ht.widget.Button();
  239. lookButton2.setWidth(70 * ratio.ratioX);
  240. lookButton2.setHeight(29 *ratio.ratioY);
  241. lookButton2.setLabel("查询");
  242. lookButton2.setLabelFont(buttonLabelFont);
  243. lookButton2.setSelectBackground(transparentColor);
  244. lookButton2.setBorderColor(transparentColor);
  245. lookButton2.setBackground(transparentColor);
  246. // lookButton2.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  247. //lookButton2.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  248. lookButton2.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
  249. SetButtonStyle(lookButton2,"f2button","#333");
  250. $btnView = $(lookButton2.getView());
  251. $btnView.css("background-size", "70px 29px");
  252. lookButton2.onClicked = function (e)
  253. {
  254. StartTime = NodeStartTimeDiv.value + " 0:0:0"
  255. EndTime = NodeEndTimeDiv.value + " 0:0:0";
  256. if (!GD.testSearchTime(StartTime, EndTime)) {
  257. return ;
  258. }
  259. if (ReportType != "OwnerReport") //非自定义报表
  260. {
  261. listView.dm().clear();
  262. dayStrList.forEach(function (val, index, arr) {
  263. var tempEndTime1 = new Date(Date.parse(val.Name + " 0:0:0"));
  264. tempEndTime1.setMilliseconds(0);
  265. var tempStartTime = new Date(Date.parse(StartTime));
  266. tempStartTime.setMilliseconds(0);
  267. var tempEndTime = new Date(Date.parse(EndTime));
  268. tempEndTime.setMilliseconds(0);
  269. if (tempEndTime1 >= tempStartTime && tempEndTime1 <= tempEndTime)
  270. AddListViewElem(listView, val);
  271. });
  272. listView.setSortFunc(sortFunc);
  273. }
  274. else //自定义报表
  275. {
  276. FreshReport(ReportSpread, "", false);
  277. }
  278. }
  279. lookButton2.drawBackground= function (A, Y, g, xx, U, X)
  280. {
  281. X && (A.fillStyle = X);
  282. A.beginPath();
  283. A.fillStyle = 'red';
  284. A.rect(Y, g, x, U);
  285. A.fill();
  286. }
  287. //报表导出
  288. downloadButton2 = new ht.widget.Button();
  289. downloadButton2.setWidth(70 * ratio.ratioX);
  290. downloadButton2.setHeight(29 * ratio.ratioY);
  291. downloadButton2.setLabel("导出");
  292. downloadButton2.setLabelFont(buttonLabelFont);
  293. //downloadButton2.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  294. //downloadButton2.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  295. downloadButton2.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
  296. downloadButton2.setSelectBackground(transparentColor);
  297. downloadButton2.setBorderColor(transparentColor);
  298. downloadButton2.setBackground(transparentColor);
  299. downloadButton2.onClicked = function (e) {
  300. if (!SelectTime)
  301. return;
  302. SpreadExport(ReportSpread, ReportFileName + "(" + SelectTime + ")", paneStyle.ExportWhiteBackBlackFont);
  303. }
  304. SetButtonStyle(downloadButton2, "f2button", "#333");
  305. $btnView = $(downloadButton2.getView());
  306. $btnView.css("background-size", "70px 29px");
  307. //数据补抽
  308. var recaluBtn = new ht.widget.Button();
  309. recaluBtn.setWidth(100 * ratio.ratioX);
  310. recaluBtn.setHeight(29 * ratio.ratioY);
  311. recaluBtn.setLabel("数据补抽");
  312. recaluBtn.setLabelFont(buttonLabelFont);
  313. recaluBtn.setBorderColor(transparentColor);
  314. recaluBtn.setBackground(transparentColor);
  315. //recaluBtn.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  316. //recaluBtn.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  317. recaluBtn.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
  318. SetButtonStyle(recaluBtn,"f4button","#333");
  319. $btnView=$(recaluBtn.getView());
  320. ;(function () {
  321. var userLevel = GD.getParams('userLevel');
  322. var dis = userLevel == 1 ? 'block' : 'none';
  323. $btnView.css('display', dis);
  324. })();
  325. $btnView.css("background-size","100px 29px");
  326. recaluBtn.onClicked = function (e)
  327. {
  328. startReculate=true;
  329. progressBtn.setWidth(60);
  330. if (ReportType == "DayReport") {
  331. StartTime = NodeStartTimeDiv.value + " 0:0:0";
  332. EndTime = NodeEndTimeDiv.value + " 0:0:0";
  333. }
  334. else if (ReportType == "MonthReport") {
  335. StartTime = NodeStartTimeDiv.value + "-1 0:0:0";
  336. EndTime = NodeEndTimeDiv.value + "-1 0:0:0";
  337. }
  338. else {
  339. StartTime = NodeStartTimeDiv.value + " 0:0:0";
  340. EndTime = NodeEndTimeDiv.value + " 0:0:0";
  341. }
  342. recaluBtn.setDisabled(true);
  343. var obj = new CommandObj();
  344. obj.method = "HisDataReGet";
  345. obj.parm1 = StartTime;
  346. obj.parm2 = EndTime;
  347. var objStr = JSON.stringify(obj);
  348. socket.send(objStr);
  349. }
  350. //进度按钮
  351. var progressBtn = new ht.widget.Button();
  352. progressBtn.setWidth(0);
  353. progressBtn.setLabel("0%");
  354. progressBtn.setLabelFont(buttonLabelFont);
  355. progressBtn.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : toolBarBackColor);
  356. progressBtn.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : toolBarBackColor);
  357. progressBtn.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
  358. //进度条
  359. ht.Default.setImage('progress', {
  360. width: 150,
  361. height: 12,
  362. comps: [
  363. // 绘制背景
  364. {
  365. type: 'rect',
  366. rect: { x: 0, y: 0, width: 115, height: 12 },
  367. background: { func: function (data) { return data.a('background'); } }
  368. },
  369. // 绘制前景
  370. {
  371. rect: { x: 0, y: 0, width: 115, height: 12 },
  372. type: function (g, rect, comp, data, view) {
  373. var width = rect.width, height = rect.height, value = data.getValue(),
  374. foreWidth = width / 100 * value;
  375. g.fillStyle = data.a('foreground');
  376. g.fillRect(0, 0, foreWidth, height);
  377. }
  378. }
  379. ]
  380. });
  381. //进度条
  382. var progressNode = new ht.widget.Slider();
  383. progressNode.setBackground(toolBarBackColor);
  384. progressNode.setMax(100);
  385. progressNode.setMin(0);
  386. progressNode.setButton("");
  387. progressNode.setThickness(16*ratio.ratioY);
  388. progressNode.setValue(0);
  389. progressNode.setWidth(200 * ratio.ratioX);
  390. progressNode.setDisabled(true);
  391. //进度条不可点击
  392. var proView = progressNode.getView();
  393. if (proView.childNodes.length >= 2) {
  394. proView.childNodes[1].style.backgroundColor = "rgba(0,0,0,0)";
  395. }
  396. //重绘进度条圆角效果
  397. progressNode.drawBackground = function (A, Y, g, xx, U, X)
  398. {
  399. if(!startReculate)
  400. return;
  401. X && (A.fillStyle = X);
  402. A.beginPath();
  403. A.fillStyle =paneStyle.paneBackColor;
  404. //A.rect(Y, g, x, U);
  405. drawRoundRect(A, Y, g, xx, U, 8 * ratio.ratioX, 8 * ratio.ratioY, "#083684",1)
  406. A.fill();
  407. }
  408. progressNode.drawLeftBackground = function (A, Y, g, xx, U, X)
  409. {
  410. X && (A.fillStyle = X);
  411. if(xx<2)//宽度小于2,不画
  412. return;
  413. A.beginPath();
  414. A.fillStyle ="#7EF9FE";// paneStyle.btnFontColor;
  415. //A.rect(Y, g, x, U);
  416. drawRoundRect(A, Y, g, xx, U, 8* ratio.ratioX, 8*ratio.ratioY, X, 1)
  417. A.fill();
  418. }
  419. //批量导出
  420. var batchExportBtn = new ht.widget.Button();
  421. batchExportBtn.setWidth(125* ratio.ratioX);
  422. batchExportBtn.setHeight(28 * ratio.ratioY);
  423. batchExportBtn.setLabel("批量导出");
  424. batchExportBtn.setLabelFont(buttonLabelFont);
  425. batchExportBtn.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  426. batchExportBtn.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  427. batchExportBtn.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
  428. batchExportBtn.setSelectBackground(transparentColor);
  429. batchExportBtn.setBorderColor(transparentColor);
  430. batchExportBtn.setBackground(transparentColor);
  431. $btnView = $(batchExportBtn.getView());
  432. $btnView.css("background-size", "100px 29px");
  433. $btnView.css("left","0px");
  434. SetButtonStyle(batchExportBtn, "xxxxxx", "#094196");
  435. batchExportBtn.onClicked = function (e) {
  436. var dataArray = listView.dm();
  437. if (!dataArray)
  438. return;
  439. if (!dataArray._datas)
  440. return;
  441. dataArray._datas.forEach(function (val, index, arr) {
  442. exportTaskList.push(val.a('Name'));
  443. });
  444. batchExportTimer = setInterval(DoExportTask, 1000);
  445. }
  446. //批量导出
  447. function DoExportTask() {
  448. if (!exportTaskList) {
  449. clearInterval(batchExportTimer);
  450. return;
  451. }
  452. if (exportTaskList.length <= 0) {
  453. clearInterval(batchExportTimer);
  454. return;
  455. }
  456. if (isExporting)
  457. return;
  458. var dateStr = exportTaskList.pop();
  459. if (ReportType == "DayReport") {
  460. var tempEndTime1 = new Date(Date.parse(dateStr + " 0:0:0"));
  461. StartTime = tempEndTime1.toDateString() + " 0:0:0";
  462. tempEndTime1.setDate(tempEndTime1.getDate() + 1);
  463. EndTime = tempEndTime1.toDateString() + " 0:0:0";
  464. }
  465. else if (ReportType == "MonthReport") {
  466. var tempEndTime1 = new Date(Date.parse(dateStr + " 0:0:0"));
  467. StartTime = tempEndTime1.toDateString() + " 0:0:0";
  468. tempEndTime1.setMonth(tempEndTime1.getMonth() + 1);
  469. tempEndTime1.setSeconds(tempEndTime1.getSeconds() - 1);
  470. EndTime = tempEndTime1.toDateString() + " 23:59:59";
  471. }
  472. isExporting = true;
  473. FreshReport(ReportSpread, ReportFileName + "(" + dateStr + ")", paneStyle.ExportWhiteBackBlackFont, jsonFileNameFunc);
  474. }
  475. // toolbar.getSelectBackground = function(item){ return '#3D97D0'; };
  476. //toolbar.getSelectBackground = function(item){ return "red"; };
  477. //设置工具栏背景色
  478. toolbar.getView().style.background = toolBarBackColor;// paneStyle.paneBackColor;
  479. toolbar2.getView().style.background = toolBarBackColor;// paneStyle.paneBackColor;
  480. toolbar.setItems([
  481. {
  482. id: 'text',
  483. label: ' ',
  484. unfocusable: true,
  485. textField: {
  486. width: 150 * ratio.ratioX,
  487. height:0,
  488. background: toolBarBackColor,
  489. color: paneStyle.paneBackColor,
  490. border: 'none',
  491. editable: false,
  492. }
  493. },
  494. {
  495. id: 'nation',
  496. unfocusable: true,
  497. textField: {
  498. text: '开始时间:',
  499. width: 90 * ratio.ratioX,
  500. background: "#00000000",
  501. color: '#A0A0A0',//paneStyle.DialogTitleFontColor,
  502. border: 'none',
  503. editable: false,
  504. font: timeTextLabelFont,
  505. }
  506. },
  507. {
  508. id: 'nation',
  509. unfocusable: true,
  510. label: ' ',
  511. element: NodeStartTimeDiv
  512. },
  513. {
  514. id: 'nation',
  515. unfocusable: true,
  516. textField: {
  517. text: '',
  518. width: 20,
  519. height: 0,
  520. background: toolBarBackColor,
  521. color: paneStyle.DialogTitleFontColor,
  522. border: 'none',
  523. editable: false
  524. }
  525. },
  526. {
  527. id: 'nation',
  528. unfocusable: true,
  529. textField: {
  530. text: '结束时间:',
  531. width: 90 * ratio.ratioX,
  532. background: "#00000000",
  533. color: '#A0A0A0',// paneStyle.DialogTitleFontColor,
  534. border: 'none',
  535. editable: false,
  536. font: timeTextLabelFont,
  537. }
  538. },
  539. {
  540. id: 'nation',
  541. unfocusable: true,
  542. label: ' ',
  543. element: NodeEndTimeDiv
  544. },
  545. {
  546. id: 'nation',
  547. unfocusable: true,
  548. textField: {
  549. text: '',
  550. width: 20,
  551. height:0,
  552. background: toolBarBackColor,
  553. color: paneStyle.DialogTitleFontColor,
  554. border: 'none',
  555. editable: false
  556. }
  557. },
  558. {
  559. label: '',
  560. unfocusable: true,
  561. element: lookButton2
  562. },
  563. {
  564. id: 'nation',
  565. unfocusable: true,
  566. textField: {
  567. text: '',
  568. width: 20,
  569. height: 0,
  570. background: toolBarBackColor,
  571. color: paneStyle.DialogTitleFontColor,
  572. border: 'none',
  573. editable: false
  574. }
  575. },
  576. {
  577. label: '',
  578. unfocusable: true,
  579. element: downloadButton2
  580. },
  581. {
  582. id: 'nation',
  583. unfocusable: true,
  584. textField: {
  585. text: '',
  586. width: 20,
  587. height:0,
  588. background: toolBarBackColor,
  589. color: paneStyle.DialogTitleFontColor,
  590. border: 'none',
  591. editable: false
  592. }
  593. },
  594. {
  595. label: '',
  596. unfocusable: true,
  597. element: recaluBtn
  598. },
  599. {
  600. label: '',
  601. unfocusable: true,
  602. element: progressNode
  603. },
  604. {
  605. label: '',
  606. unfocusable: true,
  607. element: progressBtn
  608. },
  609. ]);
  610. /*
  611. toolbar2.setItems([
  612. {
  613. id: 'botRange',
  614. label: ' ',
  615. unfocusable: true,
  616. visible: true,
  617. textField: {
  618. width: range,
  619. height:0,
  620. background: toolBarBackColor,
  621. color: paneStyle.paneBackColor,
  622. border: 'none',
  623. editable: false
  624. }
  625. },
  626. {
  627. label: '',
  628. unfocusable: true,
  629. element: downloadButton2
  630. },
  631. ]);
  632. */
  633. //建立一个websocket链接
  634. var socket = new WebSocket('ws://' + webServiceIP + ':10087/Command');
  635. // 打开Socket
  636. socket.onopen = function (event) {
  637. console.log('web socket connceted!', event);
  638. if (dayMonth == "DayReport")
  639. //请求报表生成日期列表
  640. socket.send("{\"method\":\"GetHaveSaveDayList\"}");
  641. else if (dayMonth == "MonthReport")
  642. socket.send("{\"method\":\"GetHaveSaveMonthList\"}");
  643. else if (dayMonth == "OwnerReport")
  644. socket.send("{\"method\":\"GetOwnReportXlsxList\"}");
  645. };
  646. //日期列表 日
  647. var dayStrList = new Array();
  648. var isInitListView=false;
  649. // 监听消息
  650. socket.onmessage = function (event) {
  651. console.log('Client received a message', event);
  652. var receiveObj = JSON.parse(event.data);
  653. var tempStartTime = new Date(Date.parse(NodeStartTimeDiv.value + " 0:0:0"));
  654. tempStartTime.setMilliseconds(0);
  655. var tempEndTime = new Date(Date.parse(NodeEndTimeDiv.value + " 0:0:0"));
  656. tempEndTime.setMilliseconds(0);
  657. if (receiveObj.method == "GetHaveSaveDayList") //获得日报表列表
  658. {
  659. if (ReportType != "DayReport")
  660. return;
  661. var dayList = JSON.parse(receiveObj.obj);
  662. listView.dm().clear();
  663. dayStrList = new Array();
  664. dayList.forEach(function (val, index, arr) {
  665. dayStrList.push(val);
  666. var tempEndTime1 = new Date(Date.parse(val.Name + " 0:0:0"));
  667. tempEndTime1.setMilliseconds(0);
  668. var nowDay = new Date();
  669. nowDay.setHours(0);
  670. nowDay.setMinutes(0);
  671. nowDay.setSeconds(0);
  672. nowDay.setMilliseconds(0);
  673. if (tempEndTime1 >= tempStartTime && tempEndTime1 <= tempEndTime && tempEndTime1 < nowDay)//不能超过今天0点
  674. {
  675. var data= AddListViewElem(listView, val);
  676. if(!isInitListView)
  677. {
  678. listView.getSelectionModel().setSelection(data);
  679. SelectTime = data.a('Name');
  680. }
  681. }
  682. });
  683. isInitListView=true;
  684. listView.setSortFunc(sortFunc);
  685. }
  686. else if (receiveObj.method == "GetHaveSaveMonthList") //获得月报表列表
  687. {
  688. if (ReportType != "MonthReport")
  689. return;
  690. var dayList = JSON.parse(receiveObj.obj);
  691. listView.dm().clear();
  692. dayStrList = new Array();
  693. dayList.forEach(function (val, index, arr) {
  694. dayStrList.push(val);
  695. var tempEndTime1 = new Date(Date.parse(val.Name + "-1 0:0:0"));
  696. tempEndTime1.setMilliseconds(0);
  697. if (tempEndTime1 >= tempStartTime && tempEndTime1 <= tempEndTime)
  698. {
  699. var data= AddListViewElem(listView, val);
  700. if(!isInitListView)
  701. {
  702. listView.getSelectionModel().setSelection(data);
  703. SelectTime = data.a('Name');
  704. }
  705. }
  706. });
  707. listView.setSortFunc(sortFunc);
  708. }
  709. else if (receiveObj.method == "GetReportJsFile") //获得报表js数据
  710. {
  711. if (ReportType != "OwnerReport")
  712. return;
  713. var jsObj = JSON.parse(receiveObj.obj);
  714. importJSON(ReportSpread, jsObj);
  715. ReportSpread.options.backColor = paneStyle.paneBackColor;
  716. ReportSpread.options.grayAreaBackColor = paneStyle.paneBackColor;
  717. FreshReport(ReportSpread);
  718. ReportSpread.getActiveSheet().options.selectionBorderColor = 'gray';
  719. }
  720. else if (receiveObj.method == "HisDataReGet") //历史回抽数据进度
  721. {
  722. var jsObj = receiveObj.obj;
  723. progressBtn.setLabel(jsObj + "%");
  724. progressNode.setValue(jsObj);
  725. if (parseInt(jsObj) >= 100) {
  726. progressBtn.setLabel("0%");
  727. progressBtn.setWidth(0);
  728. progressNode.setValue(0);
  729. recaluBtn.setDisabled(false);
  730. startReculate=false;
  731. }
  732. }
  733. else if (receiveObj.method == "GetOwnReportXlsxList") //获得自定义报表列表
  734. {
  735. if (ReportType != "OwnerReport")
  736. return;
  737. var dayList = JSON.parse(receiveObj.obj);
  738. listView.dm().clear();
  739. dayList.forEach(function (val, index, arr) {
  740. AddListViewElem(listView, val);
  741. });
  742. listView.setSortFunc(sortFunc);
  743. }
  744. };
  745. // 监听Socket的关闭
  746. socket.onclose = function (event) {
  747. console.log('Client notified socket has closed', event);
  748. //自动重连
  749. setTimeout(function(){
  750. socket = new WebSocket('ws://' + webServiceIP + ':10087/Command');
  751. }, 1000);
  752. };
  753. //列表控件---------------------------------------------------------------列表控件-----------------------------------------------------
  754. listView = new ht.widget.ListView();
  755. listView.setRowLineColor(toolBarBackColor);
  756. listView.setScrollBarColor("#1C4E89");
  757. listView.setAutoHideScrollBar(true);
  758. listView.setScrollBarSize(10);
  759. var toolbar3 = new ht.widget.Toolbar();
  760. var gap=toolbar3.getItemGap();
  761. toolbar3.setItemGap(0);
  762. toolbar3.getView().style.background ="#094196";
  763. toolbar3.height=40;
  764. toolbar3.setItems(
  765. [
  766. {
  767. id: 'nation',
  768. unfocusable: true,
  769. label: ' ',
  770. element: batchExportBtn,
  771. },
  772. ]);
  773. innerPane.setBottomView(toolbar3,40);
  774. innerPane.setCenterView(listView);
  775. borderPaneDayReport.setLeftView(innerPane, listViewWidth);
  776. //borderPaneDayReport.setLeftView(listView, listViewWidth);
  777. var listView_View = listView.getView();
  778. listView_View.style.backgroundColor ="#09225A";// paneStyle.paneBackColor;
  779. listView.getLabelFont=function()
  780. {
  781. return listViewLabelFont;
  782. }
  783. //listView.setCheckMode(true);
  784. var SelectTime = "";
  785. listView.onDataClicked = function (data) //选择某个数据
  786. {
  787. if (!data)
  788. return;
  789. if (ReportType == "DayReport")//日报表
  790. {
  791. SelectTime = data.a('Name');
  792. var tempEndTime1 = new Date(Date.parse(SelectTime + " 0:0:0"));
  793. StartTime = tempEndTime1.toDateString() + " 0:0:0";
  794. tempEndTime1.setDate(tempEndTime1.getDate() + 1);
  795. EndTime = tempEndTime1.toDateString() + " 0:0:0";
  796. FreshReport(ReportSpread, "", paneStyle.ExportWhiteBackBlackFont, jsonFileNameFunc);
  797. }
  798. else if (ReportType == "MonthReport")//月报表
  799. {
  800. SelectTime = data.a('Name');
  801. var tempEndTime1 = new Date(Date.parse(SelectTime + " 0:0:0"));
  802. StartTime = tempEndTime1.toDateString() + " 0:0:0";
  803. tempEndTime1.setMonth(tempEndTime1.getMonth() + 1);
  804. tempEndTime1.setSeconds(tempEndTime1.getSeconds() - 1);
  805. EndTime = tempEndTime1.toDateString() + " 23:59:59";
  806. FreshReport(ReportSpread, "", paneStyle.ExportWhiteBackBlackFont, jsonFileNameFunc);
  807. }
  808. else //自定义报表
  809. {
  810. StartTime = NodeStartTimeDiv.value + " 0:0:0";
  811. EndTime = NodeEndTimeDiv.value + " 0:0:0";
  812. SelectTime = data.a('Name');
  813. var obj = new CommandObj();
  814. obj.method = "GetReportJsFile";
  815. obj.parm1 = SelectTime.replace(".xlsx", "");
  816. var objStr = JSON.stringify(obj);
  817. socket.send(objStr);
  818. }
  819. }
  820. listView.setRowHeight(listViewHeight);
  821. //添加列表中的数据
  822. listView.enableToolTip();
  823. //获得列表控件中文字颜色
  824. listView.getLabelColor = function (data) {
  825. return this.isSelected(data) ? paneStyle.ListSelTextColor : paneStyle.DialogTitleFontColor;
  826. };
  827. //绘制
  828. /* listView.drawLabel =function (F, H, T, N, I)
  829. {
  830. F.font = listView.getLabelFont(H);
  831. var text=listView.getLabel(H);
  832. F.fillText(text, T, N);
  833. F.strokeText(text, T, N);
  834. // Wp(F, listView.getLabel(H), listView.getLabelFont(H), listView.getLabelColor(H), T, N, 0, I)
  835. }*/
  836. //列表控件绘制
  837. listView.drawRowBackground = function (g, data, selected, xx, yy, widthb, heightb) {
  838. if (this.isSelected(data)) {
  839. g.fillStyle = paneStyle.ListSelBackColor;
  840. }
  841. else if (this.getRowIndex(data) % 2 === 0) {
  842. g.fillStyle = paneStyle.paneBackColor;
  843. }
  844. else {
  845. g.fillStyle = paneStyle.paneBackColor;
  846. }
  847. g.beginPath();
  848. g.strokeStyle = "#083684";//toolBarBackColor;
  849. g.rect(xx, yy, widthb, heightb);
  850. g.fill();
  851. g.lineWidth = 2;
  852. g.strokeRect(xx, yy, widthb, heightb);
  853. };
  854. listView.setIndent(60);
  855. listView.enableToolTip();
  856. listView.getLabel = function (data) {
  857. return data.a('label');
  858. //return data.a('Name');
  859. };
  860. //列表控件排序
  861. sortFunc = function (d1, d2) {
  862. var str1 = d1.a('Name');
  863. var str2 = d2.a('Name');
  864. var strInt1 = str1.replace('-', '');
  865. strInt1 = strInt1.replace('-', '');
  866. var strInt2 = str2.replace('-', '');
  867. strInt2 = strInt2.replace('-', '');
  868. return parseInt(strInt2) - parseInt(strInt1);
  869. };
  870. listView.setSortFunc(sortFunc);
  871. //--------------------------------------------------------------------列表控件---------------------------------------------------
  872. borderPaneRealNode.setScalable(false);
  873. borderPaneRealNode.s({
  874. '2d.selectable': true,
  875. '2d.movable': false
  876. });
  877. borderPaneRealNode.setHtml(borderPaneDayReport);
  878. borderPaneRealNode.setPosition({
  879. x: x,
  880. y: y
  881. });
  882. borderPaneRealNode.setWidth(width);
  883. borderPaneRealNode.setHeight(height);
  884. borderPaneRealNode.setPadding(0);
  885. var usedTime = (new Date() - openStartTime);
  886. console.log("creat report ctrl use time:" + usedTime);
  887. return borderPaneRealNode;
  888. };
  889. //添加列表控件的数据
  890. function AddListViewElem(listView, obj) {
  891. var data = new ht.Data();
  892. data.a(obj);
  893. data.a("label"," "+obj.Name);
  894. listView.dm().add(data);
  895. return data;
  896. }
  897. function ChangeScrollBarStyle() {
  898. //修改滚动条滑块的位置
  899. if ($(".gc-scroll-container").first())
  900. {
  901. $(".gc-scroll-container").first().css("background-color","transparent");
  902. $(".gc-scroll-container").first().parent().css("background-color","transparent");
  903. }
  904. if ($(".gc-scroll-container").last())
  905. {
  906. $(".gc-scroll-container").last().css("background-color","transparent");
  907. $(".gc-scroll-container").last().parent().css("background-color","transparent");
  908. }
  909. //隐藏滚轮箭头
  910. divs = document.getElementsByClassName("gc-scroll-arrow");
  911. if (divs) {
  912. for (var xx = 0; xx < divs.length; xx++) {
  913. divs[xx].style.display = "none";
  914. }
  915. }
  916. //修改滚动条宽度
  917. if ($(".gc-scroll-bar").first()) {
  918. $(".gc-scroll-bar").first().css("width", "10px");
  919. $(".gc-scroll-bar").first().css("left", "3px");
  920. }
  921. if ($(".gc-scroll-bar").last()) {
  922. $(".gc-scroll-bar").last().css("height", "10px");
  923. $(".gc-scroll-bar").last().css("top", "3px");
  924. }
  925. var divx=document.getElementById("vp_vp");
  926. if(divx)
  927. {
  928. var divwidth = (divx.width + 16);
  929. divx.style.width=divwidth+"px";
  930. var divheight=(divx.height+16);
  931. divx.style.height=divheight+"px";
  932. }
  933. }
  934. //设置时间选择控件的时间
  935. function SetTimeSelectDivValue(elem, timeValue, type) {
  936. timeValue = getRelativeDate(timeValue, type);
  937. var end=laydate.render({
  938. elem: elem,
  939. type: type,
  940. theme: 'blueblack',
  941. value: timeValue,
  942. done: function (value, date) {
  943. setTimeout(function () {
  944. ;
  945. }, 100)
  946. }
  947. });;
  948. GD.setupDatePicker(elem, end);
  949. }
  950. function CommandObj() {
  951. var method = "";
  952. var parm1 = "";
  953. var parm2 = "";
  954. }
  955. function ReceiveObj() {
  956. var method = "";
  957. var obj = "";
  958. }
  959. //处理按钮的样式
  960. function SetButtonStyle(buttonName,buttonPng,shadowColor) {
  961. //修改查询按钮的样式
  962. $btnView = $(buttonName.getView());
  963. $mask = $('<div class="button-mask"></div>');
  964. (function ($btnView, $mask) {
  965. $btnView.css({
  966. 'borderRadius': '2px',
  967. 'overflow': 'hidden',
  968. 'padding': 0,
  969. 'margin': 0,
  970. 'textAlign': 'center',
  971. 'background-image':"url("+PAGEROOTDIR+"/script/image/"+buttonPng+".png) ",
  972. cursor: 'pointer',
  973. borderColor: '#ccc',
  974. boxShadow: '0 0 5px ' + shadowColor,
  975. }).hover(function () {
  976. $btnView.append($mask).css({
  977. boxShadow: '0 0 5px ' + '#eee'
  978. })
  979. }, function () {
  980. $mask.remove();
  981. $btnView.css({
  982. boxShadow: '0 0 5px ' + shadowColor
  983. })
  984. }).on('mousedown', function () {
  985. $btnView.parent().css({
  986. padding: '1px 0 0 1px'
  987. })
  988. }).on('mouseup', function () {
  989. $btnView.parent().css({
  990. padding: 0
  991. });
  992. }).find('canvas').css({
  993. 'top': 0,
  994. 'left': 0,
  995. });
  996. })($btnView, $mask);
  997. }