From 27626e6aa8cf35a800d2719fb4c60202857277b1 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Tue, 3 Feb 2026 13:17:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(inventory):=20=E5=95=86=E5=93=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=96=B0=E5=A2=9E=E5=84=B2=E4=BD=8D=E6=AC=84=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ProductController.php | 3 ++ app/Modules/Inventory/Models/Product.php | 1 + ..._131000_add_location_to_products_table.php | 28 +++++++++++++++++++ .../js/Components/Product/ProductDialog.tsx | 12 ++++++++ .../js/Components/Product/ProductTable.tsx | 4 +++ resources/js/Pages/Product/Index.tsx | 1 + 6 files changed, 49 insertions(+) create mode 100644 database/migrations/tenant/2026_02_03_131000_add_location_to_products_table.php diff --git a/app/Modules/Inventory/Controllers/ProductController.php b/app/Modules/Inventory/Controllers/ProductController.php index ee67217..f47a65e 100644 --- a/app/Modules/Inventory/Controllers/ProductController.php +++ b/app/Modules/Inventory/Controllers/ProductController.php @@ -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 碼', diff --git a/app/Modules/Inventory/Models/Product.php b/app/Modules/Inventory/Models/Product.php index 03b364d..ae42392 100644 --- a/app/Modules/Inventory/Models/Product.php +++ b/app/Modules/Inventory/Models/Product.php @@ -26,6 +26,7 @@ class Product extends Model 'large_unit_id', 'conversion_rate', 'purchase_unit_id', + 'location', ]; protected $casts = [ diff --git a/database/migrations/tenant/2026_02_03_131000_add_location_to_products_table.php b/database/migrations/tenant/2026_02_03_131000_add_location_to_products_table.php new file mode 100644 index 0000000..0a06193 --- /dev/null +++ b/database/migrations/tenant/2026_02_03_131000_add_location_to_products_table.php @@ -0,0 +1,28 @@ +string('location')->nullable()->after('specification')->comment('儲位註記'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('products', function (Blueprint $table) { + $table->dropColumn('location'); + }); + } +}; diff --git a/resources/js/Components/Product/ProductDialog.tsx b/resources/js/Components/Product/ProductDialog.tsx index cad6e70..550c6ca 100644 --- a/resources/js/Components/Product/ProductDialog.tsx +++ b/resources/js/Components/Product/ProductDialog.tsx @@ -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 &&

{errors.brand}

} +
+ + setData("location", e.target.value)} + placeholder="例:A-1-1" + /> + {errors.location &&

{errors.location}

} +
diff --git a/resources/js/Components/Product/ProductTable.tsx b/resources/js/Components/Product/ProductTable.tsx index a5b6e9b..d40bec5 100644 --- a/resources/js/Components/Product/ProductTable.tsx +++ b/resources/js/Components/Product/ProductTable.tsx @@ -98,6 +98,7 @@ export default function ProductTable({ 規格 換算率 + 儲位 操作 @@ -157,6 +158,9 @@ export default function ProductTable({ '-' )} + + {product.location || '-'} +
{/* diff --git a/resources/js/Pages/Product/Index.tsx b/resources/js/Pages/Product/Index.tsx index 7e74e4b..a0d49d6 100644 --- a/resources/js/Pages/Product/Index.tsx +++ b/resources/js/Pages/Product/Index.tsx @@ -37,6 +37,7 @@ export interface Product { conversionRate?: number; purchaseUnitId?: number; purchaseUnit?: Unit; + location?: string; createdAt?: string; updatedAt?: string; }