Compare commits

...

12 Commits

Author SHA1 Message Date
56e30a85bb refactor: changes to inventory status (approved/unapprove)
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Successful in 1m6s
Koori-ERP-Deploy-System / deploy-production (push) Has been skipped
2026-01-29 13:04:54 +08:00
46753cc3bc fix(auth): 使用 Inertia::location 修復登入後重定向失敗問題
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 49s
2026-01-29 10:25:37 +08:00
7f726e80bd fix(config): 更新 Session Cookie 名稱以強制解決瀏覽器舊 Cookie 衝突
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 44s
2026-01-29 10:18:00 +08:00
8bc95db43d fix(auth): 登出時強制清除 Session Cookie 以解決二次登入問題
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 47s
2026-01-29 10:08:57 +08:00
95a1763d04 fix(framework): 修正 TrustProxies 配置以解決 HTTPS 識別問題
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 42s
2026-01-29 10:04:32 +08:00
90cb7a82de fix(deploy): 恢復 node_modules 排除清單
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 47s
2026-01-29 10:00:04 +08:00
bbb2c4c4a3 style(deploy): 移除多餘空行
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 49s
2026-01-29 09:56:13 +08:00
8cb95e1a56 fix(deploy): 修正正式環境部署漏掉 storage 排除清單導致檔案遺失的問題 2026-01-29 09:51:36 +08:00
fc59c86305 fix(deploy): 確保每次部署後重建 storage 軟連結
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 44s
2026-01-29 09:48:59 +08:00
b613cdb796 chore(docker): 啟動時自動檢查並建立 storage 軟連結
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 49s
2026-01-29 09:45:12 +08:00
b1745555cc feat(tenancy): 租戶初始化流程新增自動補全基本單位資料 2026-01-29 09:38:23 +08:00
1833ca192d feat(inventory): 優化盤點顯示與權限設定 2026-01-29 09:36:07 +08:00
20 changed files with 610 additions and 349 deletions

View File

@@ -247,6 +247,30 @@ tooltip
</Can> </Can>
``` ```
### 3.4 返回按鈕規範
詳情頁面(如:查看庫存、進貨單詳情)的返回按鈕應統一放置於 **頁面標題上方**,並採用「**圖標 + 文字**」的 Outlined 樣式。
**樣式規格**
- **位置**:標題區域上方 (`mb-6`),獨立於標題列
- **樣式**`variant="outline"` + `className="gap-2 button-outlined-primary"`
- **圖標**`<ArrowLeft className="h-4 w-4" />`
- **文字**:清楚說明返回目的地,例如「返回倉庫管理」、「返回列表」
```tsx
<div className="mb-6">
<Link href={route('resource.index')}>
<Button
variant="outline"
className="gap-2 button-outlined-primary"
>
<ArrowLeft className="h-4 w-4" />
返回列表
</Button>
</Link>
</div>
```
--- ---
## 4. 圖標規範 ## 4. 圖標規範

View File

@@ -100,6 +100,7 @@ jobs:
npm run build && npm run build &&
# 3. Laravel 初始化與優化 # 3. Laravel 初始化與優化
php artisan storage:link &&
php artisan migrate --force && php artisan migrate --force &&
php artisan db:seed --force && php artisan db:seed --force &&
php artisan optimize:clear && php artisan optimize:clear &&
@@ -130,6 +131,7 @@ jobs:
--exclude='.env' \ --exclude='.env' \
--exclude='node_modules' \ --exclude='node_modules' \
--exclude='vendor' \ --exclude='vendor' \
--exclude='storage' \
--exclude='public/build' \ --exclude='public/build' \
-e "ssh -p 2224 -i ~/.ssh/id_rsa_prod -o StrictHostKeyChecking=no" \ -e "ssh -p 2224 -i ~/.ssh/id_rsa_prod -o StrictHostKeyChecking=no" \
./ root@erp.koori.tw:/var/www/star-erp/ ./ root@erp.koori.tw:/var/www/star-erp/
@@ -169,7 +171,6 @@ jobs:
script: | script: |
cd /var/www/star-erp cd /var/www/star-erp
chown -R 1000:1000 . chown -R 1000:1000 .
# 檢查是否需要重建 # 檢查是否需要重建
if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -qE '(Dockerfile|compose\.yaml|docker-compose\.yaml)'; then if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -qE '(Dockerfile|compose\.yaml|docker-compose\.yaml)'; then
echo "🔄 偵測到 Docker 相關檔案變更,執行完整重建..." echo "🔄 偵測到 Docker 相關檔案變更,執行完整重建..."
@@ -192,6 +193,7 @@ jobs:
npm install && npm install &&
npm run build npm run build
php artisan storage:link &&
php artisan migrate --force && php artisan migrate --force &&
php artisan optimize:clear && php artisan optimize:clear &&
php artisan optimize && php artisan optimize &&

View File

@@ -7,6 +7,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Inertia\Inertia; use Inertia\Inertia;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Illuminate\Support\Facades\Cookie;
class LoginController extends Controller class LoginController extends Controller
{ {
@@ -44,15 +45,14 @@ class LoginController extends Controller
if (Auth::attempt($credentials, $request->boolean('remember'))) { if (Auth::attempt($credentials, $request->boolean('remember'))) {
$request->session()->regenerate(); $request->session()->regenerate();
$centralDomains = config('tenancy.central_domains', []);
$centralDomains = config('tenancy.central_domains', []); $centralDomains = config('tenancy.central_domains', []);
// [Hack] Demo 環境特殊規則 // [Hack] Demo 環境特殊規則
$demoPort = config('tenancy.demo_tenant_port'); $demoPort = config('tenancy.demo_tenant_port');
if ((!$demoPort || $request->getPort() != $demoPort) && in_array($request->getHost(), $centralDomains)) { if ((!$demoPort || $request->getPort() != $demoPort) && in_array($request->getHost(), $centralDomains)) {
return redirect()->intended(route('landlord.dashboard')); return Inertia::location(route('landlord.dashboard'));
} }
return redirect()->intended(route('dashboard')); return Inertia::location(route('dashboard'));
} }
throw ValidationException::withMessages([ throw ValidationException::withMessages([
@@ -71,6 +71,10 @@ class LoginController extends Controller
$request->session()->regenerateToken(); $request->session()->regenerateToken();
// 強制清除 Session Cookie (對付 HTTPS/Proxy 環境下的殘留問題)
$sessionCookieName = config('session.cookie');
Cookie::queue(Cookie::forget($sessionCookieName));
return redirect('/'); return redirect('/');
} }
} }

View File

@@ -40,7 +40,12 @@ class CountDocController extends Controller
$perPage = 15; $perPage = 15;
} }
$docs = $query->orderByDesc('created_at') $countQuery = function ($query) {
$query->whereNotNull('counted_qty');
};
$docs = $query->withCount(['items', 'items as counted_items_count' => $countQuery])
->orderByDesc('created_at')
->paginate($perPage) ->paginate($perPage)
->withQueryString() ->withQueryString()
->through(function ($doc) { ->through(function ($doc) {
@@ -53,6 +58,8 @@ class CountDocController extends Controller
'completed_at' => $doc->completed_at ? $doc->completed_at->format('Y-m-d H:i') : '-', 'completed_at' => $doc->completed_at ? $doc->completed_at->format('Y-m-d H:i') : '-',
'created_by' => $doc->createdBy?->name, 'created_by' => $doc->createdBy?->name,
'remarks' => $doc->remarks, 'remarks' => $doc->remarks,
'total_items' => $doc->items_count,
'counted_items' => $doc->counted_items_count,
]; ];
}); });
@@ -116,6 +123,39 @@ class CountDocController extends Controller
]); ]);
} }
public function print(InventoryCountDoc $doc)
{
$doc->load(['items.product.baseUnit', 'createdBy', 'completedBy', 'warehouse']);
$docData = [
'id' => (string) $doc->id,
'doc_no' => $doc->doc_no,
'warehouse_name' => $doc->warehouse->name,
'snapshot_date' => $doc->snapshot_date ? $doc->snapshot_date->format('Y-m-d') : date('Y-m-d'), // Use date only
'created_at' => $doc->created_at->format('Y-m-d'),
'print_date' => date('Y-m-d'),
'created_by' => $doc->createdBy?->name,
'items' => $doc->items->map(function ($item) {
return [
'id' => (string) $item->id,
'product_name' => $item->product->name,
'product_code' => $item->product->code,
'specification' => $item->product->specification,
'unit' => $item->product->baseUnit?->name,
'quantity' => (float) ($item->counted_qty ?? $item->system_qty), // Default to system qty if counted is null, or just counted? User wants "Count Sheet" -> maybe blank if not counted?
// Actually, if it's "Completed", we show counted. If it's "Pending", we usually show blank or system.
// The 'Show' page logic suggests we show counted_qty.
'counted_qty' => $item->counted_qty,
'notes' => $item->notes,
];
}),
];
return Inertia::render('Inventory/Count/Print', [
'doc' => $docData,
]);
}
public function update(Request $request, InventoryCountDoc $doc) public function update(Request $request, InventoryCountDoc $doc)
{ {
if ($doc->status === 'completed') { if ($doc->status === 'completed') {
@@ -137,12 +177,29 @@ class CountDocController extends Controller
if ($request->input('action') === 'complete') { if ($request->input('action') === 'complete') {
$this->countService->complete($doc, auth()->id()); $this->countService->complete($doc, auth()->id());
return redirect()->route('inventory.count.index') return redirect()->route('inventory.count.index')
->with('success', '盤點已完成並過帳'); ->with('success', '盤點已完成');
} }
return redirect()->back()->with('success', '暫存成功'); return redirect()->back()->with('success', '暫存成功');
} }
public function reopen(InventoryCountDoc $doc)
{
if ($doc->status !== 'completed') {
return redirect()->back()->with('error', '只有已核准的盤點單可以取消核准');
}
// TODO: Move logic to Service if complex
$doc->update([
'status' => 'counting', // Revert to counting (draft)
'completed_at' => null,
'completed_by' => null,
]);
return redirect()->route('inventory.count.show', [$doc->id])
->with('success', '已取消核准,單據回復為盤點中狀態');
}
public function destroy(InventoryCountDoc $doc) public function destroy(InventoryCountDoc $doc)
{ {
if ($doc->status === 'completed') { if ($doc->status === 'completed') {

View File

@@ -81,7 +81,9 @@ Route::middleware('auth')->group(function () {
Route::post('/inventory/count-docs', [CountDocController::class, 'store'])->name('inventory.count.store'); Route::post('/inventory/count-docs', [CountDocController::class, 'store'])->name('inventory.count.store');
Route::put('/inventory/count-docs/{doc}', [CountDocController::class, 'update'])->name('inventory.count.update'); Route::put('/inventory/count-docs/{doc}', [CountDocController::class, 'update'])->name('inventory.count.update');
Route::delete('/inventory/count-docs/{doc}', [CountDocController::class, 'destroy'])->name('inventory.count.destroy'); Route::delete('/inventory/count-docs/{doc}', [CountDocController::class, 'destroy'])->name('inventory.count.destroy');
Route::put('/inventory/count-docs/{doc}/reopen', [CountDocController::class, 'reopen'])->name('inventory.count.reopen');
}); });
Route::get('/inventory/count-docs/{doc}/print', [CountDocController::class, 'print'])->name('inventory.count.print');
}); });
// 庫存盤調 (Stock Adjustment) - Global // 庫存盤調 (Stock Adjustment) - Global

View File

@@ -75,55 +75,8 @@ class CountService
public function complete(InventoryCountDoc $doc, int $userId): void public function complete(InventoryCountDoc $doc, int $userId): void
{ {
DB::transaction(function () use ($doc, $userId) { DB::transaction(function () use ($doc, $userId) {
foreach ($doc->items as $item) { // 僅更新單據狀態為「已完成」,不執行庫存入庫/調整
// 如果沒有輸入實盤數量,預設跳過或是視為 0? // 盤點單僅作為記錄,後續調整由盤調單 (AdjustDoc) 執行
// 安全起見:如果 counted_qty 是 null表示沒盤到跳過不處理 (或者依業務邏輯視為0)
// 這裡假設前端會確保有送出資料,若 null 則不做異動
if (is_null($item->counted_qty)) {
continue;
}
$diff = $item->counted_qty - $item->system_qty;
// 如果無差異,更新 item 狀態即可 (diff_qty 已經是 computed field 或在儲存時計算)
// 這裡 update 一下 diff_qty 以防萬一
$item->update(['diff_qty' => $diff]);
if (abs($diff) > 0.0001) {
// 找回原本的 Inventory
$inventory = Inventory::where('warehouse_id', $doc->warehouse_id)
->where('product_id', $item->product_id)
->where('batch_number', $item->batch_number)
->first();
if (!$inventory) {
// 如果原本沒庫存紀錄 (例如是新增的盤點項目),需要新建 Inventory
// 但目前 snapshot 邏輯只抓現有。若允許 "盤盈" (發現不在帳上的),需要額外邏輯
// 暫時略過 "新增 Inventory" 的複雜邏輯,假設只能針對 existing batch 調整
continue;
}
$oldQty = $inventory->quantity;
$newQty = $oldQty + $diff;
$inventory->quantity = $newQty;
$inventory->total_value = $inventory->unit_cost * $newQty;
$inventory->save();
// 寫入 Transaction
$inventory->transactions()->create([
'type' => '盤點調整',
'quantity' => $diff,
'unit_cost' => $inventory->unit_cost,
'balance_before' => $oldQty,
'balance_after' => $newQty,
'reason' => "盤點單 {$doc->doc_no} 過帳",
'actual_time' => now(),
'user_id' => $userId,
]);
}
}
$doc->update([ $doc->update([
'status' => 'completed', 'status' => 'completed',
'completed_at' => now(), 'completed_at' => now(),

View File

@@ -8,8 +8,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
use Spatie\Permission\Exceptions\UnauthorizedException; use Spatie\Permission\Exceptions\UnauthorizedException;
use Inertia\Inertia; use Inertia\Inertia;
// 信任所有代理(用於反向代理環境)
TrustProxies::at('*');
return Application::configure(basePath: dirname(__DIR__)) return Application::configure(basePath: dirname(__DIR__))
->withRouting( ->withRouting(
@@ -18,6 +16,9 @@ return Application::configure(basePath: dirname(__DIR__))
health: '/up', health: '/up',
) )
->withMiddleware(function (Middleware $middleware): void { ->withMiddleware(function (Middleware $middleware): void {
// 信任所有代理(用於反向代理環境)
$middleware->trustProxies(at: '*');
// Tenancy 必須最先執行,確保資料庫連線在 Session 讀取之前建立 // Tenancy 必須最先執行,確保資料庫連線在 Session 讀取之前建立
$middleware->web(prepend: [ $middleware->web(prepend: [
\App\Http\Middleware\UniversalTenancy::class, \App\Http\Middleware\UniversalTenancy::class,

View File

@@ -129,7 +129,7 @@ return [
'cookie' => env( 'cookie' => env(
'SESSION_COOKIE', 'SESSION_COOKIE',
Str::slug((string) env('APP_NAME', 'laravel')).'-session' Str::slug((string) env('APP_NAME', 'laravel')).'_v2_session'
), ),
/* /*

View File

@@ -36,7 +36,8 @@ class PermissionSeeder extends Seeder
'inventory.view', 'inventory.view',
'inventory.view_cost', // 查看成本與價值 'inventory.view_cost', // 查看成本與價值
'inventory.adjust', 'inventory.adjust',
'inventory.transfer', 'inventory.count', // 庫存盤點
'inventory.transfer', // 庫存調撥
'inventory.delete', 'inventory.delete',
// 進貨單管理 // 進貨單管理
@@ -132,7 +133,7 @@ class PermissionSeeder extends Seeder
// warehouse-manager 管理庫存與倉庫 // warehouse-manager 管理庫存與倉庫
$warehouseManager->givePermissionTo([ $warehouseManager->givePermissionTo([
'products.view', 'products.view',
'inventory.view', 'inventory.adjust', 'inventory.transfer', 'inventory.delete', 'inventory.view', 'inventory.adjust', 'inventory.count', 'inventory.transfer', 'inventory.delete',
'goods_receipts.view', 'goods_receipts.create', 'goods_receipts.edit', 'goods_receipts.delete', 'goods_receipts.view', 'goods_receipts.create', 'goods_receipts.edit', 'goods_receipts.delete',
'production_orders.view', 'production_orders.create', 'production_orders.edit', 'production_orders.view', 'production_orders.create', 'production_orders.edit',
'warehouses.view', 'warehouses.create', 'warehouses.edit', 'warehouses.view', 'warehouses.create', 'warehouses.edit',

View File

@@ -34,6 +34,9 @@ class TenantDatabaseSeeder extends Seeder
// 呼叫權限 Seeder 設定權限與角色 // 呼叫權限 Seeder 設定權限與角色
$this->call(PermissionSeeder::class); $this->call(PermissionSeeder::class);
// 初始化基本單位資料
$this->call(UnitSeeder::class);
// 確保 admin 擁有 super-admin 角色 // 確保 admin 擁有 super-admin 角色
if (!$admin->hasRole('super-admin')) { if (!$admin->hasRole('super-admin')) {
$admin->assignRole('super-admin'); $admin->assignRole('super-admin');

View File

@@ -15,6 +15,11 @@ fi
chmod -R ugo+rw /.composer chmod -R ugo+rw /.composer
# 確保 storage 軟連結存在
if [ ! -L /var/www/html/public/storage ]; then
php /var/www/html/artisan storage:link
fi
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
if [ "$SUPERVISOR_PHP_USER" = "root" ]; then if [ "$SUPERVISOR_PHP_USER" = "root" ]; then
exec "$@" exec "$@"

View File

@@ -15,6 +15,11 @@ fi
chmod -R ugo+rw /.composer chmod -R ugo+rw /.composer
# 確保 storage 軟連結存在
if [ ! -L /var/www/html/public/storage ]; then
php /var/www/html/artisan storage:link
fi
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
if [ "$SUPERVISOR_PHP_USER" = "root" ]; then if [ "$SUPERVISOR_PHP_USER" = "root" ]; then
exec "$@" exec "$@"

View File

@@ -163,7 +163,7 @@ export default function Index({ docs, warehouses, filters }: { docs: DocsPaginat
<ClipboardCheck className="h-6 w-6 text-primary-main" /> <ClipboardCheck className="h-6 w-6 text-primary-main" />
調 調
</h1> </h1>
<p className="text-sm text-gray-500 mt-1">調 ()</p> <p className="text-gray-500 mt-1">調 ()</p>
</div> </div>
</div> </div>
@@ -392,14 +392,14 @@ export default function Index({ docs, warehouses, filters }: { docs: DocsPaginat
</div> </div>
</div> </div>
<DialogFooter className="bg-gray-50 -mx-6 -mb-6 p-4 rounded-b-lg"> <DialogFooter className="bg-gray-50 -mx-6 -mb-6 p-4 rounded-b-lg gap-2">
<Button variant="ghost" onClick={() => setIsDialogOpen(false)}></Button> <Button variant="outline" className="button-outlined-primary" onClick={() => setIsDialogOpen(false)}></Button>
<Button <Button
className="button-filled-primary" className="button-filled-primary"
disabled={processing || !data.warehouse_id || !data.reason} disabled={processing || !data.warehouse_id || !data.reason}
onClick={() => handleCreate()} onClick={() => handleCreate()}
> >
調
</Button> </Button>
</DialogFooter> </DialogFooter>
</DialogContent> </DialogContent>

View File

@@ -11,12 +11,6 @@ import {
import { Button } from "@/Components/ui/button"; import { Button } from "@/Components/ui/button";
import { Input } from "@/Components/ui/input"; import { Input } from "@/Components/ui/input";
import { Badge } from "@/Components/ui/badge"; import { Badge } from "@/Components/ui/badge";
import {
Card,
CardContent,
CardHeader,
CardTitle,
} from "@/Components/ui/card";
import { import {
AlertDialog, AlertDialog,
AlertDialogAction, AlertDialogAction,
@@ -30,7 +24,7 @@ import {
} from "@/Components/ui/alert-dialog"; } from "@/Components/ui/alert-dialog";
import { Label } from "@/Components/ui/label"; import { Label } from "@/Components/ui/label";
import { Textarea } from "@/Components/ui/textarea"; import { Textarea } from "@/Components/ui/textarea";
import { Save, CheckCircle, Trash2, ArrowLeft, Plus, X, Search, FileText } from "lucide-react"; import { Save, CheckCircle, Trash2, ArrowLeft, Plus, X, Search, FileText, ClipboardCheck } from "lucide-react";
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { import {
Dialog, Dialog,
@@ -79,7 +73,6 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
action: 'save', action: 'save',
}); });
const [newItemOpen, setNewItemOpen] = useState(false);
// Helper to add new item // Helper to add new item
const addItem = (product: any, batchNumber: string | null) => { const addItem = (product: any, batchNumber: string | null) => {
@@ -107,7 +100,6 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
notes: '', notes: '',
} }
]); ]);
setNewItemOpen(false);
}; };
const removeItem = (index: number) => { const removeItem = (index: number) => {
@@ -158,49 +150,61 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
breadcrumbs={[ breadcrumbs={[
{ label: '商品與庫存管理', href: '#' }, { label: '商品與庫存管理', href: '#' },
{ label: '庫存盤調', href: route('inventory.adjust.index') }, { label: '庫存盤調', href: route('inventory.adjust.index') },
{ label: doc.doc_no, href: route('inventory.adjust.show', [doc.id]), isPage: true }, { label: `盤調單: ${doc.doc_no}`, href: route('inventory.adjust.show', [doc.id]), isPage: true },
]} ]}
> >
<Head title={`盤調單 ${doc.doc_no}`} /> <Head title={`盤調單 ${doc.doc_no}`} />
<div className="container mx-auto p-6 max-w-7xl animate-in fade-in duration-500"> <div className="container mx-auto p-6 max-w-7xl animate-in fade-in duration-500 space-y-6">
<div className="space-y-6"> <div>
<Link href={route('inventory.adjust.index')}>
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div className="flex items-center gap-4">
<Button <Button
variant="outline" variant="outline"
size="icon" className="gap-2 button-outlined-primary mb-6"
className="h-10 w-10 border-grey-200"
onClick={() => router.visit(route('inventory.adjust.index'))}
> >
<ArrowLeft className="h-5 w-5 text-grey-600" /> <ArrowLeft className="h-4 w-4" />
調
</Button> </Button>
</Link>
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div> <div>
<h1 className="text-2xl font-bold text-grey-0 flex items-center gap-3"> <div className="flex items-center gap-2">
{doc.doc_no} <h1 className="text-2xl font-bold text-grey-0 flex items-center gap-2">
<ClipboardCheck className="h-6 w-6 text-primary-main" />
調: {doc.doc_no}
</h1>
{isDraft ? ( {isDraft ? (
<Badge variant="secondary" className="bg-gray-100 text-gray-600 border-none">稿</Badge> <Badge variant="secondary" className="bg-gray-100 text-gray-600 border-none">稿</Badge>
) : ( ) : (
<Badge className="bg-green-100 text-green-700 border-none"></Badge> <Badge className="bg-green-100 text-green-700 border-none"></Badge>
)} )}
</h1>
<div className="flex items-center gap-3 mt-1 text-sm text-grey-500">
<span className="flex items-center gap-1"><CheckCircle className="h-3 w-3" /> : {doc.warehouse_name}</span>
<span>|</span>
<span>: {doc.created_by}</span>
<span>|</span>
<span>: {doc.created_at}</span>
</div> </div>
<p className="text-sm text-gray-500 mt-1 font-medium flex items-center gap-2">
: {doc.warehouse_name} <span className="mx-1">|</span>
: {doc.created_by} <span className="mx-1">|</span>
: {doc.created_at}
{doc.count_doc_id && (
<>
<span className="mx-1">|</span>
<Link
href={route('inventory.count.show', [doc.count_doc_id])}
className="flex items-center gap-1 text-primary-main hover:underline"
>
: {doc.count_doc_no}
</Link>
</>
)}
</p>
</div> </div>
</div> <div className="flex items-center gap-2">
<div className="flex items-center gap-3">
{isDraft && ( {isDraft && (
<Can permission="inventory.adjust"> <Can permission="inventory.adjust">
<AlertDialog> <AlertDialog>
<AlertDialogTrigger asChild> <AlertDialogTrigger asChild>
<Button variant="ghost" className="text-red-500 hover:bg-red-50 hover:text-red-600"> <Button variant="outline" size="sm" disabled={processing} className="button-outlined-error">
<Trash2 className="mr-2 h-4 w-4" /> <Trash2 className="w-4 h-4 mr-2" />
</Button> </Button>
</AlertDialogTrigger> </AlertDialogTrigger>
<AlertDialogContent> <AlertDialogContent>
@@ -217,111 +221,94 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>
<Button variant="outline" className="border-primary-200 text-primary-main hover:bg-primary-50" onClick={handleSave} disabled={processing}> <Button
<Save className="mr-2 h-4 w-4" /> variant="outline"
稿 size="sm"
className="button-outlined-primary"
onClick={handleSave}
disabled={processing}
>
<Save className="w-4 h-4 mr-2" />
</Button> </Button>
<Button className="button-filled-primary" onClick={handlePost} disabled={processing}> <Button
<CheckCircle className="mr-2 h-4 w-4" /> size="sm"
className="button-filled-primary"
onClick={handlePost}
disabled={processing}
>
<CheckCircle className="w-4 h-4 mr-2" />
</Button> </Button>
</Can> </Can>
)} )}
</div> </div>
</div> </div>
</div>
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6"> <div className="bg-white rounded-lg shadow-sm border p-6 space-y-4">
<Card className="lg:col-span-2 shadow-sm border-grey-100"> {/* Header Fields - Inline */}
<CardHeader className="bg-grey-50/50 border-b border-grey-100 py-3"> <div className="grid grid-cols-1 md:grid-cols-2 gap-4 pb-2">
<CardTitle className="text-sm font-semibold text-grey-600"></CardTitle> <div className="space-y-1">
</CardHeader>
<CardContent className="pt-6 grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="space-y-2">
<Label className="text-xs font-bold text-grey-500 uppercase tracking-wider">調</Label> <Label className="text-xs font-bold text-grey-500 uppercase tracking-wider">調</Label>
{isDraft ? ( {isDraft ? (
<Input <Input
value={data.reason} value={data.reason}
onChange={e => setData('reason', e.target.value)} onChange={e => setData('reason', e.target.value)}
className="focus:ring-primary-main" className="focus:ring-primary-main h-9"
placeholder="請輸入調整原因..."
/> />
) : ( ) : (
<div className="text-grey-900 font-medium">{data.reason}</div> <div className="text-grey-900 font-medium py-1">{data.reason}</div>
)} )}
</div> </div>
<div className="space-y-2"> <div className="space-y-1">
<Label className="text-xs font-bold text-grey-500 uppercase tracking-wider"></Label> <Label className="text-xs font-bold text-grey-500 uppercase tracking-wider"></Label>
{isDraft ? ( {isDraft ? (
<Textarea <Input
value={data.remarks} value={data.remarks}
onChange={e => setData('remarks', e.target.value)} onChange={e => setData('remarks', e.target.value)}
rows={1} className="focus:ring-primary-main h-9"
className="focus:ring-primary-main" placeholder="選填備註..."
/> />
) : ( ) : (
<div className="text-grey-600">{data.remarks || '-'}</div> <div className="text-grey-600 py-1">{data.remarks || '-'}</div>
)} )}
</div> </div>
</CardContent>
</Card>
<Card className="shadow-sm border-grey-100 bg-primary-50/30">
<CardHeader className="py-3">
<CardTitle className="text-sm font-semibold text-primary-main"></CardTitle>
</CardHeader>
<CardContent className="space-y-3">
<div>
<Label className="text-[10px] font-bold text-primary-main/60 uppercase"></Label>
{doc.count_doc_id ? (
<div className="mt-1">
<Link
href={route('inventory.count.show', [doc.count_doc_id])}
className="text-primary-main font-bold hover:underline flex items-center gap-2"
>
<FileText className="h-4 w-4" />
{doc.count_doc_no || '檢視盤點單'}
</Link>
</div>
) : (
<div className="text-grey-400 italic text-sm mt-1"></div>
)}
</div>
<div className="pt-2 border-t border-primary-100">
<Label className="text-[10px] font-bold text-primary-main/60 uppercase"></Label>
<p className="font-bold text-grey-900">{doc.warehouse_name}</p>
</div>
</CardContent>
</Card>
</div> </div>
<Card className="border border-gray-200 shadow-sm overflow-hidden gap-0"> <div className="border-t pt-4"></div>
<CardHeader className="bg-white border-b flex flex-row items-center justify-between py-4 px-6">
<CardTitle className="text-lg font-medium text-grey-900">調</CardTitle> <div className="flex flex-row items-center justify-between mb-2">
<h3 className="text-lg font-medium text-grey-900">調</h3>
{isDraft && ( {isDraft && (
<ProductSearchDialog <ProductSearchDialog
warehouseId={doc.warehouse_id} warehouseId={doc.warehouse_id}
onSelect={(product, batch) => addItem(product, batch)} onSelect={(product, batch) => addItem(product, batch)}
/> />
)} )}
</CardHeader> </div>
<div className="border rounded-lg overflow-hidden">
<Table> <Table>
<TableHeader className="bg-gray-50"> <TableHeader className="bg-gray-50">
<TableRow> <TableRow>
<TableHead className="w-[60px] text-center font-medium text-grey-600">#</TableHead> <TableHead className="w-[50px] text-center font-medium text-grey-600">#</TableHead>
<TableHead className="pl-4 font-medium text-grey-600"></TableHead> <TableHead className="pl-4 font-medium text-grey-600"></TableHead>
<TableHead className="font-medium text-grey-600"></TableHead> <TableHead className="font-medium text-grey-600"></TableHead>
<TableHead className="w-24 text-center font-medium text-grey-600"></TableHead> <TableHead className="w-24 text-center font-medium text-grey-600"></TableHead>
<TableHead className="w-32 text-right font-medium text-grey-600 text-primary-main">調</TableHead> <TableHead className="w-32 text-right font-medium text-grey-600">調</TableHead>
<TableHead className="w-40 text-right font-medium text-grey-600">調 (+/-)</TableHead> <TableHead className="w-40 text-right font-medium text-grey-600">調 (+/-)</TableHead>
<TableHead className="font-medium text-grey-600"></TableHead> <TableHead className="font-medium text-grey-600"></TableHead>
{isDraft && <TableHead className="w-[80px]"></TableHead>} {isDraft && <TableHead className="w-[50px]"></TableHead>}
</TableRow> </TableRow>
</TableHeader> </TableHeader>
<TableBody> <TableBody>
{data.items.length === 0 ? ( {data.items.length === 0 ? (
<TableRow> <TableRow>
<TableCell colSpan={isDraft ? 8 : 7} className="h-32 text-center text-grey-400"> <TableCell colSpan={isDraft ? 8 : 7} className="h-32 text-center text-grey-400">
調
</TableCell> </TableCell>
</TableRow> </TableRow>
) : ( ) : (
@@ -331,7 +318,7 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
className="group hover:bg-gray-50/50 transition-colors" className="group hover:bg-gray-50/50 transition-colors"
> >
<TableCell className="text-center text-grey-400 font-medium">{index + 1}</TableCell> <TableCell className="text-center text-grey-400 font-medium">{index + 1}</TableCell>
<TableCell className="pl-4"> <TableCell className="pl-4 py-3">
<div className="font-bold text-grey-900">{item.product_name}</div> <div className="font-bold text-grey-900">{item.product_name}</div>
<div className="text-xs text-grey-500 font-mono">{item.product_code}</div> <div className="text-xs text-grey-500 font-mono">{item.product_code}</div>
</TableCell> </TableCell>
@@ -357,10 +344,10 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
<TableCell> <TableCell>
{isDraft ? ( {isDraft ? (
<Input <Input
className="h-9 border-grey-200 focus:ring-primary-main" className="h-9 border-grey-200 focus:ring-primary-main text-sm"
value={item.notes || ''} value={item.notes || ''}
onChange={e => updateItem(index, 'notes', e.target.value)} onChange={e => updateItem(index, 'notes', e.target.value)}
placeholder="輸入備註..." placeholder="備註..."
/> />
) : ( ) : (
<span className="text-grey-600 text-sm">{item.notes || '-'}</span> <span className="text-grey-600 text-sm">{item.notes || '-'}</span>
@@ -383,22 +370,10 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
)} )}
</TableBody> </TableBody>
</Table> </Table>
</Card>
<div className="bg-gray-50/80 border border-dashed border-grey-200 rounded-lg p-4 flex items-start gap-3">
<CheckCircle className="h-5 w-5 text-primary-main mt-0.5 shrink-0" />
<div className="text-xs text-grey-500 leading-relaxed">
<p className="font-bold text-grey-700"></p>
<ul className="list-disc ml-4 space-y-1 mt-1">
<li><strong>調 (+/-)</strong> (+) () (-) ()</li>
<li><strong></strong>調</li>
<li><strong></strong></li>
</ul>
</div> </div>
</div> </div>
</div> </div>
</div>
</AuthenticatedLayout> </AuthenticatedLayout>
); );
} }

View File

@@ -220,11 +220,11 @@ export default function Index({ auth, docs, warehouses, filters }: any) {
</div> </div>
</div> </div>
<DialogFooter> <DialogFooter>
<Button type="button" variant="outline" onClick={() => setIsCreateDialogOpen(false)}> <Button type="button" variant="outline" className="button-outlined-primary" onClick={() => setIsCreateDialogOpen(false)}>
</Button> </Button>
<Button type="submit" className="button-filled-primary" disabled={processing || !data.warehouse_id}> <Button type="submit" className="button-filled-primary" disabled={processing || !data.warehouse_id}>
</Button> </Button>
</DialogFooter> </DialogFooter>
</form> </form>
@@ -244,6 +244,7 @@ export default function Index({ auth, docs, warehouses, filters }: any) {
<TableHead></TableHead> <TableHead></TableHead>
<TableHead></TableHead> <TableHead></TableHead>
<TableHead></TableHead> <TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead> <TableHead></TableHead>
<TableHead></TableHead> <TableHead></TableHead>
<TableHead className="text-center"></TableHead> <TableHead className="text-center"></TableHead>
@@ -252,7 +253,7 @@ export default function Index({ auth, docs, warehouses, filters }: any) {
<TableBody> <TableBody>
{docs.data.length === 0 ? ( {docs.data.length === 0 ? (
<TableRow> <TableRow>
<TableCell colSpan={8} className="text-center h-24 text-gray-500"> <TableCell colSpan={9} className="text-center h-24 text-gray-500">
</TableCell> </TableCell>
</TableRow> </TableRow>
@@ -266,6 +267,11 @@ export default function Index({ auth, docs, warehouses, filters }: any) {
<TableCell>{doc.warehouse_name}</TableCell> <TableCell>{doc.warehouse_name}</TableCell>
<TableCell>{getStatusBadge(doc.status)}</TableCell> <TableCell>{getStatusBadge(doc.status)}</TableCell>
<TableCell className="text-gray-500 text-sm">{doc.snapshot_date}</TableCell> <TableCell className="text-gray-500 text-sm">{doc.snapshot_date}</TableCell>
<TableCell>
<span className="font-medium text-gray-700">{doc.counted_items}</span>
<span className="text-gray-400 mx-1">/</span>
<span className="text-gray-500">{doc.total_items}</span>
</TableCell>
<TableCell className="text-gray-500 text-sm">{doc.completed_at || '-'}</TableCell> <TableCell className="text-gray-500 text-sm">{doc.completed_at || '-'}</TableCell>
<TableCell className="text-sm">{doc.created_by}</TableCell> <TableCell className="text-sm">{doc.created_by}</TableCell>
<TableCell className="text-center"> <TableCell className="text-center">
@@ -279,11 +285,10 @@ export default function Index({ auth, docs, warehouses, filters }: any) {
title={doc.status === 'completed' ? '查閱' : '盤點'} title={doc.status === 'completed' ? '查閱' : '盤點'}
> >
{doc.status === 'completed' ? ( {doc.status === 'completed' ? (
<Eye className="w-4 h-4 mr-1" /> <Eye className="w-4 h-4" />
) : ( ) : (
<Pencil className="w-4 h-4 mr-1" /> <Pencil className="w-4 h-4" />
)} )}
{doc.status === 'completed' ? '查閱' : '盤點'}
</Button> </Button>
</Link> </Link>
</Can> </Can>

View File

@@ -0,0 +1,166 @@
import { useEffect, useRef } from 'react';
import { Head } from '@inertiajs/react';
import JsBarcode from 'jsbarcode';
interface PrintProps {
doc: {
doc_no: string;
warehouse_name: string;
snapshot_date: string;
created_at: string;
print_date: string;
created_by: string;
items: Array<{
id: string;
product_name: string;
product_code: string;
specification: string;
unit: string;
quantity: number;
counted_qty: number | null;
notes: string;
}>;
};
}
export default function Print({ doc }: PrintProps) {
const barcodeRef = useRef<SVGSVGElement>(null);
useEffect(() => {
if (barcodeRef.current) {
try {
JsBarcode(barcodeRef.current, doc.doc_no, {
format: "CODE128",
width: 2, // Thicker bars for better scanning
height: 50, // Taller
displayValue: false,
margin: 10, // Mandatory quiet zone for scanners
marginBottom: 5
});
} catch (e) {
console.error("Barcode generation failed", e);
}
}
// Delay print slightly to ensure render
const timer = setTimeout(() => {
window.print();
}, 500);
return () => clearTimeout(timer);
}, [doc.doc_no]);
return (
<div className="bg-white text-black font-sans text-sm min-h-screen">
<Head title={`列印盤點單 ${doc.doc_no}`} />
<style>{`
@media print {
@page {
size: A4 landscape;
margin: 10mm;
}
body {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
/* Hide browser default header/footer if possible (browser dependent) */
}
`}</style>
{/* Header Section */}
<div className="relative mb-6">
{/* Barcode - Top Right */}
<div className="absolute top-0 right-0 flex flex-col items-end">
<svg ref={barcodeRef}></svg>
{/* <span className="text-xs font-mono mt-1">{doc.doc_no}</span> */}
</div>
{/* Company & Title - Center */}
<div className="text-center pt-4">
<h1 className="text-2xl font-bold tracking-widest mb-2"></h1>
<h2 className="text-xl font-bold tracking-widest"></h2>
</div>
</div>
{/* Info Section */}
<div className="flex justify-between items-end mb-2 border-b-2 border-black pb-2">
<div className="space-y-1">
<div className="flex gap-4">
<span className="font-bold"></span>
<span className="font-mono font-bold">{doc.doc_no}</span>
</div>
<div className="flex gap-4">
<span className="font-bold"></span>
<span>{doc.created_at}</span>
</div>
<div className="flex gap-4">
<span className="font-bold"></span>
<span>{doc.warehouse_name}</span>
</div>
</div>
<div className="text-right">
<div className="flex gap-4">
<span className="font-bold"></span>
<span>{doc.print_date}</span>
</div>
</div>
</div>
{/* Table Section */}
<table className="w-full border-collapse border border-black mb-8">
<thead>
<tr className="bg-gray-100">
<th className="border border-black px-2 py-1 w-12 text-center"></th>
<th className="border border-black px-2 py-1 w-32 text-left"></th>
<th className="border border-black px-2 py-1 text-left"></th>
<th className="border border-black px-2 py-1 w-32 text-left"></th>
<th className="border border-black px-2 py-1 w-20 text-right"></th>
<th className="border border-black px-2 py-1 w-16 text-center"></th>
<th className="border border-black px-2 py-1 w-32 text-left"></th>
</tr>
</thead>
<tbody>
{doc.items.map((item, index) => (
<tr key={item.id}>
<td className="border border-black px-2 py-2 text-center">{index + 1}</td>
<td className="border border-black px-2 py-2 font-mono">{item.product_code}</td>
<td className="border border-black px-2 py-2">{item.product_name}</td>
<td className="border border-black px-2 py-2">{item.specification || '-'}</td>
<td className="border border-black px-2 py-2 text-right">
{item.counted_qty !== null ? Number(item.counted_qty).toFixed(2) : ''}
</td>
<td className="border border-black px-2 py-2 text-center">{item.unit || '-'}</td>
<td className="border border-black px-2 py-2">{item.notes}</td>
</tr>
))}
{/* Empty rows filler if needed, but usually not required unless strictly paging */}
</tbody>
</table>
{/* Footer Section */}
<div className="fixed bottom-0 w-full mb-4">
<div className="flex justify-between items-end px-4">
<div className="w-1/3 border-b border-black pb-1 mb-1">
<span className="font-bold"></span>
<span className="ml-2">{doc.created_by}</span>
</div>
<div className="w-1/3 border-b border-black pb-1 mb-1 mx-4">
<span className="font-bold"></span>
</div>
<div className="w-1/3 border-b border-black pb-1 mb-1">
<span className="font-bold"></span>
</div>
</div>
<div className="flex justify-between items-center text-xs mt-4 px-4">
<div>
&nbsp;&nbsp; {doc.created_by}
</div>
<div>
1 / 1
</div>
</div>
</div>
</div>
);
}

View File

@@ -1,5 +1,5 @@
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'; import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
import { Head, useForm } from '@inertiajs/react'; import { Head, useForm, Link } from '@inertiajs/react'; // Added Link
import { import {
Table, Table,
TableBody, TableBody,
@@ -10,9 +10,8 @@ import {
} from '@/Components/ui/table'; } from '@/Components/ui/table';
import { Button } from '@/Components/ui/button'; import { Button } from '@/Components/ui/button';
import { Input } from '@/Components/ui/input'; import { Input } from '@/Components/ui/input';
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/Components/ui/card';
import { Badge } from '@/Components/ui/badge'; import { Badge } from '@/Components/ui/badge';
import { Save, CheckCircle, Printer, Trash2, ClipboardCheck, Eye, Pencil } from 'lucide-react'; import { Save, CheckCircle, Printer, Trash2, ClipboardCheck, ArrowLeft, RotateCcw } from 'lucide-react'; // Added ArrowLeft
import { import {
AlertDialog, AlertDialog,
AlertDialogAction, AlertDialogAction,
@@ -25,11 +24,10 @@ import {
AlertDialogTrigger, AlertDialogTrigger,
} from "@/Components/ui/alert-dialog" } from "@/Components/ui/alert-dialog"
import { Can } from '@/Components/Permission/Can'; import { Can } from '@/Components/Permission/Can';
import { Link } from '@inertiajs/react';
export default function Show({ doc }: any) { export default function Show({ doc }: any) {
// Transform items to form data structure // Transform items to form data structure
const { data, setData, put, delete: destroy, processing } = useForm({ const { data, setData, put, delete: destroy, processing, transform } = useForm({
items: doc.items.map((item: any) => ({ items: doc.items.map((item: any) => ({
id: item.id, id: item.id,
counted_qty: item.counted_qty, counted_qty: item.counted_qty,
@@ -46,18 +44,25 @@ export default function Show({ doc }: any) {
}; };
const handleSubmit = (action: string) => { const handleSubmit = (action: string) => {
setData('action', action); transform((data) => ({
put(route('inventory.count.update', [doc.id]), { ...data,
onSuccess: () => { action: action,
// Handle success if needed }));
} put(route('inventory.count.update', [doc.id]));
});
}; };
const handleDelete = () => { const handleDelete = () => {
destroy(route('inventory.count.destroy', [doc.id])); destroy(route('inventory.count.destroy', [doc.id]));
}; };
const handleReopen = () => {
if (confirm('確定要取消核准嗎?單據將回復為盤點中狀態,且庫存異動將被撤回(若已過帳)。')) {
router.visit(route('inventory.count.reopen', [doc.id]), {
method: 'put',
});
}
}
const isCompleted = doc.status === 'completed'; const isCompleted = doc.status === 'completed';
// Calculate progress // Calculate progress
@@ -75,9 +80,19 @@ export default function Show({ doc }: any) {
> >
<Head title={`盤點單 ${doc.doc_no}`} /> <Head title={`盤點單 ${doc.doc_no}`} />
<div className="container mx-auto p-6 max-w-7xl"> <div className="container mx-auto p-6 max-w-7xl animate-in fade-in duration-500 space-y-6">
<div className="flex items-center justify-between mb-6"> <div>
<div className="flex items-center gap-4"> <Link href={route('inventory.count.index')}>
<Button
variant="outline"
className="gap-2 button-outlined-primary mb-6"
>
<ArrowLeft className="h-4 w-4" />
</Button>
</Link>
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div> <div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<h1 className="text-2xl font-bold text-grey-0 flex items-center gap-2"> <h1 className="text-2xl font-bold text-grey-0 flex items-center gap-2">
@@ -85,17 +100,42 @@ export default function Show({ doc }: any) {
: {doc.doc_no} : {doc.doc_no}
</h1> </h1>
{doc.status === 'completed' ? ( {doc.status === 'completed' ? (
<Badge className="bg-green-500 hover:bg-green-600"></Badge> <Badge className="bg-green-500 hover:bg-green-600"></Badge>
) : ( ) : (
<Badge className="bg-blue-500 hover:bg-blue-600"></Badge> <Badge className="bg-blue-500 hover:bg-blue-600"></Badge>
)} )}
</div> </div>
<p className="text-sm text-gray-500 mt-1"> <p className="text-sm text-gray-500 mt-1 font-medium">
: {doc.warehouse_name} | : {doc.created_by} | : {doc.snapshot_date} : {doc.warehouse_name} <span className="mx-2">|</span> : {doc.created_by} <span className="mx-2">|</span> : {doc.snapshot_date}
</p> </p>
</div> </div>
</div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Button
variant="outline"
size="sm"
className="button-outlined-primary"
onClick={() => window.open(route('inventory.count.print', [doc.id]), '_blank')}
>
<Printer className="w-4 h-4 mr-2" />
</Button>
{isCompleted && (
<Can permission="inventory.adjust">
<Button
variant="outline"
size="sm"
className="button-outlined-error"
onClick={handleReopen}
disabled={processing}
>
<RotateCcw className="w-4 h-4 mr-2" />
</Button>
</Can>
)}
{!isCompleted && ( {!isCompleted && (
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Can permission="inventory.view"> <Can permission="inventory.view">
@@ -103,7 +143,7 @@ export default function Show({ doc }: any) {
<AlertDialogTrigger asChild> <AlertDialogTrigger asChild>
<Button variant="outline" size="sm" disabled={processing} className="button-outlined-error"> <Button variant="outline" size="sm" disabled={processing} className="button-outlined-error">
<Trash2 className="w-4 h-4 mr-2" /> <Trash2 className="w-4 h-4 mr-2" />
</Button> </Button>
</AlertDialogTrigger> </AlertDialogTrigger>
<AlertDialogContent> <AlertDialogContent>
@@ -128,7 +168,7 @@ export default function Show({ doc }: any) {
disabled={processing} disabled={processing}
> >
<Save className="w-4 h-4 mr-2" /> <Save className="w-4 h-4 mr-2" />
</Button> </Button>
<Button <Button
size="sm" size="sm"
@@ -137,53 +177,50 @@ export default function Show({ doc }: any) {
disabled={processing} disabled={processing}
> >
<CheckCircle className="w-4 h-4 mr-2" /> <CheckCircle className="w-4 h-4 mr-2" />
</Button> </Button>
</Can> </Can>
</div> </div>
)} )}
{isCompleted && ( </div>
<Button variant="outline" size="sm" onClick={() => window.print()}>
<Printer className="w-4 h-4 mr-2" />
</Button>
)}
</div> </div>
</div> </div>
<div className="max-w-7xl mx-auto space-y-6">
{!isCompleted && ( {!isCompleted && (
<Card className="border-none shadow-sm overflow-hidden"> <div className="bg-white rounded-lg shadow-sm border p-6 space-y-4">
<CardContent className="py-4"> <div className="flex items-center justify-between text-sm">
<div className="flex items-center justify-between text-sm mb-2"> <span className="text-gray-500 font-medium">: {countedItems} / {totalItems} </span>
<span className="text-gray-500">: {countedItems} / {totalItems} </span> <span className="font-bold text-primary-main">{progress}%</span>
<span className="font-semibold text-primary-main">{progress}%</span>
</div> </div>
<div className="w-full bg-gray-200 rounded-full h-2"> <div className="w-full bg-gray-200 rounded-full h-2">
<div className="bg-primary-main h-2 rounded-full transition-all duration-300" style={{ width: `${progress}%` }}></div> <div className="bg-primary-main h-2 rounded-full transition-all duration-300" style={{ width: `${progress}%` }}></div>
</div> </div>
</CardContent> </div>
</Card>
)} )}
<Card className="border border-gray-200 shadow-sm overflow-hidden gap-0"> <div className="bg-white rounded-lg shadow-sm border p-6 space-y-4">
<CardHeader className="bg-white border-b px-6 py-4"> <div className="flex items-center justify-between">
<CardTitle className="text-lg font-medium"></CardTitle> <div>
<CardDescription> <h3 className="font-semibold text-lg text-grey-900"></h3>
<p className="text-sm text-grey-500">
</CardDescription> </p>
</CardHeader> </div>
</div>
<div className="border rounded-lg overflow-hidden">
<Table> <Table>
<TableHeader className="bg-gray-50"> <TableHeader className="bg-gray-50">
<TableRow> <TableRow>
<TableHead className="w-[50px] text-center">#</TableHead> <TableHead className="w-[50px] text-center font-medium text-grey-600">#</TableHead>
<TableHead> / </TableHead> <TableHead className="font-medium text-grey-600"> / </TableHead>
<TableHead></TableHead> <TableHead className="font-medium text-grey-600"></TableHead>
<TableHead className="text-right"></TableHead> <TableHead className="text-right font-medium text-grey-600"></TableHead>
<TableHead className="text-right w-32"></TableHead> <TableHead className="text-right w-32 font-medium text-grey-600"></TableHead>
<TableHead className="text-right"></TableHead> <TableHead className="text-right font-medium text-grey-600"></TableHead>
<TableHead></TableHead> <TableHead className="font-medium text-grey-600"></TableHead>
<TableHead></TableHead> <TableHead className="font-medium text-grey-600"></TableHead>
{!isCompleted && <TableHead className="w-[50px]"></TableHead>}
</TableRow> </TableRow>
</TableHeader> </TableHeader>
<TableBody> <TableBody>
@@ -199,17 +236,17 @@ export default function Show({ doc }: any) {
<TableCell className="text-gray-500 font-medium text-center"> <TableCell className="text-gray-500 font-medium text-center">
{index + 1} {index + 1}
</TableCell> </TableCell>
<TableCell> <TableCell className="py-3">
<div className="flex flex-col"> <div className="flex flex-col">
<span className="font-medium text-gray-900">{item.product_code}</span> <span className="font-semibold text-gray-900">{item.product_name}</span>
<span className="text-xs text-gray-500">{item.product_name}</span> <span className="text-xs text-gray-500 font-mono">{item.product_code}</span>
</div> </div>
</TableCell> </TableCell>
<TableCell className="text-sm font-mono">{item.batch_number || '-'}</TableCell> <TableCell className="text-sm font-mono">{item.batch_number || '-'}</TableCell>
<TableCell className="text-right font-medium">{item.system_qty.toFixed(2)}</TableCell> <TableCell className="text-right font-medium">{item.system_qty.toFixed(2)}</TableCell>
<TableCell className="text-right px-1"> <TableCell className="text-right px-1 py-3">
{isCompleted ? ( {isCompleted ? (
<span className="font-medium mr-2">{item.counted_qty}</span> <span className="font-semibold mr-2">{item.counted_qty}</span>
) : ( ) : (
<Input <Input
type="number" type="number"
@@ -249,27 +286,33 @@ export default function Show({ doc }: any) {
/> />
)} )}
</TableCell> </TableCell>
{!isCompleted && (
<TableCell className="text-center">
<Button
variant="ghost"
size="sm"
className="h-8 w-8 text-red-400 hover:text-red-600 hover:bg-red-50 p-0"
onClick={() => {
updateItem(index, 'counted_qty', '');
}}
>
<Trash2 className="h-4 w-4" />
</Button>
</TableCell>
)
}
</TableRow> </TableRow>
); );
})} })}
</TableBody> </TableBody>
</Table> </Table>
</Card> </div>
</div>
<div className="bg-gray-50/80 border border-dashed border-grey-200 rounded-lg p-4 flex items-start gap-3">
<div className="bg-blue-100 p-2 rounded-lg">
<Save className="w-5 h-5 text-blue-600" />
</div>
<div>
<h4 className="font-semibold text-gray-900 mb-1 text-sm"></h4>
<p className="text-xs text-gray-500 leading-relaxed">
調
</p>
</div>
</div>
</div>
</div> </div>
</AuthenticatedLayout > </AuthenticatedLayout >
); );
} }

View File

@@ -184,10 +184,10 @@ export default function Index({ auth, orders, warehouses, filters }) {
</div> </div>
</div> </div>
<DialogFooter> <DialogFooter>
<Button variant="outline" onClick={() => setIsCreateOpen(false)}></Button> <Button variant="outline" className="button-outlined-primary" onClick={() => setIsCreateOpen(false)}></Button>
<Button onClick={handleCreate} disabled={creating || !sourceWarehouseId || !targetWarehouseId}> <Button onClick={handleCreate} className="button-filled-primary" disabled={creating || !sourceWarehouseId || !targetWarehouseId}>
{creating && <Loader2 className="mr-2 h-4 w-4 animate-spin" />} {creating && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
稿
</Button> </Button>
</DialogFooter> </DialogFooter>
</DialogContent> </DialogContent>

View File

@@ -1,7 +1,7 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout"; import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
import { Head, router, usePage } from "@inertiajs/react"; import { Head, router, usePage, Link } from "@inertiajs/react";
import { Button } from "@/Components/ui/button"; import { Button } from "@/Components/ui/button";
import { Input } from "@/Components/ui/input"; import { Input } from "@/Components/ui/input";
import { Label } from "@/Components/ui/label"; import { Label } from "@/Components/ui/label";
@@ -132,10 +132,28 @@ export default function Show({ auth, order }) {
return ( return (
<AuthenticatedLayout <AuthenticatedLayout
user={auth.user} user={auth.user}
header={ breadcrumbs={[
{ label: '首頁', href: '/' },
{ label: '庫存調撥', href: route('inventory.transfer.index') },
{ label: order.doc_no, href: route('inventory.transfer.show', [order.id]) },
]}
>
<Head title={`調撥單 ${order.doc_no}`} />
<div className="container mx-auto p-6 max-w-7xl">
<div className="mb-6">
<Link href={route('inventory.transfer.index')}>
<Button
variant="outline"
className="gap-2 button-outlined-primary mb-6"
>
<ArrowLeft className="h-4 w-4" />
調
</Button>
</Link>
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">
<h2 className="font-semibold text-xl text-gray-800 leading-tight flex items-center gap-2"> <h2 className="font-bold text-2xl text-gray-800 leading-tight flex items-center gap-2">
<ArrowLeft className="h-5 w-5 cursor-pointer" onClick={() => router.visit(route('inventory.transfer.index'))} />
調 ({order.doc_no}) 調 ({order.doc_no})
</h2> </h2>
<div className="flex gap-2"> <div className="flex gap-2">
@@ -157,17 +175,9 @@ export default function Show({ auth, order }) {
)} )}
</div> </div>
</div> </div>
} </div>
breadcrumbs={[
{ label: '首頁', href: '/' },
{ label: '庫存調撥', href: route('inventory.transfer.index') },
{ label: order.doc_no, href: route('inventory.transfer.show', [order.id]) },
]}
>
<Head title={`調撥單 ${order.doc_no}`} />
<div className="py-12"> <div className="space-y-6">
<div className="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
{/* Header Info */} {/* Header Info */}
<div className="bg-white p-6 rounded-lg shadow-sm border border-gray-100 grid grid-cols-1 md:grid-cols-4 gap-6"> <div className="bg-white p-6 rounded-lg shadow-sm border border-gray-100 grid grid-cols-1 md:grid-cols-4 gap-6">
<div> <div>

5
resources/js/ziggy.js Normal file

File diff suppressed because one or more lines are too long