1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147 |
- 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 (!GD.testSearchTime(StartTime, EndTime)) {
- return ;
- }
- 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());
- ;(function () {
- var userLevel = GD.getParams('userLevel');
- var dis = userLevel == 1 ? 'block' : 'none';
- $btnView.css('display', dis);
- })();
- $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, jsonFileNameFunc);
- }
- // 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);
- }
|