فهرست منبع

先传,港澳台身份证验证没完成

sugangqiang 2 سال پیش
والد
کامیت
f922c7510b

+ 1 - 0
app/common/api/DictApi.php

@@ -166,6 +166,7 @@ class DictApi {
             "graduate_school" => "毕业院校",
             "major" => "专业",
             "professional" => "专业技术职称",
+            "pro_qua" => "职业资格",
             "bank" => "开户银行",
             "bank_number" => "银行行号",
             "bank_branch_name" => "开户银行网点",

+ 181 - 0
app/common/api/IdCardApi.php

@@ -0,0 +1,181 @@
+<?php
+
+namespace app\common\api;
+
+/**
+ * Description of IdCardApi
+ *
+ * @author sgq
+ */
+class IdCardApi {
+
+    /**
+     * 校验身份证号是否合法
+     * @param string $num 待校验的身份证号
+     * @return bool
+     */
+    public static function isValid(string $num) {
+        //老身份证长度15位,新身份证长度18位
+        $length = strlen($num);
+        if ($length == 15) { //如果是15位身份证
+            //15位身份证没有字母
+            if (!is_numeric($num)) {
+                return false;
+            }
+            // 省市县(6位)
+            $areaNum = substr($num, 0, 6);
+            // 出生年月(6位)
+            $dateNum = substr($num, 6, 6);
+        } else if ($length == 18) { //如果是18位身份证
+            //基本格式校验
+            if (!preg_match('/^\d{17}[0-9xX]$/', $num)) {
+                return false;
+            }
+            // 省市县(6位)
+            $areaNum = substr($num, 0, 6);
+            // 出生年月日(8位)
+            $dateNum = substr($num, 6, 8);
+        } else { //假身份证
+            return false;
+        }
+
+        //验证地区
+        if (!self::isAreaCodeValid($areaNum)) {
+            return false;
+        }
+
+        //验证日期
+        if (!self::isDateValid($dateNum)) {
+            return false;
+        }
+
+        //验证最后一位
+        if (!self::isVerifyCodeValid($num)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * 省市自治区校验
+     * @param string $area 省、直辖市代码
+     * @return bool
+     */
+    private static function isAreaCodeValid(string $area) {
+        $provinceCode = substr($area, 0, 2);
+
+        // 根据GB/T2260—999,省市代码11到65
+        if (11 <= $provinceCode && $provinceCode <= 65) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 验证出生日期合法性
+     * @param string $date 日期
+     * @return bool
+     */
+    private static function isDateValid(string $date) {
+        if (strlen($date) == 6) { //15位身份证号没有年份,这里拼上年份
+            $date = '19' . $date;
+        }
+        $year = intval(substr($date, 0, 4));
+        $month = intval(substr($date, 4, 2));
+        $day = intval(substr($date, 6, 2));
+
+        //日期基本格式校验
+        if (!checkdate($month, $day, $year)) {
+            return false;
+        }
+
+        //日期格式正确,但是逻辑存在问题(如:年份大于当前年)
+        $currYear = date('Y');
+        if ($year > $currYear) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 验证18位身份证最后一位
+     * @param string $num 待校验的身份证号
+     * @return bool
+     */
+    private static function isVerifyCodeValid(string $num) {
+        if (strlen($num) == 18) {
+            $factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
+            $tokens = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
+
+            $checkSum = 0;
+            for ($i = 0; $i < 17; $i++) {
+                $checkSum += intval($num{$i}) * $factor[$i];
+            }
+
+            $mod = $checkSum % 11;
+            $token = $tokens[$mod];
+
+            $lastChar = strtoupper($num{17});
+
+            if ($lastChar != $token) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 验证其他身份证号,港澳台身份证
+     * @param $IDCard
+     * @return bool
+     */
+    public static function isValidExceptMainland($IDCard) {
+        $IDCard = strtoupper($IDCard);
+        $IDCard = str_replace(array('(', ')'), array('(', ')'), $IDCard);
+        preg_match('/^([A-Z])([\d]{6})\(([A\d])\)$/', $IDCard, $hongkong); //香港
+        if ($hongkong && count($hongkong) === 4) {
+            $sum = (ord($hongkong[1]) - 64) * 8;
+            $index = 7;
+            for ($j = 0; $j < 6; $j++) {
+                $sum += $hongkong[2]{$j} * $index;
+                $index--;
+            }
+            $get_num = $sum % 11;
+            if ($get_num === 1) {
+                $get_num = 'A';
+            } elseif ($get_num > 1) {
+                $get_num = 11 - $get_num;
+            }
+
+            if ($hongkong[3] === $get_num) {
+                return true;
+            }
+            return false;
+        }
+        preg_match('/^([A-Z])([\d]{9})$/', $IDCard, $taiwan); //中国台湾省
+        if ($taiwan && count($taiwan) === 3) {//首位数字代表性别,男性为1、女性为2
+            $area_code = array('A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15, 'G' => 16, 'H' => 17, 'I' => 34, 'J' => 18, 'K' => 19, 'L' => 20, 'M' => 21, 'N' => 22, 'O' => 35, 'P' => 23, 'Q' => 24, 'R' => 25, 'S' => 26, 'T' => 27, 'U' => 28, 'V' => 29, 'W' => 32, 'X' => 30, 'Y' => 31, 'Z' => 33);
+            $code = $area_code[$taiwan[1]];
+            $sum = $code{0} + $code{1} * 9;
+            $index = 8;
+            for ($k = 1; $k < 8; $k++) {
+                $sum += $taiwan[2]{$k} * $index;
+                $index--;
+            }
+
+            $get_num = $sum % 10;
+            if ($get_num === $taiwan[2]{8}) {
+                return true;
+            }
+            return false;
+        }
+        preg_match('/^[157][\d]{6}\([\d]\)$/', $IDCard, $aomen); //澳门
+        if ($aomen) {
+            return true;
+        }
+        return false;
+    }
+
+}

+ 168 - 184
app/enterprise/controller/Base.php

@@ -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() {

+ 130 - 139
app/enterprise/controller/Talent.php

@@ -8,6 +8,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复核失败
 
@@ -38,25 +40,30 @@ class Talent extends EnterpriseController {
         }
         $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
         if ($request->isPost()) {
-            $batch = \app\common\api\BatchApi::getValidBatch(1, $this->user["type"]);
-            if (!$batch) {
-                $res = ["msg" => "不在人才认定申报申请时间内"];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
-                exit;
-            }
+            $this->save($info, $request, TalentState::SCND_SAVE);
+            exit();
+        }
+        $enterprise_info = \app\common\model\Enterprise::find($this->user["uid"]);
+        $info["enterprise"] = $enterprise_info;
+        $batch = \app\common\api\BatchApi::getValidBatch(1, $enterprise_info["type"]);
+        return view("second", ["year" => $info["apply_year"] ?: $batch["batch"], "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() {
+        $params = $this->request->param();
+        $id = $params["id"];
+        if (!$info = self::chkIsOwner($id, $this->user["uid"]))
+            return json(["msg" => "没有对应的人才认定申报信息"]);
+        $checkState = $info["checkState"];
+        if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_VERIFY_PASS) {
             $field_dict = \app\common\api\DictApi::getTalentFields(2);
-            //可以用匹配键的方式,可以少很多代码。。先这样吧。
-            $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
-                "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
-                "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
-                "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary"];
-            foreach ($all_valid_keys as $key) {
-                $data[$key] = trim($params[$key]);
-                if (strpos($key, "time") !== false && strtotime($params[$key]) === false) {
-                    unset($data[$key]); //时间格式的验证不通过就清掉,下面判断是否为空如果赫然在列就不能通过
-                }
-            }
 
             $no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
                 "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
@@ -74,23 +81,23 @@ class Talent extends EnterpriseController {
             if ($abroad_files)
                 $abroad_file_ids = array_column($abroad_files, "id");
 
-            if ($data["study_abroad"] == 1) {
+            if ($params["study_abroad"] == 1) {
                 $no_empty[] = "abroad_school";
                 $no_empty[] = "abroad_major";
             }
-            if (in_array($data["source"], [1, 3])) {
+            if (in_array($params["source"], [1, 3])) {
                 $no_empty[] = "source_batch";
                 $no_empty[] = "fujian_highcert_pubtime";
                 $no_empty[] = "fujian_highcert_exptime";
-                if ($data["source"] == 3) {
+                if ($params["source"] == 3) {
                     $no_empty[] = "source_city";
                 }
             }
-            if (in_array($data["source"], [2, 4])) {
+            if (in_array($params["source"], [2, 4])) {
                 $no_empty[] = "source_batch";
                 $no_empty[] = "quanzhou_highcert_pubtime";
                 $no_empty[] = "quanzhou_highcert_exptime";
-                if ($data["source"] == 4) {
+                if ($params["source"] == 4) {
                     $no_empty[] = "source_county";
                 }
             }
@@ -103,34 +110,13 @@ class Talent extends EnterpriseController {
             $no_empty = array_filter($no_empty);
             $return = [];
             foreach ($no_empty as $key) {
-                if (!$data[$key]) {
+                if (!$params[$key]) {
                     $return[] = sprintf("请填写“%s”", $field_dict[$key]);
                 }
             }
             if (count($return) > 0) {
                 $res = ["msg" => implode("<br>", $return)];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
-                exit;
-            }
-            if (!preg_match("/^(13|14|15|17|18|19)[\d]{9}$/", $data["phone"])) {
-                $res = ["msg" => "手机号码格式错误"];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
-                exit;
-            }
-            if (!filter_var($data["email"], FILTER_VALIDATE_EMAIL)) {
-                $res = ["msg" => "电子邮箱格式错误"];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
-                exit;
-            }
-
-            if (!in_array($data["talent_arrange"], [1, 2, 3, 4, 5, 6, 7])) {
-                $res = ["msg" => "人才层次只能在预设范围内选择"];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
-                exit;
-            }
-            if (!in_array($data["source"], [1, 2, 3, 4, 5])) {
-                $res = ["msg" => "来源只能在预设范围内选择"];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
+                echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
                 exit;
             }
 
@@ -152,7 +138,7 @@ class Talent extends EnterpriseController {
                 $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
             }
             $ft_ids = array_column($filetypes, "id");
-            if ($data["study_abroad"] == 1) {
+            if ($params["study_abroad"] == 1) {
                 //选中留学,如果存在留学附件变成必传
                 $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
             } else {
@@ -167,114 +153,119 @@ class Talent extends EnterpriseController {
 
             if ($upload_type_counts != count($ft_ids)) {
                 $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
+                echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
                 exit;
             }
-            if ($info["real_state"] == 8) {
-                //真实状态8是驳回,需要判断什么字段可以提交                
-                $modify_fields = array_filter(explode(",", $info["modify_fields"]));
-                $tmp_data = $data;
-                $data = [];
-                foreach ($modify_fields as $field) {
-                    $data[$field] = $tmp_data[$field];
-                }
-            }
-            $data["apply_year"] = $batch["batch"];
-            $data["id"] = $id;
-            $data["checkState"] = TalentState::SCND_SAVE;
-            if (TalentModel::update($data)) {
-                $res = ["code" => 200, "msg" => "保存成功", "obj" => ["id" => $id, "checkState" => TalentState::SCND_SAVE]];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
-            } else {
-                $res = ["code" => 500, "msg" => "保存失败"];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
-            }
-            exit();
-        }
-        $enterprise_info = \app\common\model\Enterprise::find($this->user["uid"]);
-        $info["enterprise"] = $enterprise_info;
-        $batch = \app\common\api\BatchApi::getValidBatch(1, $enterprise_info["type"]);
-        return view("second", ["year" => $info["apply_year"] ?: $batch["batch"], "row" => $info]);
-    }
 
-    public function view(\think\Request $request) {
-        $id = $request->param("id");
-        $info = \app\common\api\VerifyApi::getTalentInfoById($id);
-        return view("view", ["row" => $info]);
+            $this->save($info, $this->request, TalentState::SCND_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;
     }
 
-    // 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::SCND_SAVE) {
-            $condition_info = Db::table("new_talent_condition")->findOrEmpty($info["talent_condition"]);
-
-            if ($condition_info["bindFileTypes"]) {
-                $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
-                $whr[] = ["must", "=", 1];
+    /**
+     * 保存表单
+     * @param type $info talent_info
+     * @param type $param request->param();
+     */
+    private function save($info, \think\Request $request, $checkState) {
+        try {
+            $batch = \app\common\api\BatchApi::getValidBatch(1, $this->user["type"]);
+            if (!$batch) {
+                throw new ValidateException("不在人才认定申报申请时间内");
             }
+            $param = $request->param();
+            validate(TalentInfo::class)->check($param);
+            $data["apply_year"] = $batch["batch"];
 
-            $where = [];
-            $where[] = ["rel", "=", "study_abroad"];
-            $where[] = ["step", "=", 2];
-            $where[] = ["project", "=", 1];
-            $where[] = ["active", "=", 1];
-            $where[] = ["delete", "=", 0];
-            $where[] = ["type", "=", $this->user["type"]];
-            $where[] = ["isConditionFile", "<>", 1];
-            $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
-            $abroad_file_ids = null;
-            if ($abroad_files)
-                $abroad_file_ids = array_column($abroad_files, "id");
+            $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
+                "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
+                "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
+                "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
+            foreach ($all_valid_keys as $key) {
+                $data[$key] = trim($param[$key]);
+            }
 
-            $where = [];
-            $where[] = ["step", "=", 2];
-            $where[] = ["project", "=", 1];
-            $where[] = ["type", "=", $this->user["type"]];
-            $where[] = ["must", "=", 1];
-            $where[] = ["active", "=", 1];
-            $where[] = ["delete", "=", 0];
-            $where[] = ["isConditionFile", "<>", 1];
-            if ($whr) {
-                $filetypes = Db::table("new_common_filetype")->where([$where, $whr])->select()->toArray();
+            if ($data["study_abroad"] == 1) {
+                $data["abroad_school"] = $param["abroad_school"];
+                $data["abroad_major"] = $param["abroad_major"];
             } else {
-                $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
+                $data["abroad_school"] = null;
+                $data["abroad_major"] = null;
             }
-            $ft_ids = array_column($filetypes, "id");
-            if ($info["study_abroad"] == 1) {
-                //选中留学,如果存在留学附件变成必传
-                $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
-            } else {
-                //没选中,留学附件就算设成必传也不用验证
-                $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
+            switch ($data["source"]) {
+                case 1:
+                    $data["source_batch"] = $param["source_batch"];
+                    $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
+                    $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
+                    $data["source_city"] = null;
+                    break;
+                case 2:
+                    $data["source_batch"] = $param["source_batch"];
+                    $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
+                    $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
+                    $data["source_county"] = null;
+                    break;
+                case 3:
+                    $data["source_batch"] = $param["source_batch"];
+                    $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
+                    $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
+                    $data["source_city"] = $param["source_city"];
+                    break;
+                case 4:
+                    $data["source_batch"] = $param["source_batch"];
+                    $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
+                    $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
+                    $data["source_county"] = $param["source_county"];
+                    break;
             }
-            $whr = [];
-            $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" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
+            $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
+
+            if ($condition_info["isSalary"] == 1) {
+                $data["annual_salary"] = $param["annual_salary"];
+            } else {
+                $data["annual_salary"] = null;
             }
 
-            $change_state = TalentState::SCND_SUBMIT; //等待初审
-            $data["id"] = $id;
-            $data["checkState"] = $change_state;
-            $data["active"] = 1;
-            $data["new_submit_time"] = date("Y-m-d H:i:s");
-            TalentModel::update($data);
-            TalentLogApi::write(1, $id, $change_state, "确认提交审核", 1);
-            return json(["code" => 200, "msg" => "提交成功"]);
-        } else if ($checkState == TalentState::REVERIFY_FAIL) {
-            return ["msg" => "审核失败,不能再提交审核"];
+            if ($info["real_state"] == 8) {
+                //真实状态8是驳回,需要判断什么字段可以提交                
+                $modify_fields = array_filter(explode(",", $info["modify_fields"]));
+                $tmp_data = $data;
+                $data = [];
+                foreach ($modify_fields as $field) {
+                    $data[$field] = $tmp_data[$field];
+                }
+            }
+            $data["checkState"] = $checkState;
+            $data["id"] = $info["id"];
+            if ($checkState == TalentState::SCND_SAVE) {
+                $success_msg = "提交成功";
+                $error_msg = "提交失败";
+                TalentModel::update($data);
+            } else if ($checkState == TalentState::SCND_SUBMIT) {
+                $success_msg = "提交成功";
+                $error_msg = "提交失败";
+                $data["new_submit_time"] = date("Y-m-d H:i:s");
+                TalentModel::update($data);
+                TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
+            } else {
+                throw new ValidateException($error_msg);
+            }
+            $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
+            $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
+            echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
+        } catch (ValidateException $e) {
+            $res = ["msg" => $e->getMessage()];
+            $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
+            echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
+            exit();
         }
-        return json(["msg" => "已提交审核,请耐心等待"]);
     }
 
     public function delete() {

+ 128 - 5
app/enterprise/validate/TalentInfo.php

@@ -12,13 +12,136 @@ use think\Validate;
 class TalentInfo extends Validate {
 
     protected $rule = [
-        'name' => 'require',
-        'sex' => 'require|number|between:1,2',
-        'email' => 'email',
+        "name" => "regex:/^[\x{4e00}-\x{9fa5}]+$/u",
+        "nation" => "checkInSelect:nation,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57",
+        "card_type" => "between:1,3",
+        "card_number" => "checkCardNumber|unique:new_talent_info",
+        "sex" => "between:1,2",
+        "politics" => "checkInSelect:politics,01,02,03,04,05,06,07,08,09,10,11,12,13,14",
+        "birthday" => "dateFormat:Y-m-d",
+        "nationality" => "checkInSelect:nationality,cn,cn_hk,cn_mc,cn_tw,us,en,jp,co,nl,sg,other",
+        "talent_type" => "between:1,3",
+        "tax_insurance_month" => "checkRangeDate:tax_insurance_month",
+        "labor_contract_rangetime" => "checkRangeDate:labor_contract_rangetime",
+        "fst_work_time" => "dateFormat:Y-m-d",
+        "pre_import_type" => "between:1,2",
+        "experience" => "max:200",
+        "education" => "max:200",
+        "phone" => "mobile|unique:new_talent_info",
+        "email" => "email",
+        "highest_degree" => "checkInSelect:highest_degree,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21",
+        "study_abroad" => "between:1,2",
+        "import_way" => "between:1,3",
+        "cur_entry_time" => "dateFormat:Y-m-d",
+        "source" => "between:1,5",
+        "fujian_highcert_pubtime" => "dateFormat:Y-m-d",
+        "fujian_highcert_exptime" => "dateFormat:Y-m-d",
+        "quanzhou_highcert_pubtime" => "dateFormat:Y-m-d",
+        "quanzhou_highcert_exptime" => "dateFormat:Y-m-d",
+        "talent_arrange" => "between:1,7",
+        "bank" => "regex:/^[\x{4e00}-\x{9fa5}]+银行$/u",
+        "bank_number" => "regex:/^\d+$/",
+        "bank_branch_name" => "regex:/^[\x{4e00}-\x{9fa5}]+银行[\x{4e00}-\x{9fa5}]+省?[\x{4e00}-\x{9fa5}]+市[\x{4e00}-\x{9fa5}]+$/u",
+        "bank_account" => "regex:/^\d+$/",
     ];
     protected $message = [
-        'name.require' => '名称必须',
-        'email' => '邮箱格式错误',
+        "name.regex" => "姓名只能是中文",
+        "card_type.between" => "不存在的证件类型,请在列表中选择",
+        "card_number.unique" => "身份证已经存在",
+        "sex.between" => "性别只能在预设列表中选择",
+        "politics.between" => "政治面貌只能在预设列表中选择",
+        "birthday.dateFormat" => "生日必需是有效日期格式[yyyy-MM-dd]",
+        "talent_type.between" => "不存在的人才类型,请在列表中选择",
+        "fst_work_time.dateFormat" => "来晋工作时间必需是有效的日期格式[yyyy-MM-dd]",
+        "pre_import_type.between" => "预引进类型只能在预设列表中选择",
+        "experience.max" => "工作经历不能超过200个字符,请简明扼要的描述您的工作经历",
+        "education.max" => "教育背景不能超过200个字符,请简明扼要的描述您的教育背景",
+        "phone.mobile" => "请填写正确的手机号",
+        "phone.unique" => "手机号已经存在",
+        "email.email" => "电子邮箱格式错误",
+        "highest_degree.between" => "最高学历只能在预设列表中选择",
+        "study_abroad.between" => "留学经历只能选择是与否",
+        "import_way.between" => "不存在的引进方式,请在列表中选择",
+        "cur_entry_time.dateFormat" => "本单位入职时间必需是有效的日期格式[yyyy-MM-dd]",
+        "source.between" => "不存在的申报来源,请在列表中选择",
+        "fujian_highcert_pubtime.dateFormat" => "福建省高层次人才证书发证日期必需是有效的日期格式[yyyy-MM-dd]",
+        "fujian_highcert_exptime.dateFormat" => "福建省高层次人才证书有效期必需是有效的日期格式[yyyy-MM-dd]",
+        "quanzhou_highcert_pubtime.dateFormat" => "泉州高层次人才证书发证日期必需是有效的日期格式[yyyy-MM-dd]",
+        "quanzhou_highcert_exptime.dateFormat" => "泉州高层次人才证书有效期必需是有效的日期格式[yyyy-MM-dd]",
+        "talent_arrange" => "不存在的人才层次,请在列表中选择",
+        "bank.regex" => "开户银行格式应为[XX银行]",
+        "bank_number.regex" => "银行行号只能是数字",
+        "bank_branch_name.regex" => "开户银行网点格式应为[XX银行XX省XX市XX行/处]",
+        "bank_account.regex" => "银行账号只能是数字",
     ];
 
+    protected function checkInSelect($value, $rule, $data = []) {
+        $title = "";
+        $select = explode(",", $rule);
+        $type = array_shift($select);
+        switch ($type) {
+            case "nation":
+                $title = "民族";
+                break;
+            case "politics":
+                $title = "政治面貌";
+                break;
+            case "nationality":
+                $title = "国籍/地区";
+                break;
+            case "highest_degree":
+                $title = "最高学历";
+                break;
+        }
+        return in_array($value, $select) ?: "{$title}只能在预设列表中选择";
+    }
+
+    protected function checkCardNumber($value, $rule, $data = []) {
+        if (!$data["card_type"]) {
+            return "填写证件号码前请先选择证件类型";
+        }
+        if ($data["card_type"] == 1) {
+            $num = strlen($value);
+            switch ($num) {
+                case 15:
+                case 18:
+                    return \app\common\api\IdCardApi::isValid($value) ?: "身份证号码不合法";
+                    break;
+                default:
+                    //return \app\common\api\IdCardApi::isValidExceptMainland($value) ?: "身份证号码不合法";
+                    break;
+            }
+        }
+        return true;
+    }
+
+    protected function checkRangeDate($value, $rule, $data = []) {
+        $title = "";
+        $format = "[yyyy-MM-dd - yyyy-MM-dd]";
+        $str = "日期";
+        switch ($rule) {
+            case "tax_insurance_month":
+                $format = "[yyyy-MM - yyyy-MM]";
+                $str = "月份";
+                if ($data["talent_type"] == 1) {
+                    $title = "缴交社会保险或个人所得税月份";
+                }
+                if ($data["talent_type"] == 2) {
+                    $title = "首次在我市缴交社会保险或个人所得税月份";
+                }
+                break;
+            case "labor_contract_rangetime":
+                $title = "劳动合同起止时间";
+                break;
+        }
+        $arr = explode(" - ", $value);
+        $chk1 = strtotime($arr[0]);
+        $chk2 = strtotime($arr[1]);
+        if (!$chk1 || !$chk2)
+            return "{$title}日期范围格式应为{$format}";
+        if ($chk1 > $chk2)
+            return "{$title}起始{$str}不能大于结束{$str}";
+        return true;
+    }
+
 }

+ 3 - 2
public/static/modular/gate/talentBase/talentBase.js

@@ -32,9 +32,10 @@ TalentInfo.initColumn = function () {
             formatter: function (value, row, index) {
                 if (row.sex == 1) {
                     return value + '<span style="color:#6495ED">【男】</span>';
-                }
-                if (row.sex == 2) {
+                } else if (row.sex == 2) {
                     return value + '<span style="color:#FF82AB">【女】</span>';
+                } else {
+                    return value;
                 }
             }
         },

+ 46 - 8
public/static/modular/gate/talentBase/talentInfo_info.js

@@ -234,9 +234,9 @@ TalentInfoInfoDlg.validate = function () {
 TalentInfoInfoDlg.addSubmit = function () {
     this.clearData();
     this.collectData();
-    if (!TalentInfoInfoDlg.validate()) {
-        return;
-    }
+    /*if (!TalentInfoInfoDlg.validate()) {
+     return;
+     }*/
     var id = $('#id').val();
     $("#province_name").val($("#province").find("option:selected").text());
     $("#city_name").val($("#city").find("option:selected").text());
@@ -260,6 +260,7 @@ TalentInfoInfoDlg.addSubmit = function () {
         return;
     }
     locked = true;
+    $("#talentInfoForm").attr("action", "/enterprise/base/add");
     $("#talentInfoForm")[0].submit();
 }
 
@@ -721,14 +722,38 @@ TalentInfoInfoDlg.deleteFile = function (id, state) {
  * 提交审核
  */
 TalentInfoInfoDlg.submitToCheck = function () {
+    /*if (!TalentInfoInfoDlg.validate()) {
+     return;
+     }*/
     var id = $("#id").val();
-    if (id == null || id == "") {
-        Feng.info("请先填写基础信息并上传附件");
-        return;
-    }
+    /*if (id == null || id == "") {
+     Feng.info("请先填写基础信息并上传附件");
+     return;
+     }*/
     if (!TalentInfoInfoDlg.validateIsEdit())
         return;
     var operation = function () {
+        TalentInfoInfoDlg.clearData();
+        TalentInfoInfoDlg.collectData();
+        /*if (!TalentInfoInfoDlg.validate()) {
+         return;
+         }*/
+        var id = $('#id').val();
+        if (id != null && id != '') {
+            if (!TalentInfoInfoDlg.validateIsEdit())
+                return;
+        }
+        $("select").each(function () {
+            $(this).removeAttr("disabled");
+        });
+        if (locked) {
+            return;
+        }
+        locked = true;
+        $("#talentInfoForm").attr("action", "/enterprise/base/submit");
+        $("#talentInfoForm")[0].submit();
+
+        return;
         var ajax = new $ax(Feng.ctxPath + "/enterprise/base/submit", function (data) {
             if (data.code == 200) {
                 Feng.success(data.msg);
@@ -746,6 +771,19 @@ TalentInfoInfoDlg.submitToCheck = function () {
     }
     Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
 }
+//回调
+TalentInfoInfoDlg.submitCallback = function (data) {
+    locked = false;
+    TalentInfoInfoDlg.setNoChangeField();
+    if (data.code == 200) {
+        Feng.success(data.msg);
+        // $("#checkState").val(data.obj);
+        window.parent.TalentInfo.table.refresh();
+        TalentInfoInfoDlg.close();
+    } else {
+        Feng.error(data.msg);
+    }
+}
 
 /**
  * 校验是否可以修改/提交审核
@@ -987,7 +1025,7 @@ function async_padding(card_number, card_type) {
 $(function () {
     TalentInfoInfoDlg.talentTypeFlag = false;
     TalentInfoInfoDlg.talentTypeOneTwo = true;
-    Feng.initValidatorTip("talentInfoForm", TalentInfoInfoDlg.validateFields);
+    //Feng.initValidatorTip("talentInfoForm", TalentInfoInfoDlg.validateFields);
     var id = $("#id").val();
     var checkState = $("#checkState").val();
     //批量加载字典表数据

+ 3 - 2
public/static/modular/gate/talentInfo/talentInfo.js

@@ -23,9 +23,10 @@ TalentInfo.initColumn = function () {
             formatter: function (value, row, index) {
                 if (row.sex == 1) {
                     return value + '<span style="color:#6495ED">【男】</span>';
-                }
-                if (row.sex == 2) {
+                } else if (row.sex == 2) {
                     return value + '<span style="color:#FF82AB">【女】</span>';
+                } else {
+                    return value;
                 }
             }
         },

+ 47 - 19
public/static/modular/gate/talentInfo/talentInfo_info.js

@@ -385,21 +385,10 @@ TalentInfoInfoDlg.initFileTable = function () {
 TalentInfoInfoDlg.addSubmit = function () {
     this.clearData();
     this.collectData();
-    if (!TalentInfoInfoDlg.validate()) {
-        return;
-    }
+    /*if (!TalentInfoInfoDlg.validate()) {
+     return;
+     }*/
     var id = $('#id').val();
-    $("#province_name").val($("#province").find("option:selected").text());
-    $("#city_name").val($("#city").find("option:selected").text());
-    if ($("#county").val() != null && $("#county").val() != '') {
-        $("#county_name").val($("#county").find("option:selected").text());
-    }
-    if ($("#source_city").val() != null && $("#source_city").val() != '') {
-        $("#source_city_name").val($("#source_city").find("option:selected").text());
-    }
-    if ($("#source_county").val() != null && $("#source_county").val() != '') {
-        $("#source_county_name").val($("#source_county").find("option:selected").text());
-    }
     if (id != null && id != '') {
         if (!TalentInfoInfoDlg.validateIsEdit())
             return;
@@ -411,6 +400,7 @@ TalentInfoInfoDlg.addSubmit = function () {
         return;
     }
     locked = true;
+    $("#talentInfoForm").attr("action", "/enterprise/talent/second");
     $("#talentInfoForm")[0].submit();
 }
 
@@ -701,14 +691,39 @@ TalentInfoInfoDlg.deleteFile = function (id, state) {
  * 提交审核
  */
 TalentInfoInfoDlg.submitToCheck = function () {
+    /*if (!TalentInfoInfoDlg.validate()) {
+     return;
+     }*/
     var id = $("#id").val();
-    if (id == null || id == "") {
-        Feng.info("请先填写基础信息并上传附件");
-        return;
-    }
+    /*if (id == null || id == "") {
+     Feng.info("请先填写基础信息并上传附件");
+     return;
+     }*/
     if (!TalentInfoInfoDlg.validateIsEdit())
         return;
     var operation = function () {
+        TalentInfoInfoDlg.clearData();
+        TalentInfoInfoDlg.collectData();
+        /*if (!TalentInfoInfoDlg.validate()) {
+         return;
+         }*/
+        var id = $('#id').val();
+        if (id != null && id != '') {
+            if (!TalentInfoInfoDlg.validateIsEdit())
+                return;
+        }
+        $("select").each(function () {
+            $(this).removeAttr("disabled");
+        });
+        if (locked) {
+            return;
+        }
+        locked = true;
+        $("#talentInfoForm").attr("action", "/enterprise/talent/submit");
+        $("#talentInfoForm")[0].submit();
+
+
+        return;
         var ajax = new $ax(Feng.ctxPath + "/enterprise/talent/submit", function (data) {
             if (data.code == 200) {
                 Feng.success(data.msg);
@@ -726,6 +741,19 @@ TalentInfoInfoDlg.submitToCheck = function () {
     }
     Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
 }
+//回调
+TalentInfoInfoDlg.submitCallback = function (data) {
+    locked = false;
+    TalentInfoInfoDlg.setNoChangeField();
+    if (data.code == 200) {
+        Feng.success(data.msg);
+        // $("#checkState").val(data.obj);
+        window.parent.TalentInfo.table.refresh();
+        TalentInfoInfoDlg.close();
+    } else {
+        Feng.error(data.msg);
+    }
+}
 
 /**
  * 校验是否可以修改/提交审核
@@ -960,7 +988,7 @@ function async_padding(card_number, card_type) {
     }
 }
 $(function () {
-    Feng.initValidatorTip("talentInfoForm", TalentInfoInfoDlg.validateFields);
+    //Feng.initValidatorTip("talentInfoForm", TalentInfoInfoDlg.validateFields);
     var id = $("#id").val();
     var checkState = $("#checkState").val();
     //批量加载字典表数据