From dada3a6512a4cd0853a8f6d8f98fcb71f315eb5e Mon Sep 17 00:00:00 2001 From: sky121113 Date: Thu, 5 Feb 2026 13:12:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(product):=20=E5=95=86=E5=93=81=E4=BB=A3?= =?UTF-8?q?=E8=99=9F=E5=8A=A0=E5=85=A5=E9=9A=A8=E6=A9=9F=E7=94=A2=E7=94=9F?= =?UTF-8?q?=E6=8C=89=E9=88=95=20(8=E7=A2=BC=E5=A4=A7=E5=AF=AB=E8=8B=B1?= =?UTF-8?q?=E6=95=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/Components/Product/ProductDialog.tsx | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/resources/js/Components/Product/ProductDialog.tsx b/resources/js/Components/Product/ProductDialog.tsx index 1e55fe3..eea361a 100644 --- a/resources/js/Components/Product/ProductDialog.tsx +++ b/resources/js/Components/Product/ProductDialog.tsx @@ -115,6 +115,15 @@ export default function ProductDialog({ setData("barcode", randomDigits.toString()); }; + const generateRandomCode = () => { + const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + let result = ""; + for (let i = 0; i < 8; i++) { + result += chars.charAt(Math.floor(Math.random() * chars.length)); + } + setData("code", result); + }; + return ( @@ -164,14 +173,26 @@ export default function ProductDialog({ - setData("code", e.target.value)} - placeholder="例:A1 (2-8碼)" - maxLength={8} - className={errors.code ? "border-red-500" : ""} - /> +
+ setData("code", e.target.value)} + placeholder="例:A1 (2-8碼)" + maxLength={8} + className={`flex-1 ${errors.code ? "border-red-500" : ""}`} + /> + +
{errors.code &&

{errors.code}

}