sugangqiang 2 жил өмнө
parent
commit
70226583c5

+ 40 - 0
app/common/api/IntegralRecordApi.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\common\api;
+
+use app\common\api\DictApi;
+use app\admin\model\Enterprise;
+use think\facade\Db;
+use app\common\model\IntegralRecord;
+use app\common\api\IntegralState;
+
+/**
+ * Description of IntegralRecordApi
+ *
+ * @author sgq
+ */
+class IntegralRecordApi {
+
+    public static function getOne($id) {
+        return IntegralRecord::where("id", "=", $id)->find();
+    }
+
+    public static function getList() {
+        
+    }
+
+    public static function checkIsEditable($id) {
+        $info = self::getOne($id);
+        if (!$info || !in_array($info["checkState"], [0, IntegralState::SAVE]))
+            return false;
+        return true;
+    }
+
+    static public function chkIsOwner($id, $uid) {
+        $info = self::getOne($id);
+        if ($info["enterprise_id"] != $uid)
+            return null;
+        return $info;
+    }
+
+}

+ 29 - 1
app/common/api/TalentState.php

@@ -60,7 +60,7 @@ class TalentState {
                 return "基础复核通过";
             case 6:
                 return "基础复核驳回";
-            case7:
+            case 7:
                 return "基础复核失败";
             case 8:
                 return "保存未提交";
@@ -139,3 +139,31 @@ class TalentState {
     }
 
 }
+
+class IntegralState {
+
+    public const SAVE = 1; //保存未提交
+    public const SUBMIT = 2; //已提交未审核
+    public const VERIFY_PASS = 3; //初审通过
+    public const VERIFY_REJECT = 4; //初审驳回
+    public const VERIFY_FAIL = 5; //初审失败
+    public const REVERIFY_PASS = 6; //复审通过
+    public const REVERIFY_REJECT = 7; //复审驳回
+    public const REVERIFY_FAIL = 8; //复审失败
+    public const ZX_PASS = 21; //征信通过|待公示
+    public const ZX_FAIL = 22; //征信失信|审核不通过
+    public const ANNOUNCED = 23; //已公示
+    public const ANNOUNCED_REVERIFY_PASS = 24; //公示再审核通过|待公布
+    public const ANNOUNCED_REVERIFY_FAIL = 25; //公示再审核不通过
+    public const PUBLISH_PASS = 26; //公布通过
+    public const PUBLISH_FAIL = 27; //公布不通过
+    public const SUCCESS = 28; //积分兑现成功
+
+}
+
+class Project {
+
+    public const TALENT = 1; //人才认定
+    public const INTEGRAL = 20; //积分申报
+
+}

+ 16 - 0
app/common/model/IntegralDetail.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * Description of IntegralDetail
+ *
+ * @author sgq
+ */
+class IntegralDetail extends Model {
+
+    protected $table = "new_integral_detail";
+
+}

+ 20 - 0
app/common/model/IntegralRecord.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * Description of IntegralRecord
+ *
+ * @author sgq
+ */
+class IntegralRecord extends Model {
+
+    protected $table = "new_integral_record";
+
+    public function detail() {
+        return $this->hasOne(IntegralDetail::class);
+    }
+
+}

+ 100 - 181
app/enterprise/controller/Integral.php

@@ -6,6 +6,10 @@ use app\enterprise\common\EnterpriseController;
 use think\facade\Db;
 use app\common\api\EnterpriseApi;
 use app\enterprise\validate\TalentInfo;
+use app\common\api\IntegralState;
+use app\common\api\IntegralRecordApi;
+use app\common\api\TalentLogApi;
+use app\common\api\Project;
 
 /**
  * Description of 积分申报
@@ -19,7 +23,7 @@ class Integral extends EnterpriseController {
     }
 
     public function list() {
-        $res = IntegralLogApi::getList($this->request, $step);
+        $res = IntegralRecordApi::getList($this->request, $step);
         return json($res);
     }
 
@@ -30,28 +34,26 @@ class Integral extends EnterpriseController {
         $type = $this->user["type"];
         $param = $request->param();
         $id = isset($param["id"]) ? $param["id"] : 0;
-        $info = \app\common\api\VerifyApi::getTalentInfoById($id);
+        $info = IntegralRecordApi::getOne($id);
         $ep = EnterpriseApi::getOne($this->user["uid"]);
-        if (!chkEnterpriseFull($ep))
-            return;
         if ($info) {
-            $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
+            $info["real_state"] = TalentLogApi::getLastLog($id, Project::INTEGRAL)["state"];
         }
-        if ($info && in_array($info["checkState"], [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL])) {
+        if ($info && in_array($info["checkState"], [IntegralState::VERIFY_PASS, IntegralState::REVERIFY_PASS, IntegralState::REVERIFY_FAIL])) {
             return $this->view($request);
             exit();
         }
         if ($request->isPost()) {
             $checkState = $info["checkState"] ?: 0;
-            if ($checkState == TalentState::SCND_SAVE || $checkState == 0) {
-                $this->save($info, $request, TalentState::SCND_SAVE);
-            } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
+            if ($checkState == IntegralState::SAVE || $checkState == 0) {
+                $this->save($info, $request, IntegralState::SAVE);
+            } else if (in_array($checkState, [IntegralState::VERIFY_FAIL, IntegralState::REVERIFY_FAIL])) {
                 $res = ["msg" => "审核失败,不能再保存"];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
+                echo sprintf("<script>parent.IntegralInfoDlg.infoCallback(%s);</script>", json_encode($res));
                 exit;
             }
             $res = ["msg" => "已提交审核,请耐心等待"];
-            echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
+            echo sprintf("<script>parent.IntegralInfoDlg.infoCallback(%s);</script>", json_encode($res));
             exit;
         }
         $checkState = $info["checkState"] ?: 0;
@@ -146,7 +148,7 @@ class Integral extends EnterpriseController {
             }
             if (count($return) > 0) {
                 $res = ["msg" => implode("<br>", $return)];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
+                echo sprintf("<script>parent.IntegralInfoDlg.submitCallback(%s);</script>", json_encode($res));
                 exit;
             }
 
@@ -212,18 +214,18 @@ class Integral extends EnterpriseController {
             $upload_type_counts = count($distinct_filetypes);
             if ($upload_type_counts != count($ft_ids)) {
                 $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
-                echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
+                echo sprintf("<script>parent.IntegralInfoDlg.submitCallback(%s);</script>", json_encode($res));
                 exit;
             }
 
             return $this->mixSave($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, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
             $res = ["msg" => "审核失败,不能再提交审核"];
-            echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
+            echo sprintf("<script>parent.IntegralInfoDlg.submitCallback(%s);</script>", json_encode($res));
             exit;
         }
         $res = ["msg" => "已提交审核,请耐心等待"];
-        echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
+        echo sprintf("<script>parent.IntegralInfoDlg.submitCallback(%s);</script>", json_encode($res));
         exit;
     }
 
@@ -234,165 +236,81 @@ class Integral extends EnterpriseController {
      */
     private function save($info, \think\Request $request, $checkState) {
         try {
-            $batch = \app\common\api\BatchApi::getValidBatch(20, $this->user["type"]);
+            $batch = \app\common\api\BatchApi::getValidBatch(Project::INTEGRAL, $this->user["type"]);
             if (!$batch) {
                 throw new ValidateException("不在人才认定申报申请时间内");
             }
             $param = $request->param();
-            validate(TalentInfo::class)->check($param);
+            validate(IntegralValidator::class)->check($param);
             $id = $param["id"];
+            $files = $param["uploadFiles"];
             if ($id) {
                 if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
-                    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>");
+                    throw new ValidateException("没有对应的积分申报信息");
                 }
-                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::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"];
-
-            $all_valid_keys = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education",
-                "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"];
+            $all_valid_keys = ["name", "card_type", "card_number", "phone", "email"];
             foreach ($all_valid_keys as $key) {
                 $data[$key] = trim($param[$key]);
             }
-            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["salary_pay_way"] = $param["salary_pay_way"];
-                $data["salary_pay_month"] = $param["salary_pay_month"];
-                $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["salary_pay_way"] = null;
-                $data["salary_pay_month"] = null;
-                $data["fst_work_time"] = null;
-                $data['pre_import_type'] = $param["pre_import_type"];
-            }
 
-            if ($data["study_abroad"] == 1) {
-                $data["abroad_school"] = $param["abroad_school"];
-                $data["abroad_major"] = $param["abroad_major"];
-            } else {
-                $data["abroad_school"] = null;
-                $data["abroad_major"] = null;
-            }
-            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;
-            }
-
-            $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
-            if ($condition_info["isSalary"] == 1) {
-                $data["annual_salary"] = $param["annual_salary"];
-            } else {
-                $data["annual_salary"] = null;
-            }
-            if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
-                //真实状态11是驳回,需要判断什么字段可以提交                
+            $updateDetailList = [];
+            $insertDetailList = [];
+            $data["batch_id"] = $batch["id"];
+            $detail_ids = $param["detail_id"];
+            $projectTypes = $param["projectType"];
+            $projectIds = $param["projectId"];
+            $item_ids = $param["item_id"];
+            $amounts = $param["amount"];
+            if ($info["real_state"] == IntegralState::VERIFY_REJECT) {
+                //真实状态是驳回,需要判断什么字段可以提交                
                 $modify_fields = array_filter(explode(",", $info["modify_fields"]));
                 $tmp_data = $data;
                 $data = [];
                 foreach ($modify_fields as $field) {
                     $data[$field] = $tmp_data[$field];
                 }
+                $tmp_item_ids = [];
+                if ($info["modify_files"]) {
+                    $detailCounts = count($detail_ids);
+                    for ($i = 0; $i < $detailCounts; $i++) {
+                        if (!in_array($item_ids[$i], $tmp_item_ids)) {
+                            $tmp_item_ids[] = $item_ids[$i];
+                        }
+                        if ($detail_ids[$i]) {
+                            $updateDetailList[] = [
+                                "id" => $detail_ids[$i],
+                                "record_id" => "",
+                                "item_id" => "",
+                                "amount" => "",
+                                "unit" => "",
+                                "file_id"
+                            ];
+                        } else {
+                            $insertDetailList[] = [
+                                "id" => getStringId(),
+                                "record_id" => "",
+                                "item_id" => "",
+                                "amount" => "",
+                                "unit" => "",
+                                "file_id"
+                            ];
+                        }
+                    }
+                }
             }
             $data["checkState"] = $checkState;
             $data["id"] = $id;
             $success_msg = "提交成功";
             $error_msg = "提交失败";
-            if ($checkState == TalentState::SCND_SAVE) {
+            if ($checkState == IntegralState::SAVE) {
                 $success_msg = "保存成功";
                 if ($data["id"]) {
                     //编辑
                     TalentModel::update($data);
-                    $last_log = TalentLogApi::getLastLog($data["id"], 1);
-                    if ($last_log["new_state"] != TalentState::SCND_SAVE) {
+                    $last_log = TalentLogApi::getLastLog($data["id"], Project::INTEGRAL);
+                    if ($last_log["new_state"] != IntegralState::SAVE) {
                         TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
                     } else {
                         TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
@@ -400,85 +318,86 @@ class Integral extends EnterpriseController {
                 } else {
                     //新增
                     $data["enterprise_id"] = $this->user["uid"];
-                    $id = TalentModel::insertGetId($data);
-                    TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
+                    $data["id"] = getStringId();
+                    \app\common\model\IntegralRecord::insert($data);
+                    TalentLogApi::write(Project::INTEGRAL, $data["id"], $checkState, "保存未提交", 1);
                     $whr = [];
                     $whr[] = ["fileId", "in", $files];
-                    $upd_checklog["mainId"] = $id;
+                    $upd_checklog["mainId"] = $data["id"];
                     Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
                 }
-            } else if ($checkState == TalentState::SCND_SUBMIT) {
+            } else if ($checkState == IntegralState::SUBMIT) {
                 if (!$info["first_submit_time"]) {
                     $data["first_submit_time"] = date("Y-m-d H:i:s");
                 } else {
                     $data["new_submit_time"] = date("Y-m-d H:i:s");
                 }
                 if ($data["id"]) {
-                    TalentModel::update($data);
+                    \app\common\model\IntegralRecord::update($data);
                 } else {
                     //新增
                     $data["enterprise_id"] = $this->user["uid"];
-                    $id = TalentModel::insertGetId($data);
+                    $data["id"] = getStringId();
+                    \app\common\model\IntegralRecord::insert($data);
                     $whr = [];
                     $whr[] = ["fileId", "in", $files];
-                    $upd_checklog["mainId"] = $id;
+                    $upd_checklog["mainId"] = $data["id"];
                     Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
                 }
-                TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
+                TalentLogApi::write(Project::INTEGRAL, $id, $checkState, "确认提交审核", 1);
             } else {
                 throw new ValidateException($error_msg);
             }
 
-            if ($id) {
-                if ($deletes) {
-                    //删除多余的附件,一般是选择人才类型留下来的
+            if ($data["id"]) {
+                //删除多余的附件,一般是选择人才类型留下来的
+                $whr = [];
+                $whr[] = ["mainId", "=", $data["id"]];
+                $whr[] = ["type", "=", Project::INTEGRAL];
+                $whr[] = ["id", "not 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[] = ["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[] = ["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));
+                $callback = $checkState == IntegralState::SAVE ? "infoCallback" : "submitCallback";
+                echo sprintf("<script>parent.IntegralInfoDlg.{$callback}(%s);</script>", json_encode($res));
                 exit();
             } else {
                 throw new ValidateException($error_msg);
             }
         } 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));
+            $callback = $checkState == IntegralState::SAVE ? "infoCallback" : "submitCallback";
+            echo sprintf("<script>parent.IntegralInfoDlg.{$callback}(%s);</script>", json_encode($res));
             exit();
         }
     }
 
     public function delete() {
-        $id = $this->request->param("talentInfoId");
-        $info = Talent::chkIsOwner($id, $this->user["uid"]);
+        $id = $this->request->param("id");
+        $info = IntegralRecordApi::chkIsOwner($id, $this->user["uid"]);
         if (!$info) {
             return json(["msg" => "操作失败"]);
         }
         $checkState = $info["checkState"];
         if (in_array($checkState, [0, 1])) {
-            $log = TalentLogApi::getLastLog($id, 1);
+            $log = TalentLogApi::getLastLog($id, Project::INTEGRAL);
             if ($log["state"] > 1) {
                 //有提交审核记录
                 return json(["msg" => "该申报已提交审核,无法删除"]);
@@ -486,7 +405,7 @@ class Integral extends EnterpriseController {
         }
         $data["id"] = $id;
         $data["delete"] = 1;
-        TalentModel::update($data);
+        \app\common\model\IntegralRecord::update($data);
         return json(["msg" => "删除成功"]);
     }
 

+ 46 - 0
app/enterprise/validate/IntegralValidator.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace app\enterprise\validate;
+
+use think\Validate;
+
+/**
+ * Description of IntegralValidator
+ * @author sgq
+ */
+class IntegralValidator extends Validate {
+
+    protected $rule = [
+        "name" => "regex:/^[\x{4e00}-\x{9fa5}]+$/u",
+        "card_type" => "between:1,3",
+        "card_number" => "checkCardNumber",
+        "phone" => "mobile",
+        "email" => "email"
+    ];
+    protected $message = [
+        "name.regex" => "姓名只能是中文",
+        "card_type.between" => "不存在的证件类型,请在列表中选择",
+        "phone.mobile" => "请填写正确的手机号",
+        "email.email" => "电子邮箱格式错误"
+    ];
+
+    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 "身份证号码不合法";
+    }
+
+}

+ 58 - 0
app/enterprise/view/integral/apply.html

@@ -62,6 +62,9 @@
         text-align:center;
         border-left:1px solid #ddd;
     }
+    .has-feedback label~.form-control-feedback{
+        top: 31px;
+    }
 </style>
 <div class="ibox float-e-margins">
     <div class="ibox-content">
@@ -146,12 +149,66 @@
                                 <div class="panel panel-default">
                                     <div class="panel-heading" onclick="$(this).next().toggle()">申报项目</div>
                                     <div class="panel-body" id="itemList">
+                                        {if condition="$row['detail']"}                                        
+                                        {volist name="row.detail" id="item"}                                 
+                                        <table style="width:100%;border-collapse: collapse;" class="table table-bordered">
+                                            <tr>
+                                                <td style="width:40px;">
+                                                    <div class="rowGroup">
+                                                        <label class=" control-label spacing td-label">选择</label>
+                                                        <input type="checkbox" name="chk[]" class="form-control"/>
+                                                        <input type="hidden" name="detail_id[]" value="{$item.id}"/>
+                                                    </div>
+                                                </td>
+                                                <td>
+                                                    <div class="rowGroup">
+                                                        <label class=" control-label spacing td-label"><span style="color: red">*</span>项目类别</label>
+                                                        <select class="form-control" name="projectType[]" value="{$item.projectType}" onchange="IntegralInfoDlg.onProjectTypeChange(this);">
+                                                            <option value="">请选择</option>
+                                                            <option value="1">基础分</option>
+                                                            <option value="2">贡献分</option>
+                                                            <option value="3">资历分</option>
+                                                        </select>
+                                                    </div>
+                                                </td>
+                                                <td>
+                                                    <div class="rowGroup">
+                                                        <label class=" control-label spacing td-label"><span style="color: red">*</span>积分项目</label>
+                                                        <select class="form-control" name="projectId[]" value="{$item.projectId}" onchange="IntegralInfoDlg.onProjectChange(this);">
+                                                            <option value="">请选择</option>
+                                                        </select>
+                                                    </div>
+                                                </td>
+                                                <td>
+                                                    <div class="rowGroup">
+                                                        <label class=" control-label spacing td-label"><span style="color: red">*</span>积分标准</label>
+                                                        <select class="form-control" name="item_id[]" value="{$item.item_id}" onchange="IntegralInfoDlg.onItemChange(this);">
+                                                            <option value="">请选择</option>
+                                                        </select>
+                                                    </div>
+                                                </td>
+                                                <td>
+                                                    <div class="rowGroup">
+                                                        <label class="control-label spacing td-label"><span style="color: red">*</span>数额<span class="unit"></span></label>
+                                                        <input type="text" class="form-control" name="amount[]" value="{$item.amount}"/>
+                                                    </div>
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <td colspan="5">
+                                                    <table class="fileTable"></table>
+                                                </td>
+                                            </tr>
+                                        </table>
+                                        {/volist}
+                                        {else/}                                        
                                         <table style="width:100%;border-collapse: collapse;" class="table table-bordered">
                                             <tr>
                                                 <td style="width:40px;">
                                                     <div class="rowGroup">
                                                         <label class=" control-label spacing td-label">选择</label>
                                                         <input type="checkbox" name="chk[]" class="form-control"/>
+                                                        <input type="hidden" name="detail_id[]" value=""/>
                                                     </div>
                                                 </td>
                                                 <td>
@@ -194,6 +251,7 @@
                                                 </td>
                                             </tr>
                                         </table>
+                                        {/if}
                                         <div id="toolbar" style="text-align:center;">
                                             <button type="button" class="btn btn-sm btn-info " onclick="IntegralInfoDlg.addItem()" id="">
                                                 <i class="fa fa-plus"></i>&nbsp;增加项目

+ 5 - 5
public/static/modular/gate/integral/integral.js

@@ -224,10 +224,10 @@ Integral.addInfo = function () {
                 btnAlign: 'c',
                 btn1: function (index, layero) {
                     var obj = layero.find("iframe")[0].contentWindow;
-                    obj.TalentInfoInfoDlg.addSubmit();
+                    obj.IntegralInfoDlg.addSubmit();
                 }, btn2: function (index, layero) {
                     var obj = layero.find("iframe")[0].contentWindow;
-                    obj.TalentInfoInfoDlg.submitToCheck();
+                    obj.IntegralInfoDlg.submitToCheck();
                     return false;
                 },
                 success: function (layero, index) {
@@ -267,10 +267,10 @@ Integral.editInfo = function () {
                     btnAlign: 'c',
                     btn1: function (index, layero) {
                         var obj = layero.find("iframe")[0].contentWindow;
-                        obj.TalentInfoInfoDlg.addSubmit();
+                        obj.IntegralInfoDlg.addSubmit();
                     }, btn2: function (index, layero) {
                         var obj = layero.find("iframe")[0].contentWindow;
-                        obj.TalentInfoInfoDlg.submitToCheck();
+                        obj.IntegralInfoDlg.submitToCheck();
                         return false;
                     },
                     success: function (layero, index) {
@@ -330,7 +330,7 @@ Integral.delete = function () {
             }, function (data) {
                 Feng.error("删除失败!" + data.responseJSON.message + "!");
             });
-            ajax.set("talentInfoId", Integral.seItem.id);
+            ajax.set("id", Integral.seItem.id);
             ajax.start();
         }
         Feng.confirm("删除后无法恢复,确认删除吗?", operation);

+ 33 - 35
public/static/modular/gate/integral/integralInfo.js

@@ -3,7 +3,7 @@
  */
 var locked = false;
 var IntegralInfoDlg = {
-    talentInfoInfoData: {},
+    integralInfoData: {},
     validateFields: {
         name: {validators: {notEmpty: {message: '姓名不能为空'}}},
         card_type: {validators: {notEmpty: {message: '证件类型不能为空'}}},
@@ -43,7 +43,7 @@ var IntegralInfoDlg = {
  * 清除数据
  */
 IntegralInfoDlg.clearData = function () {
-    this.talentInfoInfoData = {};
+    this.integralInfoData = {};
 }
 
 /**
@@ -57,7 +57,7 @@ IntegralInfoDlg.set = function (key, val) {
     if (dis == "disabled") {
         $("#" + key).removeAttr("disabled");
     }
-    this.talentInfoInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
+    this.integralInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
     if (dis == "disabled") {
         $("#" + key).prop("disabled", true);
     }
@@ -296,9 +296,9 @@ IntegralInfoDlg.onItemChange = function (obj) {
 IntegralInfoDlg.addSubmit = function () {
     this.clearData();
     this.collectData();
-    /*if (!IntegralInfoDlg.validate()) {
-     return;
-     }*/
+    if (!IntegralInfoDlg.validate()) {
+        return;
+    }
     var id = $('#id').val();
     if (id != null && id != '') {
         if (!IntegralInfoDlg.validateIsEdit())
@@ -308,10 +308,10 @@ IntegralInfoDlg.addSubmit = function () {
         $(this).removeAttr("disabled");
     });
     if (locked) {
-        return;
+        //return;
     }
     locked = true;
-    $("#integralInfoForm").attr("action", "/enterprise/talent/apply");
+    $("#integralInfoForm").attr("action", "/enterprise/integral/apply");
     $("#integralInfoForm")[0].submit();
 }
 
@@ -543,7 +543,7 @@ IntegralInfoDlg.setNoChangeField = function () {
     var checkState = $("#checkState").val();
     var fields = $("#fields").val();
     var realState = $("#realState").val();
-    if (realState == 11) {
+    if (realState == 4) {
         $("input,textarea").each(function () {
             $(this).attr("readonly", "readonly");
         });
@@ -568,35 +568,33 @@ IntegralInfoDlg.setNoChangeField = function () {
     }
 }
 $(function () {
-//Feng.initValidatorTip("integralInfoForm", IntegralInfoDlg.validateFields);
-    var id = $("#id").val();
-    var checkState = $("#checkState").val();
-    //批量加载时间控件
-    $(".date").each(function () {
-        laydate.render({
-            elem: this
-            , type: 'date'
-            , trigger: 'click'
+    $('#integralInfoForm').bootstrapValidator({
+        feedbackIcons: {
+            valid: 'glyphicon glyphicon-ok',
+            invalid: 'glyphicon glyphicon-remove',
+            validating: 'glyphicon glyphicon-refresh'
+        },
+        container: 'tooltip',
+        group: '.rowGroup',
+        fields: IntegralInfoDlg.validateFields,
+        live: 'enabled',
+        message: '该字段不能为空'
+    }).on('error.field.bv', function (e, data) {
+        // Get the tooltip
+        var $parent = data.element.parents('#integralInfoForm'),
+                $icon = $parent.find('.form-control-feedback[data-bv-icon-for="' + data.field + '"]'),
+                title = $icon.data('bs.tooltip').getTitle();
+        $icon.tooltip('show').tooltip({
+            html: true,
+            placement: 'right',
+            title: title,
+            container: 'body'
         });
     });
-    $(".rangedate").each(function () {
-        laydate.render({
-            elem: this,
-            type: "date",
-            range: true,
-            trigger: "click"
-        })
-    })
-    $(".rangemonth").each(function () {
-        laydate.render({
-            elem: this,
-            type: "month",
-            range: true,
-            trigger: "click"
-        })
-    })
+    var id = $("#id").val();
+    var checkState = $("#checkState").val();
     if (id != null && id != '') {
-//select初始化
+        //select初始化
         $("select").each(function () {
             $(this).val($(this).attr("value")).trigger("change");
         });