diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index ea2c9d5c..0a86b4fa 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -490,7 +490,10 @@ class Index extends Base $sheet->setCellValue('C'.$i, $value['student']); $colcnt = 3; foreach ($ks->ks_subject as $k => $val) { - $sheet->setCellValue($colname[$colcnt].$i, $value[$val->subject_name->lieming]); + if(isset($value[$val->subject_name->lieming])) + { + $sheet->setCellValue($colname[$colcnt].$i, $value[$val->subject_name->lieming]); + } $colcnt++; } $sheet->setCellValue($colname[$colcnt].$i, $value['avg']); diff --git a/application/keti/controller/KetiInfo.php b/application/keti/controller/KetiInfo.php index 4344fd41..2d054c4d 100644 --- a/application/keti/controller/KetiInfo.php +++ b/application/keti/controller/KetiInfo.php @@ -500,5 +500,92 @@ class KetiInfo extends Base } + // 下载课题信息表 + public function outXlsx($ketice) + { + $ketiinfo = new ketiinfo(); + $list = $ketiinfo->srcTuceRy($ketice); + + halt($list); + + if($list->isEmpty()) + { + $this->error('兄弟,没有要下载的信息呀~'); + return ''; + }else{ + $filename = $list[0]['ryTuce']['title']; + $fzschool = $list[0]['ryTuce']['fz_school']['title']; + $fzshijian = strtotime($list[0]['ryTuce']['fzshijian']); + $fzshijian = date('Ym',$fzshijian); + } + + //通过工厂模式创建内容 + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('jsRongyu.xlsx'); + $worksheet = $spreadsheet->getActiveSheet(); + + $worksheet->getCell('A1')->setValue($filename); + $worksheet->getCell('A2')->setValue('发证单位:'.$fzschool); + $worksheet->getCell('G2')->setValue('发证时间:'.$list[0]['ryTuce']['fzshijian']); + // 循环为excel每行赋值 + foreach ($list as $key => $value) { + $myrowid = $key + 4; + $worksheet->getCell('A'.$myrowid)->setValue($key+1); + $worksheet->getCell('B'.$myrowid)->setValue($value->title); + $worksheet->getCell('C'.$myrowid)->setValue($value->hjJsName); + if($value->hj_school){ + $worksheet->getCell('D'.$myrowid)->setValue($value->hj_school->jiancheng); + } + if($value->ry_subject){ + $worksheet->getCell('E'.$myrowid)->setValue($value->ry_subject->title); + } + $worksheet->getCell('F'.$myrowid)->setValue($value->cyJsName); + if($value->jx_category){ + $worksheet->getCell('G'.$myrowid)->setValue($value->jx_category->title); + } + $worksheet->getCell('H'.$myrowid)->setValue($value->bianhao); + } + + // 给单元格加边框 + $styleArray = [ + 'borders' => [ + 'allBorders' => [ + 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'color' => ['argb' => '00000000'], + ], + ], + ]; + + if($key+4>9) + { + + $worksheet->getStyle('A10:I'.($key+4))->applyFromArray($styleArray); + // 设置行高 + for($i = 10; $i<=($key+4); $i++){ + $worksheet->getRowDimension($i)->setRowHeight(30); + } + + } + + $worksheet->getStyle('A4')->applyFromArray($styleArray); + + + //告诉浏览器输出07Excel文件 + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + //告诉浏览器输出浏览器名称 + header('Content-Disposition: attachment;filename="'. $filename .$fzshijian.'.xlsx"'); + //禁止缓存 + header('Cache-Control: max-age=0'); + $writer = new Xlsx($spreadsheet); + $writer->save('php://output'); + // ob_end_clean(); + // ob_start(); + // 释放内存 + $spreadsheet->disconnectWorksheets(); + unset($spreadsheet); + + // return '下载后请关闭窗口'; + } + + } diff --git a/application/keti/model/KetiInfo.php b/application/keti/model/KetiInfo.php index 59b0093e..26c84b64 100644 --- a/application/keti/model/KetiInfo.php +++ b/application/keti/model/KetiInfo.php @@ -97,6 +97,59 @@ class KetiInfo extends Base } + //搜索课题册 + public function srcketi($ketice) + { + $data = $this + ->order([$src['field'] =>$src['type']]) + ->where('ketice',$ketice) + ->with( + [ + 'fzSchool'=>function($query){ + $query->field('id,jiancheng'); + }, + 'KtCe'=>function($query){ + $query->field('id,lxdanweiid,category,lxshijian') + ->with([ + 'ktCategory' => function($q){ + $q->field('id,title'); + }, + 'ktLxdanwei' => function($q){ + $q->field('id,jiancheng'); + } + ]); + }, + 'ktCategory'=>function($query){ + $query->field('id,title'); + }, + 'ktSubject'=>function($query){ + $query->field('id,title'); + }, + 'ktZcr'=>function($query){ + $query->field('ketiinfoid,teacherid') + ->with([ + 'teacher'=>function($q){ + $q->field('id,xingming'); + } + ]); + }, + 'ktCy'=>function($query){ + $query->field('ketiinfoid,teacherid') + ->with([ + 'teacher'=>function($q){ + $q->field('id,xingming'); + } + ]); + } + ] + ) + ->select(); + + + return $data; + } + + // 课题主持人关联 public function ktZcr() { diff --git a/application/keti/view/keti_info/create.html b/application/keti/view/keti_info/create.html index bd58dde9..9ede2800 100644 --- a/application/keti/view/keti_info/create.html +++ b/application/keti/view/keti_info/create.html @@ -217,6 +217,7 @@ keyup:function(){ var val = $.trim($(this).val()); if(val.length>0){ + layer.msg('bb'); cjgl.selectOnfocus(this,val,'hjteachers[]'); } }, diff --git a/application/keti/view/keti_info/keti_list.html b/application/keti/view/keti_info/keti_list.html index a8cba543..92864c0c 100644 --- a/application/keti/view/keti_info/keti_list.html +++ b/application/keti/view/keti_info/keti_list.html @@ -88,6 +88,9 @@ + @@ -168,6 +171,9 @@ case 'add': cjgl.add('添加课题','/ktinfoadd/'+"{$list.ketice}",'','',true); break; + case 'download': + cjgl.add('下载课题信息','/ktout/'+"{$list.ketice}",'300','200',false); + break; }; }); diff --git a/application/rongyu/controller/JsRongyuInfo.php b/application/rongyu/controller/JsRongyuInfo.php index 63bad15b..07b74905 100644 --- a/application/rongyu/controller/JsRongyuInfo.php +++ b/application/rongyu/controller/JsRongyuInfo.php @@ -414,11 +414,11 @@ class JsRongyuInfo extends Base // 下载荣誉信息 - public function outXlsx($id) + public function outXlsx($rongyuce) { $ryinfo = new ryinfo(); - $list = $ryinfo->srcTuceRy($id); + $list = $ryinfo->srcTuceRy($rongyuce); // halt($list); diff --git a/application/rongyu/view/js_rongyu_info/rongyu_list.html b/application/rongyu/view/js_rongyu_info/rongyu_list.html index f4fab939..d51f4ad1 100644 --- a/application/rongyu/view/js_rongyu_info/rongyu_list.html +++ b/application/rongyu/view/js_rongyu_info/rongyu_list.html @@ -61,6 +61,9 @@ + @@ -138,6 +141,9 @@ case 'add': cjgl.add('添加荣誉','/jsryinfoadd/'+"{$list.rongyuce}",'','',true); break; + case 'download': + cjgl.add('下载荣誉信息','/ryout/'+"{$list.rongyuce}",'300','200',false); + break; }; }); diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index 230c8069..b73f1940 100644 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -222,6 +222,7 @@ class Rule extends Seeder ['title'=>'状态','name'=>'keti/ketiinfo/setStatus','paixu'=>5,'pid'=>902], ['title'=>'批量上传','name'=>'keti/ketiinfo/createAll','paixu'=>6,'pid'=>902], ['title'=>'结题','name'=>'keti/ketiinfo/jieTi','paixu'=>7,'pid'=>902], + ['title'=>'下载','name'=>'keti/KetiInfo/outXlsx','paixu'=>8,'pid'=>902], diff --git a/public/static/xadmin/js/cjgl.js b/public/static/xadmin/js/cjgl.js index 6fc957c5..34bb61b6 100644 --- a/public/static/xadmin/js/cjgl.js +++ b/public/static/xadmin/js/cjgl.js @@ -116,35 +116,35 @@ layui.define(['table'],function(exports){ //提示:模块也可以依赖其它 }); }); }, - getSearchVal:function(name){ - // 声明对象,用于存表单名与数值 - var obj={}; - // 循环获取有表单的div - $(name).children('div.layui-form-item').each(function(i){ - // 声明二级div - var myblock = $(this).children('div.layui-input-block'); - var name=$(myblock).children("input:first").attr("name"); - // 判断二级div下的第一个input是不是text - if($(myblock).children("input:first").attr("type") == 'text'){ - // 如果是文本框,则直接获取。 - var value=$(myblock).children('input').val(); - obj[name] = value; - }else if($(myblock).children("input:first").attr("type") == 'checkbox'){ - // 如果是复选框,获取被选中的div - var checkdiv = $(myblock).children("div.layui-form-checked"); - obj[name] = new Array(); - $(checkdiv).each(function(cd){ - var value = $(this).prev('input').val(); - obj[name].push(value); - }); - }else if($(myblock).children("input:first").attr("type") == 'radio'){ - var checkdiv = $(myblock).children("div.layui-form-radioed"); - var value = $(checkdiv).prev('input').val(); - obj[name] = value; - } - }); - return obj; - }, + // getSearchVal:function(name){ + // // 声明对象,用于存表单名与数值 + // var obj={}; + // // 循环获取有表单的div + // $(name).children('div.layui-form-item').each(function(i){ + // // 声明二级div + // var myblock = $(this).children('div.layui-input-block'); + // var name=$(myblock).children("input:first").attr("name"); + // // 判断二级div下的第一个input是不是text + // if($(myblock).children("input:first").attr("type") == 'text'){ + // // 如果是文本框,则直接获取。 + // var value=$(myblock).children('input').val(); + // obj[name] = value; + // }else if($(myblock).children("input:first").attr("type") == 'checkbox'){ + // // 如果是复选框,获取被选中的div + // var checkdiv = $(myblock).children("div.layui-form-checked"); + // obj[name] = new Array(); + // $(checkdiv).each(function(cd){ + // var value = $(this).prev('input').val(); + // obj[name].push(value); + // }); + // }else if($(myblock).children("input:first").attr("type") == 'radio'){ + // var checkdiv = $(myblock).children("div.layui-form-radioed"); + // var value = $(checkdiv).prev('input').val(); + // obj[name] = value; + // } + // }); + // return obj; + // }, // 表格重载 reLoadTable:function(formname,tableID,mydata={}){ var formval = this.getSearchVal(formname); @@ -164,6 +164,7 @@ layui.define(['table'],function(exports){ //提示:模块也可以依赖其它 }, // Select获取焦点 selectOnfocus:function(myobj,val,addname){ + layer.msg('aa'); // 声明变量 var srcInput = $(myobj); @@ -175,10 +176,9 @@ layui.define(['table'],function(exports){ //提示:模块也可以依赖其它 // 声明变量 var mydl = srcInput.next().children('dl'); - // 获取数据 $.post( - "/banji/banjilist", + "/srcteacher", { "str":val, }, @@ -197,7 +197,7 @@ layui.define(['table'],function(exports){ //提示:模块也可以依赖其它 ); - }, + }, // 添加教师 addTeacher:function(myobj){ var myId = $(myobj).attr('id') diff --git a/route/keti.php b/route/keti.php index 7eba7ae4..753ba470 100644 --- a/route/keti.php +++ b/route/keti.php @@ -15,6 +15,7 @@ Route::resource('ktinfo','keti/KetiInfo'); // 课题册中课题列表 Route::get('ktlist/:ketice/:title','keti/KetiInfo/ketilist'); +Route::get('ktout/:ketice','keti/KetiInfo/outXlsx'); // 结题编辑 Route::get('ktjt/:id/edit','keti/KetiInfo/jieTi'); Route::put('ktjt/:id','keti/KetiInfo/jtUpdate'); diff --git a/route/renshi.php b/route/renshi.php index e67204d3..4d88e258 100644 --- a/route/renshi.php +++ b/route/renshi.php @@ -13,7 +13,10 @@ Route::resource('teacher','renshi/Index'); Route::get('teacher/createall','renshi/Index/createAll'); // 定义GET请求路由规则 Route::post('teacher/createall','renshi/Index/saveAll'); // 定义POST请求路由规则 +Route::post('srcteacher','renshi/Index/srcTeacher'); // 定义POST请求路由规则 + Route::resource('student','renshi/Student'); Route::get('student/createall','renshi/Student/createAll'); // 定义GET请求路由规则 Route::post('student/createall','renshi/Student/saveAll'); // 定义POST请求路由规则 + // Route::post('student/download','renshi/Student/download'); // 定义POST请求路由规则