colly_wyx
2017-07-24 73dd53d79b45217db5b890612cbfb82d9639c092
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
 
    <link rel="stylesheet" href="/themes/AdminLTE/plugins/datatables/dataTables.bootstrap.css">
 
    <section class="content-header">
      <h1>
        用户管理
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Tables</a></li>
        <li class="active">Data tables</li>
      </ol>
    </section>
 
     <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">用户列表</h3>
            </div>
            
            <!-- /.box-header -->
            <div class="box-body">
              <table id="table_list" class="table table-bordered table-hover">
                <thead>
                  <tr>
                    <th>手机号</th>
                    <th>昵称</th>
                    <th>刷新频率</th>
                    <th>是否上报</th>
                    <th>铃声</th>
                    <th>状态</th>
                    <th>操作</th>
                  </tr>
                </thead>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </section>
 
<script>
  $(function () {
    var config = {
      "dom": 'l<"#toolbar">frtip',
      /*
       * 默认为false
       * 当表格在处理的时候(比如排序操作)是否显示“处理中...”
       * 当表格的数据中的数据过多以至于对其中的记录进行排序时会消耗足以被察觉的时间的时候,该选项会有些用处
       */
         "processing":true,
      /*
        * 默认为true
        * 是否允许终端用户从一个选择列表中选择分页的页数,页数为10,25,50和100,需要分页组件bPaginate的支持
        */
        "lengthChange":false,
        "serverSide":true,
        "autoWidth": true,
        "language":{
          "lengthMenu": "每页显示 _MENU_ 条",
          "emptyTable": "没有任何数据记录",
          "processing": "正在载入数据...",
          "search": "搜索 _INPUT_",
          "info": "显示 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
          "zeroRecords": "暂时没有任何数据记录",
          "sInfoEmpty": "",
          "paginate": {
            "first": "首页",
            "previous": "上一页",
            "next": "下一页",
            "last": "尾页"
          },
        },
        "ajax":{
          "url": "/user/user/list",
          "type":"POST",
        },
        "columns":[
          {
            "data":"phone",
            "orderable":false
          },
          {
            "data":"nickname",
            "orderable":false
          },
          {
            "data":"refresh_frequency",
            "orderable":false
          },
          {
            "data":"is_open_upload",
            "orderable":false
          },
          {
            "data":"video",
            "orderable":false
          },
          {
            "data":"is_lock",
            "orderable":false
          },
          {
            "data":null,
            "orderable":false
          },
        ],
        "columnDefs": [
          {
            "targets":2,
            "searchable":false,
            "render":function(data, type, row, meta){
              return data+"秒/次";
            }
          },
          {
            "targets":3,
            "searchable":false,
            "render":function(data, type, row, meta){
              if(data == 0) {
                return "否";
              }
              else{
                return "是";
              }
            }
          },
          {
            "targets":5,
            "searchable":false,
            "render":function(data, type, row, meta){
              if(data == 0) {
                return "正常";
              }
              else{
                return "冻结";
              }
            }
          },
          {
            "targets":6,
            "searchable":false,
            "render":function(data, type, row, meta){
              return '<a class="btn btn-primary" href="/<?php echo $route['module']?>/<?php echo $route['controller']?>/edit/id/'+row['_id']+'">编辑</a>'
            }
          }
        ],
        "initComplete": function(){
          $("#toolbar").css("width", "100px").css("display", "inline").css("margin-left", "10px");
          $("#toolbar").append('<a id="build"  class="btn btn-success" data-toggle="modal" data-target="" href="/<?php echo $route['module']?>/<?php echo $route['controller']?>/add"> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>添加 <a> ');
        }
 
    }
    $("#table_list").DataTable(config);
  });
</script>