瀏覽代碼

积分申报++

sugangqiang 2 年之前
父節點
當前提交
4fc93c8cba

+ 9 - 3
app/common/api/IntegralRecordApi.php

@@ -6,7 +6,7 @@ use app\common\api\DictApi;
 use app\admin\model\Enterprise;
 use think\facade\Db;
 use app\common\model\IntegralRecord;
-use app\common\api\IntegralState;
+use app\common\state\IntegralState;
 
 /**
  * Description of IntegralRecordApi
@@ -19,8 +19,14 @@ class IntegralRecordApi {
         return IntegralRecord::where("id", "=", $id)->find();
     }
 
-    public static function getList() {
-        
+    public static function getList($params) {
+        $where = [];
+        $order = $params["order"] ?: "desc";
+        $offset = $params["offset"] ?: 0;
+        $limit = $params["limit"] ?: 10;
+        $count = IntegralRecord::where($where)->count();
+        $list = IntegralRecord::where($where)->field("*,if(updateTime is not null,updateTime,createTime) as orderTime")->limit($offset, $limit)->order("orderTime " . $order)->select();
+        return ["total" => $count, "rows" => $list];
     }
 
     public static function checkIsEditable($id) {

+ 0 - 28
app/common/api/TalentState.php

@@ -139,31 +139,3 @@ 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; //积分申报
-
-}

+ 1 - 1
app/common/model/IntegralRecord.php

@@ -14,7 +14,7 @@ class IntegralRecord extends Model {
     protected $table = "new_integral_record";
 
     public function detail() {
-        return $this->hasOne(IntegralDetail::class);
+        return $this->hasOne(IntegralDetail::class, "record_id");
     }
 
 }

+ 24 - 0
app/common/state/IntegralState.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace app\common\state;
+
+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; //积分兑现成功
+
+}

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

@@ -0,0 +1,10 @@
+<?php
+
+namespace app\common\state;
+
+class ProjectState {
+
+    public const TALENT = 1; //人才认定
+    public const INTEGRAL = 20; //积分申报
+
+}

+ 45 - 43
app/enterprise/controller/Integral.php

@@ -5,11 +5,12 @@ namespace app\enterprise\controller;
 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\state\IntegralState;
 use app\common\api\IntegralRecordApi;
 use app\common\api\TalentLogApi;
-use app\common\api\Project;
+use app\common\state\ProjectState;
+use app\enterprise\validate\IntegralValidator;
+use think\exception\ValidateException;
 
 /**
  * Description of 积分申报
@@ -23,7 +24,7 @@ class Integral extends EnterpriseController {
     }
 
     public function list() {
-        $res = IntegralRecordApi::getList($this->request, $step);
+        $res = IntegralRecordApi::getList($this->request->param());
         return json($res);
     }
 
@@ -37,7 +38,7 @@ class Integral extends EnterpriseController {
         $info = IntegralRecordApi::getOne($id);
         $ep = EnterpriseApi::getOne($this->user["uid"]);
         if ($info) {
-            $info["real_state"] = TalentLogApi::getLastLog($id, Project::INTEGRAL)["state"];
+            $info["real_state"] = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL)["state"];
         }
         if ($info && in_array($info["checkState"], [IntegralState::VERIFY_PASS, IntegralState::REVERIFY_PASS, IntegralState::REVERIFY_FAIL])) {
             return $this->view($request);
@@ -236,7 +237,7 @@ class Integral extends EnterpriseController {
      */
     private function save($info, \think\Request $request, $checkState) {
         try {
-            $batch = \app\common\api\BatchApi::getValidBatch(Project::INTEGRAL, $this->user["type"]);
+            $batch = \app\common\api\BatchApi::getValidBatch(ProjectState::INTEGRAL, $this->user["type"]);
             if (!$batch) {
                 throw new ValidateException("不在人才认定申报申请时间内");
             }
@@ -255,14 +256,35 @@ class Integral extends EnterpriseController {
                 $data[$key] = trim($param[$key]);
             }
 
-            $updateDetailList = [];
             $insertDetailList = [];
+            $tmp_item_ids = [];
             $data["batch_id"] = $batch["id"];
-            $detail_ids = $param["detail_id"];
             $projectTypes = $param["projectType"];
             $projectIds = $param["projectId"];
             $item_ids = $param["item_id"];
             $amounts = $param["amount"];
+
+            $detailCounts = count($item_ids);
+            for ($i = 0; $i < $detailCounts; $i++) {
+                if (!in_array($item_ids[$i], $tmp_item_ids)) {
+                    $tmp_item_ids[] = $item_ids[$i];
+                }
+                if (!is_numeric($amounts[$i]) || $amounts[$i] < 0) {
+                    throw new ValidateException(sprintf("第%d个积分标准项的数额填写错误,应填入大于0的数字", $i + 1));
+                }
+                $insertDetailList[] = [
+                    "id" => getStringId(),
+                    "record_id" => "",
+                    "item_id" => "",
+                    "amount" => "",
+                    "unit" => "",
+                    "file_id"
+                ];
+            }
+            if (count($tmp_item_ids) != $detailCounts) {
+                throw new ValidateException("同一个申报中,同一个积分标准不能申报多次");
+            }
+
             if ($info["real_state"] == IntegralState::VERIFY_REJECT) {
                 //真实状态是驳回,需要判断什么字段可以提交                
                 $modify_fields = array_filter(explode(",", $info["modify_fields"]));
@@ -273,31 +295,7 @@ class Integral extends EnterpriseController {
                 }
                 $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;
@@ -308,8 +306,9 @@ class Integral extends EnterpriseController {
                 $success_msg = "保存成功";
                 if ($data["id"]) {
                     //编辑
-                    TalentModel::update($data);
-                    $last_log = TalentLogApi::getLastLog($data["id"], Project::INTEGRAL);
+                    $data["updateTime"] = date("Y-m-d H:i:s");
+                    \app\common\model\IntegralRecord::update($data);
+                    $last_log = TalentLogApi::getLastLog($data["id"], ProjectState::INTEGRAL);
                     if ($last_log["new_state"] != IntegralState::SAVE) {
                         TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
                     } else {
@@ -317,10 +316,11 @@ class Integral extends EnterpriseController {
                     }
                 } else {
                     //新增
-                    $data["enterprise_id"] = $this->user["uid"];
                     $data["id"] = getStringId();
+                    $data["enterprise_id"] = $this->user["uid"];
+                    $data["createTime"] = date("Y-m-d H:i:s");
                     \app\common\model\IntegralRecord::insert($data);
-                    TalentLogApi::write(Project::INTEGRAL, $data["id"], $checkState, "保存未提交", 1);
+                    TalentLogApi::write(ProjectState::INTEGRAL, $data["id"], $checkState, "保存未提交", 1);
                     $whr = [];
                     $whr[] = ["fileId", "in", $files];
                     $upd_checklog["mainId"] = $data["id"];
@@ -333,18 +333,20 @@ class Integral extends EnterpriseController {
                     $data["new_submit_time"] = date("Y-m-d H:i:s");
                 }
                 if ($data["id"]) {
+                    $data["updateTime"] = date("Y-m-d H:i:s");
                     \app\common\model\IntegralRecord::update($data);
                 } else {
                     //新增
-                    $data["enterprise_id"] = $this->user["uid"];
                     $data["id"] = getStringId();
+                    $data["enterprise_id"] = $this->user["uid"];
+                    $data["createTime"] = date("Y-m-d H:i:s");
                     \app\common\model\IntegralRecord::insert($data);
                     $whr = [];
                     $whr[] = ["fileId", "in", $files];
                     $upd_checklog["mainId"] = $data["id"];
                     Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
                 }
-                TalentLogApi::write(Project::INTEGRAL, $id, $checkState, "确认提交审核", 1);
+                TalentLogApi::write(ProjectState::INTEGRAL, $data["id"], $checkState, "确认提交审核", 1);
             } else {
                 throw new ValidateException($error_msg);
             }
@@ -353,7 +355,7 @@ class Integral extends EnterpriseController {
                 //删除多余的附件,一般是选择人才类型留下来的
                 $whr = [];
                 $whr[] = ["mainId", "=", $data["id"]];
-                $whr[] = ["type", "=", Project::INTEGRAL];
+                $whr[] = ["type", "=", ProjectState::INTEGRAL];
                 $whr[] = ["id", "not in", $files];
                 $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
                 $_logfileIds[] = [];
@@ -373,8 +375,8 @@ class Integral extends EnterpriseController {
 
                 $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]];
+                Db::table("new_talent_file")->where($whr)->save(["mainId" => $data["id"]]);
+                $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $data["id"], "checkState" => $checkState]];
                 $callback = $checkState == IntegralState::SAVE ? "infoCallback" : "submitCallback";
                 echo sprintf("<script>parent.IntegralInfoDlg.{$callback}(%s);</script>", json_encode($res));
                 exit();
@@ -397,7 +399,7 @@ class Integral extends EnterpriseController {
         }
         $checkState = $info["checkState"];
         if (in_array($checkState, [0, 1])) {
-            $log = TalentLogApi::getLastLog($id, Project::INTEGRAL);
+            $log = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL);
             if ($log["state"] > 1) {
                 //有提交审核记录
                 return json(["msg" => "该申报已提交审核,无法删除"]);

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

@@ -157,7 +157,6 @@
                                                     <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>
@@ -208,7 +207,6 @@
                                                     <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>

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

@@ -317,11 +317,12 @@ IntegralInfoDlg.addSubmit = function () {
 
 //回调
 IntegralInfoDlg.infoCallback = function (data) {
+    console.log(data)
     locked = false;
     IntegralInfoDlg.setNoChangeField();
     Feng.info(data.msg);
     if (data.code == 200) {
-        window.parent.TalentInfo.table.refresh();
+        window.parent.Integral.table.refresh();
         $("#id").val(data.obj.id);
         $("#fileLi").removeAttr("style");
         $("#checkState").val(data.obj.checkState);
@@ -450,14 +451,14 @@ IntegralInfoDlg.submitCallback = function (data) {
  */
 IntegralInfoDlg.validateIsEdit = function () {
     var checkState = $("#checkState").val();
-    if (checkState != 0 && checkState != 8) {
-        if (checkState == 16 || checkState == -1 || checkState == -2 || checkState == 7) {
+    if (checkState != 0 && checkState != 1) {
+        if (checkState == 5 || checkState == 8) {
             Feng.error("您的申报审核不通过,无法再修改");
             return false;
         } else if (checkState == 28) {
             Feng.error("申报已完成");
             return false;
-        } else if (checkState == 14) {
+        } else if (checkState == 6) {
             Feng.error("您的申报已审核通过,无法再修改");
             return false;
         } else if (checkState == 22 || checkState == 25 || checkState == 27) {