|  | @@ -10,6 +10,8 @@ use app\enterprise\model\Talent as TalentModel;
 | 
	
		
			
				|  |  |  use think\facade\Db;
 | 
	
		
			
				|  |  |  use app\common\api\TalentLogApi;
 | 
	
		
			
				|  |  |  use app\common\api\TalentState;
 | 
	
		
			
				|  |  | +use think\exception\ValidateException;
 | 
	
		
			
				|  |  | +use app\enterprise\validate\TalentInfo;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -54,99 +56,38 @@ class Base extends EnterpriseController {
 | 
	
		
			
				|  |  |              exit();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($request->isPost()) {
 | 
	
		
			
				|  |  | -            if ($id) {
 | 
	
		
			
				|  |  | -                $data["id"] = $id;
 | 
	
		
			
				|  |  | -                if (!$info) {
 | 
	
		
			
				|  |  | -                    $res = ["msg" => "没有对应的人才认定申报信息"];
 | 
	
		
			
				|  |  | -                    echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | -                    exit;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if ($info["checkState"] == TalentState::REVERIFY_FAIL) {
 | 
	
		
			
				|  |  | -                    $res = ["msg" => "审核失败,不能再修改"];
 | 
	
		
			
				|  |  | -                    echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | -                    exit;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if (!in_array($info["checkState"], [TalentState::FST_SAVE, TalentState::BASE_VERIFY_PASS, TalentState::SCND_SAVE])) {
 | 
	
		
			
				|  |  | -                    $res = ["msg" => "审核中,不能修改"];
 | 
	
		
			
				|  |  | -                    echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | -                    exit;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            $files = $param["uploadFiles"];
 | 
	
		
			
				|  |  | +            $this->save($info, $request, TalentState::FST_SAVE);
 | 
	
		
			
				|  |  | +            exit();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $checkState = $info["checkState"] ?: 0;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        $info["enterprise"] = $ep;
 | 
	
		
			
				|  |  | +        $info["talent_type_list"] = \app\common\api\DictApi::findChildDictByCode("talent_type");
 | 
	
		
			
				|  |  | +        return view("first", ["year" => date("Y"), "checkState" => $checkState, "row" => $info]);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function view(\think\Request $request) {
 | 
	
		
			
				|  |  | +        $id = $request->param("id");
 | 
	
		
			
				|  |  | +        $info = \app\common\api\VerifyApi::getTalentInfoById($id);
 | 
	
		
			
				|  |  | +        return view("view", ["row" => $info]);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
 | 
	
		
			
				|  |  | +    public function submit() {
 | 
	
		
			
				|  |  | +        $checkState = $info["checkState"];
 | 
	
		
			
				|  |  | +        if ($checkState == TalentState::FST_SAVE || $checkState == 0) {
 | 
	
		
			
				|  |  | +            $param = $this->request->param();
 | 
	
		
			
				|  |  | +            $id = $param["id"];
 | 
	
		
			
				|  |  | +            $info = self::chkIsOwner($id, $this->user["uid"]);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              $filed_dict = \app\common\api\DictApi::getTalentFields(1);
 | 
	
		
			
				|  |  | -            $data["headimgurl"] = $info["headimgurl"];
 | 
	
		
			
				|  |  | -            if ($request->file()) {
 | 
	
		
			
				|  |  | -                $headimg = $request->file("photo");
 | 
	
		
			
				|  |  | -                $upload = new \app\common\api\UploadApi();
 | 
	
		
			
				|  |  | -                $result = $upload->uploadOne($headimg, "image", "talent/photo");
 | 
	
		
			
				|  |  | -                $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
 | 
	
		
			
				|  |  | -                $width = imagesx($file);
 | 
	
		
			
				|  |  | -                $height = imagesy($file);
 | 
	
		
			
				|  |  | -                //免冠二寸照长宽413:579
 | 
	
		
			
				|  |  | -                if ($width * 579 != $height * 413) {
 | 
	
		
			
				|  |  | -                    @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
 | 
	
		
			
				|  |  | -                    $res = ["msg" => "近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>"];
 | 
	
		
			
				|  |  | -                    echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | -                    exit;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if ($info && $info["headimgurl"]) {
 | 
	
		
			
				|  |  | -                    //如果新照片符合像素要求,则删除旧照片
 | 
	
		
			
				|  |  | -                    $old_head_url = "storage/" . $info["headimgurl"];
 | 
	
		
			
				|  |  | -                    if (file_exists($old_head_url))
 | 
	
		
			
				|  |  | -                        @unlink($old_head_url);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                $data["headimgurl"] = $result->filepath;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (!$data["headimgurl"]) {
 | 
	
		
			
				|  |  | -                $res = ["msg" => "请上传头像"];
 | 
	
		
			
				|  |  | -                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | -                exit;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            $no_empty = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "nation", "politics", "experience", "education"];
 | 
	
		
			
				|  |  | -            /* if (in_array($ep["enterpriseTag"], ['mtdw', 'gyqyh', 'mbfqy', 'jrjg'])) {
 | 
	
		
			
				|  |  | -              $no_empty[] = "fst_work_time";
 | 
	
		
			
				|  |  | -              } */
 | 
	
		
			
				|  |  | +            $no_empty = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education"];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (in_array($param["talent_type"], [1, 2])) {
 | 
	
		
			
				|  |  | -                list($date1, $date2) = explode(" - ", $param["tax_insurance_month"]);
 | 
	
		
			
				|  |  | -                if (strtotime($date1) > strtotime($date2)) {
 | 
	
		
			
				|  |  | -                    $res = ["msg" => $filed_dict["tax_insurance_month"] . "起始时间不能大于结束时间"];
 | 
	
		
			
				|  |  | -                    echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | -                    exit;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                /* $start = date_create($date1);
 | 
	
		
			
				|  |  | -                  $end = date_create($date2);
 | 
	
		
			
				|  |  | -                  $diff = date_diff($end, $start);
 | 
	
		
			
				|  |  | -                  $m = $diff->m ?: 0;
 | 
	
		
			
				|  |  | -                  $y = $diff->y ?: 0;
 | 
	
		
			
				|  |  | -                  $months = $y * 12 + $m;
 | 
	
		
			
				|  |  | -                  if ($months < 6) {
 | 
	
		
			
				|  |  | -                  $res = ["msg" => $filed_dict["tax_insurance_month"] . "应大于或等于6个月"];
 | 
	
		
			
				|  |  | -                  echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | -                  exit;
 | 
	
		
			
				|  |  | -                  } */
 | 
	
		
			
				|  |  |                  $no_empty[] = "tax_insurance_month";
 | 
	
		
			
				|  |  |                  $no_empty[] = "labor_contract_rangetime";
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if ($param["talent_type"] == 3) {
 | 
	
		
			
				|  |  | -                list($date1, $date2) = explode(" - ", $param["labor_contract_rangetime"]);
 | 
	
		
			
				|  |  | -                if (strtotime($date1) > strtotime($date2)) {
 | 
	
		
			
				|  |  | -                    $res = ["msg" => $filed_dict["labor_contract_rangetime"] . "起始时间不能大于结束时间"];
 | 
	
		
			
				|  |  | -                    echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | -                    exit;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                /* $start = date_create($date1);
 | 
	
		
			
				|  |  | -                  $end = date_create($date2);
 | 
	
		
			
				|  |  | -                  $diff = date_diff($end, $start);
 | 
	
		
			
				|  |  | -                  $m = $diff->m ?: 0;
 | 
	
		
			
				|  |  | -                  $y = $diff->y ?: 0;
 | 
	
		
			
				|  |  | -                  $months = $y * 12 + $m;
 | 
	
		
			
				|  |  | -                  if ($months < 6) {
 | 
	
		
			
				|  |  | -                  $res = ["msg" => $filed_dict["labor_contract_rangetime"] . "应大于或等于6个月"];
 | 
	
		
			
				|  |  | -                  echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | -                  exit;
 | 
	
		
			
				|  |  | -                  } */
 | 
	
		
			
				|  |  |                  $no_empty[] = "pre_import_type";
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              $return = [];
 | 
	
	
		
			
				|  | @@ -157,9 +98,10 @@ class Base extends EnterpriseController {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if (count($return) > 0) {
 | 
	
		
			
				|  |  |                  $res = ["msg" => implode("<br>", $return)];
 | 
	
		
			
				|  |  | -                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | +                echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  |                  exit;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              $where = [];
 | 
	
		
			
				|  |  |              $where[] = ["step", "=", 1];
 | 
	
		
			
				|  |  |              $where[] = ["project", "=", 1];
 | 
	
	
		
			
				|  | @@ -169,12 +111,10 @@ class Base extends EnterpriseController {
 | 
	
		
			
				|  |  |              $where[] = ["delete", "=", 0];
 | 
	
		
			
				|  |  |              $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              $ft_ids = [];
 | 
	
		
			
				|  |  | -            $deletes = [];
 | 
	
		
			
				|  |  |              foreach ($filetypes as $ft) {
 | 
	
		
			
				|  |  |                  if ($ft["option"]) {
 | 
	
		
			
				|  |  | -                    $selectVal = $param[$ft["rel"]];
 | 
	
		
			
				|  |  | +                    $selectVal = $info[$ft["rel"]];
 | 
	
		
			
				|  |  |                      $conditions = array_filter(explode(",", $ft["option"]));
 | 
	
		
			
				|  |  |                      if (!in_array($selectVal, $conditions)) {
 | 
	
		
			
				|  |  |                          $deletes[] = $ft["id"];
 | 
	
	
		
			
				|  | @@ -187,35 +127,124 @@ class Base extends EnterpriseController {
 | 
	
		
			
				|  |  |              //$ft_ids = array_column($filetypes, "id");
 | 
	
		
			
				|  |  |              $whr = [];
 | 
	
		
			
				|  |  |              $upload_type_counts = 0;
 | 
	
		
			
				|  |  | -            if ($files) {
 | 
	
		
			
				|  |  | +            if ($ft_ids) {
 | 
	
		
			
				|  |  |                  $whr[] = ["typeId", "in", $ft_ids];
 | 
	
		
			
				|  |  | -                $whr[] = ["id", "in", $files];
 | 
	
		
			
				|  |  | +                $whr[] = ["mainId", "=", $id];
 | 
	
		
			
				|  |  |                  $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
 | 
	
		
			
				|  |  |                  $upload_type_counts = count($distinct_filetypes);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if ($upload_type_counts != count($ft_ids)) {
 | 
	
		
			
				|  |  | -                $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
 | 
	
		
			
				|  |  | -                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | +                $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核" . count($ft_ids)];
 | 
	
		
			
				|  |  | +                echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  |                  exit;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            $data["enterprise_id"] = $this->user["uid"];
 | 
	
		
			
				|  |  | -            $data["talent_type"] = $param["talent_type"];
 | 
	
		
			
				|  |  | -            $data["tax_insurance_month"] = $param["tax_insurance_month"];
 | 
	
		
			
				|  |  | -            $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
 | 
	
		
			
				|  |  | -            $data['pre_import_type'] = $param["pre_import_type"];
 | 
	
		
			
				|  |  | +            $this->save($info, $this->request, TalentState::FST_SUBMIT);
 | 
	
		
			
				|  |  | +            //初次提交材料
 | 
	
		
			
				|  |  | +        } else if ($checkState == TalentState::REVERIFY_FAIL) {
 | 
	
		
			
				|  |  | +            $res = ["msg" => "审核失败,不能再提交审核"];
 | 
	
		
			
				|  |  | +            echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | +            exit;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $res = ["msg" => "已提交审核,请耐心等待"];
 | 
	
		
			
				|  |  | +        echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | +        exit;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 保存表单
 | 
	
		
			
				|  |  | +     * @param type $info talent_info
 | 
	
		
			
				|  |  | +     * @param type $param request->param();
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private function save($info, \think\Request $request, $checkState) {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            $param = $request->param();
 | 
	
		
			
				|  |  | +            validate(TalentInfo::class)->check($param);
 | 
	
		
			
				|  |  | +            $id = $param["id"];
 | 
	
		
			
				|  |  | +            if ($id) {
 | 
	
		
			
				|  |  | +                $data["id"] = $id;
 | 
	
		
			
				|  |  | +                if (!$info) {
 | 
	
		
			
				|  |  | +                    throw new ValidateException("没有对应的人才认定申报信息");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if ($info["checkState"] == TalentState::REVERIFY_FAIL) {
 | 
	
		
			
				|  |  | +                    throw new ValidateException("审核失败,不能再修改");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (!in_array($info["checkState"], [TalentState::FST_SAVE, 0])) {
 | 
	
		
			
				|  |  | +                    throw new ValidateException("审核中,不能修改");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $files = $param["uploadFiles"];
 | 
	
		
			
				|  |  | +            $data["headimgurl"] = $info["headimgurl"];
 | 
	
		
			
				|  |  | +            if ($request->file()) {
 | 
	
		
			
				|  |  | +                $headimg = $request->file("photo");
 | 
	
		
			
				|  |  | +                $upload = new \app\common\api\UploadApi();
 | 
	
		
			
				|  |  | +                $result = $upload->uploadOne($headimg, "image", "talent/photo");
 | 
	
		
			
				|  |  | +                $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
 | 
	
		
			
				|  |  | +                $width = imagesx($file);
 | 
	
		
			
				|  |  | +                $height = imagesy($file);
 | 
	
		
			
				|  |  | +                //免冠二寸照长宽413:579
 | 
	
		
			
				|  |  | +                if ($width * 579 != $height * 413) {
 | 
	
		
			
				|  |  | +                    @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件                    
 | 
	
		
			
				|  |  | +                    throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if ($info && $info["headimgurl"]) {
 | 
	
		
			
				|  |  | +                    //如果新照片符合像素要求,则删除旧照片
 | 
	
		
			
				|  |  | +                    $old_head_url = "storage/" . $info["headimgurl"];
 | 
	
		
			
				|  |  | +                    if (file_exists($old_head_url))
 | 
	
		
			
				|  |  | +                        @unlink($old_head_url);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                $data["headimgurl"] = $result->filepath;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (!$data["headimgurl"] && $checkState == TalentState::FST_SUBMIT)
 | 
	
		
			
				|  |  | +                throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 | 
	
		
			
				|  |  | +            $where = [];
 | 
	
		
			
				|  |  | +            $where[] = ["step", "=", 1];
 | 
	
		
			
				|  |  | +            $where[] = ["project", "=", 1];
 | 
	
		
			
				|  |  | +            $where[] = ["type", "=", $this->user["type"]];
 | 
	
		
			
				|  |  | +            $where[] = ["must", "=", 1];
 | 
	
		
			
				|  |  | +            $where[] = ["active", "=", 1];
 | 
	
		
			
				|  |  | +            $where[] = ["delete", "=", 0];
 | 
	
		
			
				|  |  | +            $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            $ft_ids = [];
 | 
	
		
			
				|  |  | +            $deletes = [];
 | 
	
		
			
				|  |  | +            foreach ($filetypes as $ft) {
 | 
	
		
			
				|  |  | +                if ($ft["option"]) {
 | 
	
		
			
				|  |  | +                    $selectVal = $param[$ft["rel"]];
 | 
	
		
			
				|  |  | +                    $conditions = array_filter(explode(",", $ft["option"]));
 | 
	
		
			
				|  |  | +                    if (!in_array($selectVal, $conditions)) {
 | 
	
		
			
				|  |  | +                        $deletes[] = $ft["id"];
 | 
	
		
			
				|  |  | +                        continue;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                $ft_ids[] = $ft["id"];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              $data["name"] = $param["name"];
 | 
	
		
			
				|  |  | +            $data["enterprise_id"] = $this->user["uid"];
 | 
	
		
			
				|  |  | +            $data["nation"] = $param["nation"];
 | 
	
		
			
				|  |  |              $data["card_type"] = $param["card_type"];
 | 
	
		
			
				|  |  |              $data["card_number"] = $param["card_number"];
 | 
	
		
			
				|  |  |              $data["sex"] = $param["sex"];
 | 
	
		
			
				|  |  |              $data["birthday"] = $param["birthday"];
 | 
	
		
			
				|  |  | +            $data["politics"] = $param["politics"];
 | 
	
		
			
				|  |  |              $data["nationality"] = $param["nationality"];
 | 
	
		
			
				|  |  |              $data["province"] = $param["province"];
 | 
	
		
			
				|  |  |              $data["city"] = $param["city"];
 | 
	
		
			
				|  |  |              $data["county"] = $param["county"];
 | 
	
		
			
				|  |  | -            $data["nation"] = $param["nation"];
 | 
	
		
			
				|  |  | -            $data["politics"] = $param["politics"];
 | 
	
		
			
				|  |  | -            $data["fst_work_time"] = $param["fst_work_time"];
 | 
	
		
			
				|  |  | +            $data["talent_type"] = $param["talent_type"];
 | 
	
		
			
				|  |  | +            if (in_array($data["talent_type"], [1, 2])) {
 | 
	
		
			
				|  |  | +                $data["tax_insurance_month"] = $param["tax_insurance_month"];
 | 
	
		
			
				|  |  | +                $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
 | 
	
		
			
				|  |  | +                $data["fst_work_time"] = $param["fst_work_time"];
 | 
	
		
			
				|  |  | +                $data['pre_import_type'] = null;
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                $data["tax_insurance_month"] = null;
 | 
	
		
			
				|  |  | +                $data["labor_contract_rangetime"] = null;
 | 
	
		
			
				|  |  | +                $data["fst_work_time"] = null;
 | 
	
		
			
				|  |  | +                $data['pre_import_type'] = $param["pre_import_type"];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              $data["experience"] = $param["experience"];
 | 
	
		
			
				|  |  |              $data["education"] = $param["education"];
 | 
	
		
			
				|  |  |              if ($info["real_state"] == 4) {
 | 
	
	
		
			
				|  | @@ -230,16 +259,37 @@ class Base extends EnterpriseController {
 | 
	
		
			
				|  |  |                      $data[$field] = $tmp_data[$field];
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if ($id > 0) {
 | 
	
		
			
				|  |  | -                TalentModel::update($data);
 | 
	
		
			
				|  |  | +            $success_msg = "保存成功";
 | 
	
		
			
				|  |  | +            $error_msg = "保存失败";
 | 
	
		
			
				|  |  | +            if ($checkState == TalentState::FST_SAVE) {
 | 
	
		
			
				|  |  | +                if ($data["id"] > 0) {
 | 
	
		
			
				|  |  | +                    TalentModel::update($data);
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    $data["checkState"] = $checkState;
 | 
	
		
			
				|  |  | +                    $id = TalentModel::insertGetId($data);
 | 
	
		
			
				|  |  | +                    TalentLogApi::write(1, $id, $checkState, "添加人才认定申报", 1);
 | 
	
		
			
				|  |  | +                    $whr = [];
 | 
	
		
			
				|  |  | +                    $whr[] = ["fileId", "in", $files];
 | 
	
		
			
				|  |  | +                    $upd_checklog["mainId"] = $id;
 | 
	
		
			
				|  |  | +                    Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else if ($checkState == TalentState::FST_SUBMIT) {
 | 
	
		
			
				|  |  | +                $success_msg = "提交成功";
 | 
	
		
			
				|  |  | +                $error_msg = "提交失败";
 | 
	
		
			
				|  |  | +                $data["checkState"] = $checkState;
 | 
	
		
			
				|  |  | +                $data["first_submit_time"] = date("Y-m-d H:i:s");
 | 
	
		
			
				|  |  | +                if ($data["id"] > 0) {
 | 
	
		
			
				|  |  | +                    TalentModel::update($data);
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    $id = TalentModel::insertGetId($data);
 | 
	
		
			
				|  |  | +                    $whr = [];
 | 
	
		
			
				|  |  | +                    $whr[] = ["fileId", "in", $files];
 | 
	
		
			
				|  |  | +                    $upd_checklog["mainId"] = $id;
 | 
	
		
			
				|  |  | +                    Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                TalentLogApi::write(1, $id, $checkState, "提交基础判定材料待审核", 1);
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | -                $data["checkState"] = TalentState::FST_SAVE;
 | 
	
		
			
				|  |  | -                $id = TalentModel::insertGetId($data);
 | 
	
		
			
				|  |  | -                TalentLogApi::write(1, $id, TalentState::FST_SAVE, "添加人才认定申报", 1);
 | 
	
		
			
				|  |  | -                $whr = [];
 | 
	
		
			
				|  |  | -                $whr[] = ["fileId", "in", $files];
 | 
	
		
			
				|  |  | -                $upd_checklog["mainId"] = $id;
 | 
	
		
			
				|  |  | -                Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
 | 
	
		
			
				|  |  | +                throw new ValidateException("错误的审核状态");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if ($id) {
 | 
	
		
			
				|  |  |                  if ($deletes) {
 | 
	
	
		
			
				|  | @@ -267,84 +317,18 @@ class Base extends EnterpriseController {
 | 
	
		
			
				|  |  |                  $whr = [];
 | 
	
		
			
				|  |  |                  $whr[] = ["id", "in", $files];
 | 
	
		
			
				|  |  |                  Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
 | 
	
		
			
				|  |  | -                $res = ["code" => 200, "msg" => "保存成功", "obj" => ["id" => $id, "checkState" => TalentState::FST_SAVE]];
 | 
	
		
			
				|  |  | -                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | +                $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
 | 
	
		
			
				|  |  | +                $callback = $checkState == TalentState::FST_SAVE ? "infoCallback" : "submitCallback";
 | 
	
		
			
				|  |  | +                echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | -                $res = ["msg" => "保存失败"];
 | 
	
		
			
				|  |  | -                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  | +                throw new ValidateException($error_msg);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +        } catch (ValidateException $e) {
 | 
	
		
			
				|  |  | +            $res = ["msg" => $e->getMessage()];
 | 
	
		
			
				|  |  | +            $callback = $checkState == TalentState::FST_SAVE ? "infoCallback" : "submitCallback";
 | 
	
		
			
				|  |  | +            echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 | 
	
		
			
				|  |  |              exit();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        $checkState = $info["checkState"] ?: 0;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        $info["enterprise"] = $ep;
 | 
	
		
			
				|  |  | -        $info["talent_type_list"] = \app\common\api\DictApi::findChildDictByCode("talent_type");
 | 
	
		
			
				|  |  | -        return view("first", ["year" => date("Y"), "checkState" => $checkState, "row" => $info]);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    public function view(\think\Request $request) {
 | 
	
		
			
				|  |  | -        $id = $request->param("id");
 | 
	
		
			
				|  |  | -        $info = \app\common\api\VerifyApi::getTalentInfoById($id);
 | 
	
		
			
				|  |  | -        return view("view", ["row" => $info]);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    // 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
 | 
	
		
			
				|  |  | -    public function submit() {
 | 
	
		
			
				|  |  | -        $id = $this->request->param("id");
 | 
	
		
			
				|  |  | -        if (!$info = self::chkIsOwner($id, $this->user["uid"]))
 | 
	
		
			
				|  |  | -            return json(["msg" => "没有对应的人才认定申报信息"]);
 | 
	
		
			
				|  |  | -        $checkState = $info["checkState"];
 | 
	
		
			
				|  |  | -        if ($checkState == TalentState::BASE_VERIFY_PASS || $checkState == 0) {
 | 
	
		
			
				|  |  | -            return json(["msg" => '请先保存资料并上传相应附件后再点击提交审核']);
 | 
	
		
			
				|  |  | -        } else if ($checkState == TalentState::FST_SAVE) {
 | 
	
		
			
				|  |  | -            //初次提交材料
 | 
	
		
			
				|  |  | -            $where = [];
 | 
	
		
			
				|  |  | -            $where[] = ["step", "=", 1];
 | 
	
		
			
				|  |  | -            $where[] = ["project", "=", 1];
 | 
	
		
			
				|  |  | -            $where[] = ["type", "=", $this->user["type"]];
 | 
	
		
			
				|  |  | -            $where[] = ["must", "=", 1];
 | 
	
		
			
				|  |  | -            $where[] = ["active", "=", 1];
 | 
	
		
			
				|  |  | -            $where[] = ["delete", "=", 0];
 | 
	
		
			
				|  |  | -            $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            $ft_ids = [];
 | 
	
		
			
				|  |  | -            foreach ($filetypes as $ft) {
 | 
	
		
			
				|  |  | -                if ($ft["option"]) {
 | 
	
		
			
				|  |  | -                    $selectVal = $info[$ft["rel"]];
 | 
	
		
			
				|  |  | -                    $conditions = array_filter(explode(",", $ft["option"]));
 | 
	
		
			
				|  |  | -                    if (!in_array($selectVal, $conditions)) {
 | 
	
		
			
				|  |  | -                        $deletes[] = $ft["id"];
 | 
	
		
			
				|  |  | -                        continue;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                $ft_ids[] = $ft["id"];
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //$ft_ids = array_column($filetypes, "id");
 | 
	
		
			
				|  |  | -            $whr = [];
 | 
	
		
			
				|  |  | -            $upload_type_counts = 0;
 | 
	
		
			
				|  |  | -            if ($ft_ids) {
 | 
	
		
			
				|  |  | -                $whr[] = ["typeId", "in", $ft_ids];
 | 
	
		
			
				|  |  | -                $whr[] = ["mainId", "=", $id];
 | 
	
		
			
				|  |  | -                $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
 | 
	
		
			
				|  |  | -                $upload_type_counts = count($distinct_filetypes);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if ($upload_type_counts != count($ft_ids)) {
 | 
	
		
			
				|  |  | -                return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            $change_state = TalentState::FST_SUBMIT; //等待审核
 | 
	
		
			
				|  |  | -            $data["id"] = $id;
 | 
	
		
			
				|  |  | -            $data["checkState"] = $change_state;
 | 
	
		
			
				|  |  | -            $data["first_submit_time"] = date("Y-m-d H:i:s");
 | 
	
		
			
				|  |  | -            $data["active"] = 1;
 | 
	
		
			
				|  |  | -            TalentModel::update($data);
 | 
	
		
			
				|  |  | -            TalentLogApi::write(1, $id, $change_state, "提交基础判定材料待审核", 1);
 | 
	
		
			
				|  |  | -            return json(["code" => 200, "msg" => "提交成功"]);
 | 
	
		
			
				|  |  | -        } else if ($checkState == TalentState::REVERIFY_FAIL) {
 | 
	
		
			
				|  |  | -            return ["msg" => "审核失败,不能再提交审核"];
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        return json(["msg" => "已提交审核,请耐心等待"]);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public function delete() {
 |