<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设备列表</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta name="decorator" content="base" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/lib/font/iconfont.css" />
    <style>
        @font-face {
            font-family: 'iconfont';
            src: url('${ctxPlugin}/lib/font/iconfont.eot');
            src: url('${ctxPlugin}/lib/font/iconfont.eot?#iefix') format('embedded-opentype'),
            url('${ctxPlugin}/lib/font/iconfont.woff2') format('woff2'),
            url('${ctxPlugin}/lib/font/iconfont.woff') format('woff'),
            url('${ctxPlugin}/lib/font/iconfont.ttf') format('truetype'),
            url('${ctxPlugin}/lib/font/iconfont.svg#iconfont') format('svg');
        }
        .iconfont {
            font-family: "iconfont" !important;
            font-size: 16px;
            font-style: normal;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
  <div class="layui-form  layui-card">
      <div class="layui-tab layui-tab-brief">
          <ul class="layui-tab-title">
              <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " type="reset"  onclick="reset()" >
                  <i class="layui-icon fs-12">&#xe9aa;</i>
                  重置
              </button>
              <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " lay-submit lay-filter="LAY-user-back-search" data-type="reload">
                  <i class="layui-icon fs-12">&#xe615;</i>
                  查询
              </button>
          </ul>
      </div>
      <div class="layui-card-body" id="searchForm">
          <div class="layui-form-item">
              <%--<div class="layui-col-lg3 layui-col-sm3">
                  <label class="layui-form-label">设备状态：</label>
                  <div class="layui-input-block">
                      <select name="deviceStatus">
                          <option value="">请选择</option>
                          <option value="1">在线</option>
                          <option value="2">离线</option>
                          <option value="3">报警</option>
                      </select>
                  </div>
              </div>--%>
              <div class="layui-col-lg3 layui-col-sm3">
                  <label class="layui-form-label">设备名称：</label>
                  <div class="layui-input-block">
                      <input type="text" name="deviceName" id="deviceName" autocomplete="off" class="layui-input">
                  </div>
              </div>
              <div class="layui-col-lg3 layui-col-sm3">
                  <label class="layui-form-label">设备S/N：</label>
                  <div class="layui-input-block">
                      <input type="text" name="SNCode" id="SNCode" autocomplete="off" class="layui-input">
                  </div>
              </div>
              <div class="layui-col-lg3 layui-col-sm3">
                  <label class="layui-form-label">设备类型：</label>
                  <div class="layui-input-block">
                      <select name="deviceType" >
                          <option value="">请选择</option>
                          <option value="1">逆变器</option>
                          <option value="2">通讯棒</option>
                      </select>
                  </div>
              </div>
          </div>
      </div>
  </div>
 <div class='layui-card'>
     <div class="layui-card-body">
         <table class="layui-hide" lay-skin="row" id="test" lay-filter="test"></table>

     </div>
 </div>

</div>

<script type="text/html" id="table-toolbar">
</script>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/font/iconfont.js"></script>
<script>
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'jquery', 'layer','laydate','form'], function(){
        $ = layui.$;
        table = layui.table;
        layer = layui.layer;
        laypage = layui.laypage;
        var  form = layui.form;

        table.render({
            elem: '#test'
            // height: 'full-140'
            // , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/monitor/collect/data/equipmentInfoList?id=${id}'
            , cols: [[
                {type: 'numbers',title:'序号'}
                /*, {field: 'status', title: '设备状态', sort: false, align: 'center', templet: function(d){
                        if (d.status == '1') {
                            return '在线';
                        } else if (d.status == '2') {
                            return '离线';
                        } else if (d.status == '3') {
                            return '报警';
                        }
                        return '--';
                    }}*/
                , {field: 'deviceName', title: '设备名称', align: 'center'}
                , {field: 'SNCode', title: '设备S/N', align: 'center'}
                , {field: 'deviceType', title: '设备类型', align: 'center', templet: function(d){
                        if (d.deviceType == '1') {
                            return '逆变器';
                        } else if (d.deviceType == '2') {
                            return '通讯棒';
                        }
                        return '--';
                    }}
                , {field: 'materialBrand', title: '设备品牌', align: 'center'}
                , {field: 'deviceModel', title: '设备型号', align: 'center'}
            ]]
        });

        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            table.reload('test', {
                where: field,
                page:{
                    curr:1
                }
            });
        });

    });

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }

    function reload(){
        table.reload('test', {
            page:{
                curr:1
            }
        });
    }

    function reset(){
        layui.form.render();
        $("#searchForm").find("select").val("");
        $("#searchForm").find("input").val("");
    }
</script>
</body>
</html>

