Browse Source

个人子女就学申报端++

sugangqiang 1 year ago
parent
commit
dcc8259953

+ 121 - 0
app/common/api/EducationApi.php

@@ -0,0 +1,121 @@
+<?php
+
+namespace app\common\api;
+
+use app\common\model\EducationSchool as EduModel;
+use app\common\state\MainState;
+use think\facade\Db;
+
+/**
+ * Description of EducationApi
+ *
+ * @author sgq
+ */
+class EducationApi {
+
+    public static function getList($params) {
+        $user = session("user");
+        $order = trim($params["order"]) ?: "desc";
+        $offset = trim($params["offset"]) ?: 0;
+        $limit = trim($params["limit"]) ?: 10;
+        $where = [];
+        if ($user["usertype"] == 3) {
+            $where[] = ["personId", "=", $user["uid"]];
+        } else if ($user["usertype"] == 1) {
+            $where[] = ["type", "=", $user["type"]];
+        } else {
+            return [];
+        }
+        if ($_where = self::getWhereByParams($params)) {
+            $where = array_merge($where, $_where);
+        }
+        $count = EduModel::where($where)->count();
+        $list = EduModel::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
+        $levelMap = DictApi::selectByParentCode("talent_arrange");
+        $streetMap = DictApi::selectByParentCode("street");
+        $relationMap = DictApi::selectByParentCode("education_relation");
+        $gradeMap = DictApi::selectByParentCode("education_grade");
+        $educationProjectMap = DictApi::selectByParentCode("education_project");
+        $schoolMap = DictApi::selectByParentCode("education_school_pool");
+        foreach ($list as $key => $item) {
+            $list[$key]["talentArrangeName"] = $levelMap[$item["talentArrange"]];
+            $list[$key]["houseStreetName"] = $streetMap[$item["houseStreet"]];
+            $list[$key]["companyStreetName"] = $streetMap[$item["companyStreet"]];
+            $list[$key]["cRelationName"] = $relationMap[$item["cRelation"]];
+            $list[$key]["nowGradeName"] = $gradeMap[$item["nowGrade"]];
+            $list[$key]["projectName"] = $educationProjectMap[$item["project"]];
+            $list[$key]["applySchoolName"] = $schoolMap[$item["applySchool"]];
+        }
+        return ["total" => $count, "rows" => $list];
+    }
+
+    public static function getWhereByParams($params) {
+        foreach ($params as &$param) {
+            $param = trim($param);
+        }unset($param);
+        $where = [];
+        if ($params["year"]) {
+            $where[] = ["year", "=", $params["year"]];
+        }
+        if ($params["enterpriseName"]) {
+            $where[] = ["enterpriseName", "like", "%" . $params["enterpriseName"] . "%"];
+        }
+        if ($params["pName"]) {
+            $where[] = ["pName", "like", "%" . $params["pName"] . "%"];
+        }
+        if ($params["pSex"]) {
+            $where[] = ["pSex", "=", $params["pSex"]];
+        }
+        if ($params["pIdcard"]) {
+            $where[] = ["pIdcard", "like", "%" . $params["pIdcard"] . "%"];
+        }
+        if ($params["talentArrange"]) {
+            $where[] = ["talentArrange", "=", $params["talentArrange"]];
+        }
+        if ($params["certificateNo"]) {
+            $where[] = ["certificateNo", "like", "%" . $params["certificateNo"] . "%"];
+        }
+        if ($params["address"]) {
+            $where[] = ["address", "like", "%" . $params["address"] . "%"];
+        }
+        if ($params["phone"]) {
+            $where[] = ["phone", "like", "%" . $params["phone"] . "%"];
+        }
+        if ($params["cName"]) {
+            $where[] = ["cName", "like", "%" . $params["cName"] . "%"];
+        }
+        if ($params["cSex"]) {
+            $where[] = ["cSex", "=", $params["cSex"]];
+        }
+        if ($params["cIdcard"]) {
+            $where[] = ["cIdcard", "like", "%" . $params["cIdcard"] . "%"];
+        }
+        if ($params["cRelation"]) {
+            $where[] = ["cRelation", "=", $params["cRelation"]];
+        }
+        if ($params["nowSchool"]) {
+            $where[] = ["nowSchool", "like", "%" . $params["nowSchool"] . "%"];
+        }
+        if ($params["nowGrade"]) {
+            $where[] = ["nowGrade", "=", $params["nowGrade"]];
+        }
+        if ($params["applySchool"]) {
+            $where[] = ["applySchool", "=", $params["applySchool"]];
+        }
+        if ($params["companyStreet"]) {
+            $where[] = ["companyStreet", "=", $params["companyStreet"]];
+        }
+        if ($params["houseStreet"]) {
+            $where[] = ["houseStreet", "=", $params["houseStreet"]];
+        }
+        if ($params["checkState"]) {
+            $where[] = ["checkState", "=", $params["checkState"]];
+        }
+        return $where;
+    }
+
+    public static function getInfoById($id) {
+        return EduModel::findOrEmpty($id)->toArray();
+    }
+
+}

+ 5 - 1
app/common/api/UserApi.php

@@ -208,7 +208,11 @@ class UserApi {
                     "sex" => $user["sex"],
                     "rolename" => "个人用户",
                     "usertype" => $this->usertype,
-                    "type" => $user["type"]
+                    "type" => $user["type"],
+                    "idCard" => $user["idCard"],
+                    "phone" => $user["phone"],
+                    "address" => $user["address"],
+                    "email" => $user["email"]
                 ]);
                 break;
         }

+ 11 - 0
app/common/model/EducationSchool.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+class EducationSchool extends Model {
+
+    protected $table = "un_education_school";
+
+}

+ 141 - 0
app/common/state/MainState.php

@@ -0,0 +1,141 @@
+<?php
+
+namespace app\common\state;
+
+class MainState {
+
+//保存
+    public const SAVE = 1;
+//待审核
+    public const NEED_CHECK = 3;
+//部门初审驳回
+    public const BEFORE_REJECT = 5;
+//审核不通过
+    public const NOTPASS = -1;
+//待初审
+    public const NEED_FIRST_CHECK = 7;
+//初审驳回
+    public const FIRST_REJECT = 10;
+//待部门审核
+    public const NEED_DEP_CHECK = 15;
+//部门审核驳回
+    public const DEP_REJECT = 20;
+//待复核
+    public const NEED_THIRD = 25;
+//复核驳回
+    public const THIRD_REJECT = 30;
+//审核通过-待公示
+    public const PASS = 35;
+
+    public static function getStateDesc($checkState) {
+        switch ($checkState) {
+            case -1:
+                return "<span class='label label-danger'>审核不通过</span>";
+            case 1:
+                return "<span class='label'>待提交</span>";
+            case 3:
+                return "<span class='label label-success'>待审核</span>";
+            case 5:
+                return "<span class='label label-danger'>部门初审驳回</span>";
+            case 7:
+                return"<span class='label label-success'>待初审</span>";
+            case 10:
+                return "<span class='label label-danger'>初审驳回</span>";
+            case 15:
+                return "<span class='label label-success'>待部门审核</span>";
+            case 20:
+                return "<span class='label label-danger'>部门驳回</span>";
+            case 25:
+                return "<span class='label label-success'>待复核</span>";
+            case 30:
+                return "<span class='label label-danger'>复核驳回</span>";
+            case 35:
+                return "<span class='label label-primary'>复核通过</span>";
+            case 40:
+                return "<span class='label label-info'>公示</span>";
+            case 45:
+                return "<span class='label label-danger'>审核不通过</span>";
+            case 50:
+                return "<span class='label label-warning'>待发证</span>";
+            case 55:
+                return "<span class='label label-primary'>已发证</span>";
+        }
+    }
+
+    public static function getStateName($state) {
+        switch ($state) {
+            case -2:
+                return "<span class='label label-success'>待提交</span>";
+            case -1:
+                return"<span class='label label-success'>审核不通过</span>";
+            case 1:
+                return "<span class='label label-success'>待审核</span>";
+            case 2:
+                return "<span class='label label-danger'>审核驳回</span>";
+            case 3:
+                return"<span class='label label-primary'>审核通过</span>";
+            case 4:
+                return "<span class='label label-warm'>上级驳回</span>";
+            case 10:
+                return "<span class='label label-default'>冻结</span>";
+            case 8:
+                return "<span class='label label-primary'>提交审核</span>";
+            case 11:
+                return "<span class='label label-primary'>撤销审核</span>";
+            case 9:
+                return "<span class='label label-primary'>重新提交</span>";
+        }
+    }
+
+    public static function getStepName($step) {
+        switch ($step) {
+            case -1:
+                return "<span class='label label-primary'>部门初审</span>";
+            case 0:
+                return "<span class='label'>用户操作</span>";
+            case 1:
+                return"<span class='label label-primary'>初级审核</span>";
+            case 2:
+                return"<span class='label label-success'>部门审核</span>";
+            case 3:
+                return"<span class='label label-danger'>复核</span>";
+            case 4:
+                return"<span class='label label-warning'>核查征信</span>";
+            case 5:
+                return"<span class='label label-warning'>公示</span>";
+            case 6:
+                return"<span class='label label-success'>公示再审核</span>";
+            case 7:
+                return"<span class='label label-warning'>公布</span>";
+            case 8:
+                return"<span class='label label-info'>发证</span>";
+            case 11:
+                return"<span class='label label-danger'>审核</span>";
+            case 12:
+                return"<span class='label label-primary'>撤回审核</span>";
+            case 20:
+                return"<span class='label label-success'>人才层次变更</span>";
+            case 21:
+                return"<span class='label label-success'>工作单位变更</span>";
+            case 22:
+                return"<span class='label label-success'>离职变更</span>";
+            case 23:
+                return"<span class='label label-success'>银行账号变更</span>";
+            case 24:
+                return"<span class='label label-success'>基础信息变更</span>";
+            case 50:
+                return"<span class='label label-primary'>兑现</span>";
+            case 55:
+                return"<span class='label label-primary'>撤销公布</span>";
+            case 60:
+                return"<span class='label label-primary'>取消优秀人才</span>";
+            case 65:
+                return"<span class='label label-primary'>恢复优秀人才</span>";
+            case 70:
+                return"<span class='label label-danger'>设置审核不通过</span>";
+            case 80:
+                return"<span class='label label-danger'>审批</span>";
+        }
+    }
+
+}

+ 1 - 0
app/common/state/ProjectState.php

@@ -5,6 +5,7 @@ namespace app\common\state;
 class ProjectState {
 
     public const TALENT = 1; //人才认定
+    public const EDUCATION = 6; //子女就学
     public const LIVINGALLOWANCE = 19; //生活补贴
     public const INTEGRAL = 20; //积分申报
 

+ 298 - 12
app/person/controller/Education.php

@@ -3,6 +3,15 @@
 namespace app\person\controller;
 
 use app\person\common\PersonController;
+use app\common\state\ProjectState;
+use app\common\state\MainState;
+use app\common\api\EducationApi;
+use app\common\api\BatchApi;
+use app\common\model\EducationSchool as EduModel;
+use think\facade\Db;
+use app\person\validate\EducationSchoolValidator;
+use app\common\model\TalentLog;
+use think\facade\Log;
 
 /**
  * Description of Education
@@ -12,32 +21,309 @@ use app\person\common\PersonController;
 class Education extends PersonController {
 
     public function index() {
-        return view();
+        return view("", ['type' => session("user")['type']]);
     }
 
     public function list() {
-        $res = [];
+        $res = EducationApi::getList($this->request);
         return json($res);
     }
 
-    public function validateIsAdd() {
-        
+    /**
+     * 申请
+     */
+    public function apply(\think\Request $request) {
+        $type = $this->user["type"];
+        $param = $request->param();
+        $id = isset($param["id"]) ? $param["id"] : 0;
+        $info = EducationApi::getInfoById($id);
+        if (!$info) {
+            $where = [];
+            $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
+            $where[] = ["card_number", "=", $this->user["idCard"]];
+            $where[] = ["isEffect", "=", 1];
+            $talentInfo = \app\enterprise\model\Talent::where($where)->find();
+            $talentCondition = \app\common\api\TalentConditionApi::getOne($talentInfo["talent_condition"]);
+            $info["personId"] = $this->user["uid"];
+            $info["type"] = $this->user["type"];
+            $info["talentId"] = $talentInfo["id"];
+            $info["pName"] = $talentInfo["name"];
+            $info["pSex"] = $talentInfo["sex"];
+            $info["pIdcard"] = $talentInfo["card_number"];
+            $info["talentArrange"] = $talentInfo["talent_arrange"];
+            $info["identifyCondition"] = $talentCondition["name"];
+            $info["certificateStartTime"] = $talentInfo["certificateGetTime"];
+            $info["qzgccrcActiveTime"] = $talentInfo["certificateExpireTime"];
+            $info["certificateNo"] = $talentInfo["certificateNo"];
+            $area = [];
+            if ($talentInfo["province"]) {
+                $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["province"])->findOrEmpty()["name"];
+            }
+            if ($talentInfo["city"]) {
+                $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["city"])->findOrEmpty()["name"];
+            }
+            if ($talentInfo["county"]) {
+                $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["county"])->findOrEmpty()["name"];
+            }
+            $info["nativePlace"] = implode("", $area);
+            $info["certificateNo"] = $talentInfo["certificateNo"];
+            $info["phone"] = $talentInfo["phone"];
+        }
+        if ($request->isPost()) {
+            return $this->save($info, $request);
+        }
+        $batch = $info["year"] ?: BatchApi::getValidBatch(ProjectState::EDUCATION, $type)["batch"];
+        return view("", ["year" => $batch, "row" => $info]);
     }
 
-    public function apply() {
-        return view();
+    public function detail(\think\Request $request) {
+        $param = $request->param();
+        $id = $param["id"];
+        $info = EducationApi::getInfoById($id);
+        return view("apply", ["row" => $info]);
     }
 
-    public function view() {
-        return view();
-    }
+    public function save($info, \think\Request $request) {
+        $response = new \stdClass();
+        $response->code = 500;
+        try {
+            $batch = BatchApi::checkBatchValid(["type" => ProjectState::EDUCATION, "year" => $info["year"], "first_submit_time" => $info["firstSubmitTime"]], $this->user["type"]);
+
+            if ($batch["code"] != 200) {
+                throw new ValidateException($batch["msg"]);
+            }
+            $data = $request->param();
+            unset($data["jstime"]); //不知道为啥把get的数据也获取了,先这样处理
+            $data["year"] = $batch["batch"];
+            validate(EducationSchoolValidator::class)->check($data);
+
+            $id = $data["id"];
+            if ($id) {
+                if (!$info || $info["id"] != $id || $info["personId"] != $this->user["uid"]) {
+                    throw new ValidateException("没有对应的子女择校申报信息");
+                }
+                $data["updateTime"] = date("Y-m-d H:i:s");
+                $data["updateUser"] = $this->user["uid"];
+                EduModel::update($data);
+
+                $log["stateChange"] = "修改子女就学申报";
+                $response->msg = "修改成功";
+            } else {
+                $talentInfo = \app\enterprise\api\TalentApi::getOne($info["talentId"]);
+                if (!$talentInfo || $talentInfo["checkState"] != \app\common\api\TalentState::CERTIFICATED) {
+                    throw new ValidateException("未查询到有效的人才数据(根据证件号码匹配),无法申报");
+                }
+                if (!strtotime($talentInfo["certificateExpireTime"]) || strtotime($talentInfo["certificateExpireTime"]) < time()) {
+                    throw new ValidateException("您的人才证书已过期,请进行人才层次变更后再申报");
+                }
+                if ($this->user["type"] == 1 && $talentInfo["talent_arrange"] > 5) {
+                    throw new ValidateException("子女择校政策只针对第一至五层次人才!");
+                }
 
-    public function save() {
-        
+                $area = [];
+                if ($talentInfo["province"]) {
+                    $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["province"])->findOrEmpty()["name"];
+                }
+                if ($talentInfo["city"]) {
+                    $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["city"])->findOrEmpty()["name"];
+                }
+                if ($talentInfo["county"]) {
+                    $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["county"])->findOrEmpty()["name"];
+                }
+
+                $data["id"] = getStringId();
+                $data["personId"] = $this->user["uid"];
+                $data["pName"] = $talentInfo["name"];
+                $data["pSex"] = $talentInfo["sex"];
+                $data["pIdcard"] = $talentInfo["card_number"];
+                $data["talentArrange"] = $talentInfo["talent_arrange"];
+                $talentCondition = \app\common\api\TalentConditionApi::getOne($talentInfo["talent_condition"]);
+                $data["identifyCondition"] = $talentCondition["name"];
+                $data["certificateNo"] = $talentInfo["certificateNo"];
+                $data["certificateStartTime"] = $talentInfo["certificateGetTime"];
+                $data["qzgccrcActiveTime"] = $talentInfo["certificateExpireTime"];
+                $data["nativePlace"] = implode("", $area);
+                $data["checkState"] = -2;
+                $data["createTime"] = date("Y-m-d H:i:s");
+                $data["createUser"] = $this->user["uid"];
+                EduModel::insert($data);
+
+                $log["stateChange"] = "添加子女就学申报";
+                $response->msg = "添加成功";
+            }
+            $log["id"] = getStringId();
+            $log["active"] = 1;
+            $log["state"] = -2;
+            $log["step"] = 0;
+            $log["type"] = ProjectState::EDUCATION;
+            $log["mainId"] = $data["id"];
+            $log["createUser"] = "申报用户";
+            $log["createTime"] = date("Y-m-d H:i:s");
+            TalentLog::create($log);
+
+            $response->code = 200;
+            $response->obj = $data;
+            return json($response);
+        } catch (ValidateException $e) {
+            $response->msg = $e->getMessage();
+            return json($response);
+        } catch (\think\Exception $e) {
+            $response->msg = "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode();
+            $logInfo = [
+                "personId" => $this->user["uid"],
+                "data" => $data,
+                "controller" => $this->request->controller(),
+                "action" => $this->request->action(),
+                "errCode" => $e->getCode(),
+                "errMsg" => $e->getMessage()
+            ];
+            Log::write($logInfo, "error");
+            return json($response);
+        }
     }
 
+    /**
+     * 提交表单
+     */
     public function submitToCheck() {
-        
+        $response = new \stdClass();
+        $response->code = 500;
+        try {
+            $id = $this->request["id"];
+            $info = EducationApi::getInfoById($id);
+            if (!$info) {
+                throw new ValidateException("提交审核失败,请先填写基础信息");
+            }
+            if ($info["personId"] != $this->user["uid"]) {
+                throw new ValidateException("没有对应的子女择校申报信息");
+            }
+            $batch = BatchApi::checkBatchValid(["type" => ProjectState::EDUCATION, "year" => $info["year"], "first_submit_time" => $info["firstSubmitTime"]], $this->user["type"]);
+            if ($batch["code"] != 200) {
+                throw new ValidateException($batch["msg"]);
+            }
+            validate(EducationSchoolValidator::class)->check($info);
+
+            $where = [];
+            $where[] = ["mainId", "=", $id];
+            $where[] = ["type", "=", ProjectState::EDUCATION];
+            $uploadedFileTypes = Db::table("new_talent_file")->where($where)->column("distinct typeId");
+
+            $where = [];
+            $where[] = ["project", "=", ProjectState::EDUCATION];
+            $where[] = ["type", "=", $this->user["type"]];
+            $where[] = ["must", "=", 1];
+            $where[] = ["active", "=", 1];
+            $where[] = ["delete", "=", 0];
+            $where[] = ["id", "not in", $uploadedFileTypes];
+            $unUploadfiletypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
+            if ($unUploadfiletypes) {
+                $msg = "以下附件为必传:<br>";
+                foreach ($unUploadfiletypes as $ft) {
+                    $msg .= "<span style='color:red;'>*</span>" . $ft["name"] . "<br>";
+                }
+                throw new ValidateException($msg);
+            }
+            $data["id"] = $id;
+            $data["checkState"] = $info["checkState"] == 2 ? 9 : 1;
+            if (!$info["firstSubmitTime"]) {
+                $data["firstSubmitTime"] = date("Y-m-d H:i:s");
+            }
+            $data["newSubmitTime"] = date("Y-m-d H:i:s");
+            EduModel::update($data);
+
+            $log["id"] = getStringId();
+            $log["active"] = 1;
+            $log["state"] = $data["checkState"];
+            $log["step"] = 0;
+            $log["stateChange"] = MainState::getStateDesc($data["checkState"]) . "->" . MainState::getStateDesc(MainState::NEED_CHECK);
+            $log["type"] = ProjectState::EDUCATION;
+            $log["mainId"] = $id;
+            $log["description"] = "确认提交审核";
+            $log["createUser"] = "申报用户";
+            $log["createTime"] = date("Y-m-d H:i:s");
+            TalentLog::create($log);
+
+            $response->msg = "提交审核成功";
+            $response->code = 200;
+            $response->obj = 1;
+            return json($response);
+        } catch (ValidateException $e) {
+            $response->msg = $e->getMessage();
+            return json($response);
+        } catch (\think\Exception $e) {
+            $response->msg = "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode();
+            $logInfo = [
+                "personId" => $this->user["uid"],
+                "data" => $data,
+                "controller" => $this->request->controller(),
+                "action" => $this->request->action(),
+                "errCode" => $e->getCode(),
+                "errMsg" => $e->getMessage()
+            ];
+            Log::write($logInfo, "error");
+            return json($response);
+        }
+    }
+
+    public function delete() {
+        $id = $this->request->param("id");
+        $info = EducationApi::getInfoById($id);
+        if (!$info || $info["personId"] != $this->user["uid"]) {
+            return json(["msg" => "操作失败"]);
+        }
+        $checkState = $info["checkState"];
+        if ($checkState != MainState::SAVE) {
+            return json(["msg" => "该申报已提交审核,无法删除"]);
+        }
+        EduModel::delete($id);
+
+        $where = [["mainId", "=", $id], ["type", "=", ProjectState::EDUCATION]];
+        $list = Db::table("new_talent_file")->where($where)->select()->toArray();
+        foreach ($list as $key => $file) {
+            if (!empty($file["url"])) {
+                $filepath = "storage/" . $file["url"];
+                if (file_exists($filepath)) {
+                    @unlink($filepath);
+                }
+            }
+
+            Db::table("new_talent_file")->delete($file["id"]);
+        }
+        return json(["msg" => "删除成功"]);
+    }
+
+    public function validateIsAdd() {
+        $response = new \stdClass();
+        $response->code = 500;
+        $projectType = ProjectState::EDUCATION;
+        $source = $this->user["type"];
+        $batchResult = BatchApi::checkBatchValid(["type" => $projectType], $source);
+        if ($batchResult["code"] != 200) {
+            $response->msg = $batchResult["msg"];
+            return json($response);
+        }
+        $batch = $batchResult["batch"];
+        $where = [];
+        $where[] = ["card_number", "=", $this->user["idCard"]];
+        $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
+        $where[] = ["isEffect", "=", 1];
+        $list = \app\enterprise\model\Talent::where($where)->select()->toArray();
+        if (!$list || count($list) == 0) {
+            $response->msg = "未查询到有效的人才数据(根据证件号码匹配),无法申报";
+            return json($response);
+        }
+        if (count($list) > 1) {
+            $response->msg = "根据证件号码查询到多条在库数据,无法申报,可联系相关单位取消重复人才资格";
+            return json($response);
+        }
+        $info = $list[0];
+        if ($this->user["type"] == 1 && (!strtotime($info["certificateExpireTime"]) || strtotime($info["certificateExpireTime"]) < time())) {
+            $response->msg = "您的人才证书已过期,请进行人才层次变更后再申报";
+            return json($response);
+        }
+        $response->code = 200;
+        $response->batch = $batch;
+        return json($response);
     }
 
 }

+ 81 - 0
app/person/validate/EducationSchoolValidator.php

@@ -0,0 +1,81 @@
+<?php
+
+namespace app\person\validate;
+
+use think\Validate;
+use app\common\model\EducationSchool;
+
+/**
+ * Description of EducationSchoolValidator
+ * @author sgq
+ */
+class EducationSchoolValidator extends Validate {
+
+    protected $rule = [
+        "enterpriseName" => "require",
+        "enterpriseAddress" => "require",
+        "address" => "require",
+        "phone" => "require|mobile",
+        "cName" => "require",
+        "cSex" => "require",
+        "cIdcard" => "require|checkIdCard",
+        "cBirthday" => "require",
+        "cRelation" => "require",
+        "nowSchool" => "require",
+        "nowGrade" => "require",
+        "project" => "require|checkApplySchool",
+        "companyStreet" => "require",
+        "houseStreet" => "require",
+        "year" => "require|checkExistThisYear",
+        "personId" => "require",
+        "talentId" => "require"
+    ];
+    protected $message = [
+        "enterpriseName.require" => "工作单位不能为空",
+        "enterpriseAddress.require" => "工作单位详细地址不能为空",
+        "address.require" => "现居地址不能为空",
+        "phone.require" => "联系电话不能为空",
+        "phone.mobile" => "联系电话格式不合法",
+        "cName.require" => "子女姓名不能为空",
+        "cSex.require" => "子女性别不能为空",
+        "cIdcard.require" => "子女证件号码不能为空",
+        "cBirthday.require" => "子女出生日期不能为空",
+        "cRelation.require" => "与申报人关系不能为空",
+        "nowSchool.require" => "现就读学校不能为空",
+        "nowGrade.require" => "现就读年级不能为空",
+        "project.require" => "申报项目不能为空",
+        "companyStreet.require" => "工作单位所属镇街不能为空",
+        "houseStreet.require" => "房产所在镇街不能为空",
+        "year.require" => "批次不能为空",
+        "personId.require" => "申报人信息不能为空",
+        "talentId.require" => "申报人人才申报信息不能为空",
+    ];
+
+    protected function checkExistThisYear($value, $rule, $data = []) {
+        $where[] = ["year", "=", $value];
+        $where[] = ["personId", "=", $data["personId"]];
+        $where[] = ["cIdcard", "=", $data["cIdcard"]];
+        if ($data["id"]) {
+            $where[] = ["id", "<>", $data["id"]];
+        }
+        $count = EducationSchool::where($where)->count();
+        if ($count > 0) {
+            return "该子女当年度已有申报记录,添加失败";
+        }
+        return true;
+    }
+
+    protected function checkApplySchool($value, $rule, $data = []) {
+        if ($value == 1 && \StrUtil::isEmpOrNull($data["applySchool"])) {
+            return "拟申请学校不能为空";
+        }
+        return true;
+    }
+
+    protected function checkIdCard($value, $rule, $data = []) {
+        if (!\app\common\api\IdCardApi::isValid($value) && !preg_match("/^([a-zA-z]|[0-9]){5,17}$/", $value) && !preg_match("/^[a-zA-Z0-9]{6,10}$/", $value) && !preg_match("/^([0-9]{8}|[0-9]{10})$/", $value))
+            return "子女证件号码不合法!";
+        return true;
+    }
+
+}

+ 8 - 8
public/static/modular/gate/education/educationSchool/educationSchool.js

@@ -102,7 +102,7 @@ EducationSchool.check = function () {
  * 点击添加子女就学
  */
 EducationSchool.openAddEducationSchool = function () {
-    var ajax = new $ax(Feng.ctxPath + "/person/education/valiateIsAdd", function (data) {
+    var ajax = new $ax(Feng.ctxPath + "/person/education/validateIsAdd", function (data) {
         if (data.code == 200) {
             var index = layer.open({
                 type: 2,
@@ -194,7 +194,7 @@ EducationSchool.openEducationSchoolSelect = function () {
             area: ['800px', '420px'], //宽高
             fix: false, //不固定
             maxmin: true,
-            content: Feng.ctxPath + '/person/education/view/id/' + EducationSchool.seItem.id,
+            content: Feng.ctxPath + '/person/education/detail/id/' + EducationSchool.seItem.id,
             btn: ['<i class="fa fa-eraser"></i>&nbsp;&nbsp;取消'],
             btnAlign: 'c',
         });
@@ -332,12 +332,12 @@ $(function () {
     EducationSchool.table = table.init();
     //批量加载字典表数据
     var arr = [
-        {"name": "companyStreet", "code": "un_street"},
-        {"name": "houseStreet", "code": "un_street"},
-        {"name": "talentArrange", "code": "un_talentLevel"},
-        {"name": "cRelation", "code": "un_education_relation"},
-        {"name": "nowGrade", "code": "un_grade"},
-        {"name": "applySchool", "code": "un_school_pool"}];
+        {"name": "companyStreet", "code": "street"},
+        {"name": "houseStreet", "code": "street"},
+        {"name": "talentArrange", "code": "talent_arrange"},
+        {"name": "cRelation", "code": "education_relation"},
+        {"name": "nowGrade", "code": "education_grade"},
+        {"name": "applySchool", "code": "education_school_pool"}];
     Feng.findChildDictBatch(JSON.stringify(arr));
     $("#applySchool").on('chosen:ready', function (e, params) {
         $(".chosen-container-single .chosen-single").css("padding", "4px 0px 0px 4px");

+ 7 - 7
public/static/modular/gate/education/educationSchool/educationSchool_info.js

@@ -266,13 +266,13 @@ $(function() {
     Feng.initValidatorTip("educationSchoolForm",EducationSchoolInfoDlg.validateFields);
     //批量加载字典表数据
     var arr = [
-        {"name":"companyStreet","code":"un_street"},
-        {"name":"houseStreet","code":"un_street"},
-        {"name":"talentArrange","code":"un_talentLevel"},
-        {"name":"cRelation","code":"un_education_relation"},
-        {"name":"nowGrade","code":"un_grade"},
-        {"name":"project","code":"un_educationSchool_project"},
-        {"name":"applySchool","code":"un_school_pool"}];
+        {"name":"companyStreet","code":"street"},
+        {"name":"houseStreet","code":"street"},
+        {"name":"talentArrange","code":"talent_arrange"},
+        {"name":"cRelation","code":"education_relation"},
+        {"name":"nowGrade","code":"education_grade"},
+        {"name":"project","code":"education_project"},
+        {"name":"applySchool","code":"education_school_pool"}];
     Feng.findChildDictBatch(JSON.stringify(arr));
     //批量加载时间控件
     $(".date").each(function(){laydate.render({elem: ".date",type: "date",trigger: 'click'});});