GoldenDayMonthReportShow.js.bak 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  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 (ReportType != "OwnerReport") //非自定义报表
  257. {
  258. listView.dm().clear();
  259. dayStrList.forEach(function (val, index, arr) {
  260. var tempEndTime1 = new Date(Date.parse(val.Name + " 0:0:0"));
  261. tempEndTime1.setMilliseconds(0);
  262. var tempStartTime = new Date(Date.parse(StartTime));
  263. tempStartTime.setMilliseconds(0);
  264. var tempEndTime = new Date(Date.parse(EndTime));
  265. tempEndTime.setMilliseconds(0);
  266. if (tempEndTime1 >= tempStartTime && tempEndTime1 <= tempEndTime)
  267. AddListViewElem(listView, val);
  268. });
  269. listView.setSortFunc(sortFunc);
  270. }
  271. else //自定义报表
  272. {
  273. FreshReport(ReportSpread, "", false);
  274. }
  275. }
  276. lookButton2.drawBackground= function (A, Y, g, xx, U, X)
  277. {
  278. X && (A.fillStyle = X);
  279. A.beginPath();
  280. A.fillStyle = 'red';
  281. A.rect(Y, g, x, U);
  282. A.fill();
  283. }
  284. //报表导出
  285. downloadButton2 = new ht.widget.Button();
  286. downloadButton2.setWidth(70 * ratio.ratioX);
  287. downloadButton2.setHeight(29 * ratio.ratioY);
  288. downloadButton2.setLabel("导出");
  289. downloadButton2.setLabelFont(buttonLabelFont);
  290. //downloadButton2.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  291. //downloadButton2.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  292. downloadButton2.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
  293. downloadButton2.setSelectBackground(transparentColor);
  294. downloadButton2.setBorderColor(transparentColor);
  295. downloadButton2.setBackground(transparentColor);
  296. downloadButton2.onClicked = function (e) {
  297. if (!SelectTime)
  298. return;
  299. SpreadExport(ReportSpread, ReportFileName + "(" + SelectTime + ")", paneStyle.ExportWhiteBackBlackFont);
  300. }
  301. SetButtonStyle(downloadButton2, "f2button", "#333");
  302. $btnView = $(downloadButton2.getView());
  303. $btnView.css("background-size", "70px 29px");
  304. //数据补抽
  305. var recaluBtn = new ht.widget.Button();
  306. recaluBtn.setWidth(100 * ratio.ratioX);
  307. recaluBtn.setHeight(29 * ratio.ratioY);
  308. recaluBtn.setLabel("数据补抽");
  309. recaluBtn.setLabelFont(buttonLabelFont);
  310. recaluBtn.setBorderColor(transparentColor);
  311. recaluBtn.setBackground(transparentColor);
  312. //recaluBtn.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  313. //recaluBtn.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  314. recaluBtn.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
  315. SetButtonStyle(recaluBtn,"f4button","#333");
  316. $btnView=$(recaluBtn.getView());
  317. $btnView.css("background-size","100px 29px");
  318. recaluBtn.onClicked = function (e)
  319. {
  320. startReculate=true;
  321. progressBtn.setWidth(60);
  322. if (ReportType == "DayReport") {
  323. StartTime = NodeStartTimeDiv.value + " 0:0:0";
  324. EndTime = NodeEndTimeDiv.value + " 0:0:0";
  325. }
  326. else if (ReportType == "MonthReport") {
  327. StartTime = NodeStartTimeDiv.value + "-1 0:0:0";
  328. EndTime = NodeEndTimeDiv.value + "-1 0:0:0";
  329. }
  330. else {
  331. StartTime = NodeStartTimeDiv.value + " 0:0:0";
  332. EndTime = NodeEndTimeDiv.value + " 0:0:0";
  333. }
  334. recaluBtn.setDisabled(true);
  335. var obj = new CommandObj();
  336. obj.method = "HisDataReGet";
  337. obj.parm1 = StartTime;
  338. obj.parm2 = EndTime;
  339. var objStr = JSON.stringify(obj);
  340. socket.send(objStr);
  341. }
  342. //进度按钮
  343. var progressBtn = new ht.widget.Button();
  344. progressBtn.setWidth(0);
  345. progressBtn.setLabel("0%");
  346. progressBtn.setLabelFont(buttonLabelFont);
  347. progressBtn.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : toolBarBackColor);
  348. progressBtn.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : toolBarBackColor);
  349. progressBtn.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
  350. //进度条
  351. ht.Default.setImage('progress', {
  352. width: 150,
  353. height: 12,
  354. comps: [
  355. // 绘制背景
  356. {
  357. type: 'rect',
  358. rect: { x: 0, y: 0, width: 115, height: 12 },
  359. background: { func: function (data) { return data.a('background'); } }
  360. },
  361. // 绘制前景
  362. {
  363. rect: { x: 0, y: 0, width: 115, height: 12 },
  364. type: function (g, rect, comp, data, view) {
  365. var width = rect.width, height = rect.height, value = data.getValue(),
  366. foreWidth = width / 100 * value;
  367. g.fillStyle = data.a('foreground');
  368. g.fillRect(0, 0, foreWidth, height);
  369. }
  370. }
  371. ]
  372. });
  373. //进度条
  374. var progressNode = new ht.widget.Slider();
  375. progressNode.setBackground(toolBarBackColor);
  376. progressNode.setMax(100);
  377. progressNode.setMin(0);
  378. progressNode.setButton("");
  379. progressNode.setThickness(16*ratio.ratioY);
  380. progressNode.setValue(0);
  381. progressNode.setWidth(200 * ratio.ratioX);
  382. progressNode.setDisabled(true);
  383. //进度条不可点击
  384. var proView = progressNode.getView();
  385. if (proView.childNodes.length >= 2) {
  386. proView.childNodes[1].style.backgroundColor = "rgba(0,0,0,0)";
  387. }
  388. //重绘进度条圆角效果
  389. progressNode.drawBackground = function (A, Y, g, xx, U, X)
  390. {
  391. if(!startReculate)
  392. return;
  393. X && (A.fillStyle = X);
  394. A.beginPath();
  395. A.fillStyle =paneStyle.paneBackColor;
  396. //A.rect(Y, g, x, U);
  397. drawRoundRect(A, Y, g, xx, U, 8 * ratio.ratioX, 8 * ratio.ratioY, "#083684",1)
  398. A.fill();
  399. }
  400. progressNode.drawLeftBackground = function (A, Y, g, xx, U, X)
  401. {
  402. X && (A.fillStyle = X);
  403. if(xx<2)//宽度小于2,不画
  404. return;
  405. A.beginPath();
  406. A.fillStyle ="#7EF9FE";// paneStyle.btnFontColor;
  407. //A.rect(Y, g, x, U);
  408. drawRoundRect(A, Y, g, xx, U, 8* ratio.ratioX, 8*ratio.ratioY, X, 1)
  409. A.fill();
  410. }
  411. //批量导出
  412. var batchExportBtn = new ht.widget.Button();
  413. batchExportBtn.setWidth(125* ratio.ratioX);
  414. batchExportBtn.setHeight(28 * ratio.ratioY);
  415. batchExportBtn.setLabel("批量导出");
  416. batchExportBtn.setLabelFont(buttonLabelFont);
  417. batchExportBtn.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  418. batchExportBtn.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
  419. batchExportBtn.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
  420. batchExportBtn.setSelectBackground(transparentColor);
  421. batchExportBtn.setBorderColor(transparentColor);
  422. batchExportBtn.setBackground(transparentColor);
  423. $btnView = $(batchExportBtn.getView());
  424. $btnView.css("background-size", "100px 29px");
  425. $btnView.css("left","0px");
  426. SetButtonStyle(batchExportBtn, "xxxxxx", "#094196");
  427. batchExportBtn.onClicked = function (e) {
  428. var dataArray = listView.dm();
  429. if (!dataArray)
  430. return;
  431. if (!dataArray._datas)
  432. return;
  433. dataArray._datas.forEach(function (val, index, arr) {
  434. exportTaskList.push(val.a('Name'));
  435. });
  436. batchExportTimer = setInterval(DoExportTask, 1000);
  437. }
  438. //批量导出
  439. function DoExportTask() {
  440. if (!exportTaskList) {
  441. clearInterval(batchExportTimer);
  442. return;
  443. }
  444. if (exportTaskList.length <= 0) {
  445. clearInterval(batchExportTimer);
  446. return;
  447. }
  448. if (isExporting)
  449. return;
  450. var dateStr = exportTaskList.pop();
  451. if (ReportType == "DayReport") {
  452. var tempEndTime1 = new Date(Date.parse(dateStr + " 0:0:0"));
  453. StartTime = tempEndTime1.toDateString() + " 0:0:0";
  454. tempEndTime1.setDate(tempEndTime1.getDate() + 1);
  455. EndTime = tempEndTime1.toDateString() + " 0:0:0";
  456. }
  457. else if (ReportType == "MonthReport") {
  458. var tempEndTime1 = new Date(Date.parse(dateStr + " 0:0:0"));
  459. StartTime = tempEndTime1.toDateString() + " 0:0:0";
  460. tempEndTime1.setMonth(tempEndTime1.getMonth() + 1);
  461. tempEndTime1.setSeconds(tempEndTime1.getSeconds() - 1);
  462. EndTime = tempEndTime1.toDateString() + " 23:59:59";
  463. }
  464. isExporting = true;
  465. FreshReport(ReportSpread, ReportFileName + "(" + dateStr + ")", paneStyle.ExportWhiteBackBlackFont);
  466. }
  467. // toolbar.getSelectBackground = function(item){ return '#3D97D0'; };
  468. //toolbar.getSelectBackground = function(item){ return "red"; };
  469. //设置工具栏背景色
  470. toolbar.getView().style.background = toolBarBackColor;// paneStyle.paneBackColor;
  471. toolbar2.getView().style.background = toolBarBackColor;// paneStyle.paneBackColor;
  472. toolbar.setItems([
  473. {
  474. id: 'text',
  475. label: ' ',
  476. unfocusable: true,
  477. textField: {
  478. width: 150 * ratio.ratioX,
  479. height:0,
  480. background: toolBarBackColor,
  481. color: paneStyle.paneBackColor,
  482. border: 'none',
  483. editable: false,
  484. }
  485. },
  486. {
  487. id: 'nation',
  488. unfocusable: true,
  489. textField: {
  490. text: '开始时间:',
  491. width: 90 * ratio.ratioX,
  492. background: "#00000000",
  493. color: '#A0A0A0',//paneStyle.DialogTitleFontColor,
  494. border: 'none',
  495. editable: false,
  496. font: timeTextLabelFont,
  497. }
  498. },
  499. {
  500. id: 'nation',
  501. unfocusable: true,
  502. label: ' ',
  503. element: NodeStartTimeDiv
  504. },
  505. {
  506. id: 'nation',
  507. unfocusable: true,
  508. textField: {
  509. text: '',
  510. width: 20,
  511. height: 0,
  512. background: toolBarBackColor,
  513. color: paneStyle.DialogTitleFontColor,
  514. border: 'none',
  515. editable: false
  516. }
  517. },
  518. {
  519. id: 'nation',
  520. unfocusable: true,
  521. textField: {
  522. text: '结束时间:',
  523. width: 90 * ratio.ratioX,
  524. background: "#00000000",
  525. color: '#A0A0A0',// paneStyle.DialogTitleFontColor,
  526. border: 'none',
  527. editable: false,
  528. font: timeTextLabelFont,
  529. }
  530. },
  531. {
  532. id: 'nation',
  533. unfocusable: true,
  534. label: ' ',
  535. element: NodeEndTimeDiv
  536. },
  537. {
  538. id: 'nation',
  539. unfocusable: true,
  540. textField: {
  541. text: '',
  542. width: 20,
  543. height:0,
  544. background: toolBarBackColor,
  545. color: paneStyle.DialogTitleFontColor,
  546. border: 'none',
  547. editable: false
  548. }
  549. },
  550. {
  551. label: '',
  552. unfocusable: true,
  553. element: lookButton2
  554. },
  555. {
  556. id: 'nation',
  557. unfocusable: true,
  558. textField: {
  559. text: '',
  560. width: 20,
  561. height: 0,
  562. background: toolBarBackColor,
  563. color: paneStyle.DialogTitleFontColor,
  564. border: 'none',
  565. editable: false
  566. }
  567. },
  568. {
  569. label: '',
  570. unfocusable: true,
  571. element: downloadButton2
  572. },
  573. {
  574. id: 'nation',
  575. unfocusable: true,
  576. textField: {
  577. text: '',
  578. width: 20,
  579. height:0,
  580. background: toolBarBackColor,
  581. color: paneStyle.DialogTitleFontColor,
  582. border: 'none',
  583. editable: false
  584. }
  585. },
  586. {
  587. label: '',
  588. unfocusable: true,
  589. element: recaluBtn
  590. },
  591. {
  592. label: '',
  593. unfocusable: true,
  594. element: progressNode
  595. },
  596. {
  597. label: '',
  598. unfocusable: true,
  599. element: progressBtn
  600. },
  601. ]);
  602. /*
  603. toolbar2.setItems([
  604. {
  605. id: 'botRange',
  606. label: ' ',
  607. unfocusable: true,
  608. visible: true,
  609. textField: {
  610. width: range,
  611. height:0,
  612. background: toolBarBackColor,
  613. color: paneStyle.paneBackColor,
  614. border: 'none',
  615. editable: false
  616. }
  617. },
  618. {
  619. label: '',
  620. unfocusable: true,
  621. element: downloadButton2
  622. },
  623. ]);
  624. */
  625. //建立一个websocket链接
  626. var socket = new WebSocket('ws://' + webServiceIP + ':10087/Command');
  627. // 打开Socket
  628. socket.onopen = function (event) {
  629. console.log('web socket connceted!', event);
  630. if (dayMonth == "DayReport")
  631. //请求报表生成日期列表
  632. socket.send("{\"method\":\"GetHaveSaveDayList\"}");
  633. else if (dayMonth == "MonthReport")
  634. socket.send("{\"method\":\"GetHaveSaveMonthList\"}");
  635. else if (dayMonth == "OwnerReport")
  636. socket.send("{\"method\":\"GetOwnReportXlsxList\"}");
  637. };
  638. //日期列表 日
  639. var dayStrList = new Array();
  640. var isInitListView=false;
  641. // 监听消息
  642. socket.onmessage = function (event) {
  643. console.log('Client received a message', event);
  644. var receiveObj = JSON.parse(event.data);
  645. var tempStartTime = new Date(Date.parse(NodeStartTimeDiv.value + " 0:0:0"));
  646. tempStartTime.setMilliseconds(0);
  647. var tempEndTime = new Date(Date.parse(NodeEndTimeDiv.value + " 0:0:0"));
  648. tempEndTime.setMilliseconds(0);
  649. if (receiveObj.method == "GetHaveSaveDayList") //获得日报表列表
  650. {
  651. if (ReportType != "DayReport")
  652. return;
  653. var dayList = JSON.parse(receiveObj.obj);
  654. listView.dm().clear();
  655. dayStrList = new Array();
  656. dayList.forEach(function (val, index, arr) {
  657. dayStrList.push(val);
  658. var tempEndTime1 = new Date(Date.parse(val.Name + " 0:0:0"));
  659. tempEndTime1.setMilliseconds(0);
  660. var nowDay = new Date();
  661. nowDay.setHours(0);
  662. nowDay.setMinutes(0);
  663. nowDay.setSeconds(0);
  664. nowDay.setMilliseconds(0);
  665. if (tempEndTime1 >= tempStartTime && tempEndTime1 <= tempEndTime && tempEndTime1 < nowDay)//不能超过今天0点
  666. {
  667. var data= AddListViewElem(listView, val);
  668. if(!isInitListView)
  669. {
  670. listView.getSelectionModel().setSelection(data);
  671. SelectTime = data.a('Name');
  672. }
  673. }
  674. });
  675. isInitListView=true;
  676. listView.setSortFunc(sortFunc);
  677. }
  678. else if (receiveObj.method == "GetHaveSaveMonthList") //获得月报表列表
  679. {
  680. if (ReportType != "MonthReport")
  681. return;
  682. var dayList = JSON.parse(receiveObj.obj);
  683. listView.dm().clear();
  684. dayStrList = new Array();
  685. dayList.forEach(function (val, index, arr) {
  686. dayStrList.push(val);
  687. var tempEndTime1 = new Date(Date.parse(val.Name + "-1 0:0:0"));
  688. tempEndTime1.setMilliseconds(0);
  689. if (tempEndTime1 >= tempStartTime && tempEndTime1 <= tempEndTime)
  690. {
  691. var data= AddListViewElem(listView, val);
  692. if(!isInitListView)
  693. {
  694. listView.getSelectionModel().setSelection(data);
  695. SelectTime = data.a('Name');
  696. }
  697. }
  698. });
  699. listView.setSortFunc(sortFunc);
  700. }
  701. else if (receiveObj.method == "GetReportJsFile") //获得报表js数据
  702. {
  703. if (ReportType != "OwnerReport")
  704. return;
  705. var jsObj = JSON.parse(receiveObj.obj);
  706. importJSON(ReportSpread, jsObj);
  707. ReportSpread.options.backColor = paneStyle.paneBackColor;
  708. ReportSpread.options.grayAreaBackColor = paneStyle.paneBackColor;
  709. FreshReport(ReportSpread);
  710. ReportSpread.getActiveSheet().options.selectionBorderColor = 'gray';
  711. }
  712. else if (receiveObj.method == "HisDataReGet") //历史回抽数据进度
  713. {
  714. var jsObj = receiveObj.obj;
  715. progressBtn.setLabel(jsObj + "%");
  716. progressNode.setValue(jsObj);
  717. if (parseInt(jsObj) >= 100) {
  718. progressBtn.setLabel("0%");
  719. progressBtn.setWidth(0);
  720. progressNode.setValue(0);
  721. recaluBtn.setDisabled(false);
  722. startReculate=false;
  723. }
  724. }
  725. else if (receiveObj.method == "GetOwnReportXlsxList") //获得自定义报表列表
  726. {
  727. if (ReportType != "OwnerReport")
  728. return;
  729. var dayList = JSON.parse(receiveObj.obj);
  730. listView.dm().clear();
  731. dayList.forEach(function (val, index, arr) {
  732. AddListViewElem(listView, val);
  733. });
  734. listView.setSortFunc(sortFunc);
  735. }
  736. };
  737. // 监听Socket的关闭
  738. socket.onclose = function (event) {
  739. console.log('Client notified socket has closed', event);
  740. //自动重连
  741. setTimeout(function(){
  742. socket = new WebSocket('ws://' + webServiceIP + ':10087/Command');
  743. }, 1000);
  744. };
  745. //列表控件---------------------------------------------------------------列表控件-----------------------------------------------------
  746. listView = new ht.widget.ListView();
  747. listView.setRowLineColor(toolBarBackColor);
  748. listView.setScrollBarColor("#1C4E89");
  749. listView.setAutoHideScrollBar(true);
  750. listView.setScrollBarSize(10);
  751. var toolbar3 = new ht.widget.Toolbar();
  752. var gap=toolbar3.getItemGap();
  753. toolbar3.setItemGap(0);
  754. toolbar3.getView().style.background ="#094196";
  755. toolbar3.height=40;
  756. toolbar3.setItems(
  757. [
  758. {
  759. id: 'nation',
  760. unfocusable: true,
  761. label: ' ',
  762. element: batchExportBtn,
  763. },
  764. ]);
  765. innerPane.setBottomView(toolbar3,40);
  766. innerPane.setCenterView(listView);
  767. borderPaneDayReport.setLeftView(innerPane, listViewWidth);
  768. //borderPaneDayReport.setLeftView(listView, listViewWidth);
  769. var listView_View = listView.getView();
  770. listView_View.style.backgroundColor ="#09225A";// paneStyle.paneBackColor;
  771. listView.getLabelFont=function()
  772. {
  773. return listViewLabelFont;
  774. }
  775. //listView.setCheckMode(true);
  776. var SelectTime = "";
  777. listView.onDataClicked = function (data) //选择某个数据
  778. {
  779. if (!data)
  780. return;
  781. if (ReportType == "DayReport")//日报表
  782. {
  783. SelectTime = data.a('Name');
  784. var tempEndTime1 = new Date(Date.parse(SelectTime + " 0:0:0"));
  785. StartTime = tempEndTime1.toDateString() + " 0:0:0";
  786. tempEndTime1.setDate(tempEndTime1.getDate() + 1);
  787. EndTime = tempEndTime1.toDateString() + " 0:0:0";
  788. FreshReport(ReportSpread, "", paneStyle.ExportWhiteBackBlackFont, jsonFileNameFunc);
  789. }
  790. else if (ReportType == "MonthReport")//月报表
  791. {
  792. SelectTime = data.a('Name');
  793. var tempEndTime1 = new Date(Date.parse(SelectTime + " 0:0:0"));
  794. StartTime = tempEndTime1.toDateString() + " 0:0:0";
  795. tempEndTime1.setMonth(tempEndTime1.getMonth() + 1);
  796. tempEndTime1.setSeconds(tempEndTime1.getSeconds() - 1);
  797. EndTime = tempEndTime1.toDateString() + " 23:59:59";
  798. FreshReport(ReportSpread, "", paneStyle.ExportWhiteBackBlackFont, jsonFileNameFunc);
  799. }
  800. else //自定义报表
  801. {
  802. StartTime = NodeStartTimeDiv.value + " 0:0:0";
  803. EndTime = NodeEndTimeDiv.value + " 0:0:0";
  804. SelectTime = data.a('Name');
  805. var obj = new CommandObj();
  806. obj.method = "GetReportJsFile";
  807. obj.parm1 = SelectTime.replace(".xlsx", "");
  808. var objStr = JSON.stringify(obj);
  809. socket.send(objStr);
  810. }
  811. }
  812. listView.setRowHeight(listViewHeight);
  813. //添加列表中的数据
  814. listView.enableToolTip();
  815. //获得列表控件中文字颜色
  816. listView.getLabelColor = function (data) {
  817. return this.isSelected(data) ? paneStyle.ListSelTextColor : paneStyle.DialogTitleFontColor;
  818. };
  819. //绘制
  820. /* listView.drawLabel =function (F, H, T, N, I)
  821. {
  822. F.font = listView.getLabelFont(H);
  823. var text=listView.getLabel(H);
  824. F.fillText(text, T, N);
  825. F.strokeText(text, T, N);
  826. // Wp(F, listView.getLabel(H), listView.getLabelFont(H), listView.getLabelColor(H), T, N, 0, I)
  827. }*/
  828. //列表控件绘制
  829. listView.drawRowBackground = function (g, data, selected, xx, yy, widthb, heightb) {
  830. if (this.isSelected(data)) {
  831. g.fillStyle = paneStyle.ListSelBackColor;
  832. }
  833. else if (this.getRowIndex(data) % 2 === 0) {
  834. g.fillStyle = paneStyle.paneBackColor;
  835. }
  836. else {
  837. g.fillStyle = paneStyle.paneBackColor;
  838. }
  839. g.beginPath();
  840. g.strokeStyle = "#083684";//toolBarBackColor;
  841. g.rect(xx, yy, widthb, heightb);
  842. g.fill();
  843. g.lineWidth = 2;
  844. g.strokeRect(xx, yy, widthb, heightb);
  845. };
  846. listView.setIndent(60);
  847. listView.enableToolTip();
  848. listView.getLabel = function (data) {
  849. return data.a('label');
  850. //return data.a('Name');
  851. };
  852. //列表控件排序
  853. sortFunc = function (d1, d2) {
  854. var str1 = d1.a('Name');
  855. var str2 = d2.a('Name');
  856. var strInt1 = str1.replace('-', '');
  857. strInt1 = strInt1.replace('-', '');
  858. var strInt2 = str2.replace('-', '');
  859. strInt2 = strInt2.replace('-', '');
  860. return parseInt(strInt2) - parseInt(strInt1);
  861. };
  862. listView.setSortFunc(sortFunc);
  863. //--------------------------------------------------------------------列表控件---------------------------------------------------
  864. borderPaneRealNode.setScalable(false);
  865. borderPaneRealNode.s({
  866. '2d.selectable': true,
  867. '2d.movable': false
  868. });
  869. borderPaneRealNode.setHtml(borderPaneDayReport);
  870. borderPaneRealNode.setPosition({
  871. x: x,
  872. y: y
  873. });
  874. borderPaneRealNode.setWidth(width);
  875. borderPaneRealNode.setHeight(height);
  876. borderPaneRealNode.setPadding(0);
  877. var usedTime = (new Date() - openStartTime);
  878. console.log("creat report ctrl use time:" + usedTime);
  879. return borderPaneRealNode;
  880. };
  881. //添加列表控件的数据
  882. function AddListViewElem(listView, obj) {
  883. var data = new ht.Data();
  884. data.a(obj);
  885. data.a("label"," "+obj.Name);
  886. listView.dm().add(data);
  887. return data;
  888. }
  889. function ChangeScrollBarStyle() {
  890. //修改滚动条滑块的位置
  891. if ($(".gc-scroll-container").first())
  892. {
  893. $(".gc-scroll-container").first().css("background-color","transparent");
  894. $(".gc-scroll-container").first().parent().css("background-color","transparent");
  895. }
  896. if ($(".gc-scroll-container").last())
  897. {
  898. $(".gc-scroll-container").last().css("background-color","transparent");
  899. $(".gc-scroll-container").last().parent().css("background-color","transparent");
  900. }
  901. //隐藏滚轮箭头
  902. divs = document.getElementsByClassName("gc-scroll-arrow");
  903. if (divs) {
  904. for (var xx = 0; xx < divs.length; xx++) {
  905. divs[xx].style.display = "none";
  906. }
  907. }
  908. //修改滚动条宽度
  909. if ($(".gc-scroll-bar").first()) {
  910. $(".gc-scroll-bar").first().css("width", "10px");
  911. $(".gc-scroll-bar").first().css("left", "3px");
  912. }
  913. if ($(".gc-scroll-bar").last()) {
  914. $(".gc-scroll-bar").last().css("height", "10px");
  915. $(".gc-scroll-bar").last().css("top", "3px");
  916. }
  917. var divx=document.getElementById("vp_vp");
  918. if(divx)
  919. {
  920. var divwidth = (divx.width + 16);
  921. divx.style.width=divwidth+"px";
  922. var divheight=(divx.height+16);
  923. divx.style.height=divheight+"px";
  924. }
  925. }
  926. //设置时间选择控件的时间
  927. function SetTimeSelectDivValue(elem, timeValue, type) {
  928. timeValue = getRelativeDate(timeValue, type);
  929. var end=laydate.render({
  930. elem: elem,
  931. type: type,
  932. theme: 'blueblack',
  933. value: timeValue,
  934. done: function (value, date) {
  935. setTimeout(function () {
  936. ;
  937. }, 100)
  938. }
  939. });;
  940. GD.setupDatePicker(elem, end);
  941. }
  942. function CommandObj() {
  943. var method = "";
  944. var parm1 = "";
  945. var parm2 = "";
  946. }
  947. function ReceiveObj() {
  948. var method = "";
  949. var obj = "";
  950. }
  951. //处理按钮的样式
  952. function SetButtonStyle(buttonName,buttonPng,shadowColor) {
  953. //修改查询按钮的样式
  954. $btnView = $(buttonName.getView());
  955. $mask = $('<div class="button-mask"></div>');
  956. (function ($btnView, $mask) {
  957. $btnView.css({
  958. 'borderRadius': '2px',
  959. 'overflow': 'hidden',
  960. 'padding': 0,
  961. 'margin': 0,
  962. 'textAlign': 'center',
  963. 'background-image':"url("+PAGEROOTDIR+"/script/image/"+buttonPng+".png) ",
  964. cursor: 'pointer',
  965. borderColor: '#ccc',
  966. boxShadow: '0 0 5px ' + shadowColor,
  967. }).hover(function () {
  968. $btnView.append($mask).css({
  969. boxShadow: '0 0 5px ' + '#eee'
  970. })
  971. }, function () {
  972. $mask.remove();
  973. $btnView.css({
  974. boxShadow: '0 0 5px ' + shadowColor
  975. })
  976. }).on('mousedown', function () {
  977. $btnView.parent().css({
  978. padding: '1px 0 0 1px'
  979. })
  980. }).on('mouseup', function () {
  981. $btnView.parent().css({
  982. padding: 0
  983. });
  984. }).find('canvas').css({
  985. 'top': 0,
  986. 'left': 0,
  987. });
  988. })($btnView, $mask);
  989. }