+ {/* سربرگ قلم */}
+
+
+
+ {faNum(idx + 1)}
+
+
+ {it.cat || "قلم جدید"} {it.brand ? `• ${it.brand}` : ""}
+
+
+ {items.length > 1 && (
+
+ )}
+
+
+ {/* ردیف ۱: متریال و برند */}
+
+
+
+ patch(it.tempId, { cat: x.label })}
+ items={allMaterialNames}
+ allowAdd
+ addSuffix="به عنوان متریال جدید"
+ placeholder="نام متریال"
+ onInputChange={(v) => patch(it.tempId, { cat: v })}
+ onBlur={() => rememberField("i-cat", it)}
+ inputClassName="!text-xs !h-9 text-right"
+ className="min-w-0"
+ />
+
+
+
+
+ patch(it.tempId, { brand: x.label })}
+ items={materialOptions(materials, selectedTopic, it, "brand", items, brandOptions)}
+ allowAdd
+ addSuffix="به عنوان برند جدید"
+ placeholder="برند"
+ onInputChange={(v) => patch(it.tempId, { brand: v })}
+ onBlur={() => rememberField("i-brand", it)}
+ inputClassName="!text-xs !h-9 text-right"
+ className="min-w-0"
+ />
+
+
+
+ {/* ردیف ۲: مشخصه فنی */}
+
+
+ patch(it.tempId, { specs })}
+ options={materialOptions(materials, selectedTopic, it, "spec", items, [], specOptions)}
+ placeholder="انتخاب مشخصات (مثلاً ضخامت، رنگ، تیپ...)"
+ className="min-w-0"
+ />
+
+
+ {/* بخش مقادیر و محاسبات مالی */}
+
+ {/* ردیف ۳: تعداد + واحد سنجش */}
+
+
+
+ {
+ patch(it.tempId, {
+ qty,
+ total: qty != null && it.price != null ? Math.round(qty * it.price) : it.total,
+ });
+ }}
+ placeholder="مقدار"
+ className="!text-right text-right"
+ />
+
+
+
+
+ patch(it.tempId, { unit: x.label })}
+ items={allUnits.filter((u) => normalize(u) !== normalize(it.unit))}
+ allowAdd
+ addSuffix="به عنوان واحد جدید"
+ placeholder="واحد (شاخه، متر، کیلو...)"
+ onInputChange={(v) => patch(it.tempId, { unit: v })}
+ onAdd={(v) => {
+ const name = v.trim();
+ if (!name) return;
+ void apiV26.catalog
+ .createUnit(name)
+ .then(() => {
+ setUnitOptions((prev) =>
+ prev.some((u) => normalize(u) === normalize(name)) ? prev : [...prev, name],
+ );
+ })
+ .catch(() => {});
+ }}
+ inputClassName="!text-xs !h-9 text-right"
+ className="min-w-0"
+ />
+
+
+
+ {/* ردیف ۴: قیمت هر واحد (راستچین شده) */}
+
+
+ {
+ patch(it.tempId, {
+ price,
+ total: it.qty != null && price != null ? Math.round(it.qty * price) : it.total,
+ });
+ }}
+ placeholder="قیمت هر واحد"
+ showWords
+ className="!text-right text-right"
+ />
+
+
+ {/* ردیف ۵: قیمت کل قلم (راستچین شده) */}
+
+
+ {
+ patch(it.tempId, {
+ total,
+ price:
+ total != null && it.qty != null && it.qty > 0 ? Math.round(total / it.qty) : it.price,
+ });
+ }}
+ placeholder="قیمت کل قلم"
+ showWords
+ className="!text-right text-right"
+ />
+
+