{extend name="public:form" /}
{block name="body"}
<style type="text/css">
.layui-table-page{
  text-align: right;
}
</style>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body">
                          <form class="layui-form">
                          </form>
                        </div>
                        
                      <div class="layui-card-body">
                      <table class="layui-table" lay-data="{  url:'/clouldlog_list', page:true, id:'idTest' }">
                       <thead>
                          <tr>
                          <th lay-data="{field:'log_id'}">ID</th>
                          <th lay-data="{field:'content'}" >信息</th>
                          <th lay-data="{field:'type', templet: '#is_type'}">操作</th>
                          <th lay-data="{field:'status', templet: '#is_status'} ">结果</th>
                          <th lay-data="{field:'create_time'}">操作时间</th>
                          </tr>
                        </thead>
                        </table>
                      </div>
                    </div>
                </div>
            </div>
        </div> 
    </body>
<script type="text/javascript" id="is_status">
            {{# if(d.status==1){ }}
                同步成功
            {{# }else if(d.status==2){ }}
                语法错误
            {{# }else if(d.status==3){ }}
                同步失败
            {{# }else if(d.status==4){ }}
                 项目编号重复
            {{# }else if(d.status==5){ }}
                暂无数据同步
             {{# }else { }}
                  接口请求超时
              {{# } }}
  </script>
<script type="text/javascript" id="is_type">
            {{# if(d.type==0){ }}
                数据添加
             {{# }else { }}
                 数据修改
              {{# } }}
  </script>
<script>
layui.use(['table','laydate'], function(){


  var table = layui.table;
  var laydate = layui.laydate;

   
  //监听表格复选框选择
  table.on('checkbox(demo)', function(obj){
    console.log(obj)
  });

  //监听工具条
  table.on('tool(demo)', function(obj){
    var data = obj.data;
    if(obj.event === 'detail'){
      layer.msg('ID：'+ data.id + ' 的查看操作');
    } else if(obj.event === 'del'){
      layer.confirm('真的删除行么', function(index){
        obj.del();
        layer.close(index);
      });
    } else if(obj.event === 'edit'){
 
      layer.open({
                    content: "真的提交申请确收吗",
                    btn: ['确定'],
                    icon: 6,
                    yes: function() {
                       
                          $.ajax({
                        url: '/editque',
                        method: "POST",
                        data: {id:JSON.stringify(data.id)},
                      
                        success: function (data) {
                         if (data.status == 1) {
                                layer.msg(data.message,{icon: 6,time: 1000 },
                                    function(){
                                        window.location.href="/meter_list"
                                    });
                            } else {
                                layer.msg(data.message,{icon: 5,time: 1000 })
                            }
                        }
                    }); 
                    }
                });
       
         }
  });
  
  var $ = layui.$, active = {
    getCheckData: function(){ //获取选中数据
      var checkStatus = table.checkStatus('idTest')
      ,data = checkStatus.data;
      layer.alert(JSON.stringify(data));
    }
    ,getCheckLength: function(){ //获取选中数目
      var checkStatus = table.checkStatus('idTest')
      ,data = checkStatus.data;
      layer.msg('选中了：'+ data.length + ' 个');
    }
    ,isAll: function(){ //验证是否全选
      var checkStatus = table.checkStatus('idTest');
      layer.msg(checkStatus.isAll ? '全选': '未全选')
    }
  };
  
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});
</script>

{/block}