From 491a3531ef2197675640153f320ce42ec96a3679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Tue, 20 Apr 2021 20:49:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=88=90=E7=BB=A9=E5=BD=95=E5=85=A5=E8=A1=A8=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=8C=89=E5=AD=A6=E7=94=9F=E5=A7=93=E5=90=8D=E9=A6=96?= =?UTF-8?q?=E6=8B=BC=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/kaohao/model/SearchMore.php | 5 +++-- app/luru/controller/Index.php | 10 ++++++---- database/seeds/Student.php | 8 +++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/kaohao/model/SearchMore.php b/app/kaohao/model/SearchMore.php index 70d972e7..1fb4afdd 100755 --- a/app/kaohao/model/SearchMore.php +++ b/app/kaohao/model/SearchMore.php @@ -180,7 +180,7 @@ class SearchMore extends BaseModel ->order(['banji_id', 'id']) ->with([ 'cjStudent' => function($q){ - $q->field('id, xingming, sex'); + $q->field('id, xingming, sex, shoupin'); } ]); } @@ -198,8 +198,9 @@ class SearchMore extends BaseModel ->where('id', $val->student_id) ->field('id, xingming') ->find(); - $data[$key]->banjiKaohao[$key]->cjStudent = array('id' => $stuinof->id, 'xingming' => $stuinof->xingming); + $data[$key]->banjiKaohao[$key]->cjStudent = array('id' => $stuinof->id, 'shoupin' => $stuinof->shoupin); } + $data[$key]['banjiKaohao'][$k]['shoupin'] = $val->cjStudent->shoupin; } } return $data; diff --git a/app/luru/controller/Index.php b/app/luru/controller/Index.php index 00312c9f..55c17f6c 100755 --- a/app/luru/controller/Index.php +++ b/app/luru/controller/Index.php @@ -519,11 +519,13 @@ class Index extends BaseController $i = 4; foreach ($kaohao as $key=>$bj) { - foreach ($bj->banjiKaohao as $k => $kh) { + $bjkh = $bj->banjiKaohao->toArray(); + $bjkh = sortArrByManyField($bjkh, 'shoupin', SORT_ASC); + foreach ($bjkh as $k => $kh) { $sheet->setCellValue('A' . $i, $i - 3); - $sheet->setCellValue('B' . $i, $md5::encrypt((string)$kh->id, 'dlbz')); - $sheet->setCellValue('C' . $i, $bj->banjiTitle); - $sheet->setCellValue('D' . $i, $kh->cjStudent->xingming); + $sheet->setCellValue('B' . $i, $md5::encrypt((string)$kh['id'], 'dlbz')); + $sheet->setCellValue('C' . $i, $bj['banjiTitle']); + $sheet->setCellValue('D' . $i, $kh['cjStudent']['xingming']); $i ++; } } diff --git a/database/seeds/Student.php b/database/seeds/Student.php index 5d84c8cf..e87d23d7 100644 --- a/database/seeds/Student.php +++ b/database/seeds/Student.php @@ -22,6 +22,7 @@ class Student extends Seeder ,'shengri' => 1349020800 ,'shenfenzhenghao' => '210202201210018223' ,'banji_id' => 1 + ,'shoupin' => 'yn' ] ,[ 'xingming' => '李倍亮' @@ -29,6 +30,7 @@ class Student extends Seeder ,'shengri' => 1349020800 ,'shenfenzhenghao' => '210202201210018214' ,'banji_id' => 1 + ,'shoupin' => 'lbl' ] ,[ 'xingming' => '张又张' @@ -36,6 +38,7 @@ class Student extends Seeder ,'shengri' => 1349020800 ,'shenfenzhenghao' => '210202201210018255' ,'banji_id' => 1 + ,'shoupin' => 'zyz' ] ,[ 'xingming' => '王小天' @@ -43,6 +46,7 @@ class Student extends Seeder ,'shengri' => 1349020800 ,'shenfenzhenghao' => '210202201210018236' ,'banji_id' => 1 + ,'shoupin' => 'wxt' ] ,[ 'xingming' => '张一凡' @@ -50,6 +54,7 @@ class Student extends Seeder ,'shengri' => 1349020800 ,'shenfenzhenghao' => '210202201210018227' ,'banji_id' => 1 + ,'shoupin' => 'zyf' ] ,[ 'xingming' => '成乐园' @@ -57,10 +62,11 @@ class Student extends Seeder ,'shengri' => 1349020800 ,'shenfenzhenghao' => '210202201210018218' ,'banji_id' => 1 + ,'shoupin' => 'cly' ] ]; // 保存数据 $this->table('student')->insert($rows)->save(); } -} \ No newline at end of file +} From 377f1914d197481442fcc1d8fe7b33439fc04ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Tue, 20 Apr 2021 21:26:14 +0800 Subject: [PATCH 2/2] 0 --- app/kaohao/controller/Index.php | 2 +- app/kaohao/model/SearchMore.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/kaohao/controller/Index.php b/app/kaohao/controller/Index.php index 98ed1bc5..a60ff529 100755 --- a/app/kaohao/controller/Index.php +++ b/app/kaohao/controller/Index.php @@ -85,7 +85,7 @@ class Index extends AdminBase ->where('kaoshi_id', $list['kaoshi_id']) ->where('student_id', $value->id) ->find(); - if($check) + if($check) # 恢复后学生还是原来的班级,删除后重新添加可能会出错 { if($check->delete_time > 0) { diff --git a/app/kaohao/model/SearchMore.php b/app/kaohao/model/SearchMore.php index 1fb4afdd..a99e3bfc 100755 --- a/app/kaohao/model/SearchMore.php +++ b/app/kaohao/model/SearchMore.php @@ -200,7 +200,7 @@ class SearchMore extends BaseModel ->find(); $data[$key]->banjiKaohao[$key]->cjStudent = array('id' => $stuinof->id, 'shoupin' => $stuinof->shoupin); } - $data[$key]['banjiKaohao'][$k]['shoupin'] = $val->cjStudent->shoupin; + $data[$key]['banjiKaohao'][$k]['shoupin'] = $val['cjStudent']['shoupin']; } } return $data;