Ver código fonte

公会和人员统计

lizhen_gitee 3 anos atrás
pai
commit
a989499528

+ 30 - 5
application/admin/controller/Gonghui.php

@@ -3,7 +3,7 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
-
+use think\Db;
 /**
  * 
  *
@@ -31,10 +31,35 @@ class Gonghui extends Backend
     }
 
     /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     * 查看
      */
-    
+    public function index()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                ->where($where)
+                ->order($sort, $order)
+                ->paginate($limit);
 
+            $rows = collection($list->items())->toArray();
+            foreach($rows as $key => $info){
+                $info['usernum'] = Db::name('user')->where('gh_id',$info['id'])->count('id');
+
+                $rows[$key] = $info;
+            }
+
+            $result = array("total" => $list->total(), "rows" => $rows);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
 }

+ 6 - 1
application/api/controller/Index.php

@@ -15,11 +15,16 @@ class Index extends Api
     protected $noNeedLogin = ['index','contactus','tcpTest','getAppShare','getWebsiteInfo','getUserCharmRankList','getPartyHotList','searchUsers','getInviteCode','getEdition','getInviteImg','getWebsiteInfoForMini','getBankList','getSwitch','getBootAnimation'];
     protected $noNeedRight = ['*'];
 
+    public function index(){
+        echo 'apisuccess';
+        exit;
+    }
+
     /**
      * 首页
      *
      */
-    public function index()
+    public function outMemberFromRoom()
     {
         // 强制关闭需要退出正在房间的用户
         $tenim = new \app\api\controller\Tenim();

+ 1 - 0
public/assets/js/backend/gonghui.js

@@ -27,6 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
                         {field: 'name', title: __('Name'), operate: 'LIKE'},
+                        {field: 'usernum', title: '人数'},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]

+ 9 - 1
public/assets/js/backend/user/user.js

@@ -17,6 +17,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 
             var table = $("#table");
 
+            //在普通搜索渲染后
+            table.on('post-common-search.bs.table', function (event, table) {
+                var form = $("form", table.$commonsearch);
+                $("input[name='gh_id']", form).addClass("selectpage").data("source", "gonghui/index").data("primaryKey", "id").data("field", "name").data("orderBy", "id asc");
+                Form.events.cxselect(form);
+                Form.events.selectpage(form);
+            });
+
             // 初始化表格
             table.bootstrapTable({
                 url: $.fn.bootstrapTable.defaults.extend.index_url,
@@ -77,7 +85,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         //{field: 'free_audio', title: __('Free_audio'), searchList: {"1":__('Free_audio 1'),"0":__('Free_audio 0')}, formatter: Table.api.formatter.normal},
                         //{field: 'free_typing', title: __('Free_typing'), searchList: {"1":__('Free_typing 1'),"0":__('Free_typing 0')}, formatter: Table.api.formatter.normal},
                         //{field: 'gonghui.id', title: __('Gonghui.id')},
-                        {field: 'gonghui.name', title: __('Gonghui.name'), operate: 'LIKE'},
+                        {field: 'gonghui.name', title: __('Gonghui.name'), operate: false},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]