diff --git a/app/common.php b/app/common.php index b031f2f8..20e92321 100644 --- a/app/common.php +++ b/app/common.php @@ -44,19 +44,6 @@ function getCategory($str = 0) } -// // 获取类别名称 -// function getCategoryTitle($id) -// { -// $category = new \app\system\model\Category; -// // 根据id查询类别名 -// $value = $category -// ->where('id',$id) -// ->vlaue('title'); -// // 返回类别名 -// return $value; -// } - - function nianjiList($riqi=0) { // 定义学年时间节点日期为每年的8月1日 diff --git a/app/renshi/common.php b/app/renshi/common.php index b9d2bde1..7ae1c79f 100644 --- a/app/renshi/common.php +++ b/app/renshi/common.php @@ -64,3 +64,31 @@ function srcZc($str) return $categoryId; } + +// 下载文件 +function smDownload($url,$newname='') +{ + $file = $url; + + if(strlen($newname)==0) + { + $newname = filesize($file); + } + + + if (file_exists($file)) { + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename='.$newname); + header('Content-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: ' . filesize($file)); + ob_clean(); + flush(); + readfile($file); + exit; + } +} + diff --git a/app/renshi/controller/Student.php b/app/renshi/controller/Student.php index 84acff28..6cecb122 100644 --- a/app/renshi/controller/Student.php +++ b/app/renshi/controller/Student.php @@ -529,8 +529,8 @@ class Student extends BaseController // 下载表格模板 public function download() { - $download = new \think\response\Download('uploads\student\student_template.xlsx'); - return $download->name('student_template.xlsx'); + $url = public_path().'public\\uploads\\student\\student_template.xlsx'; + return smDownload($url,'学生名单模板.xlsx'); } diff --git a/app/renshi/controller/Teacher.php b/app/renshi/controller/Teacher.php index 1e6f3ecd..b5dece39 100644 --- a/app/renshi/controller/Teacher.php +++ b/app/renshi/controller/Teacher.php @@ -418,17 +418,15 @@ class Teacher extends BaseController // 下载表格模板 public function downloadXls() { - // $download = new \think\response\Download('uploads\teacher\TeacherInfo.xlsx'); - // return $download->name('TeacherInfo.xlsx'); - $url = public_path().'public\\uploads\\teacher\TeacherInfo.xlsx'; - return download($url,'TeacherInfo.xlsx'); + $url = public_path().'public\\uploads\\teacher\\TeacherInfo.xlsx'; + return smDownload($url,'教师名单模板.xlsx'); } // 下载表格VBA代码 public function downloadVba() { $url = public_path().'public\\uploads\\teacher\jiaoShiXingMingVBA.bas'; - return download($url,'jiaoShiXingMingVBA.bas'); + return smDownload($url,'jiaoShiXingMingVBA.bas'); } diff --git a/app/renshi/route/renshi.php b/app/renshi/route/renshi.php index 54fd9447..450df2f4 100644 --- a/app/renshi/route/renshi.php +++ b/app/renshi/route/renshi.php @@ -26,6 +26,7 @@ Route::group('student', function () { Route::rule('saveall','student/saveAll','post'); # 批量保存 Route::rule('jiaodui','student/jiaoDui','get'); # 批量保存 Route::rule('jiaoduidel','student/jiaoduiDel','post'); # 批量保存 + Route::rule('download','student/download','get'); # 批量保存 }); diff --git a/app/renshi/view/student/index.html b/app/renshi/view/student/index.html index d0e84dea..ad9c14d2 100644 --- a/app/renshi/view/student/index.html +++ b/app/renshi/view/student/index.html @@ -132,7 +132,7 @@ cjgl.add('导入学生','student/createall','','',true); break; case 'download': - window.open("renshi/student/download"); + window.open("/renshi/student/download"); break; case 'jdsc': layer.msg('这个操作很危险,暂时不开放'); diff --git a/app/system/common.php b/app/system/common.php index b3d9bbc7..50cce95b 100644 --- a/app/system/common.php +++ b/app/system/common.php @@ -1 +1,3 @@ '编辑学科', 'butname'=>'修改', 'formpost'=>'PUT', - 'url'=>'/teach/subject/'.$id, + 'url'=>'/teach/subject/update/'.$id, ); // 模板赋值 diff --git a/app/teach/route/teach.php b/app/teach/route/teach.php index 1f7ee2af..e1ec2da4 100644 --- a/app/teach/route/teach.php +++ b/app/teach/route/teach.php @@ -11,20 +11,6 @@ use think\facade\Route; -//系统设置路由 -// Route::resource('xueqi','teach/Xueqi'); -// Route::resource('kaoshi','teach/Kaoshi'); -// Route::resource('subject','teach/Subject'); -// Route::resource('banji','teach/Banji'); -// Route::post('banji/:id/yidong','teach/Banji/yidong'); // 定义班级移动post规则 -// Route::post('banji/njbanji','teach/Banji/mybanji'); // 定义GET请求路由规则 -// Route::post('banji/schbanji','teach/Banji/banjilist'); // 定义GET请求路由规则 -// Route::get('kaoshi/:id/kaohao','teach/Kaoshi/kaohao'); -// Route::post('kaoshi/kaohao','teach/Kaoshi/kaohaosave'); -// Route::get('kaoshi/:id/biaoqian','teach/Kaoshi/biaoqian'); -// Route::get('kaoshi/:id/caiji','teach/Kaoshi/caiji'); -// Route::post('kaoshi/caiji','teach/Kaoshi/cankaomingdan'); - // 学期管理 Route::group('xueqi', function () { Route::rule('','xueqi/index','get'); # 信息列表 diff --git a/database/migrations/20181221041523_js_rongyu_info.php b/database/migrations/20181221041523_js_rongyu_info.php index fc7a8885..ee03abae 100644 --- a/database/migrations/20181221041523_js_rongyu_info.php +++ b/database/migrations/20181221041523_js_rongyu_info.php @@ -36,11 +36,11 @@ class JsRongyuInfo extends Migrator ->addColumn('title','string',['limit'=>50,'null'=>false,'comment'=>'获奖内容标题']) ->addColumn('rongyuce','integer',['limit'=>11,'null'=>false,'comment'=>'荣誉册']) ->addColumn('bianhao','string',['limit'=>15,'null'=>true,'comment'=>'证书编号']) - ->addColumn('hjschool','integer',['limit'=>11,'null'=>false,'comment'=>'证书所属单位']) - ->addColumn('subject','integer',['limit'=>11,'null'=>false,'comment'=>'所属学科']) - ->addColumn('jiangxiang','integer',['limit'=>11,'null'=>false,'comment'=>'荣誉奖项']) - ->addColumn('pic','string',['limit'=>100,'null'=>false,'comment'=>'证书图片']) - ->addColumn('hjshijian','integer',['limit'=>11,'null'=>false,'comment'=>'获奖时间']) + ->addColumn('hjschool','integer',['limit'=>11,'null'=>true,'comment'=>'证书所属单位']) + ->addColumn('subject','integer',['limit'=>11,'null'=>true,'comment'=>'所属学科']) + ->addColumn('jiangxiang','integer',['limit'=>11,'null'=>true,'comment'=>'荣誉奖项']) + ->addColumn('pic','string',['limit'=>100,'null'=>true,'comment'=>'证书图片']) + ->addColumn('hjshijian','integer',['limit'=>11,'null'=>true,'comment'=>'获奖时间']) ->addColumn('create_time','integer',['limit'=>11,'null'=>true,'comment'=>'创建时间']) ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) ->addColumn('update_time','integer',['limit'=>11,'null'=>true,'comment'=>'更新时间']) diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index b6a0a6d9..b9efafa2 100644 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -139,7 +139,7 @@ class Rule extends Seeder ['title'=>'查询教师','name'=>'renshi/Teacher/srcTeacher','paixu'=>8,'pid'=>402], ['title'=>'批量上传','name'=>'renshi/Teacher/createAll','paixu'=>9,'pid'=>402], ['title'=>'批量保存','name'=>'renshi/Teacher/saveAll','paixu'=>10,'pid'=>402], - ['title'=>'表格模板下载','name'=>'renshi/Teacher/download','paixu'=>11,'pid'=>402], + ['title'=>'表格模板下载','name'=>'renshi/Teacher/downloadXls','paixu'=>11,'pid'=>402], ['title'=>'姓名转换VBA下载','name'=>'renshi/Teacher/downloadVba','paixu'=>12,'pid'=>402], @@ -165,6 +165,7 @@ class Rule extends Seeder ['title'=>'更新','name'=>'teach/Subject/update','paixu' =>5,'pid'=>503], ['title'=>'查看','name'=>'teach/Subject/read','paixu'=>6,'pid'=>503,], ['title'=>'状态','name'=>'teach/Subject/setStatus','paixu'=>7,'pid'=>503], + ['title'=>'参加考试','name'=>'teach/subject/kaoshi','paixu'=>8,'pid'=>503], //管理员管理 diff --git a/public/uploads/student/student_template.xlsx b/public/uploads/student/student_template.xlsx index e023c2cc..3cc43258 100644 Binary files a/public/uploads/student/student_template.xlsx and b/public/uploads/student/student_template.xlsx differ