DeviceClass-.html 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. <!DOCTYPE html>
  2. <html class="x-admin-sm">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="renderer" content="webkit">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  8. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
  9. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
  10. <link rel="stylesheet" href="https://osscold.baozhida.cn/lib/layui/layui.css">
  11. <script type="text/javascript" src="https://osscold.baozhida.cn/lib/layui/layui.js" charset="utf-8"></script>
  12. <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
  13. <script src="https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js"></script>
  14. <script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
  15. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  16. <!--[if lt IE 9]>
  17. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  18. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  19. <![endif]--></head>
  20. <style>
  21. .no_select{
  22. -webkit-touch-callout: none;
  23. -moz-user-select: none; /*火狐*/
  24. -webkit-user-select: none; /*webkit浏览器*/
  25. -ms-user-select: none; /*IE10*/
  26. -khtml-user-select: none; /*早期浏览器*/
  27. user-select: none;
  28. }
  29. .box_x{
  30. border: 1px solid #1E9FFF;
  31. width: 42px;
  32. height: 16px;
  33. margin: 0;
  34. padding: 4px;
  35. float: left;
  36. text-align: center;
  37. }
  38. </style>
  39. <body>
  40. <div class="layui-fluid">
  41. <div class="layui-row">
  42. <div class="layui-form-item">
  43. <label for="T_name" class="layui-form-label" style="width: 140px">
  44. <span class="x-red">*</span>传感器 分类名称</label>
  45. <div class="layui-input-inline">
  46. <input {{if gt .id 0 }}
  47. value="{{.T.T_name}}"
  48. {{end}} type="text" id="T_name" name="T_name" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  49. </div>
  50. {{if ne .id 0 }}
  51. <div class="layui-tab layui-tab-card">
  52. <ul class="layui-tab-title">
  53. <li class="layui-this">通知规则</li>
  54. <li class="">微信通知</li>
  55. <li class="">电话通知</li>
  56. <li class="">短信通知</li>
  57. <li class="">邮箱通知</li>
  58. </ul>
  59. <div class="layui-tab-content" style="height: 340px;overflow-y: auto;">
  60. <div id="T_Notice_mechanism" class="layui-tab-item layui-show" style="" >
  61. </div>
  62. <div class="layui-tab-item " >
  63. <div class="layui-row" style="margin: 0px 10px">
  64. <div class="layui-col-xs6" >
  65. <div class="layui-row no_select" style="margin: 10px 0px;font-size: 15px;color: #1E9FFF">
  66. 方式一:二维码
  67. </div>
  68. <div class="layui-row no_select" style="margin: 0px 10px">
  69. <div style="float: left;margin-bottom: 8px">
  70. 让被通知者 通过微信扫描二维码,二维码有效期7天。
  71. </div>
  72. <img id="myimg" style="width: 150px;height: 150px;float: left" src="https://osscold.baozhida.cn/images/二维码.png">
  73. </div>
  74. <!-- <div class="layui-row no_select" style="margin: 10px 0px;font-size: 15px;color: #1E9FFF;margin-top: 18px">-->
  75. <!-- 方式二:回复内容-->
  76. <!-- </div>-->
  77. <!-- <div id="Code" class="layui-row" style="height: 50px;margin: 0px 10px;border:1px solid #cbcbcb;box-shadow: 0px 0px 8px #316fe7;padding: 6px;border-radius:5px;">-->
  78. <!-- </div>-->
  79. </div>
  80. <div id="Notice_wx_list" class="layui-col-xs6" style="padding-left: 6px;padding-right: 6px;height: 350px;border-left:1px solid #cbcbcb;overflow-y:auto;">
  81. <!-- <div class="layui-col" style="height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;">-->
  82. <!-- <img style="float: left;width: 30px;margin: 0px 10px;margin-top: 2px;" src="https://osscold.baozhida.cn/images/微信.png" height="30"-->
  83. <!-- width="30"/>-->
  84. <!-- <div style="float: left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">-->
  85. <!-- <div style="margin-top: 8px;font-size: 15px">SN:KF20210510143443</div>-->
  86. <!-- </div>-->
  87. <!-- <div class="layui-card-header" style="float: right; padding: 0px;height: 0px;">-->
  88. <!-- <span style="float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;"-->
  89. <!-- onclick=""><i class="iconfont" style="margin-right: 2px">&#xe69d;</i>删除</span>-->
  90. <!-- </div>-->
  91. <!-- </div>-->
  92. </div>
  93. </div>
  94. </div>
  95. <div class="layui-tab-item">
  96. <div class="layui-row" style="margin: 0px 10px">
  97. <div class="layui-col-xs6" >
  98. <div class="layui-row" style="margin: 20px 0px">
  99. <label for="T_name" class="layui-form-label" style="margin-left: 6px;margin-top: 6px;padding:0px;padding-right: 10px">
  100. <span class="x-red">*</span>添加手机号码</label>
  101. <div class="layui-input-inline">
  102. <input type="text" id="E_phone" name="E_phone" required="" class="layui-input">
  103. </div>
  104. </div>
  105. <div class="layui-row" style="margin: 0px 10px">
  106. <div class="layui-form-item" style="text-align: center;margin-top: 30px">
  107. <button class="layui-btn layui-btn-normal" onclick="Add_Notice_phone()">添加</button>
  108. </div>
  109. </div>
  110. </div>
  111. <div id="Notice_phone_list" class="layui-col-xs6" style="padding-left: 6px;padding-right: 6px;height: 350px;border-left:1px solid #cbcbcb;overflow-y:auto;">
  112. <!-- <div class="layui-col" style="height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;">-->
  113. <!-- <img style="float: left;width: 30px;margin: 0px 10px;margin-top: 2px;" src="https://osscold.baozhida.cn/images/微信.png" height="30"-->
  114. <!-- width="30"/>-->
  115. <!-- <div style="float: left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">-->
  116. <!-- <div style="margin-top: 8px;font-size: 15px">SN:KF20210510143443</div>-->
  117. <!-- </div>-->
  118. <!-- <div class="layui-card-header" style="float: right; padding: 0px;height: 0px;">-->
  119. <!-- <span style="float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;"-->
  120. <!-- onclick="Add_Notice_phone()"><i class="iconfont" style="margin-right: 2px">&#xe69d;</i>删除</span>-->
  121. <!-- </div>-->
  122. <!-- </div>-->
  123. </div>
  124. </div>
  125. </div>
  126. <div class="layui-tab-item">
  127. <div class="layui-row" style="margin: 0px 10px">
  128. <div class="layui-col-xs6" >
  129. <div class="layui-row" style="margin: 20px 0px">
  130. <label for="T_name" class="layui-form-label" style="margin-left: 6px;margin-top: 6px;padding:0px;padding-right: 10px">
  131. <span class="x-red">*</span>添加手机号码</label>
  132. <div class="layui-input-inline">
  133. <input type="text" id="E_message" name="E_message" required="" class="layui-input">
  134. </div>
  135. </div>
  136. <div class="layui-row" style="margin: 0px 10px">
  137. <div class="layui-form-item" style="text-align: center;margin-top: 30px">
  138. <button class="layui-btn layui-btn-normal" onclick="Add_Notice_message()">添加</button>
  139. </div>
  140. </div>
  141. </div>
  142. <div id="Notice_message_list" class="layui-col-xs6" style="padding-left: 6px;padding-right: 6px;height: 350px;border-left:1px solid #cbcbcb;overflow-y:auto;">
  143. <!-- <div class="layui-col" style="height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;">-->
  144. <!-- <img style="float: left;width: 30px;margin: 0px 10px;margin-top: 2px;" src="https://osscold.baozhida.cn/images/微信.png" height="30"-->
  145. <!-- width="30"/>-->
  146. <!-- <div style="float: left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">-->
  147. <!-- <div style="margin-top: 8px;font-size: 15px">SN:KF20210510143443</div>-->
  148. <!-- </div>-->
  149. <!-- <div class="layui-card-header" style="float: right; padding: 0px;height: 0px;">-->
  150. <!-- <span style="float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;"-->
  151. <!-- onclick="Add_Notice_phone()"><i class="iconfont" style="margin-right: 2px">&#xe69d;</i>删除</span>-->
  152. <!-- </div>-->
  153. <!-- </div>-->
  154. </div>
  155. </div>
  156. </div>
  157. <div class="layui-tab-item">
  158. <div class="layui-row" style="margin: 0px 10px">
  159. <div class="layui-col-xs6" >
  160. <div class="layui-row" style="margin: 20px 0px">
  161. <label for="T_name" class="layui-form-label" style="margin-left: 6px;margin-top: 6px;padding:0px;padding-right: 10px">
  162. <span class="x-red">*</span>添加邮箱</label>
  163. <div class="layui-input-inline">
  164. <input type="text" id="E_mailbox" name="E_phone" required=""class="layui-input">
  165. </div>
  166. </div>
  167. <div class="layui-row" style="margin: 0px 10px">
  168. <div class="layui-form-item" style="text-align: center;margin-top: 30px">
  169. <button class="layui-btn layui-btn-normal" onclick="Add_Notice_mailbox()">添加</button>
  170. </div>
  171. </div>
  172. </div>
  173. <div id="Notice_mailbox_list" class="layui-col-xs6" style="padding-left: 6px;padding-right: 6px;height: 350px;border-left:1px solid #cbcbcb;overflow-y:auto;">
  174. <!-- <div class="layui-col" style="height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;">-->
  175. <!-- <img style="float: left;width: 30px;margin: 0px 10px;margin-top: 2px;" src="https://osscold.baozhida.cn/images/微信.png" height="30"-->
  176. <!-- width="30"/>-->
  177. <!-- <div style="float: left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">-->
  178. <!-- <div style="margin-top: 8px;font-size: 15px">SN:KF20210510143443</div>-->
  179. <!-- </div>-->
  180. <!-- <div class="layui-card-header" style="float: right; padding: 0px;height: 0px;">-->
  181. <!-- <span style="float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;"-->
  182. <!-- onclick="Add_Notice_phone()"><i class="iconfont" style="margin-right: 2px">&#xe69d;</i>删除</span>-->
  183. <!-- </div>-->
  184. <!-- </div>-->
  185. </div>
  186. </div>
  187. </div>
  188. </div>
  189. </div>
  190. {{end}}
  191. <div class="layui-form-item" style="text-align: center;margin-top: 20px">
  192. <button class="layui-btn layui-btn-normal" onclick="DeviceClass_Post()">提交 {{if gt .id 0 }}(点击提交后生效){{end}}</button>
  193. </div>
  194. </div>
  195. </div>
  196. <script>
  197. //获取GET
  198. function getPar(par) {
  199. //获取当前URL
  200. var local_url = document.location.href;
  201. //获取要取得的get参数位置
  202. var get = local_url.indexOf(par + "=")
  203. ;
  204. if (get == -1) {
  205. return false;
  206. }
  207. //截取字符串
  208. //截取字符串
  209. var get_par = local_url.slice(par.length + get + 1);
  210. //判断截取后的字符串是否还有其他get参数
  211. var nextPar = get_par.indexOf("&")
  212. ;
  213. if (nextPar != -1) {
  214. get_par = get_par.slice(0, nextPar);
  215. }
  216. return get_par;
  217. }
  218. // xxxx = plusXing(strx,"o5EKB1buEEsyDP6u-6H3H326T4no2","c")
  219. function plusXing(str, wid, v) {
  220. a_x = str.indexOf(wid+"/")
  221. return str.substring(0, a_x+wid.length + 1) + v + str.substring(str.indexOf("|",a_x),str.length);
  222. };
  223. layui.use(['form', 'layer',"layedit"],
  224. function() {
  225. $ = layui.jquery;
  226. var form = layui.form,
  227. layer = layui.layer;
  228. });
  229. function hello_s5 (){
  230. //要执行的代码
  231. console.log("开启 循环")
  232. forNotice_wx = true
  233. }
  234. function ShowElement(element,tid) {
  235. forNotice_wx = false
  236. var oldhtml = element.innerHTML;
  237. //创建新的input元素
  238. var newobj = document.createElement('input');
  239. //为新增元素添加类型
  240. newobj.type = 'text';
  241. //为新增元素添加value值
  242. newobj.value = oldhtml;
  243. //为新增元素添加光标离开事件
  244. newobj.onblur = function() {
  245. console.log("离开。。",tid,this.value == oldhtml ? oldhtml : this.value)
  246. element.innerHTML = this.value == oldhtml ? oldhtml : this.value;
  247. T_Notice_wx = plusXing(T_Notice_wx,tid,this.value == oldhtml ? oldhtml : this.value)
  248. console.log("T_Notice_wx:",T_Notice_wx)
  249. DeviceClass_Post()
  250. setTimeout(hello_s5,5000);//5秒后执行
  251. //当触发时判断新增元素值是否为空,为空则不修改,并返回原有值
  252. }
  253. //设置该标签的子节点为空
  254. element.innerHTML = '';
  255. //添加该标签的子节点,input对象
  256. element.appendChild(newobj);
  257. //设置选择文本的内容或设置光标位置(两个参数:start,end;start为开始位置,end为结束位置;如果开始位置和结束位置相同则就是光标位置)
  258. newobj.setSelectionRange(0, oldhtml.length);
  259. //设置获得光标
  260. newobj.focus();
  261. }
  262. var T_name = "{{.T.T_name}}"
  263. var T_Notice_wx = "{{.T.T_Notice_wx}}"
  264. var T_Notice_phone = "{{.T.T_Notice_phone}}"
  265. var T_Notice_message = "{{.T.T_Notice_message}}"
  266. var T_Notice_mailbox = "{{.T.T_Notice_mailbox}}"
  267. var T_Notice_mechanism = "{{.T.T_Notice_mechanism}}"
  268. var Onload = true
  269. var forNotice_wx = true
  270. // 页面 加载完成后执行
  271. window.onload=function(){
  272. console.log("页面 加载完成后执行")
  273. if(Onload && parseInt(getPar("id")) > 0){
  274. Onload =false;
  275. Show_Notice_T_Notice_mechanism(); // 报警机制
  276. Show_Notice_phone_list();
  277. Show_Notice_message_list();
  278. Show_Notice_mailbox_list();
  279. Get_DeviceClassId_QRCode();
  280. setTimeout("Automaticupdate_Notice_wx()", 1000)
  281. setInterval(function(){
  282. if(forNotice_wx){
  283. // Automaticupdate_Notice_wx();
  284. }
  285. },2000);
  286. }
  287. }
  288. // 微信
  289. function Automaticupdate_Notice_wx() {
  290. Get_DeviceClassId();
  291. }
  292. function Del_Notice_wx_plusXing(str, wid) {
  293. a_x = str.indexOf(wid+"/")
  294. return str.substring(a_x, str.indexOf("|",a_x));
  295. };
  296. function Del_Notice_wx(x) {
  297. srt_r = Del_Notice_wx_plusXing(T_Notice_wx,x)
  298. if(T_Notice_wx.indexOf(srt_r) == -1){
  299. layer.msg('删除失败');
  300. return
  301. }
  302. T_Notice_wx = T_Notice_wx.replace(srt_r + "|", "")
  303. Show_Notice_wx_list()
  304. DeviceClass_Post()
  305. }
  306. function Show_Notice_wx_list() {
  307. var scores = T_Notice_wx.split("|");
  308. $('#Notice_wx_list').html("");
  309. for (let i = 0; i < scores.length; i++) {
  310. if(scores[i].length == 0){
  311. return
  312. }
  313. scores_l = scores[i].split("/")
  314. $('#Notice_wx_list').append("" +
  315. "<div class=\"layui-col\" style=\"height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;\">\n" +
  316. " <img style=\"float: left;width: 30px;margin: 0px 10px;margin-top: 2px;\" src=\"https://osscold.baozhida.cn/images/微信.png\" height=\"30\"\n" +
  317. " width=\"30\"/>\n" +
  318. " <div style=\"float: left;width: 170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap\">\n" +
  319. " <div style=\"margin-top: 8px;font-size: 15px\" ondblclick=\"ShowElement(this,'"+scores_l[0]+"')\" >"+scores_l[1]+"</div>\n" +
  320. " </div>\n" +
  321. " <div class=\"layui-card-header\" style=\"float: right; padding: 0px;height: 0px;\">\n" +
  322. " <span style=\"float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;\"\n" +
  323. " onclick=\"Del_Notice_wx('"+scores_l[0]+"')\"><i class=\"iconfont\" style=\"margin-right: 2px\">&#xe69d;</i>删除</span>\n" +
  324. " </div>\n" +
  325. "</div>")
  326. }
  327. if(scores.length == 0){
  328. $('#Notice_wx_list').append("<div style=\"color: #1E9FFF;text-align: center;font-size: 15px;margin-top: 150px\" > 没有数据 < /div>" )
  329. }
  330. }
  331. // 手机
  332. function Add_Notice_phone() {
  333. x = $("#E_phone").val()
  334. if(T_Notice_phone.indexOf(x) != -1){
  335. layer.msg('不能重复添加');
  336. return
  337. }
  338. T_Notice_phone = T_Notice_phone + x + "|"
  339. Show_Notice_phone_list()
  340. }
  341. function Del_Notice_phone(x) {
  342. if(T_Notice_phone.indexOf(x) == -1){
  343. layer.msg('删除失败');
  344. return
  345. }
  346. T_Notice_phone = T_Notice_phone.replace(x + "|", "")
  347. Show_Notice_phone_list()
  348. }
  349. function Show_Notice_phone_list() {
  350. var scores = T_Notice_phone.split("|");
  351. $('#Notice_phone_list').html("");
  352. for (let i = 0; i < scores.length; i++) {
  353. if(scores[i].length == 0){
  354. return
  355. }
  356. $('#Notice_phone_list').append("" +
  357. "<div class=\"layui-col\" style=\"height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;\">\n" +
  358. " <img style=\"float: left;width: 30px;margin: 0px 10px;margin-top: 2px;\" src=\"https://osscold.baozhida.cn/images/电话.png\" height=\"30\"\n" +
  359. " width=\"30\"/>\n" +
  360. " <div style=\"float: left;width: 170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap\">\n" +
  361. " <div style=\"margin-top: 8px;font-size: 15px\">"+scores[i]+"</div>\n" +
  362. " </div>\n" +
  363. " <div class=\"layui-card-header\" style=\"float: right; padding: 0px;height: 0px;\">\n" +
  364. " <span style=\"float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;\"\n" +
  365. " onclick=\"Del_Notice_phone('"+scores[i]+"')\"><i class=\"iconfont\" style=\"margin-right: 2px\">&#xe69d;</i>删除</span>\n" +
  366. " </div>\n" +
  367. "</div>")
  368. }
  369. if(scores.length == 0){
  370. $('#Notice_phone_list').append("<div style=\"color: #1E9FFF;text-align: center;font-size: 15px;margin-top: 150px\" > 没有数据 < /div>" )
  371. }
  372. }
  373. // 短信
  374. function Add_Notice_message() {
  375. x = $("#E_message").val()
  376. if(T_Notice_message.indexOf(x) != -1){
  377. layer.msg('不能重复添加');
  378. return
  379. }
  380. T_Notice_message = T_Notice_message + x + "|"
  381. Show_Notice_message_list()
  382. }
  383. function Del_Notice_message(x) {
  384. if(T_Notice_message.indexOf(x) == -1){
  385. layer.msg('删除失败');
  386. return
  387. }
  388. T_Notice_message = T_Notice_message.replace(x + "|", "")
  389. Show_Notice_message_list()
  390. }
  391. function Show_Notice_message_list() {
  392. var scores = T_Notice_message.split("|");
  393. $('#Notice_message_list').html("");
  394. for (let i = 0; i < scores.length; i++) {
  395. if(scores[i].length == 0){
  396. return
  397. }
  398. $('#Notice_message_list').append("" +
  399. "<div class=\"layui-col\" style=\"height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;\">\n" +
  400. " <img style=\"float: left;width: 30px;margin: 0px 10px;margin-top: 2px;\" src=\"https://osscold.baozhida.cn/images/短信.png\" height=\"30\"\n" +
  401. " width=\"30\"/>\n" +
  402. " <div style=\"float: left;width: 170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap\">\n" +
  403. " <div style=\"margin-top: 8px;font-size: 15px\">"+scores[i]+"</div>\n" +
  404. " </div>\n" +
  405. " <div class=\"layui-card-header\" style=\"float: right; padding: 0px;height: 0px;\">\n" +
  406. " <span style=\"float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;\"\n" +
  407. " onclick=\"Del_Notice_message('"+scores[i]+"')\"><i class=\"iconfont\" style=\"margin-right: 2px\">&#xe69d;</i>删除</span>\n" +
  408. " </div>\n" +
  409. "</div>")
  410. }
  411. if(scores.length == 0){
  412. $('#Notice_message_list').append("<div style=\"color: #1E9FFF;text-align: center;font-size: 15px;margin-top: 150px\" > 没有数据 < /div>" )
  413. }
  414. }
  415. // 邮件
  416. function Add_Notice_mailbox() {
  417. x = $("#E_mailbox").val()
  418. if(T_Notice_mailbox.indexOf(x) != -1){
  419. layer.msg('不能重复添加');
  420. return
  421. }
  422. T_Notice_mailbox = T_Notice_mailbox + x + "|"
  423. Show_Notice_mailbox_list()
  424. }
  425. function Del_Notice_mailbox(x) {
  426. if(T_Notice_mailbox.indexOf(x) == -1){
  427. layer.msg('删除失败');
  428. return
  429. }
  430. T_Notice_mailbox = T_Notice_mailbox.replace(x + "|", "")
  431. Show_Notice_mailbox_list()
  432. }
  433. function Show_Notice_mailbox_list() {
  434. var scores = T_Notice_mailbox.split("|");
  435. $('#Notice_mailbox_list').html("");
  436. for (let i = 0; i < scores.length; i++) {
  437. if(scores[i].length == 0){
  438. return
  439. }
  440. $('#Notice_mailbox_list').append("" +
  441. "<div class=\"layui-col\" style=\"height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;\">\n" +
  442. " <img style=\"float: left;width: 30px;margin: 0px 10px;margin-top: 2px;\" src=\"https://osscold.baozhida.cn/images/邮箱.png\" height=\"30\"\n" +
  443. " width=\"30\"/>\n" +
  444. " <div style=\"float: left;width: 170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap\">\n" +
  445. " <div style=\"margin-top: 8px;font-size: 15px\">"+scores[i]+"</div>\n" +
  446. " </div>\n" +
  447. " <div class=\"layui-card-header\" style=\"float: right; padding: 0px;height: 0px;\">\n" +
  448. " <span style=\"float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;\"\n" +
  449. " onclick=\"Del_Notice_mailbox('"+scores[i]+"')\"><i class=\"iconfont\" style=\"margin-right: 2px\">&#xe69d;</i>删除</span>\n" +
  450. " </div>\n" +
  451. "</div>")
  452. }
  453. if(scores.length == 0){
  454. $('#Notice_mailbox_list').append("<div style=\"color: #1E9FFF;text-align: center;font-size: 15px;margin-top: 150px\" > 没有数据 < /div>" )
  455. }
  456. }
  457. function Get_DeviceClassId_QRCode(){
  458. $.ajax({
  459. type: 'POST',
  460. url: 'Get_DeviceClassId_QRCode',//发送请求
  461. data: {
  462. User_tokey: $.cookie("User_tokey"),
  463. T_class_id: parseInt(getPar("id")),
  464. },
  465. success: function(result) {
  466. console.log(result)
  467. if (result.Code == 200 ){
  468. $("#myimg").attr('src',result.Data.QR);
  469. // $('#Code').html(result.Data.Code);
  470. }else {
  471. layer.msg('二维码生成失败!', {
  472. time: 2000
  473. });
  474. }
  475. }
  476. });
  477. }
  478. function Get_DeviceClassId(){
  479. $.ajax({
  480. type: 'POST',
  481. url: 'Get_DeviceClassId',//发送请求
  482. data: {
  483. User_tokey: $.cookie("User_tokey"),
  484. T_class_id: parseInt(getPar("id")),
  485. },
  486. success: function(result) {
  487. console.log(result)
  488. if (result.Code == 200 ){
  489. T_Notice_wx = result.Data.T_Notice_wx
  490. Show_Notice_wx_list()
  491. }else {
  492. layer.msg('二维码生成失败!', {
  493. time: 2000
  494. });
  495. }
  496. }
  497. });
  498. }
  499. function DeviceClass_Post(){
  500. var loading = layer.load(0, {
  501. shade: false,
  502. time: 99*1000
  503. });
  504. $.ajax({
  505. type: 'POST',
  506. url: 'DeviceClass_Post',//发送请求
  507. data: {
  508. Id:"{{.id}}",
  509. T_name:$("#T_name").val(),
  510. T_Notice_wx:T_Notice_wx,
  511. T_Notice_phone:T_Notice_phone,
  512. T_Notice_message:T_Notice_message,
  513. T_Notice_mailbox:T_Notice_mailbox,
  514. T_Notice_mechanism:Get_Notice_T_Notice_mechanism(),
  515. },
  516. success: function(result) {
  517. console.log(result)
  518. layer.close(loading)
  519. //关闭当前frame
  520. parent.layer.close();
  521. parent.location.reload();
  522. }
  523. });
  524. }
  525. </script>
  526. <script>
  527. // 初始化 报警规则机制
  528. function T_Notice_mechanism_initialization(){
  529. var loading = layer.load(0, {
  530. shade: false,
  531. time: 99*1000
  532. });
  533. $.ajax({
  534. type: 'POST',
  535. url: 'DeviceWarningListT_Tips',//发送请求
  536. success: function(result) {
  537. console.log(result)
  538. layer.close(loading)
  539. //关闭当前frame
  540. // parent.layer.close();
  541. // parent.location.reload();
  542. T_Notice_mechanism = result.Data
  543. Show_Notice_T_Notice_mechanism()
  544. }
  545. });
  546. }
  547. function Get_Notice_T_Notice_mechanism() {
  548. box = $(".box_x")
  549. if(box.length < 8){
  550. return ""
  551. }
  552. box_x = (box.length / 15) - 1
  553. console.log("box_x:",box_x)
  554. i_v = 15
  555. str_ = ""
  556. for (let i = 0; i < box_x; i++) {
  557. i_ = 15 + 15 * i
  558. str_ += box[i_+0].textContent + ","
  559. i_++
  560. if(box[i_].firstElementChild.checked == true){
  561. str_ += "1,"
  562. }else {
  563. str_ += "0,"
  564. }
  565. i_++
  566. if(box[i_].firstElementChild.checked == true){
  567. str_ += "1,"
  568. }else {
  569. str_ += "0,"
  570. }
  571. i_++
  572. if(box[i_].firstElementChild.checked == true){
  573. str_ += "1,"
  574. }else {
  575. str_ += "0,"
  576. }
  577. i_++
  578. str_ += box[i_].firstElementChild.value + ","
  579. i_++
  580. str_ += box[i_].firstElementChild.value + ","
  581. i_++
  582. if(box[i_].firstElementChild.checked == true){
  583. str_ += "1,"
  584. }else {
  585. str_ += "0,"
  586. }
  587. i_++
  588. str_ += box[i_].firstElementChild.value + ","
  589. i_++
  590. str_ += box[i_].firstElementChild.value + ","
  591. i_++
  592. if(box[i_].firstElementChild.checked == true){
  593. str_ += "1,"
  594. }else {
  595. str_ += "0,"
  596. }
  597. i_++
  598. str_ += box[i_].firstElementChild.value + ","
  599. i_++
  600. str_ += box[i_].firstElementChild.value + ","
  601. i_++
  602. if(box[i_].firstElementChild.checked == true){
  603. str_ += "1,"
  604. }else {
  605. str_ += "0,"
  606. }
  607. i_++
  608. str_ += box[i_].firstElementChild.value + ","
  609. i_++
  610. str_ += box[i_].firstElementChild.value + ""
  611. str_ += "|"
  612. }
  613. return str_
  614. }
  615. function Show_Notice_T_Notice_mechanism() {
  616. console.log("======")
  617. var scores = T_Notice_mechanism.split("|");
  618. $('#T_Notice_mechanism').html("<div class=\"layui-row\">\n" +
  619. " <span class=\"box_x\" style=\"margin-left: -1px;width: 120px;\">报警类型</span>\n" +
  620. " <span class=\"box_x\" style=\"margin-left: 1px;\">记录</span>\n" +
  621. " <span class=\"box_x\" style=\"margin-left: 1px;\">处理</span>\n" +
  622. " <span class=\"box_x\" style=\"margin-left: 1px;\">微信</span>\n" +
  623. " <span class=\"box_x\" style=\"margin-left: -1px;\">触发数</span>\n" +
  624. " <span class=\"box_x\" style=\"margin-left: -1px;\">上限数</span>\n" +
  625. " <span class=\"box_x\" style=\"margin-left: 1px;\">短信</span>\n" +
  626. " <span class=\"box_x\" style=\"margin-left: -1px;\">触发数</span>\n" +
  627. " <span class=\"box_x\" style=\"margin-left: -1px;\">上限数</span>\n" +
  628. " <span class=\"box_x\" style=\"margin-left: 1px;\">手机</span>\n" +
  629. " <span class=\"box_x\" style=\"margin-left: -1px;\">触发数</span>\n" +
  630. " <span class=\"box_x\" style=\"margin-left: -1px;\">上限数</span>\n" +
  631. " <span class=\"box_x\" style=\"margin-left: 1px;\">邮箱</span>\n" +
  632. " <span class=\"box_x\" style=\"margin-left: -1px;\">触发数</span>\n" +
  633. " <span class=\"box_x\" style=\"margin-left: -1px;\">上限数</span>\n" +
  634. " </div>");
  635. for (let i = 0; i < scores.length; i++) {
  636. if(scores[i].length == 0){
  637. break
  638. }
  639. row = scores[i].split(",");
  640. $('#T_Notice_mechanism').append("" +
  641. "\n" +
  642. " <div class=\"layui-row\">\n" +
  643. " <div class=\"box_x\" style=\"margin-left: -1px;width: 120px;\">"+row[0]+"</div>\n" +
  644. " <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
  645. " <input type=\"checkbox\">\n" +
  646. " </div>\n" +
  647. " <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
  648. " <input type=\"checkbox\">\n" +
  649. " </div>\n" +
  650. "\n" +
  651. " <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
  652. " <input type=\"checkbox\">\n" +
  653. " </div>\n" +
  654. " <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
  655. " <input type=\"text\" style=\"width: 40px;\" value='"+row[4]+"'>\n" +
  656. " </div>\n" +
  657. " <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
  658. " <input type=\"text\" style=\"width: 40px;\" value='"+row[5]+"'>\n" +
  659. " </div>\n" +
  660. "\n" +
  661. " <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
  662. " <input type=\"checkbox\">\n" +
  663. " </div>\n" +
  664. " <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
  665. " <input type=\"text\" style=\"width: 40px;\" value='"+row[7]+"'>\n" +
  666. " </div>\n" +
  667. " <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
  668. " <input type=\"text\" style=\"width: 40px;\" value='"+row[8]+"'>\n" +
  669. " </div>\n" +
  670. "\n" +
  671. " <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
  672. " <input type=\"checkbox\">\n" +
  673. " </div>\n" +
  674. " <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
  675. " <input type=\"text\" style=\"width: 40px;\" value='"+row[10]+"'>\n" +
  676. " </div>\n" +
  677. " <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
  678. " <input type=\"text\" style=\"width: 40px;\" value='"+row[11]+"'>\n" +
  679. " </div>\n" +
  680. "\n" +
  681. " <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
  682. " <input type=\"checkbox\">\n" +
  683. " </div>\n" +
  684. " <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
  685. " <input type=\"text\" style=\"width: 40px;\" value='"+row[13]+"'>\n" +
  686. " </div>\n" +
  687. " <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
  688. " <input type=\"text\" style=\"width: 40px;\" value='"+row[14]+"'>\n" +
  689. " </div>\n" +
  690. "\n" +
  691. "\n" +
  692. " </div>\n")
  693. box = $(".box_x")
  694. if(row[1] == 1){
  695. box[box.length-1-13].firstElementChild.checked = true
  696. }
  697. if(row[2] == 1){
  698. box[box.length-1-12].firstElementChild.checked = true
  699. }
  700. if(row[3] == 1){
  701. box[box.length-1-11].firstElementChild.checked = true
  702. }
  703. if(row[6] == 1){
  704. box[box.length-1-8].firstElementChild.checked = true
  705. }
  706. if(row[9] == 1){
  707. box[box.length-1-5].firstElementChild.checked = true
  708. }
  709. if(row[12] == 1){
  710. box[box.length-1-2].firstElementChild.checked = true
  711. }
  712. }
  713. $('#T_Notice_mechanism').append("<div class='layui-row' style='text-align: center;margin-top: 20px'> " +
  714. "<button class=\"layui-btn layui-btn-normal\" onclick=\"T_Notice_mechanism_initialization()\">重置数据</button><button class=\"layui-btn layui-btn-normal\" onclick=\"T_Notice_mechanism_initialization()\">说明</button>" +
  715. " </div>" )
  716. }
  717. </script>
  718. </body>
  719. </html>