80 lines
2.5 KiB
PHP
80 lines
2.5 KiB
PHP
<?php
|
||
|
||
namespace App\Modules\Inventory\Exports;
|
||
|
||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||
use Maatwebsite\Excel\Concerns\FromArray;
|
||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||
|
||
class InventoryTemplateExport implements WithMultipleSheets
|
||
{
|
||
public function sheets(): array
|
||
{
|
||
return [
|
||
new InventoryDataSheet(),
|
||
new InventoryInstructionSheet(),
|
||
];
|
||
}
|
||
}
|
||
|
||
class InventoryDataSheet implements FromArray, WithHeadings, WithTitle, ShouldAutoSize
|
||
{
|
||
public function array(): array
|
||
{
|
||
// 資料分頁保持完全空白
|
||
return [];
|
||
}
|
||
|
||
public function headings(): array
|
||
{
|
||
return [
|
||
'商品條碼',
|
||
'商品代號',
|
||
'商品名稱',
|
||
'數量',
|
||
'入庫單價',
|
||
'批號',
|
||
'產地',
|
||
'效期',
|
||
];
|
||
}
|
||
|
||
public function title(): string
|
||
{
|
||
return '資料填寫';
|
||
}
|
||
}
|
||
|
||
class InventoryInstructionSheet implements FromArray, WithHeadings, WithTitle, ShouldAutoSize
|
||
{
|
||
public function array(): array
|
||
{
|
||
return [
|
||
['商品條碼', '擇一輸入', '系統會「優先」依據條碼匹配商品。若有填寫,條碼必須存在於系統中'],
|
||
['商品代號', '擇一輸入', '若條碼未填寫,系統會依據代號匹配商品'],
|
||
['商品名稱', '選填', '僅供對照參考,匯入時系統會自動忽略此欄位內容'],
|
||
['數量', '必填', '入庫的商品數量,須為大於 0 的數字'],
|
||
['入庫單價', '選填', '未填寫時將預設使用商品的「採購成本價」'],
|
||
['批號', '選填', '如需批次控管請填寫,若留空系統會自動標記為 "NO-BATCH"'],
|
||
['產地', '選填', '商品的生產地資訊 (如:TW)'],
|
||
['效期', '選填', '格式請務必使用 YYYY-MM-DD (例如: 2026-12-31)'],
|
||
['', '', ''],
|
||
['匹配規則說明', '', '1. 系統會優先比對「商品條碼」。'],
|
||
['', '', '2. 若條碼欄位為空,則嘗試比對「商品代號」。'],
|
||
['', '', '3. 若上述兩者皆無法匹配到既有商品,該列資料將匯入失敗。'],
|
||
];
|
||
}
|
||
|
||
public function headings(): array
|
||
{
|
||
return ['欄位名稱', '必要性', '填寫說明'];
|
||
}
|
||
|
||
public function title(): string
|
||
{
|
||
return '填寫規則';
|
||
}
|
||
}
|