Przeglądaj źródła

津补贴申请时候如果有公共附件关联了正常附件并上传,正常附件变成非必选

sugangqiang 1 rok temu
rodzic
commit
58b1746889

+ 21 - 2
app/common/controller/Api.php

@@ -386,13 +386,14 @@ class Api extends BaseController {
         $isMix = $param["isMix"] ?: 0;
         $talent_condition = $param["talent_condition"];
         $token = $param["pageToken"];
+        $year = $param["year"];
         $where[] = ["project", "=", $project];
         $where[] = ["active", "=", 1];
         $where[] = ["delete", "=", 0];
         $where[] = ["type", "=", $type];
         switch ($project) {
             case 2:
-                $where[] = ["isConditionFile", "in", [0, $param["allowanceType"]]];
+                $where[] = ["isConditionFile", "=", $param["allowanceType"]];
                 break;
             case 1:
             case 8:
@@ -480,6 +481,24 @@ class Api extends BaseController {
         } else {
             $rows = Db::table("new_common_filetype")->where($where)->order("must asc")->order("sn " . $order)->select()->toArray();
         }
+        if ($project == ProjectState::JBT) {
+            $allowanceInfo = \app\common\api\TalentAllowanceApi::getInfoById($id);
+            $where = [];
+            $where[] = ["enterpriseId", "=", $allowanceInfo["enterpriseId"]];
+            $where[] = ["batch", "=", $allowanceInfo["year"]];
+            $commonFiles = Db::table("un_talent_allowance_common_file")->alias("f")->leftJoin("new_common_filetype ft", "ft.id=f.fileTypeId")->field("f.*,ft.relationIds")->where($where)->select()->toArray();
+            $relationIds = [];
+            foreach ($commonFiles as $key => $row) {
+                $_relationIds = array_filter(explode(",", $row["relationIds"]));
+                $relationIds = array_merge($relationIds, $_relationIds);
+            }
+            foreach ($rows as $key => $row) {
+                if (in_array($row["id"], $relationIds)) {
+                    $rows[$key]["must"] = 2;
+                }
+            }
+            $rows = bubbleSort($rows, "must");
+        }
         if ($id) {
             foreach ($rows as $key => $row) {
                 $where = [];
@@ -545,7 +564,7 @@ class Api extends BaseController {
         $list = [];
         if ($info) {
             $where = [["batch", "=", $info["year"]], ["enterpriseId", "=", $info["enterpriseId"]]];
-            $list = Db::table("un_talent_allowance_common_file")->where($where)->select()->toArray();
+            $list = Db::table("un_talent_allowance_common_file")->alias("f")->leftJoin("new_common_filetype ft", "ft.id=f.fileTypeId")->where($where)->field("f.*,ft.name as fileTypeName")->select()->toArray();
             foreach ($list as $key => $item) {
                 $list[$key]["ext"] = pathinfo($item["url"])["extension"];
                 $list[$key]["url"] = getStoragePath($item["url"]);

+ 46 - 1
app/enterprise/controller/TalentAllowance.php

@@ -784,10 +784,26 @@ class TalentAllowance extends EnterpriseController {
         $where = [];
         $where[] = ["type", "=", $old["type"]];
         $where[] = ["project", "=", ProjectState::JBT];
-        $where[] = ["isConditionFile", "in", [0, $old["allowanceType"]]];
+        $where[] = ["isConditionFile", "=", $old["allowanceType"]];
         $where[] = ["active", "=", 1];
         $where[] = ["delete", "=", 0];
         $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
+
+        $where = [];
+        $where[] = ["enterpriseId", "=", $old["enterpriseId"]];
+        $where[] = ["batch", "=", $old["year"]];
+        $commonFiles = Db::table("un_talent_allowance_common_file")->alias("f")->leftJoin("new_common_filetype ft", "ft.id=f.fileTypeId")->field("f.*,ft.relationIds")->where($where)->select()->toArray();
+        $relationIds = [];
+        foreach ($commonFiles as $key => $row) {
+            $_relationIds = array_filter(explode(",", $row["relationIds"]));
+            $relationIds = array_merge($relationIds, $_relationIds);
+        }
+        foreach ($filetypes as $key => $filetype) {
+            if (in_array($filetype["id"], $relationIds)) {
+                $filetypes[$key]["must"] = 2;
+            }
+        }
+
         $sb = [];
         $sb[] = "以下为必传附件:";
         foreach ($filetypes as $filetype) {
@@ -913,13 +929,42 @@ class TalentAllowance extends EnterpriseController {
         $batchId = $param["batch"];
         $where = [["batchId", "=", $batchId], ["enterpriseId", "=", $this->user["uid"]]];
         $list = Db::table("un_talent_allowance_common_file")->where($where)->select()->toArray();
+
+        $whr[] = ["type", "=", $this->user["type"]];
+        $whr[] = ["project", "=", ProjectState::JBT];
+        $whr[] = ["isConditionFile", "=", 0];
+        $whr[] = ["delete", "=", 0];
+        $commonFileTypes = Db::table("new_common_filetype")->where($whr)->whereRaw("find_in_set(:enterpriseId,enterpriseIds)", ["enterpriseId" => $this->user["uid"]])->select()->toArray();
+
         foreach ($list as $key => $item) {
             $list[$key]["ext"] = pathinfo($item["url"])["extension"];
             $list[$key]["url"] = getStoragePath($item["url"]);
+            $list[$key]["fileTypes"] = $commonFileTypes;
         }
         return json(["rows" => $list]);
     }
 
+    public function bindCommonFileWithFileType() {
+        $params = $this->request->param();
+        $fileId = $params["fileId"];
+        $fileTypeId = $params["fileTypeId"];
+        $upd["id"] = $fileId;
+        $upd["fileTypeId"] = $fileTypeId ?: 0;
+        $upd["updateTime"] = date("Y-m-d H:i:s");
+        $upd["updateUser"] = $this->user["uid"];
+        try {
+            Db::table("un_talent_allowance_common_file")->update($upd);
+            if ($fileTypeId > 0) {
+                $msg = "关联成功";
+            } else {
+                $msg = "取消关联成功";
+            }
+            return json(new Response(Response::SUCCESS, $msg));
+        } catch (\think\db\exception\DbException $e) {
+            return json(new Response(Response::ERROR, $e->getMessage()));
+        }
+    }
+
     public function deleteCommonFile() {
         $id = $this->request["id"];
         $where = [];

+ 3 - 3
public/static/modular/filetype/unCommonFiletype/unCommonFiletype_info.js

@@ -242,6 +242,9 @@ UnCommonFiletypeInfoDlg.fileChange = function (context) {
 
 $(function () {
     Feng.initValidator("unCommonFiletypeForm", UnCommonFiletypeInfoDlg.validateFields);
+    $("select").each(function () {
+        $(this).val($(this).attr("selectVal"));
+    });
     var project = $("#project").val();
     var isConditionFile = $("#isConditionFile").val();
     if (project == 2 && isConditionFile === "0") {
@@ -255,9 +258,6 @@ $(function () {
             $("#enterpriseIds").val(enterpriseIds.split(",")).trigger("chosen:updated");
         }
     }
-    $("select").each(function () {
-        $(this).val($(this).attr("selectVal"));
-    });
     UnCommonFiletypeInfoDlg.projectChange();
 });
 

+ 1 - 0
public/static/modular/gate/talentAllowance/common/talentAllowanceInfo_select.js

@@ -12,6 +12,7 @@ var TalentAllowanceInfoDlg = {
 TalentAllowanceInfoDlg.initFileTable = function () {
     TalentAllowanceInfoDlg.initContract();
     var queryData = {};
+    queryData["mainId"] = $("#id").val();
     queryData['project'] = CONFIG.project_jbt;
     queryData['type'] = $("#type").val();
     queryData['allowanceType'] = $("#allowanceType").val();

+ 5 - 1
public/static/modular/gate/talentAllowance/common/talentAllowance_info.js

@@ -595,6 +595,7 @@ TalentAllowanceInfoDlg.initFileTable = function () {
     TalentAllowanceInfoDlg.initContract();
     // Feng.showMiniFileModal(CONFIG.project_jbt,$("#type").val(),$("#id").val());
     var queryData = {};
+    queryData["mainId"] = $("#id").val();
     queryData['project'] = CONFIG.project_jbt;
     queryData['type'] = $("#type").val();
     queryData['allowanceType'] = $("#allowanceType").val();
@@ -713,7 +714,10 @@ TalentAllowanceInfoDlg.initCommonFileTable = function () {
             return {css: {"word-break": "break-word", "white-space": "inherit"}}
         },
         columns: [
-            {title: '附件原名', field: 'originalName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: '70%', formatter: function (value, row, index) {
+            {title: '附件原名', field: 'originalName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: '50%', formatter: function (value, row, index) {
+                    return value;
+                }},
+            {title: '附件类型', field: 'fileTypeName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: '20%', formatter: function (value, row, index) {
                     return value;
                 }},
             {title: '预览', field: 'url', visible: true, align: 'center', valign: 'middle', width: "20%",

+ 25 - 1
public/static/modular/gate/talentAllowance/ic/talentAllowanceInfoIC.js

@@ -357,7 +357,13 @@ TalentAllowanceInfo.initCheckFileTable = function () {
                     },
                     {title: '操作', field: 'url', visible: true, align: 'center', valign: 'middle', width: '80px',
                         formatter: function (value, row, index) {
-                            return "<button type='button' onclick=\"downloadFile('" + row.id + "','6')\" class=\"btn btn-xs btn-success\"><i class=\"fa fa-download\" aria-hidden=\"true\"></i>下载</button>" +
+                            var selector = '<select style="background:#fff;border:1px solid #000;margin-right:2px;" onchange="TalentAllowanceInfo.onCommonTypeChangeAndBind(\'' + row.id + '\',this.value);"><option value="">关联通用附件类型</option>';
+                            for (var i = 0; i < row.fileTypes.length; i++) {
+                                var selectedStr = row.fileTypes[i].id == row.fileTypeId ? "selected" : "";
+                                selector += '<option value="' + row.fileTypes[i].id + '" ' + selectedStr + '>' + row.fileTypes[i].name + '</option>'
+                            }
+                            selector += '</select>';
+                            return selector + "<button type='button' onclick=\"downloadFile('" + row.id + "','6')\" class=\"btn btn-xs btn-success\"><i class=\"fa fa-download\" aria-hidden=\"true\"></i>下载</button>" +
                                     "<button type='button' onclick=\"TalentAllowanceInfo.deleteCheckFile('" + row.id + "','" + CONFIG.project_jbt + "')\" class=\"btn btn-xs btn-danger\">" +
                                     "<i class=\"fa fa-times\"></i>删除" +
                                     "</button>";
@@ -374,6 +380,24 @@ TalentAllowanceInfo.initCheckFileTable = function () {
     });
 }
 
+TalentAllowanceInfo.onCommonTypeChangeAndBind = function (fileId, fileTypeId) {
+    var formData = new FormData();
+    formData.append('fileId', fileId.toString());
+    formData.append('fileTypeId', fileTypeId.toString());
+    $.ajax({
+        url: Feng.ctxPath + "/enterprise/talentAllowance/bindCommonFileWithFileType",
+        type: "POST",
+        processData: false,
+        contentType: false,
+        data: formData,
+        success: function (data) {
+            Feng.info(data.msg);
+        }, error: function (data) {
+            Feng.error("关联失败!" + data.responseJSON.message + "!");
+        }
+    });
+}
+
 TalentAllowanceInfo.commonColumns = function () {
     return [
         {field: "selectItem", checkbox: true},

+ 1 - 0
public/static/modular/talentAllowance/talentAllowanceInfo_select.js

@@ -261,6 +261,7 @@ TalentAllowanceInfoDlg.showLog = function(id){
 TalentAllowanceInfoDlg.initFileTable = function (){
     TalentAllowanceInfoDlg.initContract();
     var queryData = {};
+    queryData["mainId"] = $("#id").val();
     queryData['project'] = CONFIG.project_jbt;
     queryData['type'] = $("#type").val();
     queryData['allowanceType'] = $("#allowanceType").val();