From 7ebba935f0ff2c3b9defb3b1e8faad1ba0aed2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=82=E5=BE=92=E5=BC=A0=E4=B8=89?= Date: Tue, 4 Jan 2022 21:23:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=B2=E5=BD=95=E6=88=90?= =?UTF-8?q?=E7=BB=A9=E6=98=BE=E7=A4=BA=E5=92=8C=E7=BB=9F=E8=AE=A1=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chengji/model/Chengji.php | 22 +++++++++++++++++++++- app/luru/controller/Index.php | 7 +++++-- app/luru/view/index/yilu_cnt_table.html | 9 +++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/chengji/model/Chengji.php b/app/chengji/model/Chengji.php index 86b24b46..ccd6148f 100755 --- a/app/chengji/model/Chengji.php +++ b/app/chengji/model/Chengji.php @@ -139,6 +139,11 @@ class Chengji extends BaseModel ,'subject_id' => '' ,'searchval' => '' ,'user_id' => '' + ,'page' => 1 + ,'limit' => 10 + ,'field' => 'id' + ,'order' => 'desc' + ,'all' => false ); $src = array_cover($srcfrom, $src); $cjList = $this @@ -178,7 +183,6 @@ class Chengji extends BaseModel ]) ->select(); - // 重新整理成绩 $data = array(); foreach ($cjList as $key => $value) { @@ -208,7 +212,23 @@ class Chengji extends BaseModel $data[$key]['update_time'] = $value->update_time; } + + if ($src['order'] == 'asc') { + $src['order'] = SORT_ASC; + } else { + $src['order'] = SORT_DESC; + } + // halt($src['order']); + + $data = \app\facade\Tools::sortArrByManyField($data, $src['field'], $src['order']); + if($src['all'] != true) + { + $start = ($src['page'] - 1) * $src['limit']; + $data = array_slice($data, $start, $src['limit']); + } + return $data; + } diff --git a/app/luru/controller/Index.php b/app/luru/controller/Index.php index 44b7e467..96eb8ea8 100755 --- a/app/luru/controller/Index.php +++ b/app/luru/controller/Index.php @@ -52,12 +52,15 @@ class Index extends AdminBase ,'subject_id' => '' ,'searchval' ,'user_id' => session('user_id') + ,'all' => false ], 'POST'); // 根据条件查询数据 $cj = new Chengji; - $data = $cj->searchLuru($src); - $data = reset_data($data, $src); + $data = $cj->searchLuru($src); + $src['all'] = true; + $cnt = count($cj->searchLuru($src)); + $data = reset_data($data, $cnt); return json($data); } diff --git a/app/luru/view/index/yilu_cnt_table.html b/app/luru/view/index/yilu_cnt_table.html index 917d6365..b9bfc26a 100644 --- a/app/luru/view/index/yilu_cnt_table.html +++ b/app/luru/view/index/yilu_cnt_table.html @@ -120,8 +120,13 @@ layui.use(['table', 'form', 'canyuKaoshi'], function() { str = d.chengji[colname].xkcnt; } } - if (d.chengji.stucnt != str && str != 0) { - str = ''+str+'' + if (d.chengji.stucnt != str) { + if (str == 0) { + str = ''; + } else { + var cha = str - d.chengji.stucnt; + str = str + ' (' + cha + ')' + } } return str; }