{extend name="public:form" /}
{block name="body"}
<style type="text/css">

</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">
                              <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="搜索内容" autocomplete="off" id="search_text" value="{$search_text}" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                              <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">

                              <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">
                               <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" >
                                <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" target="_blank" class="layui-btn">
                                <i class="layui-icon iconfont">&#xe7e6;</i></a>
                            <div class="layui-input-inline layui-show-xs-block">
                             
                            </div>
                        </div> 
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form">
                              <thead>
                                <tr>
                                <th >编号</th>
                                <th >项目编号</th>
                                <th >站名</th>
                                <th >站号</th>
                                <th>运营商</th>
                                <th>基站状态</th>
                                <th>部门</th>
                                <th>操作</th>
                              </thead>
                                <script id="arlist" type="text/html">
                                {{# for(var i=0;i<d.length;i++){  }}

                <tr class="long-td">
             <td >
                  {{# if(d[i].page==1){ }}
                    {{[i+1]}} 
                      {{# }else{ }}
                      {{[d[i].page-1]*10+i+1}}
                      {{# } }}
                  </td>
                  <td>
                    {{# if(d[i].proj_number==null || d[i].proj_number == ""){ }}
                      无
                      {{# }else{ }}
                     
                      <a href="/base_detai?id={{d[i].station_id}}" class="layui-link" style=" width: 150px;
    overflow: hidden;display: inline-block;text-overflow: ellipsis;white-space: nowrap;"  title=" {{d[i].proj_number}}" > {{d[i].proj_number}}</a>
                      {{# } }}
                  </td>
                  <td >
                    {{# if(d[i].station_name==null || d[i].station_name == ""){ }}
                      无
                      {{# }else{ }}
<a href="/base_detai?id={{d[i].station_id}}" style=" width: 150px;
    overflow: hidden;display: inline-block;text-overflow: ellipsis;white-space: nowrap;"  title="{{d[i].station_name}}" >{{d[i].station_name}}</a>
              
                      {{# } }}
                  </td>
          
                  <td>
                    {{# if(d[i].station_sp_code==null || d[i].station_sp_code == ""){ }}
                      无
                      {{# }else{ }}
                    
                       <a href="#" style=" width: 100px;
    overflow: hidden;display: inline-block;text-overflow: ellipsis;white-space: nowrap;"  title="   {{d[i].station_sp_code}}" >   {{d[i].station_sp_code}}</a>
                      {{# } }}
                  </td>
                          <td>
                    {{# if(d[i].operator_name==null || d[i].operator_name == ""){ }}
                      无
                      {{# }else{ }}
                      {{d[i].operator_name}}
                      {{# } }}
                  </td>
                  
                                       
                     <td>
                    {{# if(d[i].cate_name==null || d[i].cate_name == "" || d[i].cate_name==0){ }}
                      无
                      {{# }else{ }}
                      {{d[i].cate_name}}
                      {{# } }}
                  </td>
        
                   <td>
                    {{# if(d[i].name==null || d[i].name == ""){ }}
                      无
                      {{# }else{ }}
                      {{d[i].name}}
                      {{# } }}
                  </td>
                  

                   
               <td class="td-manage">
                  <a title="编辑" href="/base_geteditinfo?id={{d[i].station_id}}">
                  [编辑]</a>
                  {{# if(d[i].latitude==null || d[i].latitude == "" || d[i].latitude==0 ){ }}

                  {{# }else{ }}
                <a title="位置"  onclick="xadmin.open('地图显示','/base_map?id={{d[i].station_id}}')" href="javascript:void(0);">
                  [位置]</a>
                   {{# } }}
              </td>
                {{# } }}
              </script>
                            <tbody id="article_list"></tbody>
                            </table>
                        </div>
                        <div class="layui-card-body ">
                        <div id="AjaxPage" style=" text-align: right;"></div>
                    <div id="allpage" style=" text-align: right;"></div>

                        </div>
                    </div>
                </div>
            </div>
        </div> 
    </body>
    <script type="text/javascript" src="__STATIC__/xadmin/js/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/xadmin/js/laytpl/laytpl.js"></script>
    <script type="text/javascript" src="__STATIC__/xadmin/js/laypage/laypage.js"></script>
    <script type="text/javascript">
  //laypage分页
    function Ajaxpage(curr) {
         var search_type = $('#search_type').val();
         var search_text = $('#search_text').val();
         var original_sp_id = $('#original_sp_id').val();
          var area_id = $('#area_id').val();
          var base_station_state = $('#base_station_state').val();
        $.get('/base_list', {
            page: curr || 1,
            search_type:search_type,
            search_text:search_text,
            original_sp_id:original_sp_id,
            area_id:area_id,
            base_station_state:base_station_state
        }, function(data) {
            if (data==null) {
            $("#article_list").html('<tr><td colspan="8" style="margin-top:150px;font-size:20px; text-align: center; " >暂无数据</td/></tr>');
            } else {
                article_list(data);
                laypage({
                    cont: $('#AjaxPage'), //容器。值支持id名、原生dom对象，jquery对象,
                    pages: '{$allpage}', //总页数
                    skip: true, //是否开启跳页
                    skin: '#009688',
                    layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
                    curr: curr || 1,
                    groups: 4, //连续显示分页数
                    jump: function(obj, first) {

                        if (!first) {
                            Ajaxpage(obj.curr)
                        }
                        $('#allpage').html('第' + obj.curr + '页，共' + obj.pages + '页，共' + {$count} + '条记录');
                      
                    }
                });
            }
        });

    }
    Ajaxpage();

    //接收异步获取的数据渲染到模板
    function article_list(list) {
     
        var tpl = document.getElementById('arlist').innerHTML;
        laytpl(tpl).render(list, function(html) {
            document.getElementById('article_list').innerHTML = html;
        });
    }

    </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}
