123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- namespace app\enterprise\validate;
- use think\Validate;
- /**
- * Description of TalentInfo
- * 先不用。分两步等下通不过
- * @author sgq
- */
- class TalentInfo extends Validate {
- protected $rule = [
- "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|unique:new_talent_info",
- "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.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" => "电子邮箱格式错误",
- "email.unique" => "电子邮箱已经存在",
- "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 "身份证号码不合法";
- }
- 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;
- }
- }
|