123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <!DOCTYPE html>
- <html class="x-admin-sm">
-
- <head>
- <meta charset="UTF-8">
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
- <link rel="shortcut icon" href="https://osscold.baozhida.cn/favicon.ico">
- <link rel="bookmark" href="https://osscold.baozhida.cn/favicon.ico">
- <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
- <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
- <link rel="stylesheet" href="https://osscold.baozhida.cn/layui/css/layui.css">
- <script type="text/javascript" src="https://osscold.baozhida.cn/layui/layui.js" charset="utf-8"></script>
- <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
- <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
- <!--[if lt IE 9]>
- <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
- <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
- <![endif]--></head>
-
- <body>
- <div class="layui-fluid">
- <div class="layui-row">
- <form class="layui-form">
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>SN</label>
- <div class="layui-input-inline">
- <input type="text" id="SN" name="SN" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>传感器名称</label>
- <div class="layui-input-inline">
- <input type="text" id="t_name" name="t_name" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>传感器编号</label>
- <div class="layui-input-inline">
- <input type="text" id="t_id" name="t_id" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>温度</label>
- <div class="layui-input-inline">
- <input type="text" id="t_t" name="t_t" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>温度-最低</label>
- <div class="layui-input-inline">
- <input type="text" id="t_tl" name="t_tl" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>温度-最高</label>
- <div class="layui-input-inline">
- <input type="text" id="t_tu" name="t_tu" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>湿度</label>
- <div class="layui-input-inline">
- <input type="text" id="t_rh" name="t_rh" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>湿度-最低</label>
- <div class="layui-input-inline">
- <input type="text" id="t_rhl" name="t_rhl" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>湿度-最高</label>
- <div class="layui-input-inline">
- <input type="text" id="t_rhu" name="t_rhu" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="T_name" class="layui-form-label">
- <span class="x-red">*</span>时间</label>
- <div class="layui-input-inline">
- <input type="text" id="t_time" name="t_time" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item" style="text-align: center;margin-top: 20px">
- <!-- <label for="L_repass" class="layui-form-label"></label>-->
- <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">提交</button></div>
- </form>
- </div>
- </div>
- <script>
- layui.use(['form', 'layer',"layedit"],
- function() {
- $ = layui.jquery;
- var form = layui.form,
- layer = layui.layer;
- var layedit = layui.layedit
- layedit.set({
- uploadImage: {
- url: '/UpFile' //接口url
- }
- });
- //构建一个默认的编辑器
- var index = layedit.build('T_text', {
- height: 580 //设置编辑器高度,
- });
- //监听提交
- form.on('submit(add)',
- function(data) {
- console.log("=== submit(add) ==");
- console.log(data);
- $.ajax({
- type: 'POST',
- url: 'Device_Sensor_Data_Add_data',//发送请求
- data: {
- SN:data.field.SN,
- t_name:data.field.t_name,
- t_id:data.field.t_id,
- t_t:data.field.t_t,
- t_rh:data.field.t_rh,
- t_tl:data.field.t_tl,
- t_tu:data.field.t_tu,
- t_rhl:data.field.t_rhl,
- t_rhu:data.field.t_rhu,
- t_time:data.field.t_time,
- },
- success: function(result) {
- console.log(result)
- if(result.Code == 200){
- layer.msg("操作成功", {
- icon: 1,
- time: 2000
- });
- }else {
- layer.msg("错误:"+result.Msg, {
- icon: 2,
- time: 2000
- });
- }
- //
- // //
- //关闭当前frame
- parent.layer.close(parent.layer.getFrameIndex(window.name));
- // parent.location.reload();
- // form.render('select');
- return false;
- }
- });
- return false;
- });
- });
- </script>
- <script>
- T_img = "{{.Date.T_img}}"
- layui.use('upload', function(){
- var $ = layui.jquery
- ,upload = layui.upload;
- //普通图片上传
- var uploadInst = upload.render({
- elem: '#test1'
- ,url: '/UpFile' //改成您自己的上传接口
- ,before: function(obj){
- //预读本地文件示例,不支持ie8
- obj.preview(function(index, file, result){
- $('#demo1').attr('src', result); //图片链接(base64)
- });
- }
- ,done: function(res){
- console.log(res)
- //如果上传失败
- if(res.code != 0){
- return layer.msg('上传失败');
- }
- T_img = res.data.src
- console.log(T_img)
- //上传成功
- }
- ,error: function(){
- console.log("error")
- //演示失败状态,并实现重传
- var demoText = $('#demoText');
- demoText.html('<span style="color: #ff5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
- demoText.find('.demo-reload').on('click', function(){
- uploadInst.upload();
- });
- }
- });
- //绑定原始文件域
- upload.render({
- elem: '#test20'
- ,url: 'https://httpbin.org/post' //改成您自己的上传接口
- ,done: function(res){
- layer.msg('上传成功');
- console.log(res)
- }
- });
- });
- </script>
- </body>
- </html>
|