feat(inventory): 商品管理新增儲位欄位
This commit is contained in:
@@ -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 碼',
|
||||
|
||||
@@ -26,6 +26,7 @@ class Product extends Model
|
||||
'large_unit_id',
|
||||
'conversion_rate',
|
||||
'purchase_unit_id',
|
||||
'location',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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>
|
||||
|
||||
@@ -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">
|
||||
{/*
|
||||
|
||||
@@ -37,6 +37,7 @@ export interface Product {
|
||||
conversionRate?: number;
|
||||
purchaseUnitId?: number;
|
||||
purchaseUnit?: Unit;
|
||||
location?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user