编写下载年级统计成绩
This commit is contained in:
1 parent
3f8574df34
commit
a8ef8ad403
17 files changed
+495
-51
No files matched your search
@@ -377,12 +377,20 @@ class Index extends Base
|
||||
//生成学生表格
|
||||
public function chengjixls()
|
||||
{
|
||||
// 获取表单值
|
||||
$list = request()->post();
|
||||
// 实例化验证模型
|
||||
$validate = new \app\teach\validate\Kaoshi;
|
||||
$validate = new \app\chengji\validate\Cjdownload;
|
||||
// 验证表单数据
|
||||
$result = $validate->check($list);
|
||||
$msg = $validate->getError();
|
||||
|
||||
// 如果验证不通过则停止保存
|
||||
if(!$result){
|
||||
$this->error($msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
set_time_limit(0);
|
||||
@@ -464,11 +472,11 @@ class Index extends Base
|
||||
|
||||
|
||||
// 保存文件
|
||||
$filename = $ks.'学生成绩列表'.date('ymdHis').'.xls';
|
||||
$filename = $ks.'学生成绩列表'.date('ymdHis').'.xlsx';
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="' . $filename . '"');
|
||||
header('Cache-Control: max-age=0');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save('php://output');
|
||||
ob_flush();
|
||||
flush();
|
||||
|
||||
@@ -8,11 +8,11 @@ use app\common\controller\Base;
|
||||
class Tongji extends Base
|
||||
{
|
||||
// 年级成绩汇总
|
||||
public function nianji($id)
|
||||
public function tjnianji($id)
|
||||
{
|
||||
|
||||
// 设置页面标题
|
||||
$list['title'] = '教师列表';
|
||||
$list['title'] = '年级成绩统计';
|
||||
$list['kaoshi'] = $id;
|
||||
|
||||
// 模板赋值
|
||||
@@ -83,18 +83,95 @@ class Tongji extends Base
|
||||
}
|
||||
|
||||
|
||||
// 年级、班级学生成绩统计结果下载
|
||||
public function downloadnj()
|
||||
// 年级、班级学生成绩统计结果下载界面
|
||||
public function downloadnj($id)
|
||||
{
|
||||
dump('aa');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 年级、班级学生成绩统计下载表格
|
||||
public function downloadxls($id)
|
||||
{
|
||||
dump('aa');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 获取各学校、各年级考试成绩
|
||||
public function schoolNianji()
|
||||
public function tjschool($id)
|
||||
{
|
||||
// 设置页面标题
|
||||
$list['title'] = '学校成绩统计';
|
||||
$list['kaoshi'] = $id;
|
||||
|
||||
// 模板赋值
|
||||
$this->assign('list', $list);
|
||||
|
||||
// 渲染模板
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
// 获取年级成绩统计结果
|
||||
public function ajaxSchool()
|
||||
{
|
||||
// 获取年级和班级列表名
|
||||
$njnames = nianjiList();
|
||||
|
||||
// 获取表单参数
|
||||
$getParam = request()->param();
|
||||
$school = $getParam['school'];
|
||||
|
||||
// 实例化成绩数据模型
|
||||
$cj = new \app\chengji\model\Chengji;
|
||||
|
||||
// 根据考试号和年级获取考试成绩
|
||||
$cjlist = $cj->searchNianji($getParam['kaoshiid'],$school,$getParam['ruxuenian']);
|
||||
|
||||
// 根据年级获取一个有多少个班级
|
||||
$bj = new \app\teach\model\Banji;
|
||||
$bjids = $bj->where('ruxuenian',$getParam['ruxuenian'])
|
||||
->when(!empty($school),function($query) use($school){
|
||||
$query->where('school','in',$school);
|
||||
})
|
||||
->append(['title'])
|
||||
->select();
|
||||
$cnt = $bjids->count() + 1;
|
||||
|
||||
|
||||
// 实例化成绩统计模型
|
||||
$tj = new \app\chengji\model\Tongji();
|
||||
// 获取统计成绩参数
|
||||
$canshu = $tj->getCanshu($getParam['kaoshiid']);
|
||||
|
||||
|
||||
|
||||
// 循环获取各班级成绩
|
||||
$i = 0;
|
||||
foreach ($bjids as $key => $value) {
|
||||
$data[$i]['id'] = $i+1;
|
||||
$data[$i]['title'] = $value['title'];
|
||||
$bjlist = $cjlist->where('banji',$value['id']);
|
||||
$data[$i]['data'] = $tj->tongji($bjlist,$canshu);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$data[$i]['id'] = $i+1;
|
||||
$data[$i]['title'] = '合计';
|
||||
$data[$i]['data'] = $tj->tongji($cjlist,$canshu);
|
||||
// 重组返回内容
|
||||
$data = [
|
||||
'draw'=> $getParam["draw"] , // ajax请求次数,作为标识符
|
||||
'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量)
|
||||
'recordsFiltered'=>$cnt, // 符合条件的总数据量
|
||||
'data'=>$data, //获取到的数据结果
|
||||
];
|
||||
|
||||
return json($data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,7 +56,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>年级:</label>
|
||||
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>班级:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<dl class="permission-list">
|
||||
<dt>
|
||||
|
||||
Loaded 3 of 17 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user