Explorar o código

更新导出zip

sandm hai 1 ano
pai
achega
57fe24eaad
Modificáronse 1 ficheiros con 13 adicións e 8 borrados
  1. 13 8
      app/Admin/Controllers/Recruit/RecruitController.php

+ 13 - 8
app/Admin/Controllers/Recruit/RecruitController.php

@@ -2080,6 +2080,7 @@ class RecruitController extends Controller
     {//TODO 数据太大,无法压缩,得做成异步,现阶段指定导出人员
         Permission::check('recruit_out_excel');
         $recruit_id = $request->id;
+        $realname = $request->realname;
         $recruit = Recruit::find($recruit_id);
         if (empty($recruit)) {
             return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
@@ -2090,6 +2091,9 @@ class RecruitController extends Controller
         //$where[] = ['recruit_appoint_info.audit','=',3];
         $where[] = ['recruit_appoint_info.recruit_id', '=', $recruit_id];
         //$where[] = ['recruit_appoint_info.realname', 'in', ['肖思乐','张金铭','黄奖白','何佳鹏','李光祺','陈丽虹','卢江伟']];
+        if(!empty($realname)){
+            $where[] = ['recruit_appoint_info.realname', 'in', explode(',',$realname)];
+        }
 //        $param = parse_url($data['where']);
 //        parse_str($param['query'],$param);
 //        if (is_array($param)) {
@@ -2103,7 +2107,7 @@ class RecruitController extends Controller
 //            }
 //        }
         $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
-        $model = RecruitAppointInfo::where($where)->whereIn('recruit_appoint_info.realname',['肖思乐','张金铭','黄奖白','何佳鹏','李光祺','陈丽虹','卢江伟'])->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
+        $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
         if(in_array('expand_special',explode(',', $recruit->forms))){
             $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
             $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
@@ -2193,15 +2197,16 @@ class RecruitController extends Controller
             $zipper = new Zipper();
             $folder = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/";//$public_path  被压缩的文件名
             $zipper->make($savename)->add($folder)->close();//public_path($reduce_path)  压缩之后的文件名
-//            header("Content-Type: application/zip");
-//            header("Content-Transfer-Encoding: Binary");
-//            header("Content-Length: " . filesize($savename));
-//            header("Content-Disposition: attachment; filename=\"" . $savename . "\"");
-//
-//            readfile($savename);
-//            exit;
+            header("Content-Type: application/zip");
+            header("Content-Transfer-Encoding: Binary");
+            header("Content-Length: " . filesize($savename));
+            header("Content-Disposition: attachment; filename=\"" . $savename . "\"");
+
+            readfile($savename);
+            exit;
             return response()->json(['status' => 1, 'msg' => "/zip/{$recruit->name}.zip" ], 200);
         }else{
+            echo '没有搜索到相关人员';die;
             return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
         }