瀏覽代碼

调整导出功能

liling 1 年之前
父節點
當前提交
9d1672be4e
共有 2 個文件被更改,包括 29 次插入7 次删除
  1. 17 1
      global.js
  2. 12 6
      main.html

+ 17 - 1
global.js

@@ -6,4 +6,20 @@ var DEV_HINT_COLOR = "d69d85"; //设备盘头剩余20-50之间的提示颜色
 var DEV_OFFLINE_COLOR = "666666"; //设备未接入的颜色
 var ONLIME_TIMEOUT = 1000 * 60 * 5; //在线设备定时任务时间
 var INDEX_TIMEOUT = 5 * 60 * 1000; //首页统计数据定时任务时间
-var ALARM_TIMEOUT = 30 * 1000; //告警数据定时任务时间
+var ALARM_TIMEOUT = 30 * 1000; //告警数据定时任务时间
+
+Date.prototype.Format = function(fmt) { //author: meizz
+    var o = {
+        "M+": this.getMonth() + 1, //月份
+        "d+": this.getDate(), //日
+        "h+": this.getHours(), //小时
+        "m+": this.getMinutes(), //分
+        "s+": this.getSeconds(), //秒
+        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
+        "S": this.getMilliseconds() //毫秒
+    };
+    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+    for (var k in o)
+        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
+    return fmt;
+}

+ 12 - 6
main.html

@@ -22,8 +22,7 @@
 			<div itemcode="3"><span>稼动率</span><img src="image/imp2.png" style="float: right;margin-top: 7px;"></div>
 			<div itemcode="4"><span>生产趋势</span><img src="image/imp2.png" style="float: right;margin-top: 7px;"></div>
 			<div itemcode="5"><span>能耗趋势</span><img src="image/imp2.png" style="float: right;margin-top: 7px;"></div>
-			-->
-            <div ><span>指定设备</span><input id="imp_devcode" type="text" placeholder="设备编号" maxlength="4" style="width: 80px;margin-left: 8px;font-size: 12px;"></div>
+			-->            
 			<div itemcode="1"><span>最近7天</span><img src="image/imp2.png" style="float: right;margin-top: 7px;"></div>
 			<div itemcode="2"><span>自定义日期</span><img src="image/imp2.png" style="float: right;margin-top: 7px;"></div>
 		</div>
@@ -43,6 +42,9 @@
                 <label>到</label>
                 <select id="hour2" style="width: 63px;"></select>
             </div>
+            <div style="margin-top: 5px;">
+                <span>设备:</span><input id="imp_devcode" type="text" placeholder="设备编号" maxlength="4" style="width: 140px;margin-left: 8px;font-size: 12px;">
+            </div>
 			<div class="dateSelected_ok"><button type=button>确定</button></div>
 		</div>
 		<div id="search"><input type="text" placeholder="请输入设备编号" maxlength="4"><img style="position: absolute;top: 20%;right: 5px;" src="image/search_icon.png" class="search_btn"></div>
@@ -2213,7 +2215,8 @@
 			        changeMonth: true,
 			        changeYear: true,
 			        numberOfMonths: 1,
-			        rangeSelect: true
+			        rangeSelect: true,
+                    defaultDate:new Date().Format("yyyy-MM-dd")
 		});
 		$("#date_select,#ui-datepicker-div").on("click",function(e){
 			    	e.stopPropagation();
@@ -2237,17 +2240,20 @@
 		$("#imp_item>div").on('click',function(e){
 					//导出数据
 					var code = $(this).attr("itemcode")
-                    var devcode =$.trim($("#imp_devcode").val())
+                    //var devcode =$.trim($("#imp_devcode").val())
 					if(code=="2")
 					{
                         //自定义日期导出
 						e.stopPropagation();
-						$("#datepicker1,#datepicker2").val('')
+                        var day = new Date();
+                        var day1 = new Date().setDate(day.getDate()-7)
+						$("#datepicker1").val(new Date(day1).Format("yyyy-MM-dd"))
+                        $("#datepicker2").val(day.Format("yyyy-MM-dd"))
 						$("#date_select").show().css({
 							"top":$(this).offset().top+47+"px",
 							"left":$(this).offset().left+$("#imp_item").width()-$("#date_select").width()-5+"px"
 						})
-					}else if(code=="1") window.open(SERVER_URL+"/export?devcode="+devcode)
+					}else if(code=="1") window.open(SERVER_URL+"/export")
                     else e.stopPropagation();
 		})
 		//自定义导出日期确定