143afd59
杨鑫
打印,标签
|
1
2
3
4
5
6
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { ArrowLeft, Plus, Trash2 } from 'lucide-react';
import { toast } from 'sonner';
import { Button } from '../ui/button';
import { Input } from '../ui/input';
import {
|
699ea6e8
杨鑫
完善打印逻辑
|
7
8
9
10
11
12
13
|
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '../ui/select';
import {
|
143afd59
杨鑫
打印,标签
|
14
15
16
17
18
19
20
21
22
23
24
25
26
|
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '../ui/table';
import { SearchableSelect } from '../ui/searchable-select';
import { ImageUrlUpload } from '../ui/image-url-upload';
import { getLabelTemplate, updateLabelTemplate } from '../../services/labelTemplateService';
import { getProducts } from '../../services/productService';
import { getLabelTypes } from '../../services/labelTypeService';
import { skipCountForPage } from '../../lib/paginationQuery';
|
43d16ca6
杨鑫
打印日志
|
27
|
import type { LabelElement, LabelTemplateDto, LabelType, Unit } from '../../types/labelTemplate';
|
143afd59
杨鑫
打印,标签
|
28
29
|
import {
appliedLocationToEditor,
|
58d2e61c
杨鑫
最新代码
|
30
|
canonicalElementType,
|
143afd59
杨鑫
打印,标签
|
31
32
|
dataEntryColumnLabel,
isDataEntryTableColumnElement,
|
699ea6e8
杨鑫
完善打印逻辑
|
33
|
isDateTimeDataEntryField,
|
143afd59
杨鑫
打印,标签
|
34
35
36
|
labelElementsToApiPayload,
sortTemplateElementsForDisplay,
} from '../../types/labelTemplate';
|
699ea6e8
杨鑫
完善打印逻辑
|
37
38
39
40
41
42
|
import {
LABEL_FORM_OFFSET_UNITS,
offsetFieldUiStateFromStored,
serializePrintInputOffset,
tryParsePrintInputOffsetStored,
} from '../../lib/labelFormDatePreview';
|
63289723
杨鑫
提交
|
43
44
45
46
47
48
49
|
import {
foldNutritionCompositeKeysIntoDefaults,
hydrateRowFieldValuesWithNutritionColumns,
listNutritionManualFieldSpecs,
nutritionCompositeFieldKey,
type NutritionManualFieldSpec,
} from '../../lib/nutritionManualEntry';
|
143afd59
杨鑫
打印,标签
|
50
51
|
import type { ProductDto } from '../../types/product';
import type { LabelTypeDto } from '../../types/labelType';
|
91821909
杨鑫
最新
|
52
53
54
55
|
import {
buildTemplateBarcodeQrDefaultsFromCodeValue,
isTemplateSectionBarcodeOrQrElement,
} from '../../lib/productCodeValueTemplate';
|
143afd59
杨鑫
打印,标签
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
export type TemplateDataEntryRow = {
id: string;
productId: string;
labelTypeId: string;
/** elementId -> 管理端录入的关联/默认值(真正打印时输入仍在 App) */
fieldValues: Record<string, string>;
};
function newRowId(): string {
try {
return crypto.randomUUID();
} catch {
return `row-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
}
}
|
699ea6e8
杨鑫
完善打印逻辑
|
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/** 保存前:日期类已是 JSON 则保留;纯数字等转为 JSON;其它旧文案原样保留 */
function normalizeDateTimeFieldForSave(el: LabelElement, raw: string): string {
if (!isDateTimeDataEntryField(el)) return raw ?? '';
const t = String(raw ?? '').trim();
if (!t) return '';
if (tryParsePrintInputOffsetStored(t)) return t;
const { unit, value } = offsetFieldUiStateFromStored(t);
if (!String(value).trim()) return t;
const amount = Number(String(value).trim());
if (!Number.isFinite(amount)) return t;
return serializePrintInputOffset(unit, String(value).trim());
}
|
43d16ca6
杨鑫
打印日志
|
86
87
88
89
90
|
/** 模板录入表:图片与二维码(及名称含 qrcode 的控件)用上传组件,预览区固定 100×100 */
const DATA_ENTRY_IMAGE_BOX =
'h-[100px] w-[100px] min-h-[100px] min-w-[100px] max-h-[100px] max-w-[100px] shrink-0 aspect-auto';
function dataEntryUsesImageUpload(element: LabelElement): boolean {
|
58d2e61c
杨鑫
最新代码
|
91
92
|
const type = canonicalElementType(element.type);
if (type === 'IMAGE' || type === 'QRCODE') return true;
|
43d16ca6
杨鑫
打印日志
|
93
94
95
96
|
const n = (element.elementName ?? '').trim().toLowerCase();
return n.includes('qrcode');
}
|
699ea6e8
杨鑫
完善打印逻辑
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
function DataEntryOffsetCell({
value,
onValueChange,
}: {
value: string;
onValueChange: (next: string) => void;
}) {
const { unit, value: num } = offsetFieldUiStateFromStored(value);
return (
<div className="flex flex-wrap items-center gap-2 min-w-0 max-w-[220px]">
<Select
value={unit}
onValueChange={(u) => onValueChange(serializePrintInputOffset(u, num))}
>
<SelectTrigger className="h-10 min-w-0 flex-1 bg-white text-sm border-gray-300">
<SelectValue />
</SelectTrigger>
<SelectContent>
{LABEL_FORM_OFFSET_UNITS.map((u) => (
<SelectItem key={u} value={u} className="text-xs">
{u}
</SelectItem>
))}
</SelectContent>
</Select>
<Input
type="number"
className="h-10 w-20 shrink-0 border-gray-300 bg-white"
value={num}
onChange={(e) => onValueChange(serializePrintInputOffset(unit, e.target.value))}
placeholder="Val"
/>
</div>
);
}
|
143afd59
杨鑫
打印,标签
|
133
|
function DataEntryValueCell({
|
43d16ca6
杨鑫
打印日志
|
134
|
element,
|
143afd59
杨鑫
打印,标签
|
135
136
|
value,
onValueChange,
|
91821909
杨鑫
最新
|
137
|
readOnly,
|
143afd59
杨鑫
打印,标签
|
138
|
}: {
|
43d16ca6
杨鑫
打印日志
|
139
|
element: LabelElement;
|
143afd59
杨鑫
打印,标签
|
140
141
|
value: string;
onValueChange: (next: string) => void;
|
91821909
杨鑫
最新
|
142
|
readOnly?: boolean;
|
143afd59
杨鑫
打印,标签
|
143
|
}) {
|
91821909
杨鑫
最新
|
144
145
146
147
148
149
150
151
152
153
154
|
if (readOnly || isTemplateSectionBarcodeOrQrElement(element)) {
return (
<Input
value={value}
readOnly
disabled
className="h-10 border-gray-300 max-w-[220px] bg-gray-50"
placeholder="From product Code Value"
/>
);
}
|
43d16ca6
杨鑫
打印日志
|
155
|
if (dataEntryUsesImageUpload(element)) {
|
143afd59
杨鑫
打印,标签
|
156
157
158
159
160
161
|
return (
<ImageUrlUpload
value={value}
onChange={onValueChange}
uploadSubDir="label-template-data"
oneImageOnly
|
43d16ca6
杨鑫
打印日志
|
162
|
boxClassName={DATA_ENTRY_IMAGE_BOX}
|
143afd59
杨鑫
打印,标签
|
163
164
165
166
|
hint="Upload stores full URL/path for save."
/>
);
}
|
699ea6e8
杨鑫
完善打印逻辑
|
167
168
169
|
if (isDateTimeDataEntryField(element)) {
return <DataEntryOffsetCell value={value} onValueChange={onValueChange} />;
}
|
143afd59
杨鑫
打印,标签
|
170
171
172
173
174
|
return (
<Input
value={value}
onChange={(e) => onValueChange(e.target.value)}
placeholder="—"
|
699ea6e8
杨鑫
完善打印逻辑
|
175
|
className="h-10 border-gray-300 max-w-[220px]"
|
143afd59
杨鑫
打印,标签
|
176
177
178
179
180
181
182
|
/>
);
}
export function LabelTemplateDataEntryView({
templateCode,
onBack,
|
58d2e61c
杨鑫
最新代码
|
183
|
contextHint,
|
143afd59
杨鑫
打印,标签
|
184
185
186
|
}: {
templateCode: string;
onBack: () => void;
|
58d2e61c
杨鑫
最新代码
|
187
188
|
/** 从 Labels 进入时展示:当前编辑的是哪条标签绑定的模板 */
contextHint?: string;
|
143afd59
杨鑫
打印,标签
|
189
190
191
192
193
194
|
}) {
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [templateTitle, setTemplateTitle] = useState('');
/** 详情接口完整模板,保存时随 templateProductDefaults 一并 PUT(接口 4.4) */
const [templateDto, setTemplateDto] = useState<LabelTemplateDto | null>(null);
|
143afd59
杨鑫
打印,标签
|
195
196
197
198
|
const [products, setProducts] = useState<ProductDto[]>([]);
const [types, setTypes] = useState<LabelTypeDto[]>([]);
const [rows, setRows] = useState<TemplateDataEntryRow[]>([]);
|
63289723
杨鑫
提交
|
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
const sortedTemplateElements = useMemo(
() => sortTemplateElementsForDisplay((templateDto?.elements ?? []) as LabelElement[]),
[templateDto],
);
const dataColumns = useMemo(() => {
const cols: Array<
| { kind: "element"; el: LabelElement }
| { kind: "nutrition"; parent: LabelElement; spec: NutritionManualFieldSpec }
> = [];
for (const el of sortedTemplateElements) {
if (isDataEntryTableColumnElement(el)) cols.push({ kind: "element", el });
if (canonicalElementType(el.type) === "NUTRITION") {
for (const spec of listNutritionManualFieldSpecs(el)) {
cols.push({ kind: "nutrition", parent: el, spec });
}
}
}
return cols;
}, [sortedTemplateElements]);
|
143afd59
杨鑫
打印,标签
|
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
const productOptions = useMemo(
() =>
products.map((p) => {
const label =
(p.productName ?? p.productCode ?? '').trim() || p.id;
return { value: p.id, label };
}),
[products],
);
const labelTypeOptions = useMemo(
() =>
types.map((t) => {
const label =
(t.typeName ?? t.typeCode ?? '').trim() || t.id;
return { value: t.id, label };
}),
[types],
);
useEffect(() => {
let cancelled = false;
(async () => {
setLoading(true);
try {
const [tpl, prodRes, typeRes] = await Promise.all([
getLabelTemplate(templateCode),
getProducts({ skipCount: skipCountForPage(1), maxResultCount: 500 }),
getLabelTypes({ skipCount: skipCountForPage(1), maxResultCount: 500 }),
]);
if (cancelled) return;
const title =
(tpl.templateName ?? tpl.name ?? '').trim() ||
(tpl.templateCode ?? tpl.id ?? '').trim() ||
templateCode;
setTemplateTitle(title);
|
143afd59
杨鑫
打印,标签
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
setProducts(prodRes.items ?? []);
setTypes(typeRes.items ?? []);
setTemplateDto(tpl);
const defaults = tpl.templateProductDefaults ?? [];
const fromApi =
defaults.length > 0
? [...defaults].sort((a, b) => (a.orderNum ?? 0) - (b.orderNum ?? 0))
: [];
if (fromApi.length > 0) {
setRows(
fromApi.map((d) => ({
id: newRowId(),
productId: d.productId,
labelTypeId: d.labelTypeId,
|
63289723
杨鑫
提交
|
272
273
274
275
|
fieldValues: hydrateRowFieldValuesWithNutritionColumns(
{ ...d.defaultValues },
(tpl.elements ?? []) as LabelElement[],
),
|
143afd59
杨鑫
打印,标签
|
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
})),
);
} else {
setRows([
{
id: newRowId(),
productId: '',
labelTypeId: '',
fieldValues: {},
},
]);
}
} catch (e: unknown) {
if (!cancelled) {
toast.error('Failed to load template or options.', {
description: e instanceof Error ? e.message : 'Please try again.',
});
setTemplateTitle(templateCode);
|
143afd59
杨鑫
打印,标签
|
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
setRows([]);
setTemplateDto(null);
}
} finally {
if (!cancelled) setLoading(false);
}
})();
return () => {
cancelled = true;
};
}, [templateCode]);
const addRow = useCallback(() => {
setRows((prev) => [
...prev,
{ id: newRowId(), productId: '', labelTypeId: '', fieldValues: {} },
]);
}, []);
const removeRow = useCallback((id: string) => {
setRows((prev) => (prev.length <= 1 ? prev : prev.filter((r) => r.id !== id)));
}, []);
const updateRow = useCallback((id: string, patch: Partial<TemplateDataEntryRow>) => {
setRows((prev) =>
prev.map((r) => (r.id === id ? { ...r, ...patch } : r)),
);
}, []);
|
923d50c0
杨鑫
更新bug
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
const applyProductCodeValueToRow = useCallback(
(rowId: string, productId: string) => {
const pid = productId.trim();
const product = products.find((p) => p.id === pid);
const cv = (product?.codeValue ?? '').trim();
const scanDefaults = buildTemplateBarcodeQrDefaultsFromCodeValue(
(templateDto?.elements ?? []) as LabelElement[],
cv,
);
setRows((prev) =>
prev.map((r) => {
if (r.id !== rowId) return r;
return {
...r,
productId: pid,
fieldValues: { ...r.fieldValues, ...scanDefaults },
};
}),
);
},
[products, templateDto],
);
|
143afd59
杨鑫
打印,标签
|
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
const setFieldValue = useCallback(
(rowId: string, elementId: string, value: string) => {
setRows((prev) =>
prev.map((r) => {
if (r.id !== rowId) return r;
return {
...r,
fieldValues: { ...r.fieldValues, [elementId]: value },
};
}),
);
},
[],
);
const handleSave = useCallback(async () => {
if (!templateDto) {
toast.error('Template not loaded', { description: 'Please reload the page and try again.' });
return;
}
const touched = rows.filter((r) => r.productId.trim() || r.labelTypeId.trim());
const incomplete = touched.some(
(r) => !r.productId.trim() || !r.labelTypeId.trim(),
);
if (incomplete) {
toast.error('Product and label type required', {
description:
'Each row that you started must have both Product and Label type selected.',
});
return;
}
const validRows = rows.filter((r) => r.productId.trim() && r.labelTypeId.trim());
|
63289723
杨鑫
提交
|
379
380
381
|
const fullElements = sortTemplateElementsForDisplay(
(templateDto.elements ?? []) as LabelElement[],
);
|
143afd59
杨鑫
打印,标签
|
382
|
const templateProductDefaults = validRows.map((r, i) => {
|
63289723
杨鑫
提交
|
383
|
const folded = foldNutritionCompositeKeysIntoDefaults(r.fieldValues, fullElements);
|
143afd59
杨鑫
打印,标签
|
384
|
const defaultValues: Record<string, string> = {};
|
63289723
杨鑫
提交
|
385
386
387
388
389
390
391
392
393
394
|
for (const col of dataColumns) {
if (col.kind === "element") {
defaultValues[col.el.id] = normalizeDateTimeFieldForSave(col.el, folded[col.el.id] ?? "");
}
}
for (const el of fullElements) {
if (canonicalElementType(el.type) === "NUTRITION") {
const j = folded[el.id];
if (j) defaultValues[el.id] = j;
}
|
143afd59
杨鑫
打印,标签
|
395
|
}
|
91821909
杨鑫
最新
|
396
397
398
399
400
|
const product = products.find((p) => p.id === r.productId.trim());
Object.assign(
defaultValues,
buildTemplateBarcodeQrDefaultsFromCodeValue(fullElements, product?.codeValue),
);
|
143afd59
杨鑫
打印,标签
|
401
402
403
404
405
406
407
408
|
return {
productId: r.productId.trim(),
labelTypeId: r.labelTypeId.trim(),
defaultValues,
orderNum: i + 1,
};
});
|
143afd59
杨鑫
打印,标签
|
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
if (fullElements.length === 0) {
toast.error('Template has no elements', { description: 'Cannot save this template.' });
return;
}
const loc = appliedLocationToEditor(templateDto);
setSaving(true);
try {
const updated = await updateLabelTemplate(templateCode, {
id: templateDto.id,
name: (templateDto.name ?? templateDto.templateName ?? '').trim() || templateCode,
labelType: (templateDto.labelType ?? 'PRICE') as LabelType,
unit: (templateDto.unit ?? 'inch') as Unit,
width: Number(templateDto.width ?? 2),
height: Number(templateDto.height ?? 2),
appliedLocation: loc,
showRuler: templateDto.showRuler ?? true,
showGrid: templateDto.showGrid ?? true,
state: templateDto.state ?? true,
elements: labelElementsToApiPayload(fullElements),
appliedLocationIds: loc === 'ALL' ? [] : (templateDto.appliedLocationIds ?? []),
templateProductDefaults,
});
setTemplateDto(updated);
toast.success('Saved', {
description: 'Template product defaults were updated on the server.',
});
} catch (e: unknown) {
toast.error('Save failed', {
description: e instanceof Error ? e.message : 'Please try again.',
});
} finally {
setSaving(false);
}
|
91821909
杨鑫
最新
|
443
|
}, [templateCode, templateDto, rows, dataColumns, products]);
|
143afd59
杨鑫
打印,标签
|
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
return (
<div className="h-full flex flex-col min-h-0">
<div className="flex flex-wrap items-center gap-3 pb-4 border-b border-gray-200 shrink-0">
<Button
type="button"
variant="outline"
className="h-10 gap-2"
onClick={onBack}
>
<ArrowLeft className="h-4 w-4" />
Back
</Button>
<div className="flex-1 min-w-[200px]">
<div className="text-xs font-medium text-gray-500 uppercase tracking-wide">
Label template
</div>
<h2 className="text-lg font-semibold text-gray-900 truncate" title={templateTitle}>
{templateTitle}
</h2>
|
58d2e61c
杨鑫
最新代码
|
464
465
466
467
468
|
{contextHint ? (
<p className="text-sm text-gray-600 truncate mt-0.5" title={contextHint}>
{contextHint}
</p>
) : null}
|
143afd59
杨鑫
打印,标签
|
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
|
</div>
<div className="flex items-center gap-2">
<Button type="button" variant="outline" className="h-10 gap-1" onClick={addRow}>
<Plus className="h-4 w-4" />
Add row
</Button>
<Button
type="button"
className="h-10 bg-blue-600 hover:bg-blue-700"
onClick={() => void handleSave()}
disabled={saving || loading || !templateDto}
>
{saving ? 'Saving…' : 'Save'}
</Button>
</div>
</div>
<p className="text-sm text-gray-600 py-3 shrink-0">
Bind product and label type per row. Values are saved with the template (edit API) as{' '}
|
63289723
杨鑫
提交
|
488
489
490
491
492
493
494
|
<span className="font-medium">templateProductDefaults</span> (interface doc section 4.4). Columns cover{' '}
<span className="font-medium">Label</span> group defaults, <span className="font-medium">PRINT_INPUT</span> /
Duration fields, and (when present) <span className="font-medium">Nutrition Facts</span> manual cells.{' '}
<span className="font-medium">Template</span> panel elements are edited only in the label template editor
(not here). Date / time / duration columns use <span className="font-medium">unit + value</span>; stored as
JSON with <span className="font-medium">unit</span> and <span className="font-medium">value</span> keys.
Nutrition values are stored as JSON under the nutrition element id for App print preview.
|
143afd59
杨鑫
打印,标签
|
495
496
497
498
499
|
</p>
<div className="flex-1 min-h-0 overflow-auto rounded-md border bg-white shadow-sm">
{loading ? (
<div className="p-10 text-center text-sm text-gray-500">Loading…</div>
|
63289723
杨鑫
提交
|
500
|
) : dataColumns.length === 0 ? (
|
143afd59
杨鑫
打印,标签
|
501
|
<div className="p-10 text-center text-sm text-gray-600">
|
63289723
杨鑫
提交
|
502
|
No manual input or nutrition columns in this template.
|
143afd59
杨鑫
打印,标签
|
503
504
505
506
507
508
509
510
511
512
513
|
</div>
) : (
<Table>
<TableHeader>
<TableRow className="bg-gray-50 hover:bg-gray-50">
<TableHead className="font-bold text-gray-900 w-[200px] min-w-[160px]">
Product
</TableHead>
<TableHead className="font-bold text-gray-900 w-[180px] min-w-[140px]">
Label type
</TableHead>
|
63289723
杨鑫
提交
|
514
|
{dataColumns.map((col) => (
|
143afd59
杨鑫
打印,标签
|
515
|
<TableHead
|
63289723
杨鑫
提交
|
516
517
518
519
520
|
key={
col.kind === 'element'
? col.el.id
: nutritionCompositeFieldKey(col.parent.id, col.spec.subKey)
}
|
143afd59
杨鑫
打印,标签
|
521
|
className="font-bold text-gray-900 min-w-[120px] whitespace-nowrap"
|
63289723
杨鑫
提交
|
522
|
title={col.kind === 'element' ? col.el.id : `${col.parent.id} · ${col.spec.subKey}`}
|
143afd59
杨鑫
打印,标签
|
523
|
>
|
63289723
杨鑫
提交
|
524
|
{col.kind === 'element' ? dataEntryColumnLabel(col.el) : col.spec.columnLabel}
|
143afd59
杨鑫
打印,标签
|
525
526
527
528
529
530
531
532
533
534
535
|
</TableHead>
))}
<TableHead className="w-[72px] text-center font-bold text-gray-900"> </TableHead>
</TableRow>
</TableHeader>
<TableBody>
{rows.map((row) => (
<TableRow key={row.id} className="hover:bg-gray-50">
<TableCell className="align-top py-2">
<SearchableSelect
value={row.productId}
|
923d50c0
杨鑫
更新bug
|
536
|
onValueChange={(v) => applyProductCodeValueToRow(row.id, v)}
|
143afd59
杨鑫
打印,标签
|
537
538
539
540
541
542
543
544
545
546
547
548
549
550
|
options={productOptions}
placeholder="Select product"
searchPlaceholder="Search product…"
/>
</TableCell>
<TableCell className="align-top py-2">
<SearchableSelect
value={row.labelTypeId}
onValueChange={(v) => updateRow(row.id, { labelTypeId: v })}
options={labelTypeOptions}
placeholder="Select label type"
searchPlaceholder="Search type…"
/>
</TableCell>
|
63289723
杨鑫
提交
|
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
|
{dataColumns.map((col) => (
<TableCell
key={
col.kind === 'element'
? col.el.id
: nutritionCompositeFieldKey(col.parent.id, col.spec.subKey)
}
className="align-top py-2"
>
{col.kind === 'element' ? (
<DataEntryValueCell
element={col.el}
value={row.fieldValues[col.el.id] ?? ''}
onValueChange={(v) => setFieldValue(row.id, col.el.id, v)}
/>
) : (
<Input
value={
row.fieldValues[
nutritionCompositeFieldKey(col.parent.id, col.spec.subKey)
] ?? ''
}
onChange={(e) =>
setFieldValue(
row.id,
nutritionCompositeFieldKey(col.parent.id, col.spec.subKey),
e.target.value,
)
}
placeholder="—"
className="h-10 border-gray-300 max-w-[220px]"
/>
)}
|
143afd59
杨鑫
打印,标签
|
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
</TableCell>
))}
<TableCell className="text-center align-top py-2">
<Button
type="button"
variant="ghost"
size="icon"
className="h-9 w-9 text-red-600 hover:text-red-700 hover:bg-red-50"
aria-label="Remove row"
onClick={() => removeRow(row.id)}
disabled={rows.length <= 1}
>
<Trash2 className="h-4 w-4" />
</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)}
</div>
</div>
);
}
|