xxxrrrdddd 2 years ago
parent
commit
9bd04a3b93

+ 22 - 1
application/admin/controller/DataView.php

@@ -52,5 +52,26 @@ class DataView extends Backend
         }
         return $this->view->fetch();
     }
-    public function sub_data(){}
+    public function sub_data(){
+        if ($this->request->isAjax()) {
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = (new Admin)
+                ->where($where)
+                ->where('sub',1)
+                ->field(['password', 'salt', 'token'], true)
+                ->order($sort, $order)
+                ->paginate($limit);
+
+            foreach ($list as $k => &$v) {
+                $v['order_count']=$v->mobile()->count();
+                $v['mobile_saled_count']=$v->mobile()->filterSaled()->count();
+            }
+            unset($v);
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
 }

+ 6 - 0
application/admin/model/Admin.php

@@ -31,6 +31,12 @@ class Admin extends Model
     public function mobile(){
         return $this->hasMany(Mobile::class,'proxy_id');
     }
+    public function subOrder(){
+        return $this->hasMany(MobileOrder::class,'s_id');
+    }
+    public function proxyOrder(){
+        return $this->hasMany(MobileOrder::class,'admin_id');
+    }
 
     // 密码加密
     protected function encryptPassword($password, $salt = '', $encrypt = 'md5')

+ 13 - 0
application/admin/view/data_view/sub_data.html

@@ -0,0 +1,13 @@
+<div class="panel panel-default panel-intro">
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <table id="table" class="table table-striped table-bordered table-hover"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>

+ 30 - 0
public/assets/js/backend/data_view.js

@@ -45,6 +45,36 @@ function ($, undefined, Backend, Datatable, Table, Echarts, undefined, form) {
             // 为表格绑定事件
             Table.api.bindevent(table);
         },
+        sub_data: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'data_view/proxy_data',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                columns: [
+                    [
+                        {field: 'id', title: 'ID'},
+                        {field: 'nickname', title: __('代理商名称')},
+                        {field: 'mobile_count', title: __('号码数量')},
+                        {field: 'mobile_saled_count', title: __('号码消耗量')},
+                    ]
+                ],
+                search:false,
+                showToggle: false,
+                showExport: false,
+                commonSearch: false,
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
     };
     return Controller
 });