1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <link rel="stylesheet" href="js/layui/css/layui.css" media="all"> </head> <body> <!-- 添加 --> <form class="layui-form" action="" id="addform" style="display:none"> <div class="layui-form-item"> <label class="layui-form-label">输入框</label> <div class="layui-input-inline"> <input type="text" name="movieName" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">输入框</label> <div class="layui-input-inline"> <input type="text" name="marking" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input"> </div> </div> <label class="layui-form-label">日期</label> <div class="layui-input-inline"> <!-- 注意:这一层元素并不是必须的 --> <input type="text" class="layui-input" id="widingTime" name="widingTime"> </div> <div class="layui-form-item"> <label class="layui-form-label">选择框</label> <div class="layui-input-inline"> <select name="typeId" class="typeId" lay-verify="required"> <option value="0"></option> </select> </div> </div> <div class="layui-form-item"> <div class="layui-input-inline"> <button class="layui-btn" lay-submit lay-filter="tianjia">立即提交</button> <button type="reset" class="layui-btn layui-btn-primary">重置</button> </div> </div> </form> <!-- 模糊查询 --> <form class="layui-form" action=""> <div class="layui-form-item"> <label class="layui-form-label">输入框</label> <div class="layui-input-inline"> <input type="text" name="title" id="movieName" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input"> </div> <label class="layui-form-label">日期</label> <div class="layui-input-inline"> <!-- 注意:这一层元素并不是必须的 --> <input type="text" class="layui-input" id="begin_widingTime"> </div> <div class="layui-input-inline"> <!-- 注意:这一层元素并不是必须的 --> <input type="text" class="layui-input" id="end_widingTime"> </div> <label class="layui-form-label">选择框</label> <div class="layui-input-inline"> <select name="city" id="typeId" class="typeId" lay-verify="required"> <option value=""></option> </select> </div> <div class="layui-input-inline"> <button class="layui-btn" lay-submit lay-filter="chaxun">立即提交</button> <button type="button" id="add">重置</button> </div> </div> </form> <table id="demo" lay-filter="test"></table> <script src="js/layui/layui.js"></script> <script> layui.use(['table','laydate','layer','form'], function(){ var table = layui.table; var laydate = layui.laydate; var layer = layui.layer; var form = layui.form; var $ = layui.$; //第一个实例 table.render({ elem: '#demo' ,height: 312 ,id:'mytable' ,url: 'getMov' //数据接口 ,page: true //开启分页 ,cols: [[ //表头 {field: 'movieId', title: 'ID', width:80, sort: true, fixed: 'left'} ,{field: 'movieName', title: '用户名', width:80} ,{field: '', title: '性别', width:80, sort: true,templet:function(obj){return obj.type.typeName}} ,{field: 'widingTime', title: '城市', width:80} ,{field: 'marking', title: '签名', width: 177} ]] }); $("#add").click(function(){ layer.open({ type: 1, content:$("#addform") //这里content是一个普通的String }); }); form.on('submit(tianjia)', function(data){ $.post("addMov",$("#addform").serialize(),function(res){ if (res.code==="0") { layer.closeAll(); layer.msg("cg"); table.reload("mytable") } else { layer.msg("失败"); } },"json"); return false; }); /* 模糊查询 */ form.on('submit(chaxun)', function(data){ table.reload('mytable', { url: 'getMov' ,where: { movieName:$("#movieName").val(), begin_widingTime:$("#begin_widingTime").val(), end_widingTime:$("#end_widingTime").val(), typeId:$("#typeId").val() } //设定异步数据接口的额外参数 //,height: 300 }); return false; }); $.post("getType",{},function(res){ for (var i = 0; i < res.length; i++) { $(".typeId").append(`<option value="${res[i].typeId}">${res[i].typeName}</option>`) } form.render("select"); },"json"); laydate.render({ elem: '#begin_widingTime' //指定元素 }); laydate.render({ elem: '#end_widingTime' //指定元素 }); laydate.render({ elem: '#widingTime' //指定元素 }); }); </script> </body> </html> |
相关文章
- 11-24dlpdlpyydsyyds