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