equipmanage_qxz1.html 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811
  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 '/lib/css/jquery-ui.css' %}" />
  13. <style type="text/css">
  14. body {
  15. background: #fff;
  16. }
  17. .row {
  18. margin: 0;
  19. }
  20. /* 菜单 */
  21. .menu_body .nulldata {
  22. line-height: 80px;
  23. text-align: center;
  24. height: 80px;
  25. background: #eee;
  26. }
  27. .menu_list {
  28. margin-top: 10px;
  29. }
  30. .menu_head {
  31. height: 30px;
  32. line-height: 30px;
  33. padding-left: 10px;
  34. font-size: 12px;
  35. color: #313131;
  36. cursor: pointer;
  37. border: 1px solid #e1e1e1;
  38. border-top: 0px solid #e1e1e1;
  39. position: relative;
  40. background: #f1f1f1 url(../static/img/jia.png) center right 5px no-repeat;
  41. margin: 0;
  42. word-break: keep-all;
  43. white-space: nowrap;
  44. overflow: hidden;
  45. text-overflow: ellipsis;
  46. }
  47. .menu_body {
  48. height: auto;
  49. overflow: hidden;
  50. line-height: 38px;
  51. border-left: 1px solid #e1e1e1;
  52. border-right: 1px solid #e1e1e1;
  53. }
  54. .menu_body a {
  55. display: block;
  56. height: 32px;
  57. line-height: 32px;
  58. padding-left: 10px;
  59. color: #525252;
  60. background: #fff;
  61. text-decoration: none;
  62. border-bottom: 1px solid #e1e1e1;
  63. }
  64. .menu_list .current {
  65. background: #f1f1f1 url(../static/img/jian.png) center right 5px no-repeat;
  66. font-weight: bold;
  67. color: #313131;
  68. }
  69. .menu_body .menu-active {
  70. color: #00bcd4;
  71. border-left: solid 3px #00bcd4;
  72. }
  73. .currAstive {
  74. background-color: #00bcd4;
  75. color: #fff;
  76. }
  77. /* 主题标题 */
  78. .widget-box {
  79. background: none repeat scroll 0 0 #F9F9F9;
  80. clear: both;
  81. margin-top: 16px;
  82. margin-bottom: 16px;
  83. position: relative;
  84. border: none;
  85. }
  86. .widget-title {
  87. height: 36px;
  88. border-bottom: solid 1px #e5e5e5;
  89. padding-bottom: 1px;
  90. text-align: center;
  91. }
  92. .widget-title h5 {
  93. color: #666;
  94. float: left;
  95. font-size: 12px;
  96. font-weight: bold;
  97. padding: 12px;
  98. line-height: 12px;
  99. margin: 0;
  100. margin-bottom: 3px;
  101. border-bottom: solid 2px #38b0ec;
  102. }
  103. /*状态 */
  104. .dev:HOVER {
  105. background: #2E363F;
  106. }
  107. .dev {
  108. width: 215px;
  109. height: 88px;
  110. float: left;
  111. margin: 0px;
  112. color: #f2f2f2;
  113. margin: 5px;
  114. cursor: pointer;
  115. position: relative;
  116. }
  117. .bg_lb {
  118. background: /* #27a9e3 */
  119. #4ab8e8;
  120. }
  121. .dev .left {
  122. width: 80px;
  123. padding-top: 10px;
  124. float: left;
  125. }
  126. .dev .left .img-dev {
  127. width: 45px;
  128. margin-left: 12px;
  129. margin-top: 8px;
  130. }
  131. .dev .right {
  132. width: 120px;
  133. padding-top: 3px;
  134. float: left;
  135. font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial, sans-serif;
  136. }
  137. .dev .right .name {
  138. font-size: 20px;
  139. text-align: left;
  140. padding-top: 10px;
  141. overflow: hidden;
  142. white-space: nowrap;
  143. text-overflow: ellipsis;
  144. }
  145. .dev .right .data {
  146. font-size: 14px;
  147. text-align: left;
  148. padding-top: 15px;
  149. }
  150. /* 项目 */
  151. .todo li {
  152. border-bottom: 1px solid #EBEBEB;
  153. margin-bottom: 0;
  154. padding: 10px 0;
  155. }
  156. .equipPage {
  157. line-height: 34px;
  158. text-align: center;
  159. }
  160. table tr td.nullData {
  161. text-align: center;
  162. line-height: 250px;
  163. }
  164. /* 状态块颜色 */
  165. .bg_lb {
  166. background: /* #27a9e3 */
  167. #4ab8e8;
  168. }
  169. .bg_ly {
  170. background: /* #ffb848 */
  171. #f5b761;
  172. }
  173. .bg_lg {
  174. background: /* #28b779 */
  175. #3eb984;
  176. }
  177. .bg_ls {
  178. background: /* #2255a4 */
  179. #4978c1;
  180. }
  181. .bg_lo {
  182. background: /* #da542e */
  183. #dc6442;
  184. }
  185. .bg_lr {
  186. background: /* #f74d4d */
  187. #f77979;
  188. }
  189. .aisle {
  190. position: absolute;
  191. left: 6px;
  192. bottom: 1px;
  193. font-size: 12px;
  194. }
  195. #uploadPhoto {
  196. display: none;
  197. }
  198. #viewPhoto {
  199. cursor: pointer;
  200. }
  201. /* 设备控制 */
  202. #ctrlBox>div {
  203. margin-bottom: 20px;
  204. }
  205. .handCtrlBox {
  206. margin-bottom: 20px;
  207. }
  208. input[type="checkbox"].ace.ace-switch.ace-switch-4+.lbl::before,
  209. input[type="checkbox"].ace.ace-switch.ace-switch-5+.lbl::before {
  210. text-indent: -39px;
  211. }
  212. .equipCtrl {
  213. border: 1px solid #cecece;
  214. padding: 15px 10px;
  215. background: #f5f5f5;
  216. box-shadow: 1px 1px 4px 1px #cecece;
  217. border-radius: 3px;
  218. cursor: pointer;
  219. }
  220. .equipCtrl:hover {
  221. border-color: #468fcd;
  222. box-shadow: 1px 2px 4px 0px #468fcd;
  223. }
  224. .equipCtrlInp {
  225. margin-top: 20px;
  226. text-align: right;
  227. }
  228. .isonlineicon {
  229. display: inline-block;
  230. width: 8px;
  231. height: 8px;
  232. border-radius: 50%;
  233. margin-right: 7px;
  234. }
  235. .isonlineicon.active {
  236. background: green;
  237. animation: 1s ease 0s infinite normal none running myfirst01;
  238. }
  239. .isonlineicon {
  240. background: #909090;
  241. animation: 1s ease 0s infinite normal none running myfirst02;
  242. }
  243. @keyframes myfirst01 {
  244. 0% {
  245. -moz-box-shadow: 0px 0px 6px 1px green;
  246. box-shadow: 0px 0px 6px 1px green;
  247. }
  248. 100% {
  249. -moz-box-shadow: 0px 0px 6px 1px green;
  250. box-shadow: 0px 0px 6px 1px green;
  251. }
  252. }
  253. @keyframes myfirst02 {
  254. 0% {
  255. -moz-box-shadow: 0px 0px 6px 1px #909090;
  256. box-shadow: 0px 0px 6px 1px #909090;
  257. }
  258. 100% {
  259. -moz-box-shadow: 0px 0px 6px 1px #909090;
  260. box-shadow: 0px 0px 6px 1px #909090;
  261. }
  262. }
  263. .ctrlLoading {
  264. position: absolute;
  265. bottom: 6px;
  266. }
  267. .equipCtrl .fa-cog {
  268. position: absolute;
  269. right: 26px;
  270. font-size: 20px;
  271. color: #3eb983;
  272. top: 11px;
  273. }
  274. .qxzDownCtrl {
  275. display: none;
  276. float: right;
  277. width: 53px;
  278. background: white;
  279. border: 1px solid #8aafce;
  280. color: #6688a6!important;
  281. }
  282. .numName {
  283. display: inline-block;
  284. width: 70%;
  285. overflow: hidden;
  286. text-overflow: ellipsis;
  287. white-space: nowrap;
  288. vertical-align: middle;
  289. }
  290. /* 阈值控制 */
  291. #getthresholdDiv>div,
  292. #gettimingDiv>div {
  293. padding-bottom: 20px;
  294. }
  295. .thresholdCtrl {
  296. background: #4ab8e8;
  297. border-radius: 5px;
  298. color: #fff;
  299. box-shadow: 1px 1px 4px 1px #98dbf8;
  300. border: 1px solid #98dbf8;
  301. padding: 5px 10px;
  302. cursor: pointer;
  303. position: relative;
  304. }
  305. #gettimingDiv .thresholdCtrl {
  306. background: #65b83b;
  307. box-shadow: 1px 1px 4px 1px #d1ffba;
  308. border: 1px solid #65b83b;
  309. }
  310. .setthresholdBtn {
  311. position: absolute;
  312. right: 13px;
  313. top: 12px;
  314. font-size: 20px;
  315. }
  316. .setthresholdBtn:hover {
  317. color: #08ff46;
  318. }
  319. .thresholdCtrl::before {
  320. position: absolute;
  321. content: '';
  322. bottom: 0;
  323. left: 0;
  324. right: 0;
  325. height: 30%;
  326. background: rgba(255, 255, 255, 0.5);
  327. }
  328. .thresholdCtrlName {
  329. line-height: 30px;
  330. font-size: 16px;
  331. }
  332. .thresholdCtrlShowDiv {
  333. overflow: hidden;
  334. }
  335. .thresholdCtrlShowDiv>div {
  336. float: left;
  337. }
  338. .qxys img {
  339. width: 47px;
  340. }
  341. .maxminNum {
  342. font-size: 18px;
  343. line-height: 30px;
  344. margin-top: 11px;
  345. padding-left: 7%;
  346. }
  347. /* 色值阈值框 */
  348. .layui-form-item .layui-input-inline {
  349. width: 44%;
  350. }
  351. #Modal>div,
  352. #timingOnOffModal>div {
  353. margin-top: 20px;
  354. }
  355. .layui-form-mid.layui-word-aux span {
  356. color: red;
  357. }
  358. /* 定时设置 */
  359. #timingOnOffModal .layui-form-label {
  360. width: 100px;
  361. }
  362. </style>
  363. <body>
  364. <div class="content">
  365. <div class="row">
  366. <!-- 左菜单 -->
  367. <div class="col-xs-12 col-sm-3 col-md-2">
  368. <div class="input-group">
  369. <input type="text" class="form-control" id="searchImei" name="searchImei" placeholder="输入编号或名称查询">
  370. <div class="input-group-btn">
  371. <button type="button" id="searchBtn" class="btn btn-default no-border btn-sm">
  372. <i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
  373. </button>
  374. </div>
  375. </div>
  376. <div id="firstpane" class="menu_list">
  377. <p class="menu_head current" id="area_322">设备列表</p>
  378. <div class="menu_body">
  379. <!-- <a href="javascript:;" title="设备15112501" class="text-overflow" id="15112501" data-pid="322">设备15112501</a> -->
  380. </div>
  381. <div class="equipPage">
  382. <!-- <button class="btn btn-minier btn-yellow"><i class="fa fa-sort-up" aria-hidden="true"></i></button> -->
  383. <input type="button" class="btn btn-minier btn-yellow" onclick="gotofirstpage()" value="首页">
  384. <button class="btn btn-minier btn-yellow" id="jianPage" onclick="changePage('jian')">上一页</button>
  385. <span id="currentpage">1</span>页
  386. <button class="btn btn-minier btn-yellow" id="addPage" onclick="changePage('add')">下一页</button>
  387. <span id="totelpage">4</span>页
  388. </div>
  389. </div>
  390. <div class="">
  391. <div class="widget-box" style="margin-top: 20px;">
  392. <div class="widget-title">
  393. <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
  394. <h5>项目信息</h5>
  395. </div>
  396. </div>
  397. <div class="widget-content" style="padding: 0px;margin-top: 8px;">
  398. <div>
  399. <!-- <img src="www.yfzhwlw.com/qxz_photo/default.png" class="equip_photo" width="100%" height="100%" style=""> -->
  400. <form action="" method="post" id="userPhoto" class="form-horizontal" enctype="multipart/form-data">{% csrf_token %}
  401. <input type="hidden" value="" id="qxzPhotoId" name="id">
  402. <div class="personal-avatar">
  403. <div class="top-avatar" id="viewPhotoParent">
  404. <img id="viewPhoto" class="equip_photo" onclick="$('#uploadPhoto').click()" src="" width="100%" height="100%">
  405. </div>
  406. <a class="upload-avatar" href="javascript:;">
  407. <input class="upload-btn" name="upicture" onchange="previewImage(this,'viewPhotoParent','viewPhoto','uploadPhoto','100%',200)"
  408. type="file" id="uploadPhoto">
  409. </a>
  410. <!-- <input type="hidden" name="req" value="photo"> -->
  411. </div>
  412. </form>
  413. </div>
  414. <div class="todo" style="background: white;margin-top: 5px;">
  415. <ul>
  416. <li class="clearfix">
  417. <div class="txt equip_name">&nbsp;&nbsp;项目名称:设备15112501</div>
  418. </li>
  419. <li class="clearfix">
  420. <div class="txt equip_id">&nbsp;&nbsp;设备ID:15112501</div>
  421. </li>
  422. </ul>
  423. </div>
  424. </div>
  425. </div>
  426. </div>
  427. <!-- 右 -->
  428. <div class="col-xs-12 col-sm-9 col-md-10">
  429. <!-- 实时状态 -->
  430. <div class="currTimeStatus">
  431. <div class="widget-box" style="margin-top: 0px;">
  432. <div class="widget-title">
  433. <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
  434. <h5>实时状态</h5>
  435. <span class="span5" style="min-height: 25px;text-align: right;margin-right: 20px;">
  436. <button class="btn btn-white btn-primary" id="updataTime" type="button"></button>
  437. <button class="btn btn-white btn-primary" id="newDataRefresh" onclick="newDataRefresh()" type="button">
  438. <i class="fa fa-refresh" aria-hidden="true"></i>
  439. </button>
  440. </span>
  441. <div style="position: absolute;right: 10px;top: 7px;" id="date_refresh"></div>
  442. </div>
  443. </div>
  444. </div>
  445. <div class="body-content clearfix" id="newStatusBox">
  446. <!-- <div class="dev bg_lb">
  447. <div class="left">
  448. <img class="img-dev" src="{% static '/img/switchBtnIcon.png' %}">
  449. </div>
  450. <div class="right">
  451. <div class="name">风速</div>
  452. <div class="data">
  453. <strong>
  454. <span style="font-size: 25px;">0.0</span>
  455. </strong>m/s</div>
  456. </div>
  457. </div> -->
  458. </div>
  459. <!-- 设备手动控制 -->
  460. <div id="ctrlBoxParentDiv">
  461. <div class="currTimeStatus">
  462. <div class="widget-box">
  463. <div class="widget-title">
  464. <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
  465. <h5>设备手动控制</h5>
  466. <button class="btn btn-white btn-primary qxzDownCtrl" onclick="qxzDownCtrlFun()">
  467. <i class="fa fa-refresh" aria-hidden="true"></i>
  468. </button>
  469. </div>
  470. </div>
  471. </div>
  472. <div class="row handCtrlBox" id="ctrlBox">
  473. <!-- <div class="col-xs-2">
  474. <div class="equipCtrl">
  475. <input type="hidden" value="1">
  476. <div>
  477. <span class="isonlineicon active"></span>
  478. 控制1
  479. </div>
  480. <div class="equipCtrlInp">
  481. <label>
  482. <input name="switch-field-1" checked class="ace ace-switch ace-switch-4 btn-rotate" type="checkbox">
  483. <span class="lbl"></span>
  484. </label>
  485. </div>
  486. </div>
  487. </div> -->
  488. </div>
  489. </div>
  490. <!-- 设备阈值控制 -->
  491. <div id="getthresholdDivParentDiv">
  492. <div class="currTimeStatus">
  493. <div class="widget-box" style="margin-top: 0px;">
  494. <div class="widget-title">
  495. <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
  496. <h5>设备阈值控制</h5>
  497. <button class="btn btn-white btn-primary qxzDownCtrl" id="" onclick="" type="button">
  498. <i class="fa fa-refresh" aria-hidden="true"></i>
  499. </button>
  500. </div>
  501. </div>
  502. </div>
  503. <div class="row" id="getthresholdDiv">
  504. <!-- <div class="col-xs-2 col-sm-3">
  505. <div class="thresholdCtrl">
  506. <div class="setthresholdBtn" onclick="setthresholdFun(this)">
  507. <i class="fa fa-cog setName" aria-hidden="true"></i>
  508. </div>
  509. <input type="hidden" class="currVal" value='{"JK":1,"eKey":1,"upper":700,"lower":300,"method":1}'>
  510. <div class="thresholdCtrlName">
  511. <p>开关1(e1)</p>
  512. </div>
  513. <div class="thresholdCtrlShowDiv">
  514. <div class="qxys">
  515. <div>
  516. <img src="{% static '/img/dev/icon_110.png' %}" alt="">
  517. </div>
  518. <div>雨量累计</div>
  519. </div>
  520. <div class="maxminNum">
  521. <p>最大值:
  522. <span>30</span>
  523. </p>
  524. <p>最小值:
  525. <span>10</span>
  526. </p>
  527. </div>
  528. </div>
  529. <div class="equipCtrlInp">
  530. <label>
  531. <input name="switch-field-1" class="ace ace-switch ace-switch-6" type="checkbox">
  532. <span class="lbl"></span>
  533. </label>
  534. </div>
  535. </div>
  536. </div> -->
  537. </div>
  538. </div>
  539. <!-- 设备定时控制 -->
  540. <div id="timingDivParentDiv">
  541. <div class="currTimeStatus">
  542. <div class="widget-box" style="margin-top: 0px;">
  543. <div class="widget-title">
  544. <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
  545. <h5>设备定时控制</h5>
  546. <button class="btn btn-white btn-primary qxzDownCtrl" id="" onclick="" type="button">
  547. <i class="fa fa-refresh" aria-hidden="true"></i>
  548. </button>
  549. </div>
  550. </div>
  551. </div>
  552. <div class="row" id="gettimingDiv">
  553. <!-- <div class="col-xs-2 col-sm-3">
  554. <div class="thresholdCtrl">
  555. <div class="setthresholdBtn" onclick="timingOnOff(this)">
  556. <i class="fa fa-cog setName" aria-hidden="true"></i>
  557. </div>
  558. <input type="hidden" class="currVal" value='{"JK":1,"StartTime":12,"Duration":10}'>
  559. <div class="thresholdCtrlName">
  560. <p>开关1(e1)</p>
  561. </div>
  562. <div class="thresholdCtrlShowDiv">
  563. <div class="maxminNum">
  564. <p>起始时间:
  565. <span>12</span>
  566. </p>
  567. <p>工作时长:
  568. <span>10</span>
  569. 小时
  570. </p>
  571. </div>
  572. </div>
  573. <div class="equipCtrlInp">
  574. <label>
  575. <input name="switch-field-1" class="ace ace-switch ace-switch-6" type="checkbox">
  576. <span class="lbl"></span>
  577. </label>
  578. </div>
  579. </div>
  580. </div> -->
  581. </div>
  582. </div>
  583. <!-- 24小时数据 -->
  584. <div id="data24Div">
  585. <div class="currTimeStatus">
  586. <div class="widget-box">
  587. <div class="widget-title">
  588. <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
  589. <h5>24小时数据</h5>
  590. </div>
  591. </div>
  592. </div>
  593. <div class="row">
  594. <div class="col-xs-12 col-md-12 col-lg-9">
  595. <table id="newtable" class="table table-striped table-hover">
  596. <thead>
  597. <tr>
  598. <th>传感器通道</th>
  599. <th>通道名称</th>
  600. <th>最小值</th>
  601. <th>最小值时间</th>
  602. <th>最大值</th>
  603. <th>最大值时间</th>
  604. </tr>
  605. </thead>
  606. <tbody>
  607. </tbody>
  608. </table>
  609. </div>
  610. </div>
  611. </div>
  612. </div>
  613. </div>
  614. </div>
  615. <!-- Modal -->
  616. <div id="Modal" class="model" style="display:none">
  617. <div>
  618. <form class="layui-form" action="" id="modelForm" lay-filter="formModel">
  619. <input type="hidden" value="" name="JK">
  620. <input type="hidden" value="" name="eKey">
  621. <div class="layui-form-item">
  622. <label class="layui-form-label">最大值</label>
  623. <div class="layui-input-inline">
  624. <input type="text" name="upper" id="upper" required lay-verify="required" placeholder="请输入最大值" autocomplete="off" class="layui-input">
  625. </div>
  626. </div>
  627. <div class="layui-form-item">
  628. <label class="layui-form-label">最小值</label>
  629. <div class="layui-input-inline">
  630. <input type="text" name="lower" required lay-verify="required" placeholder="请输入最小值" autocomplete="off" class="layui-input">
  631. </div>
  632. </div>
  633. <div class="layui-form-item">
  634. <label class="layui-form-label">规 则</label>
  635. <div class="layui-input-inline">
  636. <input type="radio" name="method" lay-filter="radioSwitch" value="1" title="程序一" checked="">
  637. <input type="radio" name="method" lay-filter="radioSwitch" value="0" title="程序二">
  638. </div>
  639. <div class="layui-form-mid layui-word-aux" id="hintDiv">低于下限
  640. <span>开启</span>,高于上限
  641. <span>关闭</span>
  642. </div>
  643. </div>
  644. </form>
  645. </div>
  646. </div>
  647. <!-- Modal2 -->
  648. <div id="timingOnOffModal" class="model" style="display:none">
  649. <div>
  650. <form class="layui-form" action="" id="modelForm" lay-filter="formModel">
  651. <input type="hidden" value="" name="JK">
  652. <div class="layui-form-item">
  653. <label class="layui-form-label">起始时间:</label>
  654. <div class="layui-input-inline">
  655. <input type="number" name="StartTime" id="starttime" required lay-verify="required|starttimeRegex" placeholder="请输入起始时间"
  656. autocomplete="off" class="layui-input">
  657. <!-- <select name="city" lay-verify="">
  658. <option value="">请选择一个城市</option>
  659. <option value="010">北京</option>
  660. <option value="021">上海</option>
  661. <option value="0571">杭州</option>
  662. </select>
  663. <select name="city" lay-verify="required">
  664. <option value=""></option>
  665. <option value="0">北京</option>
  666. <option value="1">上海</option>
  667. <option value="2">广州</option>
  668. <option value="3">深圳</option>
  669. <option value="4">杭州</option>
  670. </select> -->
  671. </div>
  672. <div class="layui-form-mid layui-word-aux">时间范围(0-23)</div>
  673. </div>
  674. <div class="layui-form-item">
  675. <label class="layui-form-label">工作时长:</label>
  676. <div class="layui-input-inline">
  677. <input type="number" name="Duration" id="Duration" required lay-verify="required|durationRegex" placeholder="请输入工作时长" autocomplete="off"
  678. class="layui-input">
  679. </div>
  680. <div class="layui-form-mid layui-word-aux">工作时长(1-24)</div>
  681. </div>
  682. </form>
  683. </div>
  684. </div>
  685. <script src="{% static '/lib/js/jquery-2.1.4.min.js' %}"></script>
  686. <script src="{% static '/lib/bootstrap-3.3.7/js/bootstrap.js' %}"></script>
  687. <script src="{% static '/lib/layui/layui.all.js' %}"></script>
  688. <script src="{% static '/js/common.js' %}?versions=0.5.0"></script>
  689. <script type="text/javascript">
  690. $.ajaxSetup({
  691. data: { csrfmiddlewaretoken: '{{ csrf_token }}' },
  692. });
  693. </script>
  694. <script>
  695. //默认加载设备列表
  696. getEquipList(1, '');
  697. // 搜索
  698. $('#searchBtn').on('click', function () {
  699. getEquipList(1, $('#searchImei').val())
  700. });
  701. $('#searchImei').on('keyup', function (event) {
  702. if (event.keyCode == 13) {
  703. getEquipList(1, $('#searchImei').val())
  704. }
  705. })
  706. function getEquipList(page, filter) {
  707. $.ajax({
  708. url: 'qxz_page',
  709. type: 'get',
  710. dataType: 'json',
  711. data: {
  712. page: page,
  713. f_id: filter
  714. },
  715. beforeSend: function (XMLHttpRequest) {
  716. loadingFlag = layer.load();
  717. },
  718. success: function (data) {
  719. layer.close(loadingFlag);
  720. if (data.nums) {
  721. var html = '';
  722. var msg = data.ids
  723. var pagecount = Math.ceil(data.nums / 10);
  724. for (var i = 0; i < msg.length; i++) {
  725. if (msg[i].equip_name) {
  726. var equip_name = '设备:' + msg[i].equip_name;
  727. } else {
  728. var equip_name = '设备:' + msg[i].equip_id;
  729. }
  730. // var equip_name = msg[i].equip_name?'---设备名:'+msg[i].equip_name:'';
  731. html += '<a href="javascript:;" title="设备' + msg[i].equip_id + '" class="text-overflow" id="' + msg[i].equip_id + '" data-pid="322">' + equip_name + '</a>'
  732. }
  733. $('#firstpane .menu_body').html(html);
  734. $('.equipPage').show();
  735. $('#totelpage').html(pagecount)
  736. // 菜单栏
  737. $("#firstpane .menu_body:eq(0) a:eq(0)").addClass('menu-active');
  738. $(".menu_body a").click(function () {
  739. $(".menu_head").removeClass("currAstive");
  740. $(".menu_body a").removeClass("menu-active");
  741. $(this).addClass("menu-active");
  742. $(this).parent().prev().addClass('currAstive');
  743. var facId = $(this).attr("id");
  744. if (facId && facId != null && facId != "") {
  745. loadProject(facId);
  746. $('#qxzPhotoId').val(facId);
  747. }
  748. });
  749. loadProject(msg[0].equip_id);
  750. $('#qxzPhotoId').val(msg[0].equip_id)
  751. } else {
  752. $('.equipPage').hide();
  753. var html = '<a href="javascript:;" class="text-overflow nulldata" data-pid="322">暂未设备</a>'
  754. $('#firstpane .menu_body').html(html);
  755. }
  756. },
  757. error: function (type) {
  758. layer.close(loadingFlag);
  759. }
  760. })
  761. }
  762. //设备状态
  763. function loadProject(facId) {
  764. $.ajax({
  765. url: 'qxz_detail',
  766. type: 'get',
  767. dataType: 'json',
  768. data: {
  769. id: facId,
  770. },
  771. beforeSend: function (XMLHttpRequest) {
  772. loadingFlag = layer.load();
  773. },
  774. success: function (data) {
  775. layer.close(loadingFlag);
  776. var myDate = new Date();//获取系统当前时间
  777. $('#date_refresh').html(myDate.getHours() + ':' + myDate.getMinutes() + ':' + myDate.getSeconds())
  778. // 实时状态
  779. var newData = data.new_data;
  780. newStatus('newStatusBox', newData, facId)
  781. // var runStatus = eval('('+data.qxz_switch+')');
  782. addCtrlBtn(data.qxz_switch, data.switch_name)
  783. var dayData = data.all_data;
  784. if (data.qxz_switch && (data.qxz_switch.length != 2)) {
  785. $('#ctrlBoxParentDiv').show();
  786. $('#getthresholdDivParentDiv').show();
  787. $('#timingDivParentDiv').show();
  788. $('#data24Div').hide();
  789. gettimimgFun(data);
  790. getthresholdFun(data);
  791. scrollBar()
  792. } else { // 无开关显示24小时数据
  793. $('#ctrlBoxParentDiv').hide();
  794. $('#getthresholdDivParentDiv').hide();
  795. $('#timingDivParentDiv').hide();
  796. $('#data24Div').show();
  797. $("#newtable tr:not(:first)").remove();
  798. if (dayData.length) {
  799. Fill_Table('newtable', dayData, facId)
  800. } else {
  801. Fill_null_Table('newtable', dayData, facId)
  802. }
  803. }
  804. },
  805. error: function (type) {
  806. layer.close(loadingFlag);
  807. }
  808. })
  809. }
  810. // 阈值请求
  811. function getthresholdFun(data) {
  812. var switch_name = data.switch_name;
  813. var qxz_switch = data.qxz_switch;
  814. if (data.auto_list.length) {
  815. var switchData = eval('(' + data.auto_list + ')');
  816. var qxz_switch = eval('(' + data.qxz_switch + ')');
  817. var qxz_list = data.new_data;
  818. if (switch_name.length > 2) {
  819. var switch_name = eval('(' + switch_name + ')');
  820. } else {
  821. var switch_name = [];
  822. }
  823. } else {
  824. var switchData = [];
  825. var qxz_list = [];
  826. var switch_name = [];
  827. }
  828. if (switchData.length) {
  829. var html = '';
  830. for (var i = 0; i < switchData.length; i++) {
  831. if (switchData[i].JK != 255) {
  832. if (switchData[i].upper == 32767 || switchData[i].lower == 32767) {
  833. var check = false;
  834. } else {
  835. var check = true;
  836. }
  837. // 判断通道号
  838. if (!isNaN(switchData[i].eKey)) {
  839. var eknum = switchData[i].eKey + 1;
  840. var ek = 'e' + eknum;
  841. } else {
  842. var ek = switchData[i].eKey;
  843. }
  844. // 开关名
  845. if (switchData[i].JK == qxz_switch[i].JK) {
  846. if(switch_name.length){
  847. var name = switch_name[i].name;
  848. }else{
  849. var name = '开关'+qxz_switch[i].JK;
  850. }
  851. } else {
  852. var name = timingData[i].JK;
  853. }
  854. for (var j = 0; j < qxz_list.length; j++) {
  855. if (qxz_list[j].eKey == ek) {
  856. var eNum = qxz_list[j].unit[0];
  857. var txt = qxz_list[j].unit[1];
  858. html += '<div class="col-xs-2 col-sm-3"><div class="thresholdCtrl">' +
  859. '<div class="setthresholdBtn" onclick="setthresholdFun(this)">' +
  860. '<i class="fa fa-cog setName" aria-hidden="true"></i></div>' +
  861. '<input type="hidden" class="currVal" value=\'' + JSON.stringify(switchData[i]) + '\'>' +
  862. '<div class="thresholdCtrlName"><p>' + name + '(通道' + switchData[i].eKey + ')</p></div>' +
  863. '<div class="thresholdCtrlShowDiv"><div class="qxys"><div>' +
  864. '<img src="http://www.yfzhwlw.com/static/img/dev/icon_' + eNum + '.png" alt=""></div>' +
  865. '<div>' + txt + qxz_list[j].unit[2] + '</div></div><div class="maxminNum"><p>最大值:<span>' + switchData[i].upper + '</span></p>' +
  866. '<p>最小值:<span>' + switchData[i].lower + '</span></p></div></div><div class="equipCtrlInp">';
  867. if (check) {
  868. html += '<label><input name="switch-field-1" class="ace ace-switch ace-switch-6" checked="checked" type="checkbox">' +
  869. '<span class="lbl"></span></label></div></div></div>';
  870. } else {
  871. html += '<label><input name="switch-field-1" class="ace ace-switch ace-switch-6" type="checkbox">' +
  872. '<span class="lbl"></span></label></div></div></div>';
  873. }
  874. break;
  875. }
  876. }
  877. }
  878. if (i == switchData.length - 1) {
  879. if (html) {
  880. $('#getthresholdDiv').html(html)
  881. } else {
  882. $('#getthresholdDiv').html('<div style="text-align:center">空</div>')
  883. }
  884. }
  885. }
  886. } else {
  887. $('#getthresholdDiv').html('<div style="text-align:center">空</div>')
  888. }
  889. }
  890. // 定时请求
  891. function gettimimgFun(data) {
  892. var switch_name = data.switch_name;
  893. var qxz_switch = data.qxz_switch;
  894. if (data.timing_list.length) {
  895. var timingData = eval('(' + data.timing_list + ')');
  896. var qxz_switch = eval('(' + data.qxz_switch + ')');
  897. var qxz_list = data.qxz_list;
  898. if(switch_name.length > 2){
  899. var switch_name = eval('(' + switch_name + ')');
  900. }else{
  901. var switch_name = [];
  902. }
  903. } else {
  904. var timingData = [];
  905. var qxz_list = [];
  906. var switch_name = [];
  907. }
  908. if (timingData.length) {
  909. var html = '';
  910. for (var i = 0; i < timingData.length; i++) {
  911. if (timingData[i].JK != 255) {
  912. if (timingData[i].Duration == 32767 || timingData[i].StartTime == 32767) {
  913. var check = false;
  914. var curCheckedVal = {
  915. JK: timingData[i].JK,
  916. StartTime: '--',
  917. Duration: '--'
  918. }
  919. var startTime = '--';
  920. var duration = '--';
  921. } else {
  922. var check = true;
  923. var curCheckedVal = {
  924. JK: timingData[i].JK,
  925. StartTime: timingData[i].StartTime,
  926. Duration: timingData[i].Duration
  927. }
  928. var startTime = timingData[i].StartTime;
  929. var duration = timingData[i].Duration;
  930. }
  931. if (timingData[i].JK == qxz_switch[i].JK) {
  932. if(switch_name.length){
  933. var name = switch_name[i].name;
  934. }else{
  935. var name = '开关'+qxz_switch[i].JK;
  936. }
  937. } else {
  938. var name = timingData[i].JK;
  939. }
  940. html += '<div class="col-xs-2 col-sm-3"><div class="thresholdCtrl">' +
  941. '<div class="setthresholdBtn" onclick="timingOnOff(this)">' +
  942. '<i class="fa fa-cog setName" aria-hidden="true"></i></div>' +
  943. '<input type="hidden" class="currVal" value=\'' + JSON.stringify(curCheckedVal) + '\'>' +
  944. '<div class="thresholdCtrlName"><p>' + name + '</p></div>' +
  945. '<div class="thresholdCtrlShowDiv"><div class="maxminNum">' +
  946. '<p>起始时间:<span>' + startTime + '</span>点</p><p>工作时长:<span>' + duration + '</span>小时</p>' +
  947. '</div></div><div class="equipCtrlInp"><label>';
  948. if (check) {
  949. html += '<input name="switch-field-1" checked class="ace ace-switch ace-switch-6" type="checkbox">' +
  950. '<span class="lbl"></span></label></div></div></div>';
  951. } else {
  952. html += '<input name="switch-field-1" class="ace ace-switch ace-switch-6" type="checkbox">' +
  953. '<span class="lbl"></span></label></div></div></div>';
  954. }
  955. }
  956. if (i == timingData.length - 1) {
  957. if (html) {
  958. $('#gettimingDiv').html(html)
  959. } else {
  960. $('#gettimingDiv').html('<div style="text-align:center">空</div>')
  961. }
  962. }
  963. }
  964. } else {
  965. $('#gettimingDiv').html('<div style="text-align:center">空</div>')
  966. }
  967. }
  968. // 控制按钮
  969. function addCtrlBtn(data, switch_name) {
  970. if (data && switch_name.length > 2) {
  971. var data = eval('(' + data + ')');
  972. var ctrl_name = eval('(' + switch_name + ')');
  973. $('.qxzDownCtrl').show();
  974. } else if (data) {
  975. var data = eval('(' + data + ')');
  976. var ctrl_name = [];
  977. } else {
  978. var data = []
  979. $('.qxzDownCtrl').hide();
  980. }
  981. if (data.length) {
  982. var html = '';
  983. for (var i = 0; i < data.length; i++) {
  984. if (data[i].status == 0) {
  985. var curClass = '';
  986. } else {
  987. var curClass = 'active';
  988. }
  989. if (data[i].status == 0) {
  990. var curChecked = ''; //关
  991. } else {
  992. var curChecked = 'checked';
  993. }
  994. if (ctrl_name.length) {
  995. if (ctrl_name[i].name != '') {
  996. var switch_name = ctrl_name[i].name;
  997. } else {
  998. var switch_name = '开关' + ctrl_name[i].JK;
  999. }
  1000. } else {
  1001. var switch_name = '开关' + data[i].JK;
  1002. }
  1003. html += '<div class="col-xs-2"><div class="equipCtrl"><input type="hidden" class="currStutas" value="' + data[i].JK + '">' +
  1004. '<i class="fa fa-cog setName" aria-hidden="true"></i><div><span class="isonlineicon ' + curClass + '"></span><span class="numName">' + switch_name + '</span></div><div class="equipCtrlInp">' +
  1005. '<label><input name="switch-field-1" ' + curChecked + ' class="ace ace-switch ace-switch-4 btn-rotate" type="checkbox">' +
  1006. '<span class="lbl"></span></label></div></div></div>';
  1007. if (i == data.length - 1) {
  1008. $('#ctrlBox').html(html);
  1009. }
  1010. }
  1011. } else {
  1012. $('#ctrlBox').html('<div style="text-align:center">空</div>');
  1013. }
  1014. }
  1015. $('#ctrlBox').on('click', '.btn-rotate', function () {
  1016. var _this = this;
  1017. $(this).parents('.equipCtrl').find('.ctrlLoading').remove()
  1018. $(this).attr('disabled', true);
  1019. $(this).parents('.equipCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
  1020. var currWay = $(this).parents('.equipCtrl').find('.currStutas').val();
  1021. var imei = $('#qxzPhotoId').val();
  1022. if ($(this).is(":checked")) {
  1023. var oldStatus = 0;
  1024. var currStutas = 1;
  1025. } else {
  1026. var oldStatus = 1;
  1027. var currStutas = 0;
  1028. }
  1029. $.ajax({
  1030. url: 'qxz_switch',
  1031. type: 'post',
  1032. data: {
  1033. 'req': 'set',
  1034. 'imei': imei,
  1035. 'way': currWay,
  1036. 'switch': currStutas
  1037. },
  1038. success: function (data) {
  1039. setTimeout(function () {
  1040. var id = $('#firstpane .menu-active').attr('id')
  1041. loadProject(id);
  1042. }, 5000)
  1043. // $(_this).attr('disabled', false);
  1044. // $(_this).parents('.equipCtrl').find('.ctrlLoading').html('');
  1045. // if (currStutas) {
  1046. // $(_this).parents('.equipCtrl').find('.isonlineicon').addClass('active')
  1047. // } else {
  1048. // $(_this).parents('.equipCtrl').find('.isonlineicon').removeClass('active')
  1049. // }
  1050. },
  1051. error: function (type) {
  1052. layer.close(loadingFlag);
  1053. $(_this).parents('.equipCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
  1054. $(_this).attr('disabled', false);
  1055. if (oldStatus) {
  1056. $(_this).prop('checked', true);
  1057. $(_this).parents('.equipCtrl').find('.isonlineicon').addClass('active')
  1058. } else {
  1059. $(_this).prop('checked', '');
  1060. $(_this).parents('.equipCtrl').find('.isonlineicon').removeClass('active')
  1061. }
  1062. }
  1063. })
  1064. })
  1065. // 下发控制名称
  1066. $('#ctrlBox').on('click', '.setName', function () {
  1067. var _this = this;
  1068. var ele = $(this).parents('.equipCtrl').find('.numName');
  1069. var currWay = $(this).parents('.equipCtrl').find('.currStutas').val();
  1070. layui.use('layer', function () {
  1071. var layer = layui.layer;
  1072. layer.prompt({ title: '自定义名称', offset: '300px', formType: 0, value: ele.html(), maxlength: 10 }, function (text, index) {
  1073. if (text == ele.html()) {
  1074. return false;
  1075. layer.close(index);
  1076. layer.msg('演示完毕!您的口令:' + text);
  1077. ele.html(text)
  1078. }
  1079. $.ajax({
  1080. url: 'qxz_switch_name',
  1081. type: 'post',
  1082. data: {
  1083. 'imei': $('#qxzPhotoId').val(),
  1084. 'way': currWay,
  1085. 'sw_name': text
  1086. },
  1087. success: function (data) {
  1088. if (data == 0) {
  1089. ele.html(text)
  1090. }
  1091. layer.close(index);
  1092. },
  1093. error: function (type) {
  1094. $(_this).parents('.equipCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
  1095. $(_this).attr('disabled', false);
  1096. if (oldStatus) {
  1097. $(_this).prop('checked', true);
  1098. $(_this).parents('.equipCtrl').find('.isonlineicon').addClass('active')
  1099. } else {
  1100. $(_this).prop('checked', '');
  1101. $(_this).parents('.equipCtrl').find('.isonlineicon').removeClass('active')
  1102. }
  1103. }
  1104. })
  1105. });
  1106. });
  1107. })
  1108. // 获取最新控制按钮状态
  1109. function qxzDownCtrlFun() {
  1110. $.ajax({
  1111. url: 'qxz_switch',
  1112. type: 'post',
  1113. data: {
  1114. 'req': 'conf', //
  1115. 'imei': $('#qxzPhotoId').val(),
  1116. },
  1117. beforeSend: function () {
  1118. loadFlage = layer.load();
  1119. },
  1120. complete: function () {
  1121. setTimeout(function () {
  1122. layer.close(loadFlage);
  1123. }, 5000)
  1124. },
  1125. success: function (data) {
  1126. setTimeout(function () {
  1127. loadProject($('#qxzPhotoId').val())
  1128. }, 5000)
  1129. }
  1130. })
  1131. }
  1132. // 获取最新数据
  1133. function newDataRefresh() {
  1134. $.ajax({
  1135. url: 'qxz_switch',
  1136. type: 'post',
  1137. data: {
  1138. 'req': 'read',
  1139. 'imei': $('#qxzPhotoId').val(),
  1140. },
  1141. beforeSend: function () {
  1142. loadFlage = layer.load();
  1143. },
  1144. complete: function () {
  1145. setTimeout(function () {
  1146. layer.close(loadFlage);
  1147. }, 5000)
  1148. },
  1149. success: function (data) {
  1150. setTimeout(function () {
  1151. loadProject($('#qxzPhotoId').val())
  1152. }, 5000)
  1153. }
  1154. })
  1155. }
  1156. // 设备列表
  1157. var currpage = 1;
  1158. function changePage(symbol) {
  1159. var totelpage = Number($('#totelpage').html());
  1160. if (symbol == 'add') {
  1161. if (currpage < totelpage) {
  1162. currpage++;
  1163. $('#currentpage').html(currpage);
  1164. $('addPage').attr('disable', 'false')
  1165. } else {
  1166. $('addPage').attr('disable', 'true')
  1167. return false;
  1168. }
  1169. } else {
  1170. if (currpage > 1) {
  1171. currpage--;
  1172. $('#currentpage').html(currpage);
  1173. $('jianPage').attr('disable', 'false')
  1174. } else {
  1175. $('jianPage').attr('disable', 'true')
  1176. return false;
  1177. }
  1178. }
  1179. getEquipList(currpage, $('#searchImei').val())
  1180. }
  1181. // 首页
  1182. function gotofirstpage() {
  1183. currpage = 1;
  1184. $('#currentpage').html(1);
  1185. getEquipList(1, $('#searchImei').val())
  1186. }
  1187. // 定时刷新
  1188. // msgInterval = setInterval(function () {
  1189. // var currid = $('#firstpane .menu-active').attr('id');
  1190. // loadProject(currid);
  1191. // }, 60000);
  1192. var waterTempId = [16062009, 16062010, 16062011, 16062012, 16062013, 16062014, 16062015, 16062016, 16062017, 16062018, 16062019, 16062020, 16062021, 16062022, 16062023, 16062024, 16062025];
  1193. // 实时状态
  1194. function newStatus(statusBox, dat, facId) {
  1195. var html = '';
  1196. $(document.getElementById(statusBox)).html('');
  1197. if (dat.length) {
  1198. for (var i = 0; i < dat.length; i++) {
  1199. var random = ['bg_lb', 'bg_ly', 'bg_ls', 'bg_lg', 'bg_lo', 'bg_lr']; //颜色随机
  1200. var unit = dat[i].unit;
  1201. if (unit[0] == '106' && (waterTempId.indexOf(parseInt(facId)) != -1)) {
  1202. var elementName = '水温';
  1203. var curUnit = unit[2];
  1204. var curVal = dat[i].eValue;
  1205. var icon = unit[0];
  1206. } else if (dat[i].eKey.substr(1) == '16' && (facId == '16062388')) { // 徐丹 16062388气象站
  1207. var elementName = '氮';
  1208. var curUnit = unit[2];
  1209. var curVal = dat[i].eValue;
  1210. var icon = 'n';
  1211. } else if (dat[i].eKey.substr(1) == '15' && (facId == '16062388')) { // 徐丹 16062388气象站
  1212. var elementName = '磷';
  1213. var curUnit = unit[2];
  1214. var curVal = dat[i].eValue;
  1215. var icon = 'p';
  1216. } else if (dat[i].eKey.substr(1) == '5' && (facId == '16062388')) { // 徐丹 16062388气象站
  1217. var elementName = '钾';
  1218. var curUnit = unit[2];
  1219. var curVal = dat[i].eValue;
  1220. var icon = 'k';
  1221. } else {
  1222. var elementName = unit[1];
  1223. var curUnit = unit[2];
  1224. var curVal = dat[i].eValue;
  1225. var icon = unit[0];
  1226. }
  1227. var colorClass = unit[0] % 4;
  1228. html += '<div class="dev ' + random[colorClass] + '"><div class="left">' +
  1229. '<img class="img-dev" src="/static/img/dev/icon_' + icon + '.png">' +
  1230. '</div><div class="right"><div class="name">' + elementName + '</div>' +
  1231. '<div class="data"><strong><span style="font-size: 25px;">' + curVal + '</span>' +
  1232. '</strong>' + curUnit + '</div></div><div class="aisle">通道' + dat[i].eKey.substr(1) + '</div></div>';
  1233. }
  1234. $(document.getElementById(statusBox)).append(html);
  1235. $('#updataTime').html('数据更新时间:' + dat[0].upl_time)
  1236. if (dat[0].equip_name) {
  1237. $('.widget-content .equip_name').html(dat[0].equip_name);
  1238. } else {
  1239. $('.widget-content .equip_name').html('项目名称:设备' + dat[0].equip_id);
  1240. }
  1241. $('.widget-content .equip_id').html('设备ID:' + dat[0].equip_id);
  1242. $('#viewPhoto').attr('src', dat[0].qxz_picture);
  1243. scrollBar()
  1244. } else {
  1245. html = '空';
  1246. $(document.getElementById(statusBox)).append(html);
  1247. $('#updataTime').html('暂无上传数据')
  1248. $('.widget-content .equip_name').html('');
  1249. var id = $('#firstpane .menu-active').attr('id')
  1250. $('.widget-content .equip_id').html('设备ID:' + id);
  1251. $('#viewPhoto').attr('src', 'qxz_photo/default.jpg');
  1252. scrollBar()
  1253. }
  1254. scrollBar()
  1255. }
  1256. // 24小时数据
  1257. function Fill_Table(table_id, dat, facId) {
  1258. //js循环读取json数据
  1259. var table = document.getElementById(table_id).children[1];
  1260. for (var i = 0; i < dat.length; i++) {
  1261. var row = table.insertRow(table.rows.length);
  1262. var c1 = row.insertCell(0);
  1263. c1.innerHTML = dat[i].ekey;
  1264. var c2 = row.insertCell(1);
  1265. var unit = dat[i].unit
  1266. if (unit[0] == '106' && (waterTempId.indexOf(parseInt(facId)) != -1)) {
  1267. var elementName = '水温';
  1268. } else {
  1269. var elementName = unit[1];
  1270. }
  1271. c2.innerHTML = elementName + '(' + unit[2] + ')';
  1272. var c3 = row.insertCell(2);
  1273. c3.innerHTML = dat[i].min;
  1274. var c4 = row.insertCell(3);
  1275. var min_time = dat[i].min_time;
  1276. var minlength = min_time.length - 1;
  1277. c4.innerHTML = min_time.substring(1, minlength);
  1278. var c5 = row.insertCell(4);
  1279. c5.innerHTML = dat[i].max;
  1280. var c6 = row.insertCell(5);
  1281. var max_time = dat[i].max_time;
  1282. var maxlength = max_time.length - 1;
  1283. c6.innerHTML = max_time.substring(1, maxlength);
  1284. if (i == dat.length - 1) {
  1285. scrollBar()
  1286. }
  1287. }
  1288. }
  1289. function Fill_null_Table(table_id) {
  1290. var table = document.getElementById(table_id).children[1];
  1291. var row = table.insertRow(table.rows.length);
  1292. var c1 = row.insertCell(0);
  1293. c1.setAttribute('colspan', '16');
  1294. c1.setAttribute('class', 'nullData');
  1295. c1.innerHTML = "暂无数据";
  1296. scrollBar()
  1297. }
  1298. window.onresize = function () {
  1299. scrollBar()
  1300. }
  1301. // file 文件
  1302. // divId div id
  1303. // imgId 图片id
  1304. // fileId 文件id
  1305. // width 图片宽
  1306. // height 图片高
  1307. function previewImage(file, divId, imgId, fileId, width, height) {
  1308. width = $('#viewPhotoParent').width();
  1309. var div = document.getElementById(divId);
  1310. if (file.files && file.files[0]) {
  1311. if (file.files[0].size / 1024 / 1024 < 4) {
  1312. sendUserPhoto();
  1313. div.innerHTML = '<img id=' + imgId + ' onclick=$("#' + fileId + '").click()>';
  1314. var img = document.getElementById(imgId);
  1315. img.onload = function () {
  1316. // var rect = clacImgZoomParam(width, height, img.offsetWidth, img.offsetHeight);
  1317. img.width = width;
  1318. img.height = height;
  1319. // img.style.marginTop = rect.top+'px';
  1320. }
  1321. var reader = new FileReader();
  1322. reader.onload = function (evt) {
  1323. img.src = evt.target.result;
  1324. // $(window.parent.document).find('.nav-user-photo').attr('src',evt.target.result);
  1325. }
  1326. reader.readAsDataURL(file.files[0]);
  1327. // $('#userPhoto').submit();
  1328. } else {
  1329. $(file).val('');
  1330. layer.alert("图片过大!");
  1331. }
  1332. } else {//兼容IE
  1333. var sFilter = 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
  1334. file.select();
  1335. if (document.selection != undefined) {
  1336. var src = document.selection.createRange().text;
  1337. div.innerHTML = '<img id=' + imgId + '>';
  1338. var img = document.getElementById(imgId);
  1339. img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
  1340. var rect = clacImgZoomParam(width, height, img.offsetWidth, img.offsetHeight);
  1341. status = ('rect:' + rect.top + ',' + rect.left + ',' + rect.width + ',' + rect.height);
  1342. div.innerHTML = "<div id=divhead style='width:" + rect.width + "px;height:" + rect.height + "px;" + sFilter + src + "\"'></div>";
  1343. }
  1344. }
  1345. }
  1346. function clacImgZoomParam(maxWidth, maxHeight, width, height) {
  1347. var param = { top: 0, left: 0, width: width, height: height };
  1348. if (width > maxWidth || height > maxHeight) {
  1349. var rateWidth = width / maxWidth;
  1350. var rateHeight = height / maxHeight;
  1351. if (rateWidth > rateHeight) {
  1352. param.width = maxWidth;
  1353. param.height = Math.round(height / rateWidth);
  1354. } else {
  1355. param.width = Math.round(width / rateHeight);
  1356. param.height = maxHeight;
  1357. }
  1358. }
  1359. param.left = Math.round((maxWidth - param.width) / 2);
  1360. param.top = Math.round((maxHeight - param.height) / 2);
  1361. return param;
  1362. }
  1363. // 上传图片
  1364. function sendUserPhoto() {
  1365. var formData = new FormData($("#userPhoto")[0]);
  1366. $.ajax({
  1367. url: 'qxz_photo',
  1368. type: 'POST',
  1369. data: formData,
  1370. contentType: false,
  1371. processData: false,
  1372. success: function (data) {
  1373. if (data == 0) {
  1374. $(window.parent.document).find('.nav-user-photo').attr('src', $('#viewPhoto').prop('src'));
  1375. $('#uploadPhoto').val('');
  1376. }
  1377. else { layer.msg("上传失败!"); return false; }
  1378. }
  1379. });
  1380. }
  1381. // 设置阈值
  1382. function setthresholdFun(ele) {
  1383. var obj = $(ele);
  1384. var currValstr = obj.next().val();
  1385. var currVal = eval('(' + currValstr + ')');
  1386. layui.use(['layer', 'form'], function () {
  1387. var rule0 = "低于下限<span>开启</span>,高于上限<span>关闭</span>";
  1388. var rule1 = "低于下限<span>关闭</span>,高于上限<span>开启</span>";
  1389. var layer = layui.layer;
  1390. var form = layui.form;
  1391. //给表单赋值
  1392. form.val("formModel", {
  1393. "JK": currVal.JK
  1394. , "eKey": currVal.eKey
  1395. , "upper": currVal.upper
  1396. , "lower": currVal.lower
  1397. , "method": currVal.method
  1398. });
  1399. if (currVal.method == 1) {
  1400. $('#hintDiv').html(rule1)
  1401. } else {
  1402. $('#hintDiv').html(rule0)
  1403. }
  1404. form.on('radio(radioSwitch)', function (data) {
  1405. // console.log(data.value); //被点击的radio的value值
  1406. if (data.value == 1) {
  1407. $('#hintDiv').html(rule1)
  1408. } else {
  1409. $('#hintDiv').html(rule0)
  1410. }
  1411. });
  1412. layer.open({
  1413. type: 1,
  1414. title: '阈值设置',
  1415. offset: '380px',
  1416. btn: ['确定', '取消'],
  1417. area: ['600px', '300px'], //宽高
  1418. content: $('#Modal'),
  1419. success: function (layero, index) { // 成功弹出后回调
  1420. // 添加form标识
  1421. layero.addClass('layui-form');
  1422. // 将保存按钮改变成提交按钮
  1423. layero.find('.layui-layer-btn0').attr({
  1424. 'lay-filter': 'setYuzhi',
  1425. 'lay-submit': ''
  1426. });
  1427. },
  1428. yes: function (index, layero) {
  1429. form.on('submit(setYuzhi)', function (data) {
  1430. var dat = data.field;
  1431. if (parseInt(data.field.upper) < parseInt(data.field.lower)) {
  1432. layer.tips('最大值不能小于最小值!', $('#upper'));
  1433. return false;
  1434. }
  1435. var hideVal = JSON.stringify(data.field)
  1436. var id = $('#firstpane .menu-active').attr('id')
  1437. data.field.equip_id = id;
  1438. var curinputBtn = obj.parent().find('.ace-switch');
  1439. if (curinputBtn.is(":checked")) {
  1440. var oldStatus = 0;
  1441. var currStutas = 1;
  1442. } else {
  1443. var oldStatus = 1;
  1444. var currStutas = 0;
  1445. }
  1446. obj.parents('.thresholdCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
  1447. $.ajax({
  1448. url: 'qxz_value_mqtt',
  1449. type: 'post',
  1450. data: data.field,
  1451. success: function (data) {
  1452. setTimeout(function () {
  1453. curinputBtn.attr('disabled', false);
  1454. curinputBtn.parents('.thresholdCtrl').find('.ctrlLoading').html('');
  1455. obj.parent().find('.maxminNum').find('p').eq(0).find('span').html(dat.upper)//最大值
  1456. obj.parent().find('.maxminNum').find('p').eq(1).find('span').html(dat.lower)//最小值
  1457. obj.parents('.thresholdCtrl').find('.ace-switch').prop('checked', 'checked');//开启阈值
  1458. var id = $('#firstpane .menu-active').attr('id')
  1459. loadProject(id);
  1460. }, 5000)
  1461. },
  1462. error: function (type) {
  1463. curinputBtn.parents('.thresholdCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
  1464. curinputBtn.attr('disabled', false);
  1465. }
  1466. })
  1467. // $('.maxminNum')
  1468. layer.closeAll(); //疯狂模式,关闭所有层
  1469. return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
  1470. });
  1471. }
  1472. , btn2: function (index, layero) {
  1473. $('#Modal').hide()
  1474. //return false 开启该代码可禁止点击该按钮关闭
  1475. }
  1476. });
  1477. });
  1478. }
  1479. // 下发阈值控制
  1480. $('#getthresholdDiv').on('click', '.ace-switch', function () {
  1481. var _this = this;
  1482. $(this).parents('.thresholdCtrl').find('.ctrlLoading').remove()
  1483. $(this).attr('disabled', true);
  1484. $(this).parents('.thresholdCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
  1485. var currVal = $(this).parents('.thresholdCtrl').find('.currVal').val();
  1486. var currWayjson = JSON.parse(currVal);
  1487. var id = $('#firstpane .menu-active').attr('id')
  1488. currWayjson.equip_id = id;
  1489. if ($(this).is(":checked")) { //开启
  1490. var oldStatus = 0;
  1491. var currStutas = 1;
  1492. } else { //关闭
  1493. var oldStatus = 1;
  1494. var currStutas = 0;
  1495. currWayjson.upper = '32767';
  1496. currWayjson.lower = '32767';
  1497. }
  1498. $.ajax({
  1499. url: 'qxz_value_mqtt',
  1500. type: 'post',
  1501. data: currWayjson,
  1502. success: function (data) {
  1503. setTimeout(function () {
  1504. $(_this).attr('disabled', false);
  1505. $(_this).parents('.thresholdCtrl').find('.ctrlLoading').html('');
  1506. var id = $('#firstpane .menu-active').attr('id')
  1507. loadProject(id);
  1508. }, 5000)
  1509. },
  1510. error: function (type) {
  1511. $(_this).parents('.thresholdCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
  1512. $(_this).attr('disabled', false);
  1513. if (oldStatus) {
  1514. $(_this).prop('checked', true);
  1515. } else {
  1516. $(_this).prop('checked', '');
  1517. }
  1518. }
  1519. })
  1520. })
  1521. // 定时开关
  1522. function timingOnOff(ele) {
  1523. var obj = $(ele);
  1524. var currValstr = obj.next().val();
  1525. var currVal = eval('(' + currValstr + ')');
  1526. layui.use(['layer', 'form'], function () {
  1527. var layer = layui.layer;
  1528. var form = layui.form;
  1529. form.verify({
  1530. starttimeRegex: function (value, item) { //value:表单的值、item:表单的DOM对象
  1531. if (value < 0 || value > 23) {
  1532. return '请输入范围内数值';
  1533. }
  1534. },
  1535. durationRegex: function (value, item) { //value:表单的值、item:表单的DOM对象
  1536. if (value < 1 || value > 24) {
  1537. return '请输入范围内数值';
  1538. }
  1539. }
  1540. });
  1541. //给表单赋值
  1542. form.val("formModel", {
  1543. "JK": currVal.JK
  1544. , "StartTime": currVal.StartTime
  1545. , "Duration": currVal.Duration
  1546. });
  1547. layer.open({
  1548. type: 1,
  1549. title: '阈值设置',
  1550. offset: '380px',
  1551. btn: ['确定', '取消'],
  1552. area: ['600px', '300px'], //宽高
  1553. content: $('#timingOnOffModal'),
  1554. success: function (layero, index) { // 成功弹出后回调
  1555. // 添加form标识
  1556. layero.addClass('layui-form');
  1557. // 将保存按钮改变成提交按钮
  1558. layero.find('.layui-layer-btn0').attr({
  1559. 'lay-filter': 'setdingshi',
  1560. 'lay-submit': ''
  1561. });
  1562. },
  1563. yes: function (index, layero) {
  1564. form.on('submit(setdingshi)', function (data) {
  1565. var hideVal = JSON.stringify(data.field)
  1566. var dat = data.field;
  1567. var curinputBtn = obj.parent().find('.ace-switch');
  1568. if (curinputBtn.is(":checked")) {
  1569. var oldStatus = 0;
  1570. var currStutas = 1;
  1571. } else {
  1572. var oldStatus = 1;
  1573. var currStutas = 0;
  1574. }
  1575. var id = $('#firstpane .menu-active').attr('id')
  1576. dat.equip_id = id;
  1577. obj.parents('.thresholdCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
  1578. $.ajax({
  1579. url: 'qxz_timing_mqtt',
  1580. type: 'post',
  1581. data: dat,
  1582. success: function (data) {
  1583. setTimeout(function () {
  1584. obj.next().val(hideVal)
  1585. curinputBtn.attr('disabled', false);
  1586. curinputBtn.parents('.thresholdCtrl').find('.ctrlLoading').html('');
  1587. obj.parent().find('.maxminNum').find('p').eq(0).find('span').html(dat.StartTime)//最大值
  1588. obj.parent().find('.maxminNum').find('p').eq(1).find('span').html(dat.Duration)//最小值
  1589. obj.parents('.thresholdCtrl').find('.ace-switch').prop('checked', 'checked');//开启阈值
  1590. var id = $('#firstpane .menu-active').attr('id')
  1591. loadProject(id);
  1592. }, 5000)
  1593. },
  1594. error: function (type) {
  1595. curinputBtn.parents('.thresholdCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
  1596. curinputBtn.attr('disabled', false);
  1597. }
  1598. })
  1599. // $('.maxminNum')
  1600. layer.closeAll(); //疯狂模式,关闭所有层
  1601. return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
  1602. });
  1603. }
  1604. , btn2: function (index, layero) {
  1605. $('#Modal').hide()
  1606. //return false 开启该代码可禁止点击该按钮关闭
  1607. }
  1608. });
  1609. });
  1610. }
  1611. $('#starttime').on('blur', function () {
  1612. $(this).val(parseInt($(this).val()))
  1613. })
  1614. $('#Duration').on('blur', function () {
  1615. $(this).val(parseInt($(this).val()))
  1616. })
  1617. // 下发定时开关
  1618. $('#gettimingDiv').on('click', '.ace-switch', function () {
  1619. var _this = this;
  1620. var currVal = $(this).parents('.thresholdCtrl').find('.currVal').val();
  1621. var currWayjson = JSON.parse(currVal);
  1622. var id = $('#firstpane .menu-active').attr('id')
  1623. currWayjson.equip_id = id;
  1624. if (currWayjson.StartTime == '--' || currWayjson.Duration == '--') {
  1625. $(this).parents('.thresholdCtrl').find('.setthresholdBtn').click();
  1626. layer.msg('请先设置定时时间', { icon: 2 })
  1627. return false;
  1628. }
  1629. $(this).parents('.thresholdCtrl').find('.ctrlLoading').remove()
  1630. $(this).attr('disabled', true);
  1631. $(this).parents('.thresholdCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
  1632. if ($(this).is(":checked")) { //开启
  1633. var oldStatus = 0;
  1634. var currStutas = 1;
  1635. } else { //关闭
  1636. var oldStatus = 1;
  1637. var currStutas = 0;
  1638. currWayjson.StartTime = '255';
  1639. currWayjson.Duration = '32767';
  1640. }
  1641. $.ajax({
  1642. url: 'qxz_timing_mqtt',
  1643. type: 'post',
  1644. data: currWayjson,
  1645. success: function (data) {
  1646. setTimeout(function () {
  1647. $(_this).attr('disabled', false);
  1648. $(_this).parents('.thresholdCtrl').find('.ctrlLoading').html('');
  1649. var id = $('#firstpane .menu-active').attr('id')
  1650. loadProject(id);
  1651. }, 5000)
  1652. },
  1653. error: function (type) {
  1654. $(_this).parents('.thresholdCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
  1655. $(_this).attr('disabled', false);
  1656. if (oldStatus) {
  1657. $(_this).prop('checked', true);
  1658. } else {
  1659. $(_this).prop('checked', '');
  1660. }
  1661. }
  1662. })
  1663. })
  1664. </script>
  1665. </body>
  1666. </html>