sugangqiang 2 年之前
父節點
當前提交
edc52d744e

+ 125 - 21
app/enterprise/controller/Talent.php

@@ -269,10 +269,11 @@ class Talent extends EnterpriseController {
             exit;
         }
         $checkState = $info["checkState"];
-        if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
-            $field_dict = \app\common\api\DictApi::getTalentFields(2);
+        if ($checkState == TalentState::SCND_SAVE) {
+            $field_dict = \app\common\api\DictApi::getTalentFields(4);
 
-            $no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
+            $no_empty = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "county", "talent_type", "experience", "education",
+                "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"];
 
             $where = [];
@@ -288,6 +289,13 @@ class Talent extends EnterpriseController {
             if ($abroad_files)
                 $abroad_file_ids = array_column($abroad_files, "id");
 
+            if (in_array($param["talent_type"], [1, 2])) {
+                $no_empty[] = "tax_insurance_month";
+                $no_empty[] = "labor_contract_rangetime";
+            }
+            if ($param["talent_type"] == 3) {
+                $no_empty[] = "pre_import_type";
+            }
             if ($params["study_abroad"] == 1) {
                 $no_empty[] = "abroad_school";
                 $no_empty[] = "abroad_major";
@@ -332,7 +340,6 @@ class Talent extends EnterpriseController {
                 $whr[] = ["must", "=", 1];
             }
             $where = [];
-            $where[] = ["step", "=", 2];
             $where[] = ["project", "=", 1];
             $where[] = ["type", "=", $this->user["type"]];
             $where[] = ["must", "=", 1];
@@ -364,7 +371,7 @@ class Talent extends EnterpriseController {
             }
 
             $this->save($info, $this->request, TalentState::SCND_SUBMIT);
-        } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
+        } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
             $res = ["msg" => "审核失败,不能再提交审核"];
             echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
             exit;
@@ -493,8 +500,7 @@ class Talent extends EnterpriseController {
             validate(TalentInfo::class)->check($param);
             $id = $param["id"];
             if ($id) {
-                $data["id"] = $id;
-                if (!$info) {
+                if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
                     throw new ValidateException("没有对应的人才认定申报信息");
                 }
             }
@@ -523,6 +529,41 @@ class Talent extends EnterpriseController {
             if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
                 throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 
+            $where = [];
+            $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();
+
+            $age = 0;
+            if ($param["birthday"]) {
+                $birthday = $param["birthday"];
+                $birthdayYear = substr($birthday, 0, 4);
+                $currentYear = date("Y");
+                $age = $currentYear - $birthdayYear;
+            }
+            $ft_ids = [];
+            $deletes = [];
+            foreach ($filetypes as $ft) {
+                if ($ft["option"]) {
+                    if ($ft["rel"] == "birthday") {
+                        if ($age < $ft["option"]) {
+                            $deletes[] = $ft["id"];
+                            continue;
+                        }
+                    } else {
+                        $selectVal = $param[$ft["rel"]];
+                        $conditions = array_filter(explode(",", $ft["option"]));
+                        if (!in_array($selectVal, $conditions)) {
+                            $deletes[] = $ft["id"];
+                            continue;
+                        }
+                    }
+                }
+                $ft_ids[] = $ft["id"];
+            }
 
             $data["apply_year"] = $batch["batch"];
 
@@ -588,7 +629,7 @@ class Talent extends EnterpriseController {
             }
 
             if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
-                //真实状态8是驳回,需要判断什么字段可以提交                
+                //真实状态11是驳回,需要判断什么字段可以提交                
                 $modify_fields = array_filter(explode(",", $info["modify_fields"]));
                 $tmp_data = $data;
                 $data = [];
@@ -597,28 +638,71 @@ class Talent extends EnterpriseController {
                 }
             }
             $data["checkState"] = $checkState;
-            $data["id"] = $info["id"];
+            $data["id"] = $id;
             $success_msg = "提交成功";
             $error_msg = "提交失败";
             if ($checkState == TalentState::SCND_SAVE) {
-                $last_log = TalentLogApi::getLastLog($data["id"], 1);
-                if ($last_log["new_state"] != TalentState::SCND_SAVE) {
-                    TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
+                $success_msg = "保存成功";
+                if ($data["id"]) {
+                    //编辑
+                    TalentModel::update($data);
+                    $last_log = TalentLogApi::getLastLog($data["id"], 1);
+                    if ($last_log["new_state"] != TalentState::SCND_SAVE) {
+                        TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
+                    } else {
+                        TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
+                    }
+                } else {
+                    //新增
+                    $data["enterprise_id"] = $this->user["uid"];
+                    $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);
                 }
-                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);
+                TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
+            } else {
+                throw new ValidateException($error_msg);
+            }
+
+            if ($id) {
+                if ($deletes) {
+                    //删除多余的附件,一般是选择人才类型留下来的
+                    $whr = [];
+                    $whr[] = ["typeId", "in", $deletes];
+                    $whr[] = ["id", "in", $files];
+                    $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
+                    $_logfileIds[] = [];
+                    foreach ($_wait_del_files as $_del_file) {
+                        $_logfileIds[] = $_del_file["id"];
+                        @unlink("storage/" . $_del_file["url"]);
+                    }
+                    Db::table("new_talent_file")->where($whr)->delete();
+                    if ($_logfileIds) {
+                        $whr = [];
+                        $whr[] = ["fileId", "in", $_logfileIds];
+                        $_upd_checklog["description"] = "删除附件";
+                        $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
+                        $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
+                        Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
+                    }
+                }
+
+                $whr = [];
+                $whr[] = ["id", "in", $files];
+                Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
+                $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
+                $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
+                echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
+                exit();
             } 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));
-            exit();
         } catch (ValidateException $e) {
             $res = ["msg" => $e->getMessage()];
             $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
@@ -638,7 +722,27 @@ class Talent extends EnterpriseController {
             $log = TalentLogApi::getLastLog($id, 1);
             if ($log["state"] > 1) {
                 //有提交审核记录
-                return json(["msg" => "操作失败"]);
+                return json(["msg" => "该申报已提交审核,无法删除"]);
+            }
+        }
+        $data["id"] = $id;
+        $data["delete"] = 1;
+        TalentModel::update($data);
+        return json(["msg" => "删除成功"]);
+    }
+
+    public function mixDelete() {
+        $id = $this->request->param("talentInfoId");
+        $info = Talent::chkIsOwner($id, $this->user["uid"]);
+        if (!$info) {
+            return json(["msg" => "操作失败"]);
+        }
+        $checkState = $info["checkState"];
+        if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
+            $log = TalentLogApi::getLastLog($id, 1);
+            if ($log["state"] > 1) {
+                //有提交审核记录
+                return json(["msg" => "该申报已提交审核,无法删除"]);
             }
         }
         $data["id"] = $id;

+ 22 - 6
app/enterprise/validate/TalentInfo.php

@@ -3,6 +3,7 @@
 namespace app\enterprise\validate;
 
 use think\Validate;
+use app\common\api\TalentState;
 
 /**
  * Description of TalentInfo
@@ -15,7 +16,7 @@ class TalentInfo extends Validate {
         "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",
+        "card_number" => "checkCardNumber|checkUnique: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",
@@ -27,8 +28,8 @@ class TalentInfo extends Validate {
         "pre_import_type" => "between:1,2",
         "experience" => "max:200",
         "education" => "max:200",
-        "phone" => "mobile|unique:new_talent_info",
-        "email" => "email|unique:new_talent_info",
+        "phone" => "mobile|checkUnique:new_talent_info",
+        "email" => "email|checkUnique: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",
@@ -47,7 +48,7 @@ class TalentInfo extends Validate {
     protected $message = [
         "name.regex" => "姓名只能是中文",
         "card_type.between" => "不存在的证件类型,请在列表中选择",
-        "card_number.unique" => "身份证已经存在",
+        "card_number.checkUnique" => "身份证已经存在",
         "sex.between" => "性别只能在预设列表中选择",
         "politics.between" => "政治面貌只能在预设列表中选择",
         "birthday.dateFormat" => "生日必需是有效日期格式[yyyy-MM-dd]",
@@ -57,9 +58,9 @@ class TalentInfo extends Validate {
         "experience.max" => "工作经历不能超过200个字符,请简明扼要的描述您的工作经历",
         "education.max" => "教育背景不能超过200个字符,请简明扼要的描述您的教育背景",
         "phone.mobile" => "请填写正确的手机号",
-        "phone.unique" => "手机号已经存在",
+        "phone.checkUnique" => "手机号已经存在",
         "email.email" => "电子邮箱格式错误",
-        "email.unique" => "电子邮箱已经存在",
+        "email.checkUnique" => "电子邮箱已经存在",
         "highest_degree.between" => "最高学历只能在预设列表中选择",
         "study_abroad.between" => "留学经历只能选择是与否",
         "import_way.between" => "不存在的引进方式,请在列表中选择",
@@ -76,6 +77,21 @@ class TalentInfo extends Validate {
         "bank_account.regex" => "银行账号只能是数字",
     ];
 
+    protected function checkUnique($value, $rule, $data = [], $field) {
+        $db = $this->db->name($rule);
+        $pk = $db->getPk();
+        $map = [];
+        $map[] = [$field, "=", $data[$field]];
+        $map[] = ["checkState", "not in", [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL]];
+        if ($data[$pk]) {
+            $map[] = [$pk, "<>", $data[$pk]];
+        }
+        if ($db->where($map)->field($pk)->find()) {
+            return false;
+        }
+        return true;
+    }
+
     protected function checkInSelect($value, $rule, $data = []) {
         $title = "";
         $select = explode(",", $rule);

+ 1 - 1
app/enterprise/view/talent/apply.html

@@ -143,7 +143,7 @@
                                                 <td>
                                                     <div class="rowGroup">
                                                         <label class=" control-label spacing td-label"><span style="color: red">*</span>出生日期</label>
-                                                        <input type="text" class="form-control" id="birthday" name="birthday" value="{$row.birthday}"/>
+                                                        <input type="text" class="form-control date" id="birthday" name="birthday" value="{$row.birthday}"/>
                                                     </div>
                                                 </td>
                                             </tr>

+ 1 - 1
app/enterprise/view/talent/view.html

@@ -95,7 +95,7 @@
                                                     </div>
                                                 </td>
                                                 <td rowspan="5" style="width: 200%">
-                                                    <img id="photoImg" src="{$row.headimgurl|getStoragePath}"  style="height:147px;width:105px;margin:0 auto;display:block;">
+                                                    <img id="photoImg" onclick="Feng.showImg(this)" src="{$row.headimgurl|getStoragePath}"  style="height:147px;width:105px;margin:0 auto;display:block;">
                                                     <hr />
                                                     附件:
                                                     <table class="fileTable"></table>

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

@@ -92,7 +92,7 @@ TalentInfo.initColumn = function () {
                             return "<span class='label'>待详细填报</span>";
                             break;
                         case 8:
-                            return "<span class='label'>保存未提交(II)</span>";
+                            return "<span class='label'>保存未提交</span>";
                             break;
                         case 9:
                             if (row.last_state == 11) {
@@ -324,7 +324,7 @@ TalentInfo.delete = function () {
             return;
         }
         var operation = function () {
-            var ajax = new $ax("/enterprise/talent/delete", function (data) {
+            var ajax = new $ax("/enterprise/talent/mixDelete", function (data) {
                 Feng.success("删除成功!");
                 TalentInfo.table.refresh();
             }, function (data) {

+ 1 - 0
public/static/modular/gate/talentInfo/new_talentInfo_info.js

@@ -421,6 +421,7 @@ TalentInfoInfoDlg.infoCallback = function (data) {
         $("#fileLi").removeAttr("style");
         $("#checkState").val(data.obj.checkState);
     }
+    return;
 }
 
 TalentInfoInfoDlg.getLayerCatdByLayer = function () {