浏览代码

层次变更再修改

sugangqiang 1 年之前
父节点
当前提交
8b63d35302

+ 48 - 4
app/admin/controller/TalentTypeChange.php

@@ -271,10 +271,27 @@ class TalentTypeChange extends AdminController {
         $where[] = ["isConditionFile", "<>", 1];
         $where[] = ["delete", "=", 0];
         if ($condition && $condition["bindFileTypes"]) {
+            $companyWithFileType = array_filter(explode(";", $condition["companyWithFileType"]));
+            $cfKv = [];
+            for ($i = 0; $i < count($companyWithFileType); $i++) {
+                $setting = explode(":", $companyWithFileType[$i]);
+                $_companyId = $setting[0];
+                $_files = explode(",", $setting[1]);
+                $cfKv[$_companyId] = $_files;
+            }
             $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
-            $files = Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
+            $files = Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select()->toArray();
+            for ($i = 0; $i < count($files); $i++) {
+                foreach ($cfKv as $_companyId => $_files) {
+                    if (in_array($files[$i]["id"], $_files)) {
+                        $company = getCacheById("Company", $_companyId);
+                        $files[$i]["name"] .= sprintf("<span style='color:red;'>(%s)</span>", $company["name"]);
+                        break;
+                    }
+                }
+            }
         } else {
-            $files = Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
+            $files = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
         }
         $response->code = 200;
         $response->id = $id;
@@ -388,11 +405,38 @@ class TalentTypeChange extends AdminController {
             }
             $response->data = $info;
 
+            $condition = TalentConditionApi::getOne($info["newIdentifyCondition"]);
             $whrFile = [];
-            $whrFile[] = ["type", "=", $info["type"]];
+            $whrOr = [];
             $whrFile[] = ["project", "=", ProjectState::LEVELCHANGE];
             $whrFile[] = ["active", "=", 1];
-            $response->fileList = \app\common\model\FileType::where($whrFile)->order("sn asc")->select()->toArray();
+            $whrFile[] = ["type", "=", $info["type"]];
+            $whrFile[] = ["isConditionFile", "<>", 1];
+            $whrFile[] = ["delete", "=", 0];
+            if ($condition && $condition["bindFileTypes"]) {
+                $companyWithFileType = array_filter(explode(";", $condition["companyWithFileType"]));
+                $cfKv = [];
+                for ($i = 0; $i < count($companyWithFileType); $i++) {
+                    $setting = explode(":", $companyWithFileType[$i]);
+                    $_companyId = $setting[0];
+                    $_files = explode(",", $setting[1]);
+                    $cfKv[$_companyId] = $_files;
+                }
+                $whrOr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
+                $files = \app\common\model\FileType::whereOr([$whrFile, $whrOr])->order("sn asc")->select()->toArray();
+                for ($i = 0; $i < count($files); $i++) {
+                    foreach ($cfKv as $_companyId => $_files) {
+                        if (in_array($files[$i]["id"], $_files)) {
+                            $company = getCacheById("Company", $_companyId);
+                            $files[$i]["name"] .= sprintf("<span style='color:red;'>(%s)</span>", $company["name"]);
+                            break;
+                        }
+                    }
+                }
+            } else {
+                $files = \app\common\model\FileType::where($whrFile)->order("sn asc")->select()->toArray();
+            }
+            $response->fileList = $files;
 
             $fieldList = DictApi::getTalentTypeChangeFields($info["type"]);
             $field_tmp = [];

+ 17 - 10
app/enterprise/controller/TalentTypeChange.php

@@ -71,24 +71,31 @@ class TalentTypeChange extends EnterpriseController {
         if (!$talentInfo || $talentInfo["checkState"] != TalentState::CERTIFICATED || $talentInfo["delete"] == 1) {
             return json(["msg" => "人才库中匹配不到该人才", "code" => 500]);
         }
-        $data['checkState'] = MainState::SAVE;
-        $data['basicState'] = MainState::BASIC_NEED;
-        $data['isPublic'] = 1;
-        $data['oldCertificateStartTime'] = $talentInfo["certificateGetTime"];
-        $data['oldCertificateOutTime'] = $talentInfo["certificateExpireTime"];
-        $data['oldIdentifyOutTime'] = $talentInfo["identifyExpireTime"];
-        $data['isPublic'] = 1;
-        $data['createUser'] = $this->user["uid"];
-        $data['createTime'] = date("Y-m-d H:i:s");
         $condition_info = Db::table("new_talent_condition")->findOrEmpty($data["newIdentifyCondition"]);
         if (!$condition_info) {
             return json(["msg" => "新认定条件不存在", "code" => 500]);
         }
 
         if ($data["id"]) {
+            $talentTypeChange = TalentTypeChangeModel::find($data["id"]);
+            if (!$talentTypeChange)
+                return json(["msg" => "不存在的变更记录", "code" => 500]);
+            if ($talentTypeChange["checkState"] != MainState::SAVE && $talentTypeChange["checkState"] != MainState::FIRST_REJECT && $talentTypeChange["checkState"] != MainState::BEFORE_REJECT) {
+                return json(["msg" => "正在审核中,无法修改", "code" => 500]);
+            }
+            $data['updateUser'] = $this->user["uid"];
+            $data['updateTime'] = date("Y-m-d H:i:s");
             TalentTypeChangeModel::update($data);
         } else {
             $data["id"] = getStringId();
+            $data['checkState'] = MainState::SAVE;
+            $data['basicState'] = MainState::BASIC_NEED;
+            $data['isPublic'] = 1;
+            $data['oldCertificateStartTime'] = $talentInfo["certificateGetTime"];
+            $data['oldCertificateOutTime'] = $talentInfo["certificateExpireTime"];
+            $data['oldIdentifyOutTime'] = $talentInfo["identifyExpireTime"];
+            $data['createUser'] = $this->user["uid"];
+            $data['createTime'] = date("Y-m-d H:i:s");
             TalentTypeChangeModel::create($data);
         }
         $companyName = session('user')["companyName"] ?: session('user')["rolename"];
@@ -107,7 +114,7 @@ class TalentTypeChange extends EnterpriseController {
             'createUser' => session('user')['account'] . "({$companyName})"
         ]);
 
-        return json(["msg" => "添加成功", "code" => 200, "obj" => ["id" => $data["id"], "checkState" => $data["checkState"]]]);
+        return json(["msg" => $data["id"] ? "修改成功" : "添加成功", "code" => 200, "obj" => ["id" => $data["id"], "checkState" => $data["checkState"]]]);
     }
 
     public function submitToCheck() {

+ 17 - 7
public/static/modular/gate/talentLibrary/talentTypeChange/talentTypeChange_info.js

@@ -137,7 +137,9 @@ TalentTypeChangeInfoDlg.addSubmit = function () {
         return;
     locked = true;
     if (this.talentTypeChangeInfoData.id != null && this.talentTypeChangeInfoData.id != '') {
-        TalentTypeChangeInfoDlg.editSubmit(1);
+        TalentTypeChangeInfoDlg.editSubmit(1);        
+        $("#fileTable").bootstrapTable("destroy", {});
+        TalentTypeChangeInfoDlg.initFileTable();
     } else {
         var ajax = new $ax("/enterprise/talentTypeChange/add", function (data) {
             if (data.code == "200") {
@@ -551,11 +553,13 @@ TalentTypeChangeInfoDlg.initFileTable = function () {
                     return;
                 }
                 var html = '<ul class="imgs"><li style="width: 80%;font-weight: bold;padding-top: 5px;">附件原名</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">预览</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">操作</li>';
-                var files = $("#files").val();
+                var files = $("#files").val().split(",");
+                var fields = $("#fields").val().split(",");
                 var checkState = $("#checkState").val();
                 for (var key in data) {
                     var btn = "";
-                    if (checkState != 10 || (checkState == 10 && files.indexOf(row.id) != -1)) {
+                    console.log(checkState,row.isConditionFile,files,row.id,files.indexOf(row.id))
+                    if (checkState != 10 || (checkState == 10 && ((row.isConditionFile == 0 && files.indexOf(row.id) != -1) || (row.isConditionFile == 1 && (files.indexOf(row.id) != -1 || fields.indexOf("newIdentifyCondition")))))) {
                         btn = "<button type=\'button\' onclick=\"TalentTypeChangeInfoDlg.checkFile(this,'" + row.fState + "','" + row.id + "','" + data[key].id + "')\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\">" +
                                 "<i class=\"fa fa-paste\"></i>修改" +
                                 "</button>" +
@@ -743,10 +747,16 @@ TalentTypeChangeInfoDlg.initFileTypeColumn = function () {
         {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle', width: "52%", 'class': 'uitd_showTip'},
         {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%",
             formatter: function (value, row, index) {
-                return "<button type='button' onclick=\"TalentTypeChangeInfoDlg.checkFile(this,'" + row.fState + "','" + value + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
-                        "<i class=\"fa fa-upload\"></i>上传" +
-                        "</button>";
-
+                var checkState = $("#checkState").val();
+                var files = $("#files").val().split(",");
+                var fields = $("#fields").val().split(",");
+                var html = "";
+                if (checkState != 10 || (checkState == 10 && ((row.isConditionFile == 0 && files.indexOf(value) != -1) || (row.isConditionFile == 1 && (files.indexOf(value) != -1 || fields.indexOf("newIdentifyCondition")))))) {
+                    html = "<button type='button' onclick=\"TalentTypeChangeInfoDlg.checkFile(this,'" + row.fState + "','" + value + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
+                            "<i class=\"fa fa-upload\"></i>上传" +
+                            "</button>";
+                }
+                return html;
             }
         }
     ]