qxz_report.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  1. {% load staticfiles %}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8" />
  6. <link href="{% static '/lib/bootstrap-3.3.7/css/bootstrap.css' %}" rel="stylesheet">
  7. <link rel="stylesheet" href="{% static '/lib/font-awesome/4.5.0/css/font-awesome.css' %}">
  8. <link rel="stylesheet" href="{% static '/lib/css/ace.min.css' %}" />
  9. <link rel="stylesheet" href="{% static '/lib/css/ace-skins.min.css' %}">
  10. <link rel="stylesheet" href="{% static '/lib/css/ace-rtl.min.css' %}">
  11. <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
  12. <link rel="stylesheet" href="{% static '/css/loading.css' %}?versions=0.5.0" />
  13. <style type="text/css">
  14. body {
  15. background: #fff;
  16. }
  17. /* 菜单 */
  18. .menu_body .nulldata {
  19. line-height: 80px;
  20. text-align: center;
  21. height: 80px;
  22. background: #eee;
  23. }
  24. .menu_list {
  25. margin-top: 10px;
  26. }
  27. .menu_head {
  28. height: 30px;
  29. line-height: 30px;
  30. padding-left: 10px;
  31. font-size: 12px;
  32. color: #313131;
  33. cursor: pointer;
  34. border: 1px solid #e1e1e1;
  35. border-top: 0px solid #e1e1e1;
  36. position: relative;
  37. background: #f1f1f1 url(../static/img/jia.png) center right 5px no-repeat;
  38. margin: 0;
  39. word-break: keep-all;
  40. white-space: nowrap;
  41. overflow: hidden;
  42. text-overflow: ellipsis;
  43. }
  44. .menu_body {
  45. height: auto;
  46. overflow: hidden;
  47. line-height: 38px;
  48. border-left: 1px solid #e1e1e1;
  49. border-right: 1px solid #e1e1e1;
  50. }
  51. .menu_body a {
  52. display: block;
  53. height: 32px;
  54. line-height: 32px;
  55. padding-left: 10px;
  56. color: #525252;
  57. background: #fff;
  58. text-decoration: none;
  59. border-bottom: 1px solid #e1e1e1;
  60. }
  61. .menu_body a span {
  62. display: inline-block;
  63. width: 8px;
  64. height: 8px;
  65. border-radius: 50%;
  66. margin-right: 6px;
  67. }
  68. .menu_list .current {
  69. background: #f1f1f1 url(../static/img/jian.png) center right 5px no-repeat;
  70. font-weight: bold;
  71. color: #313131;
  72. }
  73. .menu_body .menu-active {
  74. color: #00bcd4;
  75. border-left: solid 3px #00bcd4;
  76. }
  77. .currAstive {
  78. background-color: #00bcd4;
  79. color: #fff;
  80. }
  81. .equipPage {
  82. line-height: 34px;
  83. text-align: center;
  84. }
  85. /* 统计图 */
  86. .searchCover {
  87. text-align: right;
  88. }
  89. .container-cartogram>div {
  90. width: 100%;
  91. margin: 0 10px;
  92. height: 400px;
  93. text-align: center;
  94. line-height: 300px;
  95. font-size: 22px;
  96. color: #8a8a8a;
  97. position: relative;
  98. }
  99. .container-cartogram>div>div {
  100. width: 100%;
  101. height: 100%;
  102. }
  103. .container-cartogram>div>.hint {
  104. width: 100%;
  105. height: 100%;
  106. position: absolute;
  107. }
  108. .container-cartogram .echartsBox {
  109. width: 100%;
  110. margin: 0 10px;
  111. height: 500px;
  112. text-align: center;
  113. line-height: 500px;
  114. font-size: 22px;
  115. color: #8a8a8a;
  116. position: relative;
  117. }
  118. .container-cartogram .echart {
  119. width: 100%;
  120. height: 100%;
  121. }
  122. .container-cartogram .hint {
  123. width: 100%;
  124. height: 100%;
  125. position: absolute;
  126. }
  127. /* 表格 */
  128. .tablesearchCover {
  129. text-align: left;
  130. margin: 20px 0 20px 3px;
  131. }
  132. .table,
  133. .table.table-striped>thead>tr>th {
  134. text-align: center;
  135. }
  136. .table>thead:first-child>tr:first-child>th {
  137. cursor: default;
  138. }
  139. /* 统计图提示 */
  140. .echartsHint {
  141. float: left;
  142. margin-left: 5%;
  143. line-height: 30px;
  144. font-weight: 700;
  145. }
  146. .timeStage {
  147. display: none;
  148. }
  149. .downTitle {
  150. text-align: right;
  151. line-height: 27px;
  152. padding-left: 0;
  153. margin-bottom: 5px;
  154. }
  155. .downContent {
  156. padding-left: 0;
  157. margin-bottom: 5px;
  158. }
  159. /* 在线、所属公司筛选框 */
  160. .iptScreen {
  161. width: 82%;
  162. }
  163. .layui-input-block {
  164. margin-left: 0;
  165. }
  166. .input-group-btnA {
  167. display: inline-block;
  168. }
  169. .bjred {
  170. background: red;
  171. }
  172. .bjgreen {
  173. background: green;
  174. }
  175. </style>
  176. <body>
  177. <div class="content">
  178. <div class="container" style="width:98%">
  179. <div class="row">
  180. <!-- 左菜单 -->
  181. <div class="col-xs-12 col-sm-3 col-md-2">
  182. <div class="input-group">
  183. <input type="text" class="form-control" id="searchImei" name="searchImei"
  184. placeholder="输入编号或名称查询">
  185. <div class="input-group-btn">
  186. <button type="button" id="searchBtn" class="btn btn-default no-border btn-sm">
  187. <i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
  188. </button>
  189. </div>
  190. </div>
  191. <!-- 下拉框 -->
  192. <!-- 在线状态 -->
  193. {% if role == "superuser" %}
  194. <div class="layui-input-block">
  195. <p class="">在线状态:</p>
  196. <select name="status" lay-verify="required" id="selectId" class="iptScreen">
  197. <option value="" selected>全部</option>
  198. <option value="0">离线</option>
  199. <option value="1">在线</option>
  200. </select>
  201. <div class="input-group-btnA">
  202. <button type="button" id="searchBtnA" class="btn btn-default no-border btn-sm">
  203. <i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
  204. </button>
  205. </div>
  206. </div>
  207. <div class="layui-input-block">
  208. <p class="">所属公司:</p>
  209. <select name="company" lay-verify="required" id="selectIdA" class="iptScreen">
  210. <option value="" selected>全部</option>
  211. <option value="15">云飞</option>
  212. <option value="8">新普惠</option>
  213. </select>
  214. <div class="input-group-btnA">
  215. <button type="button" id="searchBtnB" class="btn btn-default no-border btn-sm">
  216. <i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
  217. </button>
  218. </div>
  219. </div>
  220. {% endif %}
  221. <div id="firstpane" class="menu_list">
  222. <p class="menu_head current" id="area_322">设备列表</p>
  223. <div class="menu_body">
  224. <!-- <a href="javascript:;" title="设备15112501" class="text-overflow" id="15112501" data-pid="322">设备15112501</a> -->
  225. </div>
  226. <div class="equipPage">
  227. <!-- <button class="btn btn-minier btn-yellow"><i class="fa fa-sort-up" aria-hidden="true"></i></button> -->
  228. <input type="button" class="btn btn-minier btn-yellow" onclick="gotofirstpage()" value="首页">
  229. <button class="btn btn-minier btn-yellow" id="jianPage"
  230. onclick="changePage('jian')">上一页</button>
  231. <span id="currentpage">1</span>页
  232. <button class="btn btn-minier btn-yellow" id="addPage"
  233. onclick="changePage('add')">下一页</button>
  234. <span id="totelpage">4</span>页
  235. </div>
  236. </div>
  237. </div>
  238. <!-- 右 -->
  239. <div class="col-xs-12 col-sm-9 col-md-10">
  240. <div class="echartsHint">
  241. <span>*</span>
  242. e代表通道
  243. </div>
  244. <div class="searchCover">
  245. 时间段搜索:
  246. <input type="text" id="timSelectBox" autocomplete="off" placeholder="请选择时间段 ">
  247. <input type="hidden" id="begin" name="begin">
  248. <input type="hidden" id="end" name="end">
  249. <button type="button" onclick="sub_filter()" class="btn btn-sm btn-primary">筛选</button>
  250. </div>
  251. <!-- 统计图 -->
  252. <div class="container-cartogram">
  253. <div class="echartsBox fl">
  254. <div class="hint"></div>
  255. <div class="fl" id="line-chart"></div>
  256. </div>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. <div>
  262. <div class="searchCover tablesearchCover">
  263. 时间段搜索:
  264. <input type="text" id="timSelectBox2" autocomplete="off" placeholder="请选择时间段 ">
  265. <input type="hidden" id="tableBegin" name="begin">
  266. <input type="hidden" id="tableEnd" name="end">
  267. <button type="button" onclick="table_filter()" class="btn btn-sm btn-primary">筛选</button>
  268. <button type="button" class="btn btn-success btn-sm" onclick="decideExport()">导出</button>
  269. </div>
  270. <table id="datatable" class="table table-striped table-hover">
  271. </table>
  272. <div class="fenpei-bottom">
  273. <div id="page" style="text-align: center;"></div>
  274. </div>
  275. <!-- 导出提示框 -->
  276. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  277. <div class="modal-dialog" role="document">
  278. <div class="modal-content">
  279. <div class="modal-header">
  280. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  281. <span aria-hidden="true">&times;</span>
  282. </button>
  283. <h4 class="modal-title" id="myModalLabel">导出信息</h4>
  284. </div>
  285. <div class="modal-body">
  286. <div class="row">
  287. <div class="col-xs-3 downTitle">文件名称:</div>
  288. <div class="col-xs-8 downContent" style=>
  289. <input type="text" id="filename" placeholder="请输入文件的名称" maxlength="15"
  290. class="col-xs-12">
  291. </div>
  292. <div class="col-xs-3 downTitle">下载类型:</div>
  293. <div class="col-xs-8 downContent">
  294. <select name="downtype" id="downtype" onchange="downtype(this)" class="col-xs-12">
  295. <option value="1">全部</option>
  296. <option value="2">时间段</option>
  297. </select>
  298. </div>
  299. <div class="col-xs-3 downTitle timeStage">时间段:</div>
  300. <div class="col-xs-8 downContent timeStage">
  301. <input type="text" id="timSelectBox3" autocomplete="off" placeholder="请选择时间段 "
  302. class="col-xs-12">
  303. <input type="hidden" id="downbegin" name="begin">
  304. <input type="hidden" id="downend" name="end">
  305. </div>
  306. </div>
  307. </div>
  308. <div class="modal-footer">
  309. <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">取消</button>
  310. <button type="button" class="btn btn-primary btn-sm" onclick="operation()">下载</button>
  311. </div>
  312. </div>
  313. </div>
  314. </div>
  315. </div>
  316. </div>
  317. <!-- loading -->
  318. <div id="loadingParent">
  319. <div id="loadCenter">
  320. <div class="skype-loader">
  321. <div class="dot">
  322. <div class="first"></div>
  323. </div>
  324. <div class="dot"></div>
  325. <div class="dot"></div>
  326. <div class="dot"></div>
  327. </div>
  328. Logging in...
  329. </div>
  330. </div>
  331. <script src="{% static '/lib/js/jquery-2.1.4.min.js' %}"></script>
  332. <script src="{% static '/lib/bootstrap-3.3.7/js/bootstrap.js' %}"></script>
  333. <script src="{% static '/lib/layui/layui.all.js' %}"></script>
  334. <script src="{% static '/lib/js/echarts.min.js' %}"></script>
  335. <script type="text/javascript">
  336. $.ajaxSetup({
  337. data: { csrfmiddlewaretoken: '{{ csrf_token }}' },
  338. });
  339. </script>
  340. <script>
  341. //默认加载设备列表
  342. getEquipList(1, '');
  343. // 搜索
  344. $('#searchBtn').on('click', function () {
  345. getEquipList(1, $('#searchImei').val(), $('#selectId').val(), $('#selectIdA').val())
  346. });
  347. $('#searchImei').on('keyup', function (event) {
  348. if (event.keyCode == 13) {
  349. getEquipList(1, $('#searchImei').val(), $('#selectId').val(), $('#selectIdA').val())
  350. }
  351. })
  352. function getEquipList(page, filter, is_online, etype) {
  353. if (etype == undefined && is_online == undefined) {
  354. var etype = ''
  355. var is_online = ''
  356. }
  357. $.ajax({
  358. url: 'qxz_page',
  359. type: 'get',
  360. dataType: 'json',
  361. data: {
  362. page: page,
  363. f_id: filter,
  364. etype: etype, //所属公司
  365. is_online: is_online, //设备状态
  366. },
  367. success: function (data) {
  368. if (data.nums) {
  369. var html = '';
  370. var msg = data.ids
  371. var pagecount = Math.ceil(data.nums / 10);
  372. for (var i = 0; i < msg.length; i++) {
  373. if (msg[i].equip_name) {
  374. var equip_name = '设备:' + msg[i].equip_name;
  375. } else if (msg[i].equip_id.length == 15) {
  376. var equip_name = '设备:' + msg[i].equip_id.substring(msg[i].equip_id.length - 8);
  377. } else {
  378. var equip_name = '设备:' + msg[i].equip_id;
  379. }
  380. // 测试
  381. var offTime = msg[i].off_time || '';
  382. if (msg[i].is_online == 1) {
  383. var classStatic = 'bjgreen';
  384. } else if (msg[i].is_online == 0) {
  385. var classStatic = 'bjred';
  386. } else {
  387. var classStatic = '';
  388. }
  389. // html += '<a href="javascript:;" title="设备' + msg[i].equip_id + '" class="text-overflow" id="' + msg[i].equip_id + '" data-pid="322">设备' + equip_name + '</a>'
  390. html += '<a href="javascript:;" isonline="' + msg[i].is_online + '" offTime="' + offTime + '" title="设备' + msg[i].equip_id + '" class="text-overflow" id="' + msg[i].equip_id + '" name="' + msg[i].equip_name + '" data-pid="322"><span class="' + classStatic + '"></span>' + equip_name + '</a>'
  391. }
  392. $('#firstpane .menu_body').html(html);
  393. $('.equipPage').show();
  394. $('#totelpage').html(pagecount)
  395. // 菜单栏
  396. $("#firstpane .menu_body:eq(0) a:eq(0)").addClass('menu-active');
  397. $(".menu_body a").click(function () {
  398. $(".menu_head").removeClass("currAstive");
  399. $(".menu_body a").removeClass("menu-active");
  400. $(this).addClass("menu-active");
  401. $(this).parent().prev().addClass('currAstive');
  402. $('#begin').val('');
  403. $('#tableBegin').val('');
  404. $('#tableEnd').val('');
  405. $('#end').val('');
  406. $('#timSelectBox').val('');
  407. $('#timSelectBox2').val('');
  408. var facId = $(this).attr("id");
  409. if (facId && facId != null && facId != "") {
  410. loadCharts(facId);
  411. loadTable(facId);
  412. }
  413. });
  414. loadCharts(msg[0].equip_id);
  415. loadTable(msg[0].equip_id);
  416. } else {
  417. $('.equipPage').hide();
  418. var html = '<a href="javascript:;" class="text-overflow nulldata" data-pid="322">暂未设备</a>'
  419. $('#firstpane .menu_body').html(html);
  420. echartFun([], '');
  421. Fill_null_Table('datatable');
  422. layui.use('laypage', function () {
  423. var laypage = layui.laypage;
  424. laypage.render({
  425. elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
  426. // , count: 30
  427. , count: 0
  428. , theme: '#428BCA'
  429. , layout: []
  430. , jump: function (obj, first) {
  431. }
  432. });
  433. });
  434. }
  435. },
  436. error: function (type) {
  437. }
  438. })
  439. }
  440. // 日历
  441. layui.use('laydate', function () {
  442. var laydate = layui.laydate;
  443. //执行一个laydate实例
  444. laydate.render({
  445. elem: '#timSelectBox' //指定元素
  446. , range: true
  447. , done: function (value, date) {
  448. var dateArray = value.split(' - ')
  449. $('#begin').val(dateArray[0])
  450. $('#end').val(dateArray[1])
  451. }
  452. });
  453. //执行一个laydate实例
  454. laydate.render({
  455. elem: '#timSelectBox2' //指定元素
  456. , range: true
  457. , done: function (value, date) {
  458. var dateArray = value.split(' - ')
  459. $('#tableBegin').val(dateArray[0])
  460. $('#tableEnd').val(dateArray[1])
  461. }
  462. });
  463. //执行一个laydate实例
  464. var _layDateMark = (new Date()).getTime();
  465. $('#timSelectBox3').attr('lay-key', '33' + _layDateMark);
  466. laydate.render({
  467. elem: '#timSelectBox3' //指定元素
  468. , range: true
  469. , done: function (value, date) {
  470. var dateArray = value.split(' - ')
  471. $('#downbegin').val(dateArray[0])
  472. $('#downend').val(dateArray[1])
  473. }
  474. });
  475. });
  476. //统计图
  477. function loadCharts(facId) {
  478. $.ajax({
  479. url: 'qxz_data_chart',
  480. type: 'post',
  481. dataType: 'json',
  482. data: {
  483. e_id: facId,
  484. begin: $('#begin').val(),
  485. end: $('#end').val(),
  486. },
  487. beforeSend: function () {
  488. loadFlage = layer.load();
  489. },
  490. complete: function () {
  491. layer.close(loadFlage);
  492. },
  493. success: function (data) {
  494. echartFun(data, facId)
  495. },
  496. error: function (type) {
  497. }
  498. })
  499. }
  500. // 设备列表
  501. var waterTempId = [16062009, 16062010, 16062011, 16062012, 16062013, 16062014, 16062015, 16062016, 16062017, 16062018, 16062019, 16062020, 16062021, 16062022, 16062023, 16062024, 16062025];
  502. var currpage = 1;
  503. function changePage(symbol) {
  504. var totelpage = Number($('#totelpage').html());
  505. if (symbol == 'add') {
  506. if (currpage < totelpage) {
  507. currpage++;
  508. $('#currentpage').html(currpage);
  509. $('addPage').attr('disable', 'false')
  510. } else {
  511. $('addPage').attr('disable', 'true')
  512. return false;
  513. }
  514. } else {
  515. if (currpage > 1) {
  516. currpage--;
  517. $('#currentpage').html(currpage);
  518. $('jianPage').attr('disable', 'false')
  519. } else {
  520. $('jianPage').attr('disable', 'true')
  521. return false;
  522. }
  523. }
  524. // getEquipList(currpage, $('#searchImei').val())
  525. getEquipList(currpage, $('#searchImei').val(), $('#selectId').val(), $('#selectIdA').val())
  526. }
  527. // 首页
  528. function gotofirstpage() {
  529. currpage = 1;
  530. $('#currentpage').html(1);
  531. getEquipList(1, $('#searchImei').val())
  532. }
  533. // 折线图搜索
  534. function sub_filter() {
  535. var currId = $(".menu_body .menu-active").attr("id");
  536. loadCharts(currId)
  537. // console.log(currId)
  538. }
  539. // 表格搜索
  540. function table_filter() {
  541. var currId = $(".menu_body .menu-active").attr("id");
  542. loadTable(currId)
  543. }
  544. // 折线图处理
  545. var color = ['#ff7b30', '#f93948', '#fb2ea4', '#bc59db', '#7457ec', '#307dfd', '#31bfff', '#46e9b1', '#19cd48', '#b2e409', '#f0f254', '#fed000', '#f06f14', '#a74040', '#90bb71', '#a07635', '#6502bd', '#048bbb', '#9ebb01', '#cc9202', '#ff8fa0', '#a3d55f', '#d9bedd', '#00a6b6', '#236093', '#009fff', '#ddc0a6', '#c4a6dd', '#dda6a6', '#779e33', '#a6ddb0'];
  546. function echartFun(data, facId) {
  547. $('#line-chart').prev().html('').css('z-index', 0);
  548. option.series = [];
  549. option.xAxis.data = [];
  550. lineChart.setOption(option, true);
  551. if (data.data.length) {
  552. var regroupData = []; //重组数据
  553. var kindArr = []; //通道数组
  554. var legend = [];
  555. var time = [];
  556. var len = Object.keys(data.data[0].dat).length
  557. for (var i = 1; i <= len; i++) {
  558. var key = 'e' + i;
  559. var valnum = data.data[0].dat[key].split('#')[1];
  560. if (data.data[0].dat[key] && (parseInt(valnum) != 163)) {
  561. kindArr.push(key);
  562. legend.push(data.conf[key].split('#')[0] + '(' + data.conf[key].split('#')[1] + ')')
  563. }
  564. if (i == Object.keys(data.data[0].dat).length) {
  565. for (var j = 0; j < data.data.length; j++) {
  566. time.unshift(data.data[j].time);
  567. for (var s = 0; s < kindArr.length; s++) {
  568. var val = data.data[j].dat[kindArr[s]];
  569. if (regroupData[s]) {
  570. if (val.split('#')[0] == -99.99) {
  571. var eVal = 'N/A';
  572. } else {
  573. var eVal = val.split('#')[0];
  574. }
  575. regroupData[s].dat.unshift(eVal);
  576. } else {
  577. if (val.split('#')[0] == -99.99) {
  578. var eVal = 'N/A';
  579. } else {
  580. var eVal = val.split('#')[0];
  581. }
  582. regroupData[s] = {
  583. name: data.conf[kindArr[s]].split('#')[0],
  584. unit: data.conf[kindArr[s]].split('#')[1],
  585. dat: [eVal]
  586. }
  587. }
  588. }
  589. if (j == data.data.length - 1) {
  590. console.log(regroupData)
  591. console.log(time)
  592. var legendData = { data: legend }
  593. option.legend = legendData;
  594. for (var count = 0; count < regroupData.length; count++) {
  595. var data = {
  596. name: legend[count],
  597. type: 'line',
  598. data: regroupData[count].dat,
  599. itemStyle: {
  600. normal: {
  601. color: color[count],
  602. shadowBlur: 1,
  603. shadowColor: color[count],
  604. borderColor: color[count],
  605. borderWidth: 2,
  606. backgroundColor: 'transparent'
  607. }
  608. },
  609. areaStyle: {
  610. normal: {
  611. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  612. offset: 0,
  613. color: color[count]
  614. }, {
  615. offset: 1,
  616. color: 'rgba(255,255,255,0)'
  617. }]),
  618. }
  619. }
  620. }
  621. option.series.push(data);
  622. }
  623. option.xAxis.data = time;
  624. setTimeout(function () {
  625. lineChart.setOption(option, true);
  626. })
  627. }
  628. }
  629. }
  630. }
  631. // var upTime = []; //
  632. // var kindCount = dat[0].e_len;
  633. // var seriesDat = [];
  634. // var legend = []; //几条折线
  635. // for (var i = 0; i < dat.length; i++) {
  636. // upTime.unshift(dat[i].upl_time);
  637. // for (var j = 0; j < dat[i].unit.length; j++) {
  638. // if (i == 0) {
  639. // if (dat[0].unit[j][4] == '106' && (waterTempId.indexOf(parseInt(facId)) != -1)) {
  640. // var elementName = '水温';
  641. // } else {
  642. // var elementName = dat[0].unit[j][1];
  643. // }
  644. // legend.push(dat[0].unit[j][3] + elementName);
  645. // }
  646. // if (seriesDat[j]) {
  647. // seriesDat[j].unshift(parseFloat(dat[i].unit[j][0]));
  648. // } else {
  649. // var arr = [];
  650. // arr.unshift(parseFloat(dat[i].unit[j][0]));
  651. // seriesDat[j] = arr;
  652. // }
  653. // }
  654. // if (i == dat.length - 1) {
  655. // // console.log(seriesDat)
  656. // var legendData = { data: legend }
  657. // option.legend = legendData;
  658. // for (var count = 0; count < kindCount; count++) {
  659. // var data = {
  660. // name: legend[count],
  661. // type: 'line',
  662. // data: seriesDat[count]
  663. // }
  664. // option.series.push(data);
  665. // }
  666. // option.xAxis.data = upTime;
  667. // setTimeout(function () {
  668. // lineChart.setOption(option, true);
  669. // })
  670. // }
  671. // }
  672. } else {
  673. $('#line-chart').prev().html('暂无数据').css('z-index', 99);
  674. option.series = [];
  675. option.xAxis.data = [];
  676. lineChart.setOption(option, true);
  677. }
  678. }
  679. //在线状态筛选
  680. $('#searchBtnA').on('click', function () {
  681. getEquipList(1, $('#searchImei').val(), $('#selectId').val(), $('#selectIdA').val())
  682. })
  683. $('#status').on('keyup', function (event) {
  684. if (event.keyCode == 13) {
  685. getEquipList(1, 1, $('#searchImei').val(), $('#selectId').val(), $('#selectIdA').val())
  686. }
  687. })
  688. //设备所属公司筛选
  689. $('#searchBtnB').on('click', function () {
  690. getEquipList(1, $('#searchImei').val(), $('#selectId').val(), $('#selectIdA').val())
  691. })
  692. $('#status').on('keyup', function (event) {
  693. if (event.keyCode == 13) {
  694. getEquipList(1, 1, $('#searchImei').val(), $('#selectId').val(), $('#selectIdA').val())
  695. }
  696. })
  697. // 滚动条
  698. scrollBar()
  699. function scrollBar() {
  700. // if ($('.content').height() > 750) {
  701. $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
  702. // } else {
  703. // $('#iframe-main', parent.document).css('height', '750px')
  704. // }
  705. }
  706. window.onresize = function () {
  707. lineChart.setOption(option, true);
  708. scrollBar()
  709. }
  710. // 统计图
  711. var lineChart = echarts.init(document.getElementById('line-chart'));
  712. var option = {
  713. title: {
  714. text: '',
  715. textStyle: {
  716. color: '#029eef'
  717. }
  718. },
  719. legend: {
  720. data: []
  721. },
  722. tooltip: {
  723. trigger: 'axis',
  724. },
  725. xAxis: {
  726. data: []
  727. },
  728. yAxis: {
  729. axisLine: { show: true },
  730. },
  731. toolbox: {
  732. left: 'center',
  733. },
  734. dataZoom: [{
  735. // startValue: '2014-06-01'
  736. }, {
  737. type: 'inside'
  738. }],
  739. grid: {
  740. left: '3%',
  741. right: '4%',
  742. bottom: '6%',
  743. containLabel: true
  744. },
  745. series: []
  746. }
  747. setTimeout(function () {
  748. lineChart.setOption(option, true);
  749. })
  750. // 填充表格
  751. // function Fill_Table(table_id, data, facId) {
  752. // var html = "";
  753. // for (var i = 0; i < data.length; i++) {
  754. // if (i == 0) {
  755. // html += "<thead><tr>";
  756. // html += "<th>采集时间</th>";
  757. // for (var j = 0; j < data[0].unit.length; j++) {
  758. // if (data[0].unit[j][1] == '土壤温度' && (waterTempId.indexOf(parseInt(facId)) != -1)) {
  759. // var elementName = '水温';
  760. // } else {
  761. // var elementName = data[0].unit[j][1];
  762. // }
  763. // html += "<th title=\'通道" + (data[0].unit[j][3]).substr(1, data[0].unit[j][3].length) + "\'>" + elementName + "(" + data[0].unit[j][2] + ")</th>";
  764. // }
  765. // html += "</tr></thead>";
  766. // }
  767. // html += "<tr>";
  768. // html += "<td>" + data[i].upl_time + "</td>";
  769. // for (var z = 0; z < data[i].unit.length; z++) {
  770. // html += "<td>" + data[i].unit[z][0] + "</td>";
  771. // }
  772. // html += "</tr>";
  773. // if (i == data.length - 1) {
  774. // $(document.getElementById(table_id)).html(html);
  775. // scrollBar()
  776. // }
  777. // }
  778. // }
  779. function Fill_Table(table_id, datum, facId) {
  780. var html = "";
  781. var data = datum.data;
  782. // 表头
  783. html += "<thead><tr>";
  784. html += "<th>采集时间</th>";
  785. for (var j = 1; j < Object.keys(data[0].dat).length; j++) {
  786. var key = 'e' + j;
  787. if (data[0].dat[key]) {
  788. var txt = datum.conf[key].split('#')[0]; //汉字名称
  789. var unit = datum.conf[key].split('#')[1]; //单位
  790. html += "<th title=\'通道" + j + "\'>" + txt + "(" + unit + ")</th>";
  791. }
  792. }
  793. html += "</tr></thead>";
  794. // 内容
  795. for (var i = 0; i < data.length; i++) {
  796. html += "<tr>";
  797. html += "<td>" + data[i].time + "</td>";
  798. for (var s = 1; s <= Object.keys(data[i].dat).length; s++) {
  799. var key = 'e' + s;
  800. if (data[i].dat[key] && data[0].dat[key]) {
  801. // var val = data[i].dat[key].split('#')[0];
  802. if (data[i].dat[key].split('#')[0] == -99.99) {
  803. var val = 'N/A';
  804. } else {
  805. var val = data[i].dat[key].split('#')[0];
  806. }
  807. html += "<td>" + val + "</td>";
  808. }
  809. }
  810. html += "</tr>";
  811. if (i == data.length - 1) {
  812. $(document.getElementById(table_id)).html(html);
  813. scrollBar()
  814. }
  815. }
  816. }
  817. function Fill_null_Table(table_id) {
  818. var html = "";
  819. html += "<thead><tr><th>采集时间</th><th>风速</th><th>温度</th></tr></thead>";
  820. html += "<tr><td colspan=3 style='line-height:100px'>暂无数据</td></tr>";
  821. $(document.getElementById(table_id)).html(html);
  822. scrollBar()
  823. }
  824. // 分页初始化
  825. function loadTable(facId) {
  826. $.ajax({
  827. url: 'qxz_data',
  828. type: 'post',
  829. data: {
  830. e_id: facId,
  831. begin: $('#tableBegin').val(),
  832. end: $('#tableEnd').val(),
  833. page: 1
  834. },
  835. dataType: 'json',
  836. beforeSend: function () {
  837. loadFlage = layer.load();
  838. },
  839. complete: function () {
  840. layer.close(loadFlage);
  841. },
  842. success: function (data) {
  843. $(document.getElementById('datatable')).empty();
  844. if (data.data.length) {
  845. Fill_Table('datatable', data, facId)
  846. layui.use('laypage', function () {
  847. var laypage = layui.laypage;
  848. laypage.render({
  849. elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
  850. // , count: 30
  851. , count: data.nums
  852. , theme: '#428BCA'
  853. , layout: ['prev', 'page', 'next', 'skip']
  854. , jump: function (obj, first) {
  855. //首次不执行
  856. if (!first) {
  857. $.ajax({
  858. url: 'qxz_data',
  859. type: 'post',
  860. data: {
  861. e_id: facId,
  862. begin: $('#tableBegin').val(),
  863. end: $('#tableEnd').val(),
  864. page: obj.curr
  865. },
  866. dataType: 'json',
  867. success: function (data) {
  868. $(document.getElementById('datatable')).empty();
  869. if (data.data.length) {
  870. Fill_Table('datatable', data, facId)
  871. }
  872. }
  873. })
  874. }
  875. }
  876. });
  877. });
  878. } else {
  879. Fill_null_Table('datatable');
  880. layui.use('laypage', function () {
  881. var laypage = layui.laypage;
  882. laypage.render({
  883. elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
  884. // , count: 30
  885. , count: 0
  886. , theme: '#428BCA'
  887. , layout: []
  888. , jump: function (obj, first) {
  889. }
  890. });
  891. });
  892. }
  893. }
  894. })
  895. }
  896. // 导出
  897. function decideExport() {
  898. $('#myModal').modal('toggle')
  899. }
  900. function downtype(obj) {
  901. if ($(obj).val() == 2) {
  902. $('.timeStage').show();
  903. } else {
  904. $('.timeStage').hide();
  905. $('#downbegin').val('');
  906. $('#downend').val('');
  907. $('#downtimSelectBox').val('');
  908. }
  909. }
  910. //导出
  911. function operation() {
  912. if (!$('#filename').val()) {
  913. // layer.msg("请填写文件名!", { time: 2000 });
  914. layer.tips('请填写文件名!', '#filename');
  915. return false;
  916. }
  917. if ($('#downtype').val() == 2) {
  918. if (!($('#downbegin').val() && $('#downbegin').val())) {
  919. layer.tips('请选择时间段!', '#timSelectBox3');
  920. return false;
  921. }
  922. }
  923. var currId = $(".menu_body .menu-active").attr("id");
  924. window.location.href = 'qxz_data_export?id=' + currId + '&begin=' + $('#downbegin').val() + '&end=' + $('#downend').val() + '&filename=' + $('#filename').val()
  925. }
  926. // echartFun(data, 'facId')
  927. </script>
  928. </body>
  929. </html>