12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139 |
- StartTime = "";
- EndTime = "";
- ReportType = "";
- var isExporting = false;
- var exportTaskList = new Array();
- var batchExportTimer;
- function CreateDayMonthReportShow(x, y, width, height, pageHeight, jsonFileNameData, jsonFileNameFunc,
- ReportFileName, dayMonth, paneStyle)
- {
- var toolBarHeight = 66 * ratio.ratioY;
- var toolBar2Height = 12 * ratio.ratioY;
-
- var buttonLabelFont = 18*ratio.ratioY+'px "苹方 粗体"';
- var timeLabelFont = 18 * ratio.ratioY +'px "苹方 粗体"';//时间选择
- var timeTextLabelFont = 18 * ratio.ratioY +'px "苹方 粗体"';//开始时间,结束时间
- var listViewLabelFont = 18 * ratio.ratioY + 'px "苹方 粗体"';
- var transparentColor = 'rgba(0,0,0,0)';
- var toolBarBackColor = transparentColor;//"00000000";//"#0005194B";
- var range = width - 100 * ratio.ratioX;//底部 两个按钮的间矩
- var openStartTime = new Date();
- var borderPaneRealNode = new ht.HtmlNode();
- ReportType = dayMonth;
- //布局控件
- borderPaneDayReport = new ht.widget.BorderPane();
- var innerPane = new ht.widget.BorderPane();
-
- //开始补帛
- var startReculate=false;
- var listViewWidth = 140 * ratio.ratioX;
- var listViewHeight = 44 * ratio.ratioY;
- ReportFileName1 = ReportFileName;
- //表格控件
- var ReportDiv = document.createElement("div");
- //ReportDiv.style.backgroundColor=paneStyle.paneBackColor;
- var ReportDivChild = document.createElement("div");
- //ReportDivChild.style.backgroundColor=paneStyle.paneBackColor;
- ReportDiv.appendChild(ReportDivChild);
- ReportDivChild.className = "sample-turtorial";
- var reportWidth = width - listViewWidth;
- var reportHeight = (height) - toolBarHeight - toolBar2Height + 1;
- ReportDivChild.style = 'width:' + reportWidth + 'px; height:' + reportHeight + 'px;border: 1px solid gray;';
- //ReportDivChild.style = 'width:100%; height:100%;border: 1px solid gray;';
- ReportSpread = new GC.Spread.Sheets.Workbook(ReportDivChild,
- {
- sheetCount: 1
- });
- ReportDivChild.style.border = "1px solid " + toolBarBackColor;
- ChangeScrollBarStyle();
- //页面缩放报表要自适应
- var resizeTimer = 0;
- //window.onresize = function () {
- $(window).on('resizeOver', function (e) {
- clearTimeout(resizeTimer);
- resizeTimer = setTimeout(function () {
- console.log(ReportDiv.style.height);
- ReportDivChild.style.height = ReportDiv.style.height;
- ReportSpread.refresh();
- ChangeScrollBarStyle();
- range = toolbar2.getWidth()-300;
- var botRange=toolbar2.getItemById("botRange");
- if (botRange)
- botRange.textField.width=range;
- }, 500);
- });
- //表格加入布局
- //borderPaneDayReport.setRightView(ReportDiv,width-180);
- borderPaneDayReport.setCenterView(ReportDiv);
- var NodeStartTimeDiv = document.createElement("input");
- NodeStartTimeDiv.style.color = '#DADBAC';// paneStyle.DialogTitleFontColor;
- NodeStartTimeDiv.style.font=timeLabelFont;
- NodeStartTimeDiv.style.backgroundColor =transparentColor;
- NodeStartTimeDiv.className="back-size100";
- NodeStartTimeDiv.style.width = 163*ratio.ratioX+'px';
- NodeStartTimeDiv.style.height = 36*ratio.ratioY+'px';
- NodeStartTimeDiv.style.border='none';
- document.body.appendChild(NodeStartTimeDiv);
-
- NodeStartTimeDiv.style.background = "url(" + PAGEROOTDIR +"/script/image/date.png)";
- NodeStartTimeDiv.style.padding =8* ratio.ratioY+'px '+15* ratio.ratioX+'px';
-
- var NodeEndTimeDiv = document.createElement("input");
- NodeEndTimeDiv.style.color = '#DADBAC';
- NodeEndTimeDiv.style.backgroundColor = toolBarBackColor;// paneStyle.paneBackColor;
-
- NodeEndTimeDiv.style.font=timeLabelFont;
-
- NodeEndTimeDiv.className = "back-size100";
- NodeEndTimeDiv.style.width = 164*ratio.ratioX+'px';
- NodeEndTimeDiv.style.height = 36*ratio.ratioY+'px';
- NodeEndTimeDiv.style.border='none';
- NodeEndTimeDiv.style.background = "url(" + PAGEROOTDIR +"/script/image/date.png)";
- NodeEndTimeDiv.style.padding = 8 * ratio.ratioY + 'px ' + 15 * ratio.ratioX + 'px';
- document.body.appendChild(NodeEndTimeDiv);
- //时间选择控件 初始化时间
- if (ReportType == "DayReport") {
- var tempDate = new Date();
- //昨天
- tempDate.setDate(tempDate.getDate() - 1);
- tempDate.setHours(0);
- tempDate.setMinutes(0);
- tempDate.setSeconds(0);
- StartTime = tempDate.toDateString() + " " + tempDate.toTimeString(); //初始化起始时间
- //30天前
- tempDate = new Date();
- tempDate.setDate(tempDate.getDate() - 30);
- tempDate.setHours(0);
- tempDate.setMinutes(0);
- tempDate.setSeconds(0);
- SetTimeSelectDivValue(NodeStartTimeDiv, tempDate, 'date');
- //今天0点
- tempDate = new Date();
- tempDate.setHours(0);
- tempDate.setMinutes(0);
- tempDate.setSeconds(0);
- SetTimeSelectDivValue(NodeEndTimeDiv, tempDate, 'date');
- EndTime = tempDate.toDateString() + " " + tempDate.toTimeString();
- }
- else if (ReportType == "MonthReport") {
- var tempDate = new Date();
- //上月一号
- tempDate.setMonth(tempDate.getMonth() - 1);
- tempDate.setDate(1);
- tempDate.setHours(0);
- tempDate.setMinutes(0);
- tempDate.setSeconds(0);
- StartTime = tempDate.toDateString() + " " + tempDate.toTimeString();
- //12月前一号
- tempDate = new Date();
- tempDate.setMonth(tempDate.getMonth() - 12);
- tempDate.setDate(1);
- tempDate.setHours(0);
- tempDate.setMinutes(0);
- tempDate.setSeconds(0);
- SetTimeSelectDivValue(NodeStartTimeDiv, tempDate, 'month');
- //本月一号
- tempDate = new Date();
- tempDate.setDate(1);
- tempDate.setHours(0);
- tempDate.setMinutes(0);
- tempDate.setSeconds(0);
- SetTimeSelectDivValue(NodeEndTimeDiv, tempDate, 'month');
- EndTime = tempDate.toDateString() + " " + tempDate.toTimeString();
- }
- else //自定义报表
- {
- var tempDate = new Date();
- //昨天
- tempDate.setDate(tempDate.getDate() - 1);
- tempDate.setHours(0);
- tempDate.setMinutes(0);
- tempDate.setSeconds(0);
- StartTime = tempDate.toDateString() + " " + tempDate.toTimeString(); //初始化起始时间
- //30天前
- tempDate = new Date();
- tempDate.setDate(tempDate.getDate() - 30);
- tempDate.setHours(0);
- tempDate.setMinutes(0);
- tempDate.setSeconds(0);
- SetTimeSelectDivValue(NodeStartTimeDiv, tempDate, 'date');
- //今天0点
- tempDate = new Date();
- tempDate.setHours(0);
- tempDate.setMinutes(0);
- tempDate.setSeconds(0);
- SetTimeSelectDivValue(NodeEndTimeDiv, tempDate, 'date');
- EndTime = tempDate.toDateString() + " " + tempDate.toTimeString();
- }
- var beforeImportTime = new Date();
- console.log("before import use time:" + (beforeImportTime - openStartTime));
- //初始化报表
- if (ReportType != "OwnerReport") {
- //网格线不显示, 此项耗时约50ms
- importJSON(ReportSpread, jsonFileNameData);
- var activeSheet = ReportSpread.getActiveSheet();
- FreshReport(ReportSpread, "", paneStyle.ExportWhiteBackBlackFont, jsonFileNameFunc);
- //延迟执行,否则影响速度
- setTimeout(function () {
- ReportSpread.suspendPaint();
- var rowNum = activeSheet.getRowCount();
- var colNum = activeSheet.getColumnCount();
- ReportSpread.options.backColor = paneStyle.paneBackColor;
- ReportSpread.options.grayAreaBackColor=paneStyle.paneBackColor;
- activeSheet.options.gridline = { color: "#FF2235", showVerticalGridline: false, showHorizontalGridline: false };
- for(var i=0;i<rowNum;i++)
- {
- for(var k=0;k<colNum;k++)
- {
- var cell = activeSheet.getCell(i, k, GC.Spread.Sheets.SheetArea.viewport);
- var color= cell.backColor();
- if(!color)
- {
- cell.backColor(paneStyle.paneBackColor);
- }
- else
- {
- if (paneStyle.paneBackColorOpacity)
- color += paneStyle.paneBackColorOpacity;
- cell.backColor(color);
- }
- }
- }
-
- ReportSpread.resumePaint();
- ChangeScrollBarStyle();
- }, 50);
- var importDoneTime = new Date();
- console.log("done import use time:" + (importDoneTime - openStartTime));
- }
- else {
- resetSpread(ReportSpread);
- ReportSpread.options.backColor = paneStyle.paneBackColor;
- ReportSpread.options.grayAreaBackColor = paneStyle.paneBackColor;
- ReportSpread.getActiveSheet().options.selectionBorderColor = 'gray';
- }
- //顶部工具栏
- toolbar = new ht.widget.Toolbar();
- borderPaneDayReport.setTopView(toolbar);
- toolbar.setHeight(toolBarHeight);
- $(toolbar.getView()).css({
- borderBottom:"10px solid rgba(0,0,0,0)"
- })
-
- //底部工具栏
- toolbar2 = new ht.widget.Toolbar();
- borderPaneDayReport.setBottomView(toolbar2);
- toolbar2.setHeight(toolBar2Height);
- //按钮
- //报表查看 此按钮已隐藏
- lookButton1 = new ht.widget.Button();
- lookButton1.setWidth(40);
- lookButton1.setHeight(29);
- lookButton1.setLabel("查看");
- lookButton1.setDisabled();
- lookButton1.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- lookButton1.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- lookButton1.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnBackColor);
- //报表直接导出 此按钮已隐藏
- downloadButton1 = new ht.widget.Button();
- downloadButton1.setWidth(40);
- downloadButton1.setHeight(29);
- downloadButton1.setLabel("导出");
- downloadButton1.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- downloadButton1.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- downloadButton1.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnBackColor);
- //报表查询 通过时间段筛选时间列表
- lookButton2 = new ht.widget.Button();
- lookButton2.setWidth(70 * ratio.ratioX);
- lookButton2.setHeight(29 *ratio.ratioY);
- lookButton2.setLabel("查询");
-
- lookButton2.setLabelFont(buttonLabelFont);
-
- lookButton2.setSelectBackground(transparentColor);
- lookButton2.setBorderColor(transparentColor);
- lookButton2.setBackground(transparentColor);
- // lookButton2.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- //lookButton2.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- lookButton2.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
- SetButtonStyle(lookButton2,"f2button","#333");
- $btnView = $(lookButton2.getView());
- $btnView.css("background-size", "70px 29px");
-
- lookButton2.onClicked = function (e)
- {
- StartTime = NodeStartTimeDiv.value + " 0:0:0"
- EndTime = NodeEndTimeDiv.value + " 0:0:0";
- if (ReportType != "OwnerReport") //非自定义报表
- {
- listView.dm().clear();
- dayStrList.forEach(function (val, index, arr) {
- var tempEndTime1 = new Date(Date.parse(val.Name + " 0:0:0"));
- tempEndTime1.setMilliseconds(0);
- var tempStartTime = new Date(Date.parse(StartTime));
- tempStartTime.setMilliseconds(0);
- var tempEndTime = new Date(Date.parse(EndTime));
- tempEndTime.setMilliseconds(0);
- if (tempEndTime1 >= tempStartTime && tempEndTime1 <= tempEndTime)
- AddListViewElem(listView, val);
- });
- listView.setSortFunc(sortFunc);
- }
- else //自定义报表
- {
- FreshReport(ReportSpread, "", false);
- }
- }
- lookButton2.drawBackground= function (A, Y, g, xx, U, X)
- {
-
- X && (A.fillStyle = X);
- A.beginPath();
- A.fillStyle = 'red';
- A.rect(Y, g, x, U);
- A.fill();
- }
- //报表导出
- downloadButton2 = new ht.widget.Button();
- downloadButton2.setWidth(70 * ratio.ratioX);
- downloadButton2.setHeight(29 * ratio.ratioY);
- downloadButton2.setLabel("导出");
- downloadButton2.setLabelFont(buttonLabelFont);
- //downloadButton2.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- //downloadButton2.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- downloadButton2.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
-
- downloadButton2.setSelectBackground(transparentColor);
- downloadButton2.setBorderColor(transparentColor);
- downloadButton2.setBackground(transparentColor);
-
-
- downloadButton2.onClicked = function (e) {
- if (!SelectTime)
- return;
- SpreadExport(ReportSpread, ReportFileName + "(" + SelectTime + ")", paneStyle.ExportWhiteBackBlackFont);
- }
- SetButtonStyle(downloadButton2, "f2button", "#333");
- $btnView = $(downloadButton2.getView());
- $btnView.css("background-size", "70px 29px");
- //数据补抽
- var recaluBtn = new ht.widget.Button();
- recaluBtn.setWidth(100 * ratio.ratioX);
- recaluBtn.setHeight(29 * ratio.ratioY);
-
- recaluBtn.setLabel("数据补抽");
- recaluBtn.setLabelFont(buttonLabelFont);
- recaluBtn.setBorderColor(transparentColor);
- recaluBtn.setBackground(transparentColor);
- //recaluBtn.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- //recaluBtn.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- recaluBtn.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
- SetButtonStyle(recaluBtn,"f4button","#333");
- $btnView=$(recaluBtn.getView());
- $btnView.css("background-size","100px 29px");
-
- recaluBtn.onClicked = function (e)
- {
- startReculate=true;
- progressBtn.setWidth(60);
- if (ReportType == "DayReport") {
- StartTime = NodeStartTimeDiv.value + " 0:0:0";
- EndTime = NodeEndTimeDiv.value + " 0:0:0";
- }
- else if (ReportType == "MonthReport") {
- StartTime = NodeStartTimeDiv.value + "-1 0:0:0";
- EndTime = NodeEndTimeDiv.value + "-1 0:0:0";
- }
- else {
- StartTime = NodeStartTimeDiv.value + " 0:0:0";
- EndTime = NodeEndTimeDiv.value + " 0:0:0";
- }
- recaluBtn.setDisabled(true);
- var obj = new CommandObj();
- obj.method = "HisDataReGet";
- obj.parm1 = StartTime;
- obj.parm2 = EndTime;
- var objStr = JSON.stringify(obj);
- socket.send(objStr);
-
- }
- //进度按钮
- var progressBtn = new ht.widget.Button();
- progressBtn.setWidth(0);
- progressBtn.setLabel("0%");
- progressBtn.setLabelFont(buttonLabelFont);
- progressBtn.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : toolBarBackColor);
- progressBtn.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : toolBarBackColor);
- progressBtn.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
- //进度条
- ht.Default.setImage('progress', {
- width: 150,
- height: 12,
- comps: [
- // 绘制背景
- {
- type: 'rect',
- rect: { x: 0, y: 0, width: 115, height: 12 },
- background: { func: function (data) { return data.a('background'); } }
- },
- // 绘制前景
- {
- rect: { x: 0, y: 0, width: 115, height: 12 },
- type: function (g, rect, comp, data, view) {
- var width = rect.width, height = rect.height, value = data.getValue(),
- foreWidth = width / 100 * value;
- g.fillStyle = data.a('foreground');
- g.fillRect(0, 0, foreWidth, height);
- }
- }
- ]
- });
-
- //进度条
- var progressNode = new ht.widget.Slider();
- progressNode.setBackground(toolBarBackColor);
- progressNode.setMax(100);
- progressNode.setMin(0);
- progressNode.setButton("");
- progressNode.setThickness(16*ratio.ratioY);
- progressNode.setValue(0);
- progressNode.setWidth(200 * ratio.ratioX);
- progressNode.setDisabled(true);
- //进度条不可点击
- var proView = progressNode.getView();
- if (proView.childNodes.length >= 2) {
- proView.childNodes[1].style.backgroundColor = "rgba(0,0,0,0)";
- }
- //重绘进度条圆角效果
- progressNode.drawBackground = function (A, Y, g, xx, U, X)
- {
- if(!startReculate)
- return;
- X && (A.fillStyle = X);
- A.beginPath();
- A.fillStyle =paneStyle.paneBackColor;
- //A.rect(Y, g, x, U);
- drawRoundRect(A, Y, g, xx, U, 8 * ratio.ratioX, 8 * ratio.ratioY, "#083684",1)
- A.fill();
- }
- progressNode.drawLeftBackground = function (A, Y, g, xx, U, X)
- {
- X && (A.fillStyle = X);
- if(xx<2)//宽度小于2,不画
- return;
- A.beginPath();
- A.fillStyle ="#7EF9FE";// paneStyle.btnFontColor;
- //A.rect(Y, g, x, U);
- drawRoundRect(A, Y, g, xx, U, 8* ratio.ratioX, 8*ratio.ratioY, X, 1)
- A.fill();
- }
- //批量导出
- var batchExportBtn = new ht.widget.Button();
- batchExportBtn.setWidth(125* ratio.ratioX);
- batchExportBtn.setHeight(28 * ratio.ratioY);
- batchExportBtn.setLabel("批量导出");
- batchExportBtn.setLabelFont(buttonLabelFont);
- batchExportBtn.setBorderColor(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- batchExportBtn.setBackground(typeof (paneStyle) == "undefined" ? "#4682B4" : paneStyle.btnBackColor);
- batchExportBtn.setLabelColor(typeof (paneStyle) == "undefined" ? "#FFFAF0" : paneStyle.btnFontColor);
-
- batchExportBtn.setSelectBackground(transparentColor);
- batchExportBtn.setBorderColor(transparentColor);
- batchExportBtn.setBackground(transparentColor);
- $btnView = $(batchExportBtn.getView());
- $btnView.css("background-size", "100px 29px");
- $btnView.css("left","0px");
-
- SetButtonStyle(batchExportBtn, "xxxxxx", "#094196");
- batchExportBtn.onClicked = function (e) {
- var dataArray = listView.dm();
- if (!dataArray)
- return;
- if (!dataArray._datas)
- return;
- dataArray._datas.forEach(function (val, index, arr) {
- exportTaskList.push(val.a('Name'));
- });
- batchExportTimer = setInterval(DoExportTask, 1000);
- }
- //批量导出
- function DoExportTask() {
- if (!exportTaskList) {
- clearInterval(batchExportTimer);
- return;
- }
- if (exportTaskList.length <= 0) {
- clearInterval(batchExportTimer);
- return;
- }
- if (isExporting)
- return;
- var dateStr = exportTaskList.pop();
- if (ReportType == "DayReport") {
- var tempEndTime1 = new Date(Date.parse(dateStr + " 0:0:0"));
- StartTime = tempEndTime1.toDateString() + " 0:0:0";
- tempEndTime1.setDate(tempEndTime1.getDate() + 1);
- EndTime = tempEndTime1.toDateString() + " 0:0:0";
- }
- else if (ReportType == "MonthReport") {
- var tempEndTime1 = new Date(Date.parse(dateStr + " 0:0:0"));
- StartTime = tempEndTime1.toDateString() + " 0:0:0";
- tempEndTime1.setMonth(tempEndTime1.getMonth() + 1);
- tempEndTime1.setSeconds(tempEndTime1.getSeconds() - 1);
- EndTime = tempEndTime1.toDateString() + " 23:59:59";
- }
- isExporting = true;
- FreshReport(ReportSpread, ReportFileName + "(" + dateStr + ")", paneStyle.ExportWhiteBackBlackFont);
- }
- // toolbar.getSelectBackground = function(item){ return '#3D97D0'; };
- //toolbar.getSelectBackground = function(item){ return "red"; };
- //设置工具栏背景色
- toolbar.getView().style.background = toolBarBackColor;// paneStyle.paneBackColor;
- toolbar2.getView().style.background = toolBarBackColor;// paneStyle.paneBackColor;
-
- toolbar.setItems([
- {
- id: 'text',
- label: ' ',
- unfocusable: true,
-
- textField: {
- width: 150 * ratio.ratioX,
- height:0,
- background: toolBarBackColor,
- color: paneStyle.paneBackColor,
- border: 'none',
- editable: false,
- }
- },
- {
- id: 'nation',
- unfocusable: true,
- textField: {
- text: '开始时间:',
- width: 90 * ratio.ratioX,
- background: "#00000000",
- color: '#A0A0A0',//paneStyle.DialogTitleFontColor,
- border: 'none',
- editable: false,
- font: timeTextLabelFont,
- }
- },
- {
- id: 'nation',
- unfocusable: true,
- label: ' ',
- element: NodeStartTimeDiv
- },
- {
- id: 'nation',
- unfocusable: true,
- textField: {
- text: '',
- width: 20,
- height: 0,
- background: toolBarBackColor,
- color: paneStyle.DialogTitleFontColor,
- border: 'none',
- editable: false
- }
- },
- {
- id: 'nation',
- unfocusable: true,
- textField: {
- text: '结束时间:',
- width: 90 * ratio.ratioX,
- background: "#00000000",
- color: '#A0A0A0',// paneStyle.DialogTitleFontColor,
- border: 'none',
- editable: false,
- font: timeTextLabelFont,
- }
- },
- {
- id: 'nation',
- unfocusable: true,
- label: ' ',
- element: NodeEndTimeDiv
- },
- {
- id: 'nation',
- unfocusable: true,
- textField: {
- text: '',
- width: 20,
- height:0,
- background: toolBarBackColor,
- color: paneStyle.DialogTitleFontColor,
- border: 'none',
- editable: false
- }
- },
- {
- label: '',
- unfocusable: true,
- element: lookButton2
- },
- {
- id: 'nation',
- unfocusable: true,
- textField: {
- text: '',
- width: 20,
- height: 0,
- background: toolBarBackColor,
- color: paneStyle.DialogTitleFontColor,
- border: 'none',
- editable: false
- }
- },
- {
- label: '',
- unfocusable: true,
- element: downloadButton2
- },
- {
- id: 'nation',
- unfocusable: true,
- textField: {
- text: '',
- width: 20,
- height:0,
- background: toolBarBackColor,
- color: paneStyle.DialogTitleFontColor,
- border: 'none',
- editable: false
- }
- },
- {
- label: '',
- unfocusable: true,
- element: recaluBtn
- },
- {
- label: '',
- unfocusable: true,
- element: progressNode
- },
- {
- label: '',
- unfocusable: true,
- element: progressBtn
- },
-
- ]);
- /*
- toolbar2.setItems([
- {
- id: 'botRange',
- label: ' ',
- unfocusable: true,
- visible: true,
- textField: {
- width: range,
- height:0,
- background: toolBarBackColor,
- color: paneStyle.paneBackColor,
- border: 'none',
- editable: false
- }
- },
- {
- label: '',
- unfocusable: true,
- element: downloadButton2
- },
- ]);
- */
- //建立一个websocket链接
- var socket = new WebSocket('ws://' + webServiceIP + ':10087/Command');
- // 打开Socket
- socket.onopen = function (event) {
- console.log('web socket connceted!', event);
- if (dayMonth == "DayReport")
- //请求报表生成日期列表
- socket.send("{\"method\":\"GetHaveSaveDayList\"}");
- else if (dayMonth == "MonthReport")
- socket.send("{\"method\":\"GetHaveSaveMonthList\"}");
- else if (dayMonth == "OwnerReport")
- socket.send("{\"method\":\"GetOwnReportXlsxList\"}");
- };
- //日期列表 日
- var dayStrList = new Array();
- var isInitListView=false;
- // 监听消息
- socket.onmessage = function (event) {
- console.log('Client received a message', event);
- var receiveObj = JSON.parse(event.data);
- var tempStartTime = new Date(Date.parse(NodeStartTimeDiv.value + " 0:0:0"));
- tempStartTime.setMilliseconds(0);
- var tempEndTime = new Date(Date.parse(NodeEndTimeDiv.value + " 0:0:0"));
- tempEndTime.setMilliseconds(0);
- if (receiveObj.method == "GetHaveSaveDayList") //获得日报表列表
- {
- if (ReportType != "DayReport")
- return;
- var dayList = JSON.parse(receiveObj.obj);
- listView.dm().clear();
- dayStrList = new Array();
- dayList.forEach(function (val, index, arr) {
- dayStrList.push(val);
- var tempEndTime1 = new Date(Date.parse(val.Name + " 0:0:0"));
- tempEndTime1.setMilliseconds(0);
- var nowDay = new Date();
- nowDay.setHours(0);
- nowDay.setMinutes(0);
- nowDay.setSeconds(0);
- nowDay.setMilliseconds(0);
- if (tempEndTime1 >= tempStartTime && tempEndTime1 <= tempEndTime && tempEndTime1 < nowDay)//不能超过今天0点
- {
- var data= AddListViewElem(listView, val);
- if(!isInitListView)
- {
- listView.getSelectionModel().setSelection(data);
- SelectTime = data.a('Name');
- }
- }
- });
- isInitListView=true;
- listView.setSortFunc(sortFunc);
- }
- else if (receiveObj.method == "GetHaveSaveMonthList") //获得月报表列表
- {
- if (ReportType != "MonthReport")
- return;
- var dayList = JSON.parse(receiveObj.obj);
- listView.dm().clear();
- dayStrList = new Array();
- dayList.forEach(function (val, index, arr) {
- dayStrList.push(val);
- var tempEndTime1 = new Date(Date.parse(val.Name + "-1 0:0:0"));
- tempEndTime1.setMilliseconds(0);
- if (tempEndTime1 >= tempStartTime && tempEndTime1 <= tempEndTime)
- {
- var data= AddListViewElem(listView, val);
- if(!isInitListView)
- {
- listView.getSelectionModel().setSelection(data);
- SelectTime = data.a('Name');
- }
- }
- });
- listView.setSortFunc(sortFunc);
- }
- else if (receiveObj.method == "GetReportJsFile") //获得报表js数据
- {
- if (ReportType != "OwnerReport")
- return;
- var jsObj = JSON.parse(receiveObj.obj);
- importJSON(ReportSpread, jsObj);
- ReportSpread.options.backColor = paneStyle.paneBackColor;
- ReportSpread.options.grayAreaBackColor = paneStyle.paneBackColor;
- FreshReport(ReportSpread);
- ReportSpread.getActiveSheet().options.selectionBorderColor = 'gray';
- }
- else if (receiveObj.method == "HisDataReGet") //历史回抽数据进度
- {
- var jsObj = receiveObj.obj;
- progressBtn.setLabel(jsObj + "%");
- progressNode.setValue(jsObj);
- if (parseInt(jsObj) >= 100) {
- progressBtn.setLabel("0%");
- progressBtn.setWidth(0);
- progressNode.setValue(0);
- recaluBtn.setDisabled(false);
- startReculate=false;
- }
- }
- else if (receiveObj.method == "GetOwnReportXlsxList") //获得自定义报表列表
- {
- if (ReportType != "OwnerReport")
- return;
- var dayList = JSON.parse(receiveObj.obj);
- listView.dm().clear();
- dayList.forEach(function (val, index, arr) {
- AddListViewElem(listView, val);
- });
- listView.setSortFunc(sortFunc);
- }
- };
- // 监听Socket的关闭
- socket.onclose = function (event) {
- console.log('Client notified socket has closed', event);
- //自动重连
- setTimeout(function(){
- socket = new WebSocket('ws://' + webServiceIP + ':10087/Command');
- }, 1000);
- };
- //列表控件---------------------------------------------------------------列表控件-----------------------------------------------------
- listView = new ht.widget.ListView();
- listView.setRowLineColor(toolBarBackColor);
- listView.setScrollBarColor("#1C4E89");
- listView.setAutoHideScrollBar(true);
- listView.setScrollBarSize(10);
- var toolbar3 = new ht.widget.Toolbar();
- var gap=toolbar3.getItemGap();
- toolbar3.setItemGap(0);
- toolbar3.getView().style.background ="#094196";
- toolbar3.height=40;
- toolbar3.setItems(
- [
- {
- id: 'nation',
- unfocusable: true,
- label: ' ',
- element: batchExportBtn,
- },
- ]);
-
- innerPane.setBottomView(toolbar3,40);
- innerPane.setCenterView(listView);
- borderPaneDayReport.setLeftView(innerPane, listViewWidth);
- //borderPaneDayReport.setLeftView(listView, listViewWidth);
- var listView_View = listView.getView();
- listView_View.style.backgroundColor ="#09225A";// paneStyle.paneBackColor;
- listView.getLabelFont=function()
- {
- return listViewLabelFont;
- }
- //listView.setCheckMode(true);
- var SelectTime = "";
- listView.onDataClicked = function (data) //选择某个数据
- {
- if (!data)
- return;
- if (ReportType == "DayReport")//日报表
- {
- SelectTime = data.a('Name');
- var tempEndTime1 = new Date(Date.parse(SelectTime + " 0:0:0"));
- StartTime = tempEndTime1.toDateString() + " 0:0:0";
- tempEndTime1.setDate(tempEndTime1.getDate() + 1);
- EndTime = tempEndTime1.toDateString() + " 0:0:0";
- FreshReport(ReportSpread, "", paneStyle.ExportWhiteBackBlackFont, jsonFileNameFunc);
- }
- else if (ReportType == "MonthReport")//月报表
- {
- SelectTime = data.a('Name');
- var tempEndTime1 = new Date(Date.parse(SelectTime + " 0:0:0"));
- StartTime = tempEndTime1.toDateString() + " 0:0:0";
- tempEndTime1.setMonth(tempEndTime1.getMonth() + 1);
- tempEndTime1.setSeconds(tempEndTime1.getSeconds() - 1);
- EndTime = tempEndTime1.toDateString() + " 23:59:59";
- FreshReport(ReportSpread, "", paneStyle.ExportWhiteBackBlackFont, jsonFileNameFunc);
- }
- else //自定义报表
- {
- StartTime = NodeStartTimeDiv.value + " 0:0:0";
- EndTime = NodeEndTimeDiv.value + " 0:0:0";
- SelectTime = data.a('Name');
- var obj = new CommandObj();
- obj.method = "GetReportJsFile";
- obj.parm1 = SelectTime.replace(".xlsx", "");
- var objStr = JSON.stringify(obj);
- socket.send(objStr);
- }
- }
- listView.setRowHeight(listViewHeight);
- //添加列表中的数据
- listView.enableToolTip();
-
- //获得列表控件中文字颜色
- listView.getLabelColor = function (data) {
- return this.isSelected(data) ? paneStyle.ListSelTextColor : paneStyle.DialogTitleFontColor;
- };
- //绘制
- /* listView.drawLabel =function (F, H, T, N, I)
- {
- F.font = listView.getLabelFont(H);
- var text=listView.getLabel(H);
- F.fillText(text, T, N);
- F.strokeText(text, T, N);
- // Wp(F, listView.getLabel(H), listView.getLabelFont(H), listView.getLabelColor(H), T, N, 0, I)
- }*/
- //列表控件绘制
- listView.drawRowBackground = function (g, data, selected, xx, yy, widthb, heightb) {
- if (this.isSelected(data)) {
- g.fillStyle = paneStyle.ListSelBackColor;
- }
- else if (this.getRowIndex(data) % 2 === 0) {
- g.fillStyle = paneStyle.paneBackColor;
- }
- else {
- g.fillStyle = paneStyle.paneBackColor;
- }
- g.beginPath();
- g.strokeStyle = "#083684";//toolBarBackColor;
- g.rect(xx, yy, widthb, heightb);
- g.fill();
- g.lineWidth = 2;
- g.strokeRect(xx, yy, widthb, heightb);
- };
- listView.setIndent(60);
- listView.enableToolTip();
- listView.getLabel = function (data) {
- return data.a('label');
- //return data.a('Name');
- };
- //列表控件排序
- sortFunc = function (d1, d2) {
- var str1 = d1.a('Name');
- var str2 = d2.a('Name');
- var strInt1 = str1.replace('-', '');
- strInt1 = strInt1.replace('-', '');
- var strInt2 = str2.replace('-', '');
- strInt2 = strInt2.replace('-', '');
- return parseInt(strInt2) - parseInt(strInt1);
- };
- listView.setSortFunc(sortFunc);
- //--------------------------------------------------------------------列表控件---------------------------------------------------
- borderPaneRealNode.setScalable(false);
- borderPaneRealNode.s({
- '2d.selectable': true,
- '2d.movable': false
- });
- borderPaneRealNode.setHtml(borderPaneDayReport);
- borderPaneRealNode.setPosition({
- x: x,
- y: y
- });
- borderPaneRealNode.setWidth(width);
- borderPaneRealNode.setHeight(height);
- borderPaneRealNode.setPadding(0);
- var usedTime = (new Date() - openStartTime);
- console.log("creat report ctrl use time:" + usedTime);
- return borderPaneRealNode;
- };
- //添加列表控件的数据
- function AddListViewElem(listView, obj) {
- var data = new ht.Data();
- data.a(obj);
- data.a("label"," "+obj.Name);
- listView.dm().add(data);
- return data;
- }
- function ChangeScrollBarStyle() {
- //修改滚动条滑块的位置
- if ($(".gc-scroll-container").first())
- {
- $(".gc-scroll-container").first().css("background-color","transparent");
- $(".gc-scroll-container").first().parent().css("background-color","transparent");
- }
-
- if ($(".gc-scroll-container").last())
- {
- $(".gc-scroll-container").last().css("background-color","transparent");
- $(".gc-scroll-container").last().parent().css("background-color","transparent");
- }
- //隐藏滚轮箭头
- divs = document.getElementsByClassName("gc-scroll-arrow");
- if (divs) {
- for (var xx = 0; xx < divs.length; xx++) {
- divs[xx].style.display = "none";
- }
- }
- //修改滚动条宽度
- if ($(".gc-scroll-bar").first()) {
- $(".gc-scroll-bar").first().css("width", "10px");
- $(".gc-scroll-bar").first().css("left", "3px");
- }
- if ($(".gc-scroll-bar").last()) {
- $(".gc-scroll-bar").last().css("height", "10px");
- $(".gc-scroll-bar").last().css("top", "3px");
- }
-
- var divx=document.getElementById("vp_vp");
- if(divx)
- {
- var divwidth = (divx.width + 16);
- divx.style.width=divwidth+"px";
-
- var divheight=(divx.height+16);
- divx.style.height=divheight+"px";
- }
- }
- //设置时间选择控件的时间
- function SetTimeSelectDivValue(elem, timeValue, type) {
- timeValue = getRelativeDate(timeValue, type);
- var end=laydate.render({
- elem: elem,
- type: type,
- theme: 'blueblack',
- value: timeValue,
- done: function (value, date) {
- setTimeout(function () {
- ;
- }, 100)
- }
- });;
- GD.setupDatePicker(elem, end);
- }
- function CommandObj() {
- var method = "";
- var parm1 = "";
- var parm2 = "";
- }
- function ReceiveObj() {
- var method = "";
- var obj = "";
- }
-
- //处理按钮的样式
- function SetButtonStyle(buttonName,buttonPng,shadowColor) {
- //修改查询按钮的样式
- $btnView = $(buttonName.getView());
- $mask = $('<div class="button-mask"></div>');
-
- (function ($btnView, $mask) {
- $btnView.css({
- 'borderRadius': '2px',
- 'overflow': 'hidden',
- 'padding': 0,
- 'margin': 0,
- 'textAlign': 'center',
- 'background-image':"url("+PAGEROOTDIR+"/script/image/"+buttonPng+".png) ",
- cursor: 'pointer',
- borderColor: '#ccc',
- boxShadow: '0 0 5px ' + shadowColor,
-
- }).hover(function () {
- $btnView.append($mask).css({
- boxShadow: '0 0 5px ' + '#eee'
- })
- }, function () {
- $mask.remove();
- $btnView.css({
- boxShadow: '0 0 5px ' + shadowColor
- })
- }).on('mousedown', function () {
- $btnView.parent().css({
- padding: '1px 0 0 1px'
- })
- }).on('mouseup', function () {
- $btnView.parent().css({
- padding: 0
- });
- }).find('canvas').css({
- 'top': 0,
- 'left': 0,
- });
- })($btnView, $mask);
- }
|