Jonlin há 6 anos atrás
pai
commit
46688483a1

+ 19 - 1
application/admin/controller/Accounts.php

@@ -86,12 +86,30 @@ class Accounts extends Base
     //用户信息导出
     public function toexcel()
     {
-        $result = db('accounts')->order('add_time', 'desc')->select();
+        $param = input('param.');
+        $start = $param['start'];
+        $end = $param['end'];
+        $where = [];
+        if(!empty($param['label_id'])){
+            $where['label_id'] = $param['label_id'];
+        }
+        if($param['account'] == 'account_name'){
+            if(!empty($param['username'])){
+                $where['account_name'] = ['like', '%' . $param['username'] . '%'];
+            }
+        }
+        if($param['account'] == 'nick_name'){
+            if(!empty($param['username'])){
+                $where['nick_name'] = ['like', '%' . $param['username'] . '%'];
+            }
+        }
+        $result = db('accounts')->whereBetween('add_time', [strtotime($start), strtotime($end . ' 23:59:59')])->where($where)->order('add_time', 'desc')->select();
         //所有标签
         $label = db('accountslabel')->select();
         foreach($result as $key=>$vo){
             $result[$key]['add_time'] = date('Y-m-d H:i:s',$result[$key]['add_time']);
             $result[$key]['last_login_time'] = date('Y-m-d H:i:s',$result[$key]['last_login_time']);
+            $result[$key]['label'] = '';
             for($j=0;$j<count($label);$j++){
                 if($vo['label_id'] == $label[$j]['id']){
                     $result[$key]['label'] = $label[$j]['name'];

+ 6 - 1
application/admin/view/accounts/index.html

@@ -167,7 +167,12 @@
 
         $("#toExcel").on("click", function () {
             $("#toExcel").val(1);
-            var url = "{:url('accounts/toexcel')}" + "?pageNumber=1&pageSize=100&toExcel=1";
+            var start = $("#start").val();
+            var end = $("#end").val();
+            var label_id = $("#label_id").val();
+            var account = $("#account").val();
+            var username = $("#username").val();
+            var url = "{:url('accounts/toexcel')}" + "?pageNumber=1&pageSize=100&start="+start+"&end="+end+"&label_id="+label_id+"&account="+account+"&username="+username+"&toExcel=1";
             window.open(url);
             return false;
         });