12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <div class="layui-layout layui-layout-admin" style="padding-left: 20px;">
- <div class="layui-row" style="margin-top: 20px;">
- <div class="layui-col-xs6">
- <a class="layui-btn" data-type="tabAdd" href="/env/add">新增</a>
- </div>
- <div class="layui-col-xs6 search_text">
- <form class="layui-form" action="" onsubmit="javascript:return false;">
- <div class="demoTable">
- <div class="layui-inline" style="width: 40%">
- <input class="layui-input" name="envName" id="envName" autocomplete="off" placeholder="环境名称" >
- </div>
- <button class="layui-btn" data-type="reload">查询</button>
- </div>
- </form>
-
- </div>
- </div>
- <table class="layui-hide" id="table_list" lay-filter="table_filter">
- </table>
- <script type="text/html" id="bar">
- <!-- <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a> -->
- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
- </script>
- </div>
- <script>
- layui.use(['table','form','element'], function(){
- var table = layui.table;
- var form = layui.form;
- var element = layui.element;
- //方法级渲染
- table.render({
- elem: '#table_list'
- ,url: '/env/table'
- ,cols: [[
- // {checkbox: true, fixed: true},
- {field:'id', title: 'ID', align:'center',sort: true, width:150}
- ,{field:'env_name',title: '环境名称'}
- ,{field:'env_host', title: 'URL地址'}
- ,{field:'detail', title: '备注'}
- ,{field:'create_time', title: '创建时间'}
- ,{field:'update_time', title: '修改时间'}
- ,{fixed: 'right', width:160, align:'center', toolbar: '#bar'}
- ]]
- ,id: 'listReload'
- ,page: true
- ,height: "full-130"
- });
- var $ = layui.$, active = {
- reload: function(){
- table.reload('listReload', {
- where: {
- envName: $('#envName').val(),
- }
- });
- }
- };
- //监听工具条
- table.on('tool(table_filter)', function(obj){
- var data = obj.data;
- if(obj.event === 'detail'){
- //layer.msg('ID:'+ data.id + ' 的查看操作');
- } else if(obj.event === 'del'){
- layer.confirm('真的删除【'+data.env_name+'】么', function(index){
- var jsData = {'id':data.id}
- $.post('{{urlfor "EnvController.AjaxDel"}}', jsData, function (out) {
- if (out.status == 0) {
- layer.alert('删除成功了', {icon: 1},function(index){
- layer.close(index);
- window.location.reload();
- });
- } else {
- layer.msg(out.message)
- }
- }, "json");
- obj.del();
- layer.close(index);
- });
- } else if(obj.event === 'edit'){
- window.location.href="/env/edit?id="+data.id
- }
- });
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- });
- </script>
|