Browse Source

部门导出增加已审待审数量单独显示,丰富导出功能

sugangqiang 2 years ago
parent
commit
9f1aaf8290
3 changed files with 37 additions and 3 deletions
  1. 18 1
      app/admin/controller/Talent.php
  2. 13 2
      app/common.php
  3. 6 0
      app/common/api/VerifyApi.php

+ 18 - 1
app/admin/controller/Talent.php

@@ -1772,10 +1772,16 @@ class Talent extends AdminController {
         $names["checkState"] = "审核状态";
         $names["checkMsg"] = "审核意见";
         $names["verifyDepts"] = "审核部门";
+        $names["deptPass"] = "部门通过";
+        $names["deptReject"] = "部门驳回";
+        $names["deptWait"] = "部门待审";
         $list = VerifyApi::getExportDatas($process, $params);
         if ($process == 4 && in_array($company["code"], ["super", "rsj"])) {
             $fields[] = "verifyDepts";
-            $verifyDeptsColumn = getExcelColumnByIndex(count($fields) - 1);
+            $fields[] = "deptPass";
+            $fields[] = "deptReject";
+            $fields[] = "deptWait";
+            $verifyDeptsColumn = getExcelColumnByIndex(count($fields) - 4);
             $setting["font"][] = [sprintf("%s%d:%s%d", $verifyDeptsColumn, 2, $verifyDeptsColumn, count($list) + 1), 8, "宋体"];
             $setting["width"][] = [$verifyDeptsColumn, 30];
         }
@@ -1787,9 +1793,20 @@ class Talent extends AdminController {
             $data = [];
             for ($n = 0; $n < count($fields); $n++) {
                 $data[] = $list[$i][$fields[$n]];
+                if ($fields[$n] == "deptPass" && $list[$i][$fields[$n]] > 0) {
+                    $setting["color"][] = [sprintf("%s%d", getExcelColumnByIndex($n), $i + 2), "15dd0f"];
+                }
+                if ($fields[$n] == "deptReject" && $list[$i][$fields[$n]] > 0) {
+                    $setting["color"][] = [sprintf("%s%d", getExcelColumnByIndex($n), $i + 2), "ff0000"];
+                }
+                if ($fields[$n] == "deptWait" && $list[$i][$fields[$n]] > 0) {
+                    $setting["color"][] = [sprintf("%s%d", getExcelColumnByIndex($n), $i + 2), "fdcb54"];
+                }
             }
             $datas[] = $data;
         }
+        $setting["freeze"] = "A2";
+        $setting["filter"] = sprintf("A1:%s1", getExcelColumnByIndex(count($columns) - 1));
         if ($datas) {
             export($columns, $datas, "人才审核列表导出", $setting);
             exit();

+ 13 - 2
app/common.php

@@ -128,8 +128,13 @@ function export($columns, $rows, $filename = "jjrcw", $settings = [], $sheetname
     $objPHPExcel->getDefaultRowDimension()->setRowHeight(30); //默认列高
     //样式设置
     $defaultSetting = getCommonExcelSetting($colCount, $rowCount);
-    $settings = $settings ? array_merge($defaultSetting, $settings) : $defaultSetting;
-    foreach ($settings as $type => $cfg) {
+    $mergeSettings = [];
+    foreach ($defaultSetting as $key => $set) {
+        $mergeSettings[$key] = is_array($set) ? array_merge((array) $set, (array) $settings[$key]) : ($settings[$key] ?: $set);
+        unset($settings[$key]);
+    }
+    $mergeSettings = $settings ? array_merge($mergeSettings, $settings) : $mergeSettings;
+    foreach ($mergeSettings as $type => $cfg) {
         switch ($type) {
             case "width":
                 for ($i = 0; $i < count($cfg); $i++) {
@@ -236,6 +241,12 @@ function export($columns, $rows, $filename = "jjrcw", $settings = [], $sheetname
             case "scale":
                 $objPHPExcel->getSheetView()->setZoomScale($cfg ?: 100);
                 break;
+            case "freeze":
+                $objPHPExcel->freezePane($cfg);
+                break;
+            case "filter":
+                $objPHPExcel->setAutoFilter($cfg);
+                break;
         }
     }
 

+ 6 - 0
app/common/api/VerifyApi.php

@@ -881,6 +881,9 @@ class VerifyApi {
             if ($process == 4 && in_array($company_info["code"], ["super", "rsj"])) {
                 $companys = array_filter(explode(",", $item["companyIds"]));
                 $verifyDepts = [];
+                $item["deptReject"] = 0;
+                $item["deptPass"] = 0;
+                $item["deptWait"] = 0;
                 foreach ($companys as $k => $companyId) {
                     $company = getCacheById("Company", $companyId);
                     $log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
@@ -888,12 +891,15 @@ class VerifyApi {
                     if ($log["active"] == 1) {
                         if ($log["new_state"] == 9) {
                             $verifyDepts[$k] .= "(审核驳回)";
+                            $item["deptReject"] ++;
                         }
                         if ($log["new_state"] == 12) {
                             $verifyDepts[$k] .= "(审核通过)";
+                            $item["deptPass"] ++;
                         }
                     } else {
                         $verifyDepts[$k] .= "(待审核)";
+                        $item["deptWait"] ++;
                     }
                 }
                 $item["verifyDepts"] = implode(chr(10), $verifyDepts);