equipManage_qxz_setAstrict.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
  8. <link rel="stylesheet" href="../css/reset.css" />
  9. <link href="../css/mui.min.css" rel="stylesheet" />
  10. <link rel="stylesheet" href="../css/iconfont.css" />
  11. <script src="../js/base.js" type="text/javascript" charset="utf-8"></script>
  12. <link href="../css/common.css" rel="stylesheet" />
  13. <style type="text/css">
  14. /*body,.mui-content {
  15. background: #fff;
  16. }*/
  17. .qxMsg {
  18. margin: 10px 20px;
  19. /*background: pink;*/
  20. }
  21. .qxMsg>li {
  22. margin-bottom: .4rem;
  23. }
  24. .thresholdCtrl {
  25. background: #4ab8e8;
  26. border-radius: 5px;
  27. color: #fff;
  28. box-shadow: 1px 1px 4px 1px #98dbf8;
  29. border: 1px solid #98dbf8;
  30. padding: 5px 10px;
  31. cursor: pointer;
  32. position: relative;
  33. }
  34. .thresholdCtrl::before {
  35. position: absolute;
  36. content: '';
  37. bottom: 0;
  38. left: 0;
  39. right: 0;
  40. height: 30%;
  41. background: rgba(255, 255, 255, 0.5);
  42. }
  43. .setthresholdBtn {
  44. position: absolute;
  45. right: 13px;
  46. top: 12px;
  47. font-size: 20px;
  48. }
  49. .thresholdCtrlName {
  50. line-height: 30px;
  51. }
  52. .thresholdCtrlName p,
  53. .maxminNum p {
  54. color: #fff;
  55. font-size: 16px;
  56. }
  57. .thresholdCtrlShowDiv {
  58. overflow: hidden;
  59. margin: 11px 0;
  60. }
  61. .thresholdCtrlShowDiv>div {
  62. float: left;
  63. }
  64. .qxys img {
  65. width: 47px;
  66. }
  67. .maxminNum {
  68. font-size: 18px;
  69. line-height: 30px;
  70. padding-left: 7%;
  71. }
  72. .equipCtrlInp {
  73. margin-top: 20px;
  74. text-align: right;
  75. }
  76. .equipCtrlInp>div {
  77. display: inline-block;
  78. }
  79. .mui-switch:before {
  80. content: '关闭';
  81. }
  82. .mui-switch.mui-active:before {
  83. content: '开启';
  84. left: 9px;
  85. }
  86. /*设置阈值弹出框*/
  87. #setthresholdModel {
  88. height: 0;
  89. z-index: 999;
  90. position: fixed;
  91. left: 0;
  92. right: 0;
  93. bottom: 0;
  94. background: #fff;
  95. border-radius: 3px 3px 0 0;
  96. transition: all .3s;
  97. }
  98. #method {
  99. height: 45px;
  100. }
  101. #method>div {
  102. width: 45%;
  103. position: absolute;
  104. }
  105. .secondInp {
  106. left: 50%;
  107. }
  108. #sendThreshold {
  109. padding: 20px;
  110. text-align: right;
  111. }
  112. #setthresholdModel>h2 {
  113. font-size: 16px;
  114. line-height: 30px;
  115. padding-left: 15px;
  116. color: #24b2e7;
  117. }
  118. .hint span {
  119. color: red;
  120. }
  121. </style>
  122. </head>
  123. <body>
  124. <header class="mui-bar mui-bar-nav">
  125. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  126. <h1 class="mui-title" id="title">阈值设置</h1>
  127. </header>
  128. <div class="mui-content">
  129. <ul class="qxMsg">
  130. <!--<li class="qxitem">
  131. <div class="thresholdCtrl">
  132. <div class="setthresholdBtn">
  133. <span class="mui-icon mui-icon-gear"></span>
  134. </div>
  135. <input type="hidden" name="" class="currVal" value="{" JK ":1,"eKey ":1,"upper ":700,"lower ":300,"method ":1}" />
  136. <div class="thresholdCtrlName">
  137. <p>开关1(通道1)</p>
  138. </div>
  139. <div class="thresholdCtrlShowDiv">
  140. <div class="qxys">
  141. <div><img src="http://www.yfzhwlw.com/static/img/dev/icon_104.png" alt=""></div>
  142. <div>雨量</div>
  143. </div>
  144. <div class="maxminNum">
  145. <p>最大值:<span>700</span></p>
  146. <p>最小值:<span>300</span></p>
  147. </div>
  148. </div>
  149. <div class="equipCtrlInp">
  150. <div class="">
  151. <div class="mui-switch mui-switch-blue">
  152. <div class="mui-switch-handle"></div>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. </li>-->
  158. </ul>
  159. <div id="setthresholdModel" class="">
  160. <h2>阈值设置</h2>
  161. <ul class="mui-table-view" id="user">
  162. <li class="mui-table-view-cell">
  163. <span class="equipTitle">最大值</span>
  164. <p id="upperInput">
  165. <input type="number" name="" id="upperInp" value="" />
  166. </p>
  167. </li>
  168. <li class="mui-table-view-cell">
  169. <span class="equipTitle">最小值</span>
  170. <p id="lowerInput">
  171. <input type="number" name="" id="lowerInp" value="" />
  172. </p>
  173. </li>
  174. <li class="mui-table-view-cell">
  175. <span class="equipTitle">规则</span>
  176. <div id="method">
  177. <div class="mui-input-row mui-radio firstInp">
  178. <label>程序一</label>
  179. <input name="method" class="redioinp1" type="radio" onclick="switchoverFun(this)" checked="checked" value="1">
  180. </div>
  181. <div class="mui-input-row mui-radio secondInp">
  182. <label>程序二</label>
  183. <input name="method" class="redioinp1" type="radio" onclick="switchoverFun(this)" value="0">
  184. </div>
  185. </div>
  186. <p class="hint">低于下限 <span>开启</span>,高于上限<span>关闭</span></p>
  187. </li>
  188. </ul>
  189. <div id="sendThreshold">
  190. <input type="hidden" name="jkcode" id="jkcode" value="" />
  191. <input type="hidden" name="eKeycode" id="eKeycode" value="" />
  192. <button type="button" class="mui-btn mui-btn-primary" onclick="sendData()">确定</button>
  193. <button type="button" class="mui-btn" onclick="cancelFun()">取消</button>
  194. </div>
  195. </div>
  196. </div>
  197. <script src="../js/jquery-2.1.0.js"></script>
  198. <script src="../js/mui.min.js"></script>
  199. <script src="../js/common.js"></script>
  200. <script src="120.27.222.26/static/js/reportmanage/qxz_dict.js"></script>
  201. <script type="text/javascript">
  202. var equipId,autoList, conf,switch_name,qxz_switch,qxzDat;
  203. mui.init();
  204. var allData = [];
  205. mui.plusReady(function() {
  206. var self = plus.webview.currentWebview();
  207. equipId = self.equipId;
  208. autoList = self.auto_list;
  209. conf = self.conf;
  210. qxz_switch = self.qxz_switch;
  211. switch_name = self.switch_name;
  212. qxzDat = self.qxzDat;
  213. var html = '';
  214. console.log(JSON.stringify(autoList));
  215. for(var i = 0; i < autoList.length; i++) {
  216. // 开关名
  217. if (autoList[i].JK == qxz_switch[i].JK) {
  218. if(switch_name[i].name){
  219. var name = switch_name[i].name;
  220. }else{
  221. var name = '开关:'+qxz_switch[i].JK;
  222. }
  223. } else {
  224. var name = autoList[i].JK;
  225. }
  226. if(autoList[i].JK != 255) {
  227. var keyNum = autoList[i].eKey;
  228. var ekey = 'e'+(keyNum+1);
  229. var eNum = qxzDat[ekey].split('#')[1];
  230. var uitTxt = conf[ekey].split('#')[0];
  231. var unit = conf[ekey].split('#')[1];
  232. html += '<li class="qxitem"><div class="thresholdCtrl">' +
  233. '<div class="setthresholdBtn" onclick="setthresholdFun(this)"><span class="mui-icon mui-icon-gear"></span>' +
  234. '</div><input type="hidden" name="" class="currVal" value=\'' + JSON.stringify(autoList[i]) + '\' />' +
  235. '<div class="thresholdCtrlName"><p>' + name+ '(通道' + keyNum + ')</p></div>' +
  236. '<div class="thresholdCtrlShowDiv"><div class="qxys">' +
  237. '<div><img src="http://www.yfzhwlw.com/static/img/dev/icon_' + eNum + '.png" alt=""></div>' +
  238. '<div>' + uitTxt+unit + '</div></div><div class="maxminNum"><p>最大值:<span>' + autoList[i].upper + '</span></p>' +
  239. '<p>最小值:<span>' + autoList[i].lower + '</span></p></div></div><div class="equipCtrlInp">';
  240. if(!(autoList[i].upper == 32767 || autoList[i].lower == 32767)) {
  241. html += '<div class=""><div class="mui-switch mui-switch-blue mui-active">' +
  242. '<div class="mui-switch-handle"></div></div></div></div></div></li>';
  243. } else {
  244. html += '<div class=""><div class="mui-switch mui-switch-blue">' +
  245. '<div class="mui-switch-handle"></div></div></div></div></div></li>';
  246. }
  247. }
  248. console.log(html)
  249. if(i == autoList.length - 1) {
  250. $('.qxMsg').html(html);
  251. console.log(html)
  252. mui('.mui-switch')['switch']();
  253. }
  254. }
  255. })
  256. // 设置阈值
  257. var currNextEle;
  258. var currobjEle;
  259. function setthresholdFun(ele) {
  260. var obj = $(ele);
  261. currobjEle = $(ele);
  262. currNextEle = obj.next();
  263. var currValstr = obj.next().val();
  264. var currVal = eval('(' + currValstr + ')');
  265. console.log(currValstr);
  266. $('#upperInp').val(currVal.upper)
  267. $('#lowerInp').val(currVal.lower)
  268. $('#jkcode').val(currVal.JK)
  269. $('#eKeycode').val(currVal.eKey)
  270. if(currVal.method == 0) {
  271. $("input[name='method'][value=0]").prop('checked', 'checked');
  272. $('.hint').html('低于下限 <span>开启</span>,高于上限<span>关闭</span>');
  273. } else {
  274. $("input[name='method'][value=1]").prop('checked', 'checked');
  275. $('.hint').html('低于下限 <span>关闭</span>,高于上限<span>开启</span>');
  276. }
  277. console.log($("input[name='method']"));
  278. var mask = mui.createMask(function() {
  279. $('#setthresholdModel').css('height', 0);
  280. }); //callback为用户点击蒙版时自动执行的回调;
  281. $('#setthresholdModel').css('height', '417px');
  282. mask.show(); //显示遮罩
  283. }
  284. //发送设置阈值
  285. function sendData() {
  286. var upper = $('#upperInp').val();
  287. var lower = $('#lowerInp').val();
  288. var method = $("input[name='method']:checked").val();
  289. var jkcode = $('#jkcode').val();
  290. var eKeycode = $('#eKeycode').val();
  291. var datajson = {
  292. "JK": jkcode,
  293. "eKey": eKeycode,
  294. "upper": upper,
  295. "lower": lower,
  296. "method": method,
  297. "equip_id":equipId
  298. }
  299. if(parseFloat(lower) > parseFloat(upper)) {
  300. mui.toast('最小值不能大于最大值')
  301. return false;
  302. } else {
  303. $.ajax({
  304. url: 'http://120.27.222.26/qxz_value_mqtt',
  305. type: 'post',
  306. data: datajson,
  307. success: function(data) {
  308. currNextEle.val(JSON.stringify(datajson));
  309. cancelFun()
  310. mui.toast('设置成功');
  311. currobjEle.parent().find('.maxminNum').find('p').eq(0).find('span').html(datajson.upper) //最大值
  312. currobjEle.parent().find('.maxminNum').find('p').eq(1).find('span').html(datajson.lower) //最小值
  313. currobjEle.parents('.thresholdCtrl').find('.mui-switch').addClass('mui-active'); //开启阈值
  314. mui('.mui-switch')['switch']()
  315. },
  316. error: function(type) {
  317. mui.toast('设置失败');
  318. }
  319. })
  320. }
  321. }
  322. $('.qxMsg').on('toggle', '.mui-switch', function(event) {
  323. //console.log(event);
  324. var currobj = $(event.target);
  325. var currVal = $(event.target).parents('li').find('.currVal').val();
  326. var data = eval('(' + currVal + ')');
  327. if(event.originalEvent.detail.isActive) {
  328. } else {
  329. //你关闭了开关
  330. data.upper = 32767;
  331. data.lower = 32767;
  332. }
  333. $.ajax({
  334. url: 'http://120.27.222.26/qxz_value_mqtt',
  335. type: 'post',
  336. data: data,
  337. success: function(data) {
  338. mui.toast('设置成功');
  339. },
  340. error: function(type) {
  341. mui.toast('设置失败');
  342. }
  343. })
  344. })
  345. //取消
  346. function cancelFun() {
  347. var mask = mui.createMask(function() {
  348. $('#setthresholdModel').css('height', 0);
  349. $('.mui-backdrop').remove();
  350. });
  351. mask.close();
  352. }
  353. //redio切换
  354. function switchoverFun(obj) {
  355. if($(obj).val() == 1) {
  356. $("input[name='method'][value=1]").prop('checked', 'checked');
  357. $('.hint').html('低于下限 <span>开启</span>,高于上限<span>关闭</span>');
  358. } else {
  359. $("input[name='method'][value=0]").prop('checked', 'checked');
  360. $('.hint').html('低于下限 <span>关闭</span>,高于上限<span>开启</span>');
  361. }
  362. }
  363. </script>
  364. </body>
  365. </html>