feat: [商品管理] 優化商品匯入邏輯,支援 13 碼條碼自動生成、Upsert 更新機制與 Excel 說明工作表
This commit is contained in:
@@ -62,8 +62,11 @@ export default function ProductForm({
|
||||
};
|
||||
|
||||
const generateRandomBarcode = () => {
|
||||
const randomDigits = Math.floor(Math.random() * 9000000000) + 1000000000;
|
||||
setData("barcode", randomDigits.toString());
|
||||
let result = "";
|
||||
for (let i = 0; i < 13; i++) {
|
||||
result += Math.floor(Math.random() * 10).toString();
|
||||
}
|
||||
setData("barcode", result);
|
||||
};
|
||||
|
||||
const generateRandomCode = () => {
|
||||
@@ -150,7 +153,7 @@ export default function ProductForm({
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="barcode">
|
||||
條碼編號 <span className="text-red-500">*</span>
|
||||
條碼編號 <span className="text-gray-400 font-normal">(選填,未填將自動生成)</span>
|
||||
</Label>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
|
||||
@@ -111,9 +111,11 @@ export default function ProductImportDialog({ open, onOpenChange }: ProductImpor
|
||||
<AccordionContent>
|
||||
<div className="text-sm text-gray-600 space-y-2 pb-2 pl-6">
|
||||
<ul className="list-disc space-y-1">
|
||||
<li><span className="font-medium text-gray-700">必填欄位</span>:商品名稱、類別名稱、基本單位、條碼。</li>
|
||||
<li><span className="font-medium text-gray-700">必填欄位</span>:商品名稱、類別名稱、基本單位。</li>
|
||||
<li><span className="font-medium text-gray-700">商品代號</span>:2-8 碼,非必填(未填將自動生成,大寫英文+數字 8 碼)。</li>
|
||||
<li><span className="font-medium text-gray-700">唯一性</span>:商品代號(若有填寫)與條碼不可與現有資料重複。</li>
|
||||
<li><span className="font-medium text-gray-700">條碼</span>:13 碼數字,非必填(未填將自動生成)。</li>
|
||||
<li><span className="font-medium text-gray-700">補充說明</span>:詳細規則亦可於 Excel 範本的<strong>「填寫說明」</strong>工作表中查看。</li>
|
||||
<li><span className="font-medium text-gray-700">更新機制</span>:若系統中已有相同<strong>「條碼」</strong>或<strong>「商品代號」</strong>,系統將自動更新該筆資料,不會重複建立。</li>
|
||||
<li><span className="font-medium text-gray-700">自動關聯</span>:類別與單位請填寫系統當前存在的「名稱」(如:飲品、瓶)。</li>
|
||||
<li><span className="font-medium text-gray-700">大單位</span>:若填寫大單位,則「換算率」為必填(需大於 0)。</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user