DataList-.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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="shortcut icon" href="https://osscold.baozhida.cn/favicon.ico">
  9. <link rel="bookmark" href="https://osscold.baozhida.cn/favicon.ico">
  10. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
  11. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
  12. <link rel="stylesheet" href="https://osscold.baozhida.cn/layui/css/layui.css">
  13. <script type="text/javascript" src="https://osscold.baozhida.cn/layui/layui.js" charset="utf-8"></script>
  14. <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.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. <body>
  21. <div class="layui-fluid">
  22. <div class="layui-row">
  23. <form class="layui-form">
  24. <div class="layui-form-item">
  25. <label for="T_name" class="layui-form-label">
  26. <span class="x-red">*</span>SN</label>
  27. <div class="layui-input-inline">
  28. <input type="text" id="SN" name="SN" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  29. </div>
  30. <div class="layui-form-item">
  31. <label for="T_name" class="layui-form-label">
  32. <span class="x-red">*</span>传感器名称</label>
  33. <div class="layui-input-inline">
  34. <input type="text" id="t_name" name="t_name" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  35. </div>
  36. <div class="layui-form-item">
  37. <label for="T_name" class="layui-form-label">
  38. <span class="x-red">*</span>传感器编号</label>
  39. <div class="layui-input-inline">
  40. <input type="text" id="t_id" name="t_id" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  41. </div>
  42. <div class="layui-form-item">
  43. <label for="T_name" class="layui-form-label">
  44. <span class="x-red">*</span>温度</label>
  45. <div class="layui-input-inline">
  46. <input type="text" id="t_t" name="t_t" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  47. </div>
  48. <div class="layui-form-item">
  49. <label for="T_name" class="layui-form-label">
  50. <span class="x-red">*</span>温度-最低</label>
  51. <div class="layui-input-inline">
  52. <input type="text" id="t_tl" name="t_tl" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  53. </div>
  54. <div class="layui-form-item">
  55. <label for="T_name" class="layui-form-label">
  56. <span class="x-red">*</span>温度-最高</label>
  57. <div class="layui-input-inline">
  58. <input type="text" id="t_tu" name="t_tu" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  59. </div>
  60. <div class="layui-form-item">
  61. <label for="T_name" class="layui-form-label">
  62. <span class="x-red">*</span>湿度</label>
  63. <div class="layui-input-inline">
  64. <input type="text" id="t_rh" name="t_rh" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  65. </div>
  66. <div class="layui-form-item">
  67. <label for="T_name" class="layui-form-label">
  68. <span class="x-red">*</span>湿度-最低</label>
  69. <div class="layui-input-inline">
  70. <input type="text" id="t_rhl" name="t_rhl" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  71. </div>
  72. <div class="layui-form-item">
  73. <label for="T_name" class="layui-form-label">
  74. <span class="x-red">*</span>湿度-最高</label>
  75. <div class="layui-input-inline">
  76. <input type="text" id="t_rhu" name="t_rhu" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  77. </div>
  78. <div class="layui-form-item">
  79. <label for="T_name" class="layui-form-label">
  80. <span class="x-red">*</span>时间</label>
  81. <div class="layui-input-inline">
  82. <input type="text" id="t_time" name="t_time" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  83. </div>
  84. <div class="layui-form-item" style="text-align: center;margin-top: 20px">
  85. <!-- <label for="L_repass" class="layui-form-label"></label>-->
  86. <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">提交</button></div>
  87. </form>
  88. </div>
  89. </div>
  90. <script>
  91. layui.use(['form', 'layer',"layedit"],
  92. function() {
  93. $ = layui.jquery;
  94. var form = layui.form,
  95. layer = layui.layer;
  96. var layedit = layui.layedit
  97. layedit.set({
  98. uploadImage: {
  99. url: '/UpFile' //接口url
  100. }
  101. });
  102. //构建一个默认的编辑器
  103. var index = layedit.build('T_text', {
  104. height: 580 //设置编辑器高度,
  105. });
  106. //监听提交
  107. form.on('submit(add)',
  108. function(data) {
  109. console.log("=== submit(add) ==");
  110. console.log(data);
  111. $.ajax({
  112. type: 'POST',
  113. url: 'Device_Sensor_Data_Add_data',//发送请求
  114. data: {
  115. SN:data.field.SN,
  116. t_name:data.field.t_name,
  117. t_id:data.field.t_id,
  118. t_t:data.field.t_t,
  119. t_rh:data.field.t_rh,
  120. t_tl:data.field.t_tl,
  121. t_tu:data.field.t_tu,
  122. t_rhl:data.field.t_rhl,
  123. t_rhu:data.field.t_rhu,
  124. t_time:data.field.t_time,
  125. },
  126. success: function(result) {
  127. console.log(result)
  128. if(result.Code == 200){
  129. layer.msg("操作成功", {
  130. icon: 1,
  131. time: 2000
  132. });
  133. }else {
  134. layer.msg("错误:"+result.Msg, {
  135. icon: 2,
  136. time: 2000
  137. });
  138. }
  139. //
  140. // //
  141. //关闭当前frame
  142. parent.layer.close(parent.layer.getFrameIndex(window.name));
  143. // parent.location.reload();
  144. // form.render('select');
  145. return false;
  146. }
  147. });
  148. return false;
  149. });
  150. });
  151. </script>
  152. <script>
  153. T_img = "{{.Date.T_img}}"
  154. layui.use('upload', function(){
  155. var $ = layui.jquery
  156. ,upload = layui.upload;
  157. //普通图片上传
  158. var uploadInst = upload.render({
  159. elem: '#test1'
  160. ,url: '/UpFile' //改成您自己的上传接口
  161. ,before: function(obj){
  162. //预读本地文件示例,不支持ie8
  163. obj.preview(function(index, file, result){
  164. $('#demo1').attr('src', result); //图片链接(base64)
  165. });
  166. }
  167. ,done: function(res){
  168. console.log(res)
  169. //如果上传失败
  170. if(res.code != 0){
  171. return layer.msg('上传失败');
  172. }
  173. T_img = res.data.src
  174. console.log(T_img)
  175. //上传成功
  176. }
  177. ,error: function(){
  178. console.log("error")
  179. //演示失败状态,并实现重传
  180. var demoText = $('#demoText');
  181. demoText.html('<span style="color: #ff5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
  182. demoText.find('.demo-reload').on('click', function(){
  183. uploadInst.upload();
  184. });
  185. }
  186. });
  187. //绑定原始文件域
  188. upload.render({
  189. elem: '#test20'
  190. ,url: 'https://httpbin.org/post' //改成您自己的上传接口
  191. ,done: function(res){
  192. layer.msg('上传成功');
  193. console.log(res)
  194. }
  195. });
  196. });
  197. </script>
  198. </body>
  199. </html>