Kaynağa Gözat

修复积分申报中附件问题及未在库和0积分也提示

sugangqiang 1 yıl önce
ebeveyn
işleme
5af91555d5

+ 30 - 30
app/common/api/IntegralRecordApi.php

@@ -582,39 +582,39 @@ class IntegralRecordApi {
      * @return array $response
      */
     public static function getIntegralRecordByIdCard($cardType, $cardNumber) {
-        $where = [];
-        $where[] = ["card_type", "=", $cardType];
-        $where[] = ["card_number", "=", $cardNumber];
-        $where[] = ["checkState", "=", TalentState::CERTIFICATED];
-        $talentInfo = Db::table("new_talent_info")->where($where)->find();
+        if ($cardType && $cardNumber) {
+            $where = [];
+            $where[] = ["card_type", "=", $cardType];
+            $where[] = ["card_number", "=", $cardNumber];
+            $where[] = ["checkState", "=", TalentState::CERTIFICATED];
+            $talentInfo = Db::table("new_talent_info")->where($where)->find();
 
-        $where = [];
-        $where[] = ["card_type", "=", $cardType];
-        $where[] = ["card_number", "=", $cardNumber];
-        $integralLog = Db::table("new_integral_log")->where($where)->order("createTime desc")->find();
-        if (session("user")["usertype"] == 2 && (($talentInfo && session("user")["uid"] != $talentInfo["enterprise_id"]) || ($integralLog && session("user")["uid"] != $integralLog["enterprise_id"]))) {
-            $response = [
-                "deny" => 1
-            ];
-        } else {
-            $response = [
-                "isTalentInLibrary" => $talentInfo ? 1 : 0,
-                "levelName" => CommonConst::getLayerNameByLayer($integralLog["talentLevel"]),
-                "level" => $integralLog["talentLevel"],
-                "totalPoints" => $integralLog["nowPoints"] ?: 0
-            ];
-        }
+            $where = [];
+            $where[] = ["card_type", "=", $cardType];
+            $where[] = ["card_number", "=", $cardNumber];
+            $integralLog = Db::table("new_integral_log")->where($where)->order("createTime desc")->find();
+            if (session("user")["usertype"] == 2 && (($talentInfo && session("user")["uid"] != $talentInfo["enterprise_id"]) || ($integralLog && session("user")["uid"] != $integralLog["enterprise_id"]))) {
+                $response = [
+                    "deny" => 1
+                ];
+            } else {
+                $response = [
+                    "isTalentInLibrary" => $talentInfo ? 1 : 0,
+                    "levelName" => CommonConst::getLayerNameByLayer($integralLog["talentLevel"]),
+                    "level" => $integralLog["talentLevel"],
+                    "totalPoints" => $integralLog["nowPoints"] ?: 0
+                ];
+            }
 
-        if ($response["deny"]) {
-            //不是本企业人员
-            return "该身份证已经在别的企业申报过优秀人才 / 积分项目";
-        } else if ($response["isTalentInLibrary"] == 1 || $response["totalPoints"] > 0) {
-            //在库人才
-            $levelTypeName = $response["level"] >= 1 && $response["level"] <= 7 ? "在库人才(" . $response["levelName"] . ")" : $response["levelName"];
-            return sprintf("该人员为%s,截至目前,已累计%d积分", $levelTypeName, $response["totalPoints"]);
-        } else {
-            return "";
+            if ($response["deny"]) {
+                //不是本企业人员
+                return "该身份证已经在别的企业申报过优秀人才 / 积分项目";
+            } else {
+                $levelTypeName = $response["level"] >= 1 && $response["level"] <= 7 ? "在库人才(" . $response["levelName"] . ")" : $response["levelName"];
+                return sprintf("该人员为%s,截至目前,已累计%d积分", $levelTypeName, $response["totalPoints"]);
+            }
         }
+        return "";
     }
 
     public static function setPublic($mainId, $state, $msg, $batch = null) {

+ 2 - 0
app/common/state/CommonConst.php

@@ -21,6 +21,7 @@ class CommonConst {
      * @return int
      */
     public static function getLayerPointsByLayer($level) {
+        $level = $level ?: 8;
         $levelAndPoints = [
             1 => 6000,
             2 => 4000,
@@ -40,6 +41,7 @@ class CommonConst {
      * @return string
      */
     public static function getLayerNameByLayer($level) {
+        $level = $level ?: 8;
         $levelAndNames = [
             1 => "第一层次",
             2 => "第二层次",

+ 41 - 14
app/enterprise/controller/Integral.php

@@ -116,48 +116,75 @@ class Integral extends EnterpriseController {
             $amounts = $params["amount"];
 
             $detailCounts = count($item_ids);
-            $ft_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));
+                    $res = ["msg" => sprintf("第%d个积分标准项的数额填写错误,应填入大于0的数字", $i + 1)];
+                    echo sprintf("<script>parent.IntegralInfoDlg.submitCallback(%s);</script>", json_encode($res));
+                    exit;
                 }
                 $integralItemInfo = \app\common\api\IntegralItemApi::getOne($item_ids[$i]);
                 if (!$integralItemInfo) {
-                    throw new ValidateException(sprintf("第%d个积分标准项不存在", $i + 1));
+                    $res = ["msg" => sprintf("第%d个积分标准项不存在", $i + 1)];
+                    echo sprintf("<script>parent.IntegralInfoDlg.submitCallback(%s);</script>", json_encode($res));
+                    exit;
+                }
+                $ft_ids = array_filter(explode(",", $integralItemInfo["fileTypeId"]));
+                if ($ft_ids) {
+                    $whereFt[] = ["id", "in", $ft_ids];
+                    $whereFt[] = ["must", "=", 1];
+                    $fts = Db::table("new_common_filetype")->where($whereFt)->select()->toArray();
+                    $count = count($fts);
+                    if ($count > 0) {
+                        $_ft_ids = array_column($fts, "id");
+                        $whr = [];
+                        $whr[] = ["type", "=", ProjectState::INTEGRAL];
+                        $whr[] = ["relationId", "=", $item_ids[$i]];
+                        $whr[] = ["typeId", "in", $_ft_ids];
+                        if ($id) {
+                            $whr[] = ["mainId", "=", $id];
+                        } else {
+                            $whr[] = ["id", "in", $params["uploadFiles"]];
+                        }
+                        $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
+                        if ($count != count($distinct_filetypes)) {
+                            $res = ["msg" => '积分项目"' . $integralItemInfo["name"] . '"缺少必传附件'];
+                            echo sprintf("<script>parent.IntegralInfoDlg.submitCallback(%s);</script>", json_encode($res));
+                            exit;
+                        }
+                    }
                 }
-                $ft_ids = array_filter(array_merge($ft_ids, (array) explode(",", $integralItemInfo["fileTypeId"])));
             }
-            $ft_ids = array_unique($ft_ids);
             if (count($tmp_item_ids) != $detailCounts) {
-                throw new ValidateException("同一个申报中,同一个积分标准不能申报多次");
+                $res = ["msg" => "同一个申报中,同一个积分标准不能申报多次"];
+                echo sprintf("<script>parent.IntegralInfoDlg.submitCallback(%s);</script>", json_encode($res));
+                exit;
             }
 
             $whrCommonFt = [];
             $whrCommonFt[] = ["project", "=", ProjectState::INTEGRAL];
             $whrCommonFt[] = ["active", "=", 1];
+            $whrCommonFt[] = ["must", "=", 1];
             $whrCommonFt[] = ["delete", "=", 0];
             $whrCommonFt[] = ["type", "=", $this->user["type"]];
             $whrCommonFt[] = ["isConditionFile", "=", 1];
             $common_fts = Db::table("new_common_filetype")->where($whrCommonFt)->select()->toArray();
             $common_ft_ids = array_column($common_fts, "id");
-            $ft_ids = array_filter(array_merge($ft_ids, (array) $common_ft_ids));
-            if ($ft_ids) {
+            if ($common_ft_ids) {
                 $whr = [];
+                $whr[] = ["type", "=", ProjectState::INTEGRAL];
+                $whr[] = ["typeId", "in", $common_ft_ids];
                 if ($id) {
                     $whr[] = ["mainId", "=", $id];
-                    $whr[] = ["type", "=", ProjectState::INTEGRAL];
                 } else {
-                    if ($params["uploadFiles"])
-                        $whr[] = ["id", "in", $params["uploadFiles"]];
+                    $whr[] = ["id", "in", $params["uploadFiles"]];
                 }
-                $whr[] = ["typeId", "in", $ft_ids];
                 $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
                 $upload_type_counts = count($distinct_filetypes);
-                if ($upload_type_counts != count($ft_ids)) {
-                    $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
+                if ($upload_type_counts != count($common_ft_ids)) {
+                    $res = ["msg" => "公共附件缺少必传附件"];
                     echo sprintf("<script>parent.IntegralInfoDlg.submitCallback(%s);</script>", json_encode($res));
                     exit;
                 }

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

@@ -443,21 +443,15 @@ IntegralInfoDlg.validId = function () {
         $("#fileLi").attr("style", "pointer-events: none");
     }
 }
-var currentTable = null;
 var currentTr = null;
 //选择附件并显示附件名
 IntegralInfoDlg.checkFile = function (content, fileTypeId, fileId, itemId) {
-    currentTable = $(content).parents(".fileTable");
-    var findTr = null;
     var curTr = $(content).parents("tr");
-    while (!findTr) {
-        if (curTr.prev("tr[data-index]")) {
-            findTr = curTr.prev("tr[data-index]")
-        } else {
-            curTr = curTr.prev();
-        }
+    var index = curTr.index();
+    if (curTr.hasClass("subTitleLine")) {
+        index++;
     }
-    currentTr = findTr.data("index");
+    currentTr = index;
     if (!IntegralInfoDlg.validateIsEdit())
         return;
     $("#upload_file").unbind("change");
@@ -645,7 +639,7 @@ IntegralInfoDlg.callBack = function (data) {
 <button type="button" onclick="IntegralInfoDlg.checkFile(this,' + data.typeId + ',' + data.id + ',' + data.itemId + ')" style="margin-right: 10px" class="btn btn-xs btn-info"><i class="fa fa-paste"></i>修改</button>\n\
 <button type="button" onclick="IntegralInfoDlg.deleteFile(' + data.id + ')" class="btn btn-xs btn-danger"><i class="fa fa-times"></i>删除</button>\n\
 </div></li></ul>';
-            $(currentTable).find("tr[data-index='" + currentTr + "']").next().next().find(".imgs").append(html);
+            $(".fileTable tbody tr").eq(currentTr).find(".imgs").append(html);
         }
     }
 }

+ 4 - 10
public/static/modular/gate/integral/integralInfo_select.js

@@ -179,21 +179,15 @@ IntegralInfoDlg.onItemChange = function (obj) {
     IntegralInfoDlg.changeAndLoadFile();
 }
 
-var currentTable = null;
 var currentTr = null;
 //选择附件并显示附件名
 IntegralInfoDlg.checkFile = function (content, fileTypeId, fileId, itemId) {
-    currentTable = $(content).parents(".fileTable");
-    var findTr = null;
     var curTr = $(content).parents("tr");
-    while (!findTr) {
-        if (curTr.prev("tr[data-index]")) {
-            findTr = curTr.prev("tr[data-index]")
-        } else {
-            curTr = curTr.prev();
-        }
+    var index = curTr.index();
+    if (curTr.hasClass("subTitleLine")) {
+        index++;
     }
-    currentTr = findTr.data("index");
+    currentTr = index;
     if (!IntegralInfoDlg.validateIsEdit())
         return;
     $("#upload_file").unbind("change");