equipManage_qxz_setTiming.html 11 KB

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