{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">
                              <div class="layui-input-inline layui-show-xs-block" style="width:130px;">
                              <select name="search_type" id="search_type">
                                <option value="1" {if $search_type eq 1 } selected {/if}>站名</option>
                                <option value="2" {if $search_type eq 2 } selected {/if}>站号</option>
                                <option value="3" {if $search_type eq 3 } selected {/if}>项目编号</option>

                              </select>
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                              <input type="text" name="search_text" placeholder="搜索内容" style="width:150px;" autocomplete="off" id="search_text" value="{$search_text}" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block" style="width:130px;">
                              <select name="original_sp_id" id="original_sp_id">
                                <option value="0">运营商</option>
                                {volist name="operators" id="item"}
                                <option value="{$item.operator_id}"  {if $original_sp_id eq $item.operator_id } selected {/if} >{$item.operator_name}</option>
                                {/volist}
                              </select>
                            </div>
                            <div class="layui-input-inline layui-show-xs-block" style="width:130px;">

                              <select name="area_id" id="area_id">
                              <option value="0"> 区域</option>
                              {volist name="regions" id="region"}
                              {if $region.level == 0}
                                <option disabled='disabled'  class='layui-disabled' >{$region.region_name}</option>
                              {else /}
                              <option value="{$region.id}" {if $area_id eq $region.id } selected {/if} >&nbsp;&nbsp;&nbsp;&nbsp;{$region.region_name}</option>
                              {/if}
                              
                              {/volist}
                             
                              </select>
                            </div>

                            <div class="layui-input-inline layui-show-xs-block" style="width:130px;">
                               <select name="base_station_state"  id="base_station_state">
                                 <option value="0"> 基站状态</option>
                                    {volist name="basestatus" id="basestatu"}
                                    {if $basestatu.level == 0}
                                      <option disabled='disabled'  class='layui-disabled' >{$basestatu.cate_name}</option>
                                    {else /}
                                    <option value="{$basestatu.cate_id}" {if $base_station_state eq  $basestatu.cate_id} selected {/if} >&nbsp;&nbsp;&nbsp;&nbsp;{$basestatu.cate_name}</option>
                                    {/if}
                                    
                                    {/volist}
                              </select>
                            </div>
                    
                            <div class="layui-input-inline layui-show-xs-block">
                              <button class="layui-btn" lay-submit="" lay-filter="search">
                                <i class="layui-icon">&#xe615;</i></button>
                            </div>
                          </form>
                        </div>
                            <div class="layui-card-header">
                            <button class="layui-btn" onclick="xadmin.open('添加','/base_add')" >
                            <i class="layui-icon"></i>添加</button>          
                            <button class="layui-btn" id="BaseImport">
                            <i class="layui-icon iconfont">&#xe7e4;</i></button>
                            <a href="/base_export"  class="layui-btn">
                            <i class="layui-icon iconfont">&#xe7e6;</i></a>
                        </div> 
                      <div class="layui-card-body">
                      <table class="layui-table" lay-data="{  url:'/base_list', page:true,  id:'idTest',where:{search_type:document.getElementById('search_type').value,search_text:document.getElementById('search_text').value,original_sp_id:document.getElementById('original_sp_id').value,area_id:document.getElementById('area_id').value,base_station_state:document.getElementById('base_station_state').value} }">
                       <thead>
                          <tr>
                          <th lay-data="{templet: '#proj_number'}">项目编号</th>
                          <th lay-data="{field:'station_name',templet: '#station_name'}" >基站名称</th>
                          <th lay-data="{field:'station_sp_code',templet: '#station_sp_code'}">基站编号</th>
                          <th lay-data="{field:'operator_name',templet: '#operator_name'} ">运营商</th>
                          <th lay-data="{field:'name',templet: '#name'}">部门</th>
                          <th lay-data="{field:'region_name',templet: '#region_name'}">区域</th>
                          <th lay-data="{field:'business_name',templet: '#business_name'}">业务线</th>
                          <th lay-data="{field:'cate_name',templet: '#cate_name'}">基站状态</th>
                            <th lay-data="{fixed: 'right',  align:'center', toolbar: '#barDemo'}">操作</th>
                          </tr>
                        </thead>
                        </table>
                      </div>
                    </div>
                </div>
            </div>
        </div> 
    </body>
<script type="text/html" id="proj_number">
         <a class="layui-link" href="/base_detai?id={{d.station_id}}">{{d.proj_number}}</a>
</script>
<script type="text/html" id="station_name">
        {{# if(d.station_name==null){ }}
           无
        {{# }else{ }}
        {{d.station_name}}
        {{# } }}
</script>
<script type="text/html" id="station_sp_code">
        {{# if(d.station_sp_code==null || d.station_sp_code==0){ }}
            无
        {{# }else{ }}
        {{d.station_sp_code}}
        {{# } }}
</script>
<script type="text/html" id="operator_name">
        {{# if(d.operator_name==null){ }}
          无
        {{# }else{ }}
        {{d.operator_name}}
        {{# } }}
</script>
<script type="text/html" id="name">
        {{# if(d.name==null){ }}
          无
        {{# }else{ }}
        {{d.name}}
        {{# } }}
</script>
<script type="text/html" id="region_name">
        {{# if(d.region_name==null  || d.region_name==0){ }}
           无
        {{# }else{ }}
        {{d.region_name}}
        {{# } }}
</script>
<script type="text/html" id="business_name">
        {{# if(d.business_name==null  || d.business_name==0){ }}
           无
        {{# }else{ }}
        {{d.business_name}}
        {{# } }}
</script>
<script type="text/html" id="cate_name">
        {{# if(d.cate_name==null){ }}
          无
        {{# }else{ }}
        {{d.cate_name}}
        {{# } }}
</script>
<script type="text/html" id="barDemo">
<a title="编辑" href="/base_geteditinfo?id={{d.station_id}}">
[编辑]</a>
{{# if(d.latitude==null || d.latitude == "" || d.latitude==0 ){ }}

{{# }else{ }}
<a title="位置"  onclick="xadmin.open('地图显示','/base_map?id={{d.station_id}}')" href="javascript:void(0);">
[位置]</a>
{{# } }}
</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;
    
  });
  
  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>
   <script>
      layui.use(['upload'], function(){
        var  upload  = layui.upload;
        var BaseImport = upload.render({
          elem: '#BaseImport' , 
          url: '/base_import',
          accept:'file',
          field: 'file_name',
          done: function (res) {

              if(res.status == 1){
                layer.open({
                    content: res.message,
                    btn: ['确定'],
                    yes: function() {
                        layer.closeAll();
                        window.location.reload();
                    }
                });
              }
              if(res.status == 0){
              layer.open({
                    content: res.message,
                    btn: ['确定'],
                    yes: function() {
                        layer.closeAll();
                        window.location.reload();
                    }
                });
              }

              else {
                  //layMsg(res.message,5)
                  return;
              }                  
          }
      });
   });
    </script>
{/block}