feat(inventory): 商品管理新增儲位欄位
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 47s

This commit is contained in:
2026-02-03 13:17:46 +08:00
parent a160e3f15f
commit 27626e6aa8
6 changed files with 49 additions and 0 deletions

View File

@@ -95,6 +95,7 @@ class ProductController extends Controller
'name' => $product->purchaseUnit->name,
] : null,
'conversionRate' => (float) $product->conversion_rate,
'location' => $product->location,
];
});
@@ -125,6 +126,7 @@ class ProductController extends Controller
'large_unit_id' => 'nullable|exists:units,id',
'conversion_rate' => 'required_with:large_unit_id|nullable|numeric|min:0.0001',
'purchase_unit_id' => 'nullable|exists:units,id',
'location' => 'nullable|string|max:255',
], [
'code.required' => '商品代號為必填',
'code.max' => '商品代號最多 8 碼',
@@ -163,6 +165,7 @@ class ProductController extends Controller
'large_unit_id' => 'nullable|exists:units,id',
'conversion_rate' => 'required_with:large_unit_id|nullable|numeric|min:0.0001',
'purchase_unit_id' => 'nullable|exists:units,id',
'location' => 'nullable|string|max:255',
], [
'code.required' => '商品代號為必填',
'code.max' => '商品代號最多 8 碼',

View File

@@ -26,6 +26,7 @@ class Product extends Model
'large_unit_id',
'conversion_rate',
'purchase_unit_id',
'location',
];
protected $casts = [

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->string('location')->nullable()->after('specification')->comment('儲位註記');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('location');
});
}
};

View File

@@ -46,6 +46,7 @@ export default function ProductDialog({
large_unit_id: "",
conversion_rate: "",
purchase_unit_id: "",
location: "",
});
useEffect(() => {
@@ -63,6 +64,7 @@ export default function ProductDialog({
large_unit_id: product.largeUnitId?.toString() || "",
conversion_rate: product.conversionRate ? product.conversionRate.toString() : "",
purchase_unit_id: product.purchaseUnitId?.toString() || "",
location: product.location || "",
});
} else {
reset();
@@ -208,6 +210,16 @@ export default function ProductDialog({
/>
{errors.brand && <p className="text-sm text-red-500">{errors.brand}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="location"></Label>
<Input
id="location"
value={data.location}
onChange={(e) => setData("location", e.target.value)}
placeholder="例A-1-1"
/>
{errors.location && <p className="text-sm text-red-500">{errors.location}</p>}
</div>
<div className="space-y-2 col-span-2">
<Label htmlFor="specification"></Label>

View File

@@ -98,6 +98,7 @@ export default function ProductTable({
</TableHead>
<TableHead className="w-[200px]"></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead className="text-center"></TableHead>
</TableRow>
</TableHeader>
@@ -157,6 +158,9 @@ export default function ProductTable({
'-'
)}
</TableCell>
<TableCell>
<span className="text-sm text-gray-600">{product.location || '-'}</span>
</TableCell>
<TableCell className="text-center">
<div className="flex justify-center gap-2">
{/*

View File

@@ -37,6 +37,7 @@ export interface Product {
conversionRate?: number;
purchaseUnitId?: number;
purchaseUnit?: Unit;
location?: string;
createdAt?: string;
updatedAt?: string;
}