dever 6 gadi atpakaļ
vecāks
revīzija
122beecf71

+ 5 - 3
front/page/__load__.py

@@ -346,7 +346,7 @@ class Device(object):
 
 		out = self.input('out')
 		if not out:
-			device = self.input('device')
+			device = self.inputs('device')
 			data = []
 			header = []
 			datas = {}
@@ -362,7 +362,6 @@ class Device(object):
 						else:
 							datas[t].append(v)
 
-
 			self.data['url'] = Device.url('type='+type+'&id=' + id)
 
 			if datas:
@@ -378,7 +377,7 @@ class Device(object):
 				file_name =  self.data['info']['name'] + '.csv'
 				file_path = day[0] + '/' + day[1] + '/' + day[2]
 				file_path = File.mkdirs(os.path.join(Demeter.path, 'runtime','upload', file_path)) + '/' + file_name
-				with open(file_path, 'w', newline='') as f:
+				with open(file_path, 'w') as f:
 					f.write(codecs.BOM_UTF8)
 					writer = csv.writer(f)
 					for row in fileData:
@@ -389,6 +388,9 @@ class Device(object):
 				self.set_header('Content-Disposition', 'attachment; filename=' + file_name)
 				self.redirect(file_path)
 
+		else:
+			self.data['search'] = {}
+
 	@staticmethod
 	def log(self):
 		id, type = Device.init(self)

+ 3 - 10
front/templates/pc/device/out.html

@@ -2,27 +2,20 @@
 {% block content %}
 {%include 'inc/menu.html'%}
 <div class="pannel">
-    <form action="/device/out" method="get">
+    <form action="/device/out" method="get" style="height: 500px;">
     <input type="hidden" name="type" id="type" value="{{data['input']['type']}}" />
     <input type="hidden" name="id" id="id" value="{{data['input']['id']}}" />
     <input type="hidden" name="method" id="method" value="mx" />
-        <select multiple="multiple" name="device" id="device">
+        <select multiple="multiple" name="device" id="device" style="height: 500px;">
             {% for v in data['device'] %}
             <option value="{{v['id']}}" {% if 'device' in data['search'] and data['search']['device'] == v['id'] %}selected{% end %}>{{v['name']}}</option>
             {% end %}
-        </select>   
-        <select name="group" id="group" {% if 'start' in data['search'] or 'end' in data['search'] %}style="display:none;"{% end %}>
-            {% for v in data['group'] %}
-            <option value="{{v['id']}}" {% if 'group' in data['search'] and data['search']['group'] == v['id'] %}selected{% end %}>{{v['name']}}</option>
-            {% end %}
-        </select>     
+        </select>    
         <input type="text" name="start" id="start" readonly class="form_datetime" value="{% if 'start' in data['search'] %}{{data['search']['start']}}{% end %}" style="width:150px;">
         ~     
         <input type="text" name="end" id="end" readonly class="form_datetime" value="{% if 'end' in data['search'] %}{{data['search']['end']}}{% end %}" style="width:150px;">
         <input type="submit" value="导出报表">  
     </form>
-    <div class="box" id="main" style="width: 100%;height:400px;">
-    </div>
 </div>
 {% end %}
 

+ 18 - 2
front/templates/pc/device/stat.html

@@ -2,8 +2,9 @@
 {% block content %}
 {%include 'inc/menu.html'%}
 <div class="pannel">
-	<form action="/device/stat" method="get">
+	<form id="f1" action="/device/stat" method="get">
     <input type="hidden" name="type" id="type" value="{{data['input']['type']}}" />
+    <input type="hidden" name="method" id="method" value="maxmin" />
     <input type="hidden" name="id" id="id" value="{{data['input']['id']}}" />
         <select name="device" id="device">
             {% for v in data['device'] %}
@@ -18,7 +19,8 @@
         <input type="text" name="start" id="start" readonly class="form_datetime" value="{% if 'start' in data['search'] %}{{data['search']['start']}}{% end %}" style="width:150px;">
         ~     
         <input type="text" name="end" id="end" readonly class="form_datetime" value="{% if 'end' in data['search'] %}{{data['search']['end']}}{% end %}" style="width:150px;">
-        <input type="submit" value="查询">  
+        <input type="button" onclick="stat()" value="查询">  
+        <input type="button" onclick="download()" value="下载明细报表">  
     </form>
 	<div class="box" id="main" style="width: 100%;height:400px;">
     </div>
@@ -29,6 +31,20 @@
 {%include 'chart/page.html'%}
 <script type="text/javascript" src="{{static_url('pc/lib/laydate/laydate.js')}}"></script>
 <script type="text/javascript">
+
+function download()
+{
+  $('#f1').attr('action', '/device/out');
+  $("#method").val('mx');
+  $('#f1').submit();
+}
+
+function stat()
+{
+  $('#f1').attr('action', '/device/stat');
+  $("#method").val('maxmin');
+  $('#f1').submit();
+}
 dateTheme = '#247ed0'
 laydate.render({
   elem: '#start'