dream 5 lat temu
rodzic
commit
bf19021284
2 zmienionych plików z 9 dodań i 14 usunięć
  1. 8 13
      app/Exports/Export.php
  2. 1 1
      app/Services/WaybillService.php

+ 8 - 13
app/Exports/Export.php

@@ -17,18 +17,20 @@ class Export extends StringValueBinder implements FromCollection,
     private $data;
     private $mergeCell;
     private $columnName;
+    private $formatNumber;
 
     /*
      * $mergeCell $columnName :合并单元格所需参数;
      * $mergeCell 需要合并的位置数组以MAP形式存储 [开始行=>结束行]
      * $columnName 需要合并列 与合并行数结合使用ARRAY存储 ['A','B']
      */
-    public function __construct($row,$data,$mergeCell=null,$columnName=null)
+    public function __construct($row,$data,$mergeCell=null,$columnName=null,$formatNumber=['D','H','I','L','O','Q','S','T','U','V'])
     {
         $this->row = $row;
         $this->data = $data;
         $this->mergeCell = $mergeCell;
         $this->columnName = $columnName;
+        $this->formatNumber = $formatNumber;
     }
 
     public function collection()
@@ -70,18 +72,11 @@ class Export extends StringValueBinder implements FromCollection,
     }
 
     public function columnFormats(): array{
-        return [
-            'D' => NumberFormat::FORMAT_TEXT,
-            'H' => NumberFormat::FORMAT_TEXT,
-            'I' => NumberFormat::FORMAT_TEXT,
-            'L' => NumberFormat::FORMAT_TEXT,
-            'O' => NumberFormat::FORMAT_TEXT,
-            'Q' => NumberFormat::FORMAT_TEXT,
-            'S' => NumberFormat::FORMAT_TEXT,
-            'T' => NumberFormat::FORMAT_TEXT,
-            'U' => NumberFormat::FORMAT_TEXT,
-            'V' => NumberFormat::FORMAT_TEXT,
-        ];
+        $formatNumber = [];
+        foreach ($this->formatNumber as $column){
+            $formatNumber[$column] = NumberFormat::FORMAT_TEXT;
+        }
+        return $formatNumber;
     }
 }
 

+ 1 - 1
app/Services/WaybillService.php

@@ -52,7 +52,7 @@ Class WaybillService
             ->whereNull('waybill_on_tops.deleted_at')
             ->orderBy('waybill_on_tops.updated_at','desc')
             ->orderBy('waybills.id','desc')
-            ->whereIn('id',explode(',',$request->data))
+            ->whereIn('waybills.id',explode(',',$request->data))
             ->get();
     }