@svadmin/ui 0.116.0 → 0.118.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/app.css +320 -26
  2. package/dist/app.theme.css +320 -26
  3. package/dist/components/AboutSettings.svelte +1 -1
  4. package/dist/components/ApprovalTimeline.svelte +170 -0
  5. package/dist/components/ApprovalTimeline.svelte.d.ts +26 -0
  6. package/dist/components/CopyableText.svelte +90 -0
  7. package/dist/components/CopyableText.svelte.d.ts +13 -0
  8. package/dist/components/Divider.svelte +89 -0
  9. package/dist/components/Divider.svelte.d.ts +19 -0
  10. package/dist/components/EllipsisText.svelte +78 -0
  11. package/dist/components/EllipsisText.svelte.d.ts +15 -0
  12. package/dist/components/ExcelExportButton.svelte +142 -0
  13. package/dist/components/ExcelExportButton.svelte.d.ts +21 -0
  14. package/dist/components/ExcelImportWizard.svelte +571 -0
  15. package/dist/components/ExcelImportWizard.svelte.d.ts +26 -0
  16. package/dist/components/FloatButtonGroup.svelte +162 -0
  17. package/dist/components/FloatButtonGroup.svelte.d.ts +34 -0
  18. package/dist/components/FullscreenButton.svelte +88 -0
  19. package/dist/components/FullscreenButton.svelte.d.ts +10 -0
  20. package/dist/components/GlobalShortcuts.svelte +229 -0
  21. package/dist/components/GlobalShortcuts.svelte.d.ts +18 -0
  22. package/dist/components/Header.svelte +17 -1
  23. package/dist/components/Header.svelte.d.ts +3 -0
  24. package/dist/components/Layout.svelte +3 -0
  25. package/dist/components/Layout.svelte.d.ts +1 -0
  26. package/dist/components/LightFilter.svelte +281 -0
  27. package/dist/components/LightFilter.svelte.d.ts +36 -0
  28. package/dist/components/LockScreen.svelte +295 -0
  29. package/dist/components/LockScreen.svelte.d.ts +21 -0
  30. package/dist/components/OrgTreePicker.svelte +325 -0
  31. package/dist/components/OrgTreePicker.svelte.d.ts +32 -0
  32. package/dist/components/PivotDrilldownModal.svelte +228 -0
  33. package/dist/components/PivotDrilldownModal.svelte.d.ts +22 -0
  34. package/dist/components/PricingCard.svelte +12 -12
  35. package/dist/components/PricingCard.svelte.d.ts +12 -12
  36. package/dist/components/PricingTable.svelte +185 -0
  37. package/dist/components/PricingTable.svelte.d.ts +40 -0
  38. package/dist/components/ProCard.svelte +267 -0
  39. package/dist/components/ProCard.svelte.d.ts +56 -0
  40. package/dist/components/ProSkeleton.svelte +186 -0
  41. package/dist/components/ProSkeleton.svelte.d.ts +20 -0
  42. package/dist/components/QuotaProgressBar.svelte +8 -8
  43. package/dist/components/QuotaProgressBar.svelte.d.ts +8 -8
  44. package/dist/components/Ribbon.svelte +97 -0
  45. package/dist/components/Ribbon.svelte.d.ts +19 -0
  46. package/dist/components/TreeTransfer.svelte +288 -0
  47. package/dist/components/TreeTransfer.svelte.d.ts +25 -0
  48. package/dist/components/TypographyEllipsis.svelte +12 -9
  49. package/dist/components/TypographyEllipsis.svelte.d.ts +9 -8
  50. package/dist/components/TypographyText.svelte +41 -3
  51. package/dist/components/TypographyText.svelte.d.ts +10 -2
  52. package/dist/components/UsageCard.svelte +97 -0
  53. package/dist/components/UsageCard.svelte.d.ts +26 -0
  54. package/dist/components/WorkflowProcessCard.svelte +93 -0
  55. package/dist/components/WorkflowProcessCard.svelte.d.ts +21 -0
  56. package/dist/components/ui/badge/badge.svelte +156 -12
  57. package/dist/components/ui/badge/badge.svelte.d.ts +9 -0
  58. package/dist/components/ui/badge/index.d.ts +1 -1
  59. package/dist/index.d.ts +44 -3
  60. package/dist/index.js +28 -2
  61. package/package.json +5 -5
@@ -0,0 +1,571 @@
1
+ <script lang="ts">
2
+ import {
3
+ Upload,
4
+ FileSpreadsheet,
5
+ ArrowRight,
6
+ ArrowLeft,
7
+ CheckCircle2,
8
+ AlertCircle,
9
+ Download,
10
+ Check,
11
+ RotateCcw,
12
+ } from '@lucide/svelte';
13
+ import { cn } from '../utils.js';
14
+ import { useTranslation } from '@svadmin/core';
15
+
16
+ export interface ExcelImportField {
17
+ name: string;
18
+ label: string;
19
+ required?: boolean | undefined;
20
+ type?: 'string' | 'number' | 'date' | undefined;
21
+ validator?: ((val: unknown) => string | null) | undefined;
22
+ }
23
+
24
+ export interface ExcelImportWizardProps {
25
+ fields: ExcelImportField[];
26
+ title?: string | undefined;
27
+ description?: string | undefined;
28
+ templateUrl?: string | undefined;
29
+ class?: string | undefined;
30
+ onimport?: ((result: {
31
+ validRows: Record<string, unknown>[];
32
+ errorRows: { row: number; errors: Record<string, string>; data: Record<string, unknown> }[];
33
+ }) => Promise<void> | void) | undefined;
34
+ oncancel?: (() => void) | undefined;
35
+ }
36
+
37
+ let {
38
+ fields = [],
39
+ title,
40
+ description,
41
+ templateUrl,
42
+ class: className = '',
43
+ onimport,
44
+ oncancel,
45
+ }: ExcelImportWizardProps = $props();
46
+
47
+ const i18n = useTranslation();
48
+
49
+ let currentStep = $state<1 | 2 | 3 | 4>(1);
50
+ let fileName = $state('');
51
+ let fileSize = $state('');
52
+ let rawHeaders = $state<string[]>([]);
53
+ let rawData = $state<Record<string, string>[]>([]);
54
+ let fieldMapping = $state<Record<string, string>>({}); // targetField -> sourceHeader
55
+ let onlyShowErrors = $state(false);
56
+ let isSubmitting = $state(false);
57
+ let isDragOver = $state(false);
58
+ let fileError = $state('');
59
+ const maxFileBytes = 5 * 1024 * 1024;
60
+
61
+ // 简单的 CSV 解析函数
62
+ function parseCSV(text: string): { headers: string[]; rows: Record<string, string>[] } {
63
+ const lines = text
64
+ .split(/\r?\n/)
65
+ .map((l) => l.trim())
66
+ .filter((l) => l.length > 0);
67
+ if (lines.length === 0) return { headers: [], rows: [] };
68
+
69
+ const parseLine = (line: string): string[] => {
70
+ const result: string[] = [];
71
+ let cur = '';
72
+ let inQuotes = false;
73
+ for (let i = 0; i < line.length; i++) {
74
+ const char = line[i];
75
+ if (char === '"') {
76
+ inQuotes = !inQuotes;
77
+ } else if (char === ',' && !inQuotes) {
78
+ result.push(cur.trim());
79
+ cur = '';
80
+ } else {
81
+ cur += char;
82
+ }
83
+ }
84
+ result.push(cur.trim());
85
+ return result;
86
+ };
87
+
88
+ const firstLine = lines[0];
89
+ if (!firstLine) return { headers: [], rows: [] };
90
+ const headers = parseLine(firstLine);
91
+ const rows: Record<string, string>[] = [];
92
+
93
+ for (let i = 1; i < lines.length; i++) {
94
+ const currentLine = lines[i];
95
+ if (!currentLine) continue;
96
+ const values = parseLine(currentLine);
97
+ const row: Record<string, string> = {};
98
+ headers.forEach((h, idx) => {
99
+ row[h] = values[idx] ?? '';
100
+ });
101
+ rows.push(row);
102
+ }
103
+ return { headers, rows };
104
+ }
105
+
106
+ // 处理文件读取
107
+ function handleFile(file: File) {
108
+ fileError = '';
109
+ if (!file.name.toLowerCase().endsWith('.csv')) {
110
+ fileError = '当前仅支持 CSV 文件';
111
+ return;
112
+ }
113
+ if (file.size > maxFileBytes) {
114
+ fileError = '文件不能超过 5 MB';
115
+ return;
116
+ }
117
+ fileName = file.name;
118
+ fileSize = `${(file.size / 1024).toFixed(1)} KB`;
119
+
120
+ const reader = new FileReader();
121
+ reader.onload = (e) => {
122
+ const content = e.target?.result as string;
123
+ const { headers, rows } = parseCSV(content);
124
+ rawHeaders = headers;
125
+ rawData = rows;
126
+
127
+ // 自动字段映射启发式算法
128
+ const initialMap: Record<string, string> = {};
129
+ fields.forEach((f) => {
130
+ const matched = headers.find(
131
+ (h) =>
132
+ h.toLowerCase() === f.name.toLowerCase() ||
133
+ h.toLowerCase() === f.label.toLowerCase() ||
134
+ h.includes(f.label) ||
135
+ f.label.includes(h),
136
+ );
137
+ if (matched) {
138
+ initialMap[f.name] = matched;
139
+ }
140
+ });
141
+ fieldMapping = initialMap;
142
+ currentStep = 2;
143
+ };
144
+ reader.onerror = () => {
145
+ fileError = '文件读取失败,请重试';
146
+ };
147
+ reader.readAsText(file);
148
+ }
149
+
150
+ function handleFileInputChange(e: Event) {
151
+ const input = e.target as HTMLInputElement;
152
+ if (input.files && input.files[0]) {
153
+ handleFile(input.files[0]);
154
+ }
155
+ }
156
+
157
+ function handleDrop(e: DragEvent) {
158
+ e.preventDefault();
159
+ isDragOver = false;
160
+ if (e.dataTransfer?.files && e.dataTransfer.files[0]) {
161
+ handleFile(e.dataTransfer.files[0]);
162
+ }
163
+ }
164
+
165
+ // 模拟加载模板文件或示例数据
166
+ function loadSampleData() {
167
+ fileName = 'sample-import-template.csv';
168
+ fileSize = '2.4 KB';
169
+ const sampleHeaders = fields.map((f) => f.label);
170
+ rawHeaders = sampleHeaders;
171
+
172
+ const sampleRowList: Record<string, string>[] = [
173
+ {},
174
+ {},
175
+ {},
176
+ ];
177
+ fields.forEach((f) => {
178
+ sampleRowList.forEach((row, rowIdx) => {
179
+ row[f.label] = f.type === 'number' ? `${(rowIdx + 1) * 100}` : `样本${f.label}_${rowIdx + 1}`;
180
+ });
181
+ });
182
+ rawData = sampleRowList;
183
+
184
+ const initialMap: Record<string, string> = {};
185
+ fields.forEach((f) => {
186
+ initialMap[f.name] = f.label;
187
+ });
188
+ fieldMapping = initialMap;
189
+ currentStep = 2;
190
+ }
191
+
192
+ // 校验数据推导
193
+ const validationResult = $derived.by(() => {
194
+ const validRows: Record<string, unknown>[] = [];
195
+ const errorRows: { row: number; errors: Record<string, string>; data: Record<string, unknown> }[] = [];
196
+
197
+ rawData.forEach((item, index) => {
198
+ const rowData: Record<string, unknown> = {};
199
+ const rowErrors: Record<string, string> = {};
200
+
201
+ fields.forEach((field) => {
202
+ const sourceHeader = fieldMapping[field.name];
203
+ const rawVal = sourceHeader ? item[sourceHeader] : undefined;
204
+
205
+ if (field.required && (rawVal === undefined || rawVal === '')) {
206
+ rowErrors[field.name] = `${field.label}为必填项`;
207
+ } else if (rawVal !== undefined && rawVal !== '') {
208
+ if (field.type === 'number' && Number.isNaN(Number(rawVal))) {
209
+ rowErrors[field.name] = '须为数值类型';
210
+ }
211
+ if (field.validator) {
212
+ const err = field.validator(rawVal);
213
+ if (err) rowErrors[field.name] = err;
214
+ }
215
+ }
216
+ rowData[field.name] = rawVal;
217
+ });
218
+
219
+ if (Object.keys(rowErrors).length > 0) {
220
+ errorRows.push({ row: index + 1, errors: rowErrors, data: rowData });
221
+ } else {
222
+ validRows.push(rowData);
223
+ }
224
+ });
225
+
226
+ return { validRows, errorRows };
227
+ });
228
+
229
+ const previewList = $derived(
230
+ onlyShowErrors ? validationResult.errorRows.map((e) => e.data) : rawData,
231
+ );
232
+
233
+ const steps = $derived([
234
+ { num: 1, label: i18n.t('excel.uploadStep') },
235
+ { num: 2, label: i18n.t('excel.mappingStep') },
236
+ { num: 3, label: i18n.t('excel.previewStep') },
237
+ { num: 4, label: i18n.t('excel.startImport') },
238
+ ]);
239
+
240
+ async function handleConfirmImport() {
241
+ isSubmitting = true;
242
+ try {
243
+ if (onimport) {
244
+ await onimport({
245
+ validRows: validationResult.validRows,
246
+ errorRows: validationResult.errorRows,
247
+ });
248
+ }
249
+ currentStep = 4;
250
+ } finally {
251
+ isSubmitting = false;
252
+ }
253
+ }
254
+
255
+ function handleReset() {
256
+ currentStep = 1;
257
+ fileName = '';
258
+ fileSize = '';
259
+ rawHeaders = [];
260
+ rawData = [];
261
+ fieldMapping = {};
262
+ onlyShowErrors = false;
263
+ }
264
+ </script>
265
+
266
+ <div
267
+ data-svadmin-component="ExcelImportWizard"
268
+ class={cn(
269
+ 'flex flex-col rounded-xl border border-border bg-card text-card-foreground shadow-sm overflow-hidden',
270
+ className,
271
+ )}
272
+ >
273
+ <!-- 头部与步骤进度 -->
274
+ <div class="border-b border-border p-5 bg-muted/20">
275
+ <div class="flex items-center justify-between mb-4">
276
+ <div>
277
+ <h3 class="text-base font-semibold text-foreground flex items-center gap-2">
278
+ <FileSpreadsheet class="h-5 w-5 text-primary" />
279
+ <span>{title ?? i18n.t('excel.import')}</span>
280
+ </h3>
281
+ {#if description}
282
+ <p class="text-xs text-muted-foreground mt-0.5">{description}</p>
283
+ {/if}
284
+ </div>
285
+
286
+ {#if templateUrl && /^https?:\/\//i.test(templateUrl)}
287
+ <a
288
+ href={templateUrl}
289
+ download
290
+ class="inline-flex items-center gap-1.5 text-xs text-primary hover:underline font-medium"
291
+ >
292
+ <Download size={14} />
293
+ <span>{i18n.t('excel.downloadTemplate')}</span>
294
+ </a>
295
+ {/if}
296
+ </div>
297
+
298
+ <!-- 步骤指示器 -->
299
+ <div class="grid grid-cols-4 gap-2 text-xs">
300
+ {#each steps as s (s.num)}
301
+ <div
302
+ class={cn(
303
+ 'flex items-center gap-2 rounded-lg p-2 border transition-colors',
304
+ currentStep === s.num
305
+ ? 'border-primary bg-primary/10 text-primary font-semibold'
306
+ : currentStep > s.num
307
+ ? 'border-border bg-muted/40 text-foreground'
308
+ : 'border-border/40 text-muted-foreground opacity-60',
309
+ )}
310
+ >
311
+ <div
312
+ class={cn(
313
+ 'flex h-5 w-5 items-center justify-center rounded-full text-[11px] font-bold shrink-0',
314
+ currentStep === s.num
315
+ ? 'bg-primary text-primary-foreground'
316
+ : currentStep > s.num
317
+ ? 'bg-muted-foreground/20 text-foreground'
318
+ : 'bg-muted text-muted-foreground',
319
+ )}
320
+ >
321
+ {#if currentStep > s.num}
322
+ <Check size={11} strokeWidth={3} />
323
+ {:else}
324
+ {s.num}
325
+ {/if}
326
+ </div>
327
+ <span class="truncate">{s.label}</span>
328
+ </div>
329
+ {/each}
330
+ </div>
331
+ </div>
332
+
333
+ <!-- 主体内容区域 -->
334
+ <div class="p-6 flex-1 min-h-0">
335
+ <!-- 步骤 1:文件上传 -->
336
+ {#if currentStep === 1}
337
+ <div class="flex flex-col items-center justify-center py-8">
338
+ <label
339
+ class={cn(
340
+ 'flex flex-col items-center justify-center w-full max-w-lg h-60 border-2 border-dashed rounded-xl cursor-pointer transition-all',
341
+ isDragOver ? 'border-primary bg-primary/5' : 'border-border hover:border-primary/50 bg-background',
342
+ )}
343
+ ondragover={(e) => { e.preventDefault(); isDragOver = true; }}
344
+ ondragleave={() => { isDragOver = false; }}
345
+ ondrop={handleDrop}
346
+ >
347
+ <input
348
+ type="file"
349
+ accept=".csv,text/csv"
350
+ class="hidden"
351
+ onchange={handleFileInputChange}
352
+ />
353
+ <div class="flex h-12 w-12 items-center justify-center rounded-full bg-primary/10 text-primary mb-3">
354
+ <Upload size={24} />
355
+ </div>
356
+ <p class="text-sm font-medium text-foreground">{i18n.t('excel.dropFile')}</p>
357
+ <p class="text-xs text-muted-foreground mt-1">{i18n.t('excel.fileHint')}</p>
358
+ {#if fileError}<p class="mt-2 text-xs text-destructive" role="alert">{fileError}</p>{/if}
359
+ </label>
360
+
361
+ <div class="mt-4 flex items-center gap-3">
362
+ <span class="text-xs text-muted-foreground">没有现成文件?</span>
363
+ <button
364
+ type="button"
365
+ class="text-xs text-primary hover:underline font-medium cursor-pointer"
366
+ onclick={loadSampleData}
367
+ >
368
+ 载入测试样本数据
369
+ </button>
370
+ </div>
371
+ </div>
372
+
373
+ <!-- 步骤 2:字段映射 -->
374
+ {:else if currentStep === 2}
375
+ <div class="space-y-4">
376
+ <div class="flex items-center justify-between text-xs bg-muted/30 p-2.5 rounded-lg border border-border">
377
+ <span class="text-muted-foreground">
378
+ 已解析文件:<strong class="text-foreground">{fileName}</strong> ({fileSize}),包含 <strong class="text-foreground">{rawData.length}</strong> 行数据
379
+ </span>
380
+ <button
381
+ type="button"
382
+ class="text-primary hover:underline font-medium cursor-pointer"
383
+ onclick={() => {
384
+ const auto: Record<string, string> = {};
385
+ fields.forEach((f) => {
386
+ const match = rawHeaders.find((h) => h.includes(f.label) || f.label.includes(h));
387
+ if (match) auto[f.name] = match;
388
+ });
389
+ fieldMapping = auto;
390
+ }}
391
+ >
392
+ {i18n.t('excel.autoMapped')}
393
+ </button>
394
+ </div>
395
+
396
+ <div class="rounded-lg border border-border overflow-hidden">
397
+ <table class="w-full text-xs text-left">
398
+ <thead class="bg-muted/40 border-b border-border text-muted-foreground font-semibold">
399
+ <tr>
400
+ <th class="p-3 w-1/3">{i18n.t('excel.targetField')}</th>
401
+ <th class="p-3 w-12 text-center"></th>
402
+ <th class="p-3 w-1/2">{i18n.t('excel.sourceColumn')}</th>
403
+ </tr>
404
+ </thead>
405
+ <tbody class="divide-y divide-border">
406
+ {#each fields as field (field.name)}
407
+ <tr class="hover:bg-muted/20">
408
+ <td class="p-3">
409
+ <div class="flex items-center gap-1.5">
410
+ <span class="font-medium text-foreground">{field.label}</span>
411
+ <span class="text-muted-foreground font-mono text-[10px]">({field.name})</span>
412
+ {#if field.required}
413
+ <span class="text-destructive">*</span>
414
+ {/if}
415
+ </div>
416
+ </td>
417
+ <td class="p-3 text-center text-muted-foreground">
418
+ <ArrowRight size={14} class="inline" />
419
+ </td>
420
+ <td class="p-3">
421
+ <select
422
+ bind:value={fieldMapping[field.name]}
423
+ class="h-8 w-full rounded-md border border-input bg-background px-2.5 text-xs focus:ring-1 focus:ring-ring"
424
+ >
425
+ <option value="">-- {i18n.t('excel.unmapped')} --</option>
426
+ {#each rawHeaders as header (header)}
427
+ <option value={header}>{header}</option>
428
+ {/each}
429
+ </select>
430
+ </td>
431
+ </tr>
432
+ {/each}
433
+ </tbody>
434
+ </table>
435
+ </div>
436
+ </div>
437
+
438
+ <!-- 步骤 3:数据校验与预览 -->
439
+ {:else if currentStep === 3}
440
+ <div class="space-y-4">
441
+ <!-- 统计栏与筛选 -->
442
+ <div class="flex items-center justify-between p-3 rounded-lg border border-border bg-muted/20 text-xs">
443
+ <div class="flex items-center gap-4">
444
+ <div class="flex items-center gap-1.5 text-primary font-medium">
445
+ <CheckCircle2 size={16} />
446
+ <span>{i18n.t('excel.validRows')}: {validationResult.validRows.length} 条</span>
447
+ </div>
448
+ <div class="flex items-center gap-1.5 text-destructive font-medium">
449
+ <AlertCircle size={16} />
450
+ <span>{i18n.t('excel.errorRows')}: {validationResult.errorRows.length} 条</span>
451
+ </div>
452
+ </div>
453
+
454
+ <label class="flex items-center gap-2 cursor-pointer select-none">
455
+ <input
456
+ type="checkbox"
457
+ bind:checked={onlyShowErrors}
458
+ class="rounded border-input text-primary focus:ring-ring h-3.5 w-3.5"
459
+ />
460
+ <span class="text-muted-foreground">仅显示异常记录</span>
461
+ </label>
462
+ </div>
463
+
464
+ <!-- 预览表格 -->
465
+ <div class="rounded-lg border border-border overflow-x-auto max-h-[300px]">
466
+ <table class="w-full text-xs text-left whitespace-nowrap">
467
+ <thead class="bg-muted/40 border-b border-border text-muted-foreground font-semibold sticky top-0">
468
+ <tr>
469
+ <th class="p-2.5 w-12 text-center">#</th>
470
+ {#each fields as f (f.name)}
471
+ <th class="p-2.5">{f.label}</th>
472
+ {/each}
473
+ </tr>
474
+ </thead>
475
+ <tbody class="divide-y divide-border">
476
+ {#each previewList as row, idx (idx)}
477
+ {@const mappedRow = row}
478
+ <tr class="hover:bg-muted/20">
479
+ <td class="p-2.5 text-center text-muted-foreground">{idx + 1}</td>
480
+ {#each fields as f (f.name)}
481
+ {@const colName = fieldMapping[f.name]}
482
+ {@const val = colName ? mappedRow[colName] ?? mappedRow[f.name] : ''}
483
+ <td class="p-2.5">{val || '-'}</td>
484
+ {/each}
485
+ </tr>
486
+ {/each}
487
+ {#if previewList.length === 0}
488
+ <tr>
489
+ <td colspan={fields.length + 1} class="py-12 text-center text-muted-foreground">
490
+ 没有可显示的数据
491
+ </td>
492
+ </tr>
493
+ {/if}
494
+ </tbody>
495
+ </table>
496
+ </div>
497
+ </div>
498
+
499
+ <!-- 步骤 4:导入完成 -->
500
+ {:else if currentStep === 4}
501
+ <div class="flex flex-col items-center justify-center py-12 text-center">
502
+ <div class="flex h-14 w-14 items-center justify-center rounded-full bg-primary/10 text-primary mb-4">
503
+ <CheckCircle2 size={32} />
504
+ </div>
505
+ <h4 class="text-base font-semibold text-foreground mb-1">导入任务已成功提交!</h4>
506
+ <p class="text-xs text-muted-foreground max-w-sm mb-6">
507
+ 已成功录入 {validationResult.validRows.length} 条有效数据。可在主列表或数据报表中查看详情。
508
+ </p>
509
+ <button
510
+ type="button"
511
+ class="inline-flex items-center gap-1.5 px-4 py-2 rounded-lg bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/90 transition-colors cursor-pointer"
512
+ onclick={handleReset}
513
+ >
514
+ <RotateCcw size={14} />
515
+ <span>继续导入下一批</span>
516
+ </button>
517
+ </div>
518
+ {/if}
519
+ </div>
520
+
521
+ <!-- 底部操作按钮 -->
522
+ {#if currentStep < 4}
523
+ <div class="border-t border-border p-4 bg-muted/10 flex items-center justify-between">
524
+ <div>
525
+ {#if currentStep > 1}
526
+ <button
527
+ type="button"
528
+ class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-background text-xs font-medium hover:bg-muted transition-colors cursor-pointer"
529
+ onclick={() => { currentStep = (currentStep - 1) as 1 | 2 | 3; }}
530
+ >
531
+ <ArrowLeft size={14} />
532
+ <span>上一步</span>
533
+ </button>
534
+ {/if}
535
+ </div>
536
+
537
+ <div class="flex items-center gap-2">
538
+ {#if oncancel}
539
+ <button
540
+ type="button"
541
+ class="px-3 py-1.5 rounded-lg border border-border bg-background text-xs font-medium hover:bg-muted transition-colors cursor-pointer"
542
+ onclick={oncancel}
543
+ >
544
+ 取消
545
+ </button>
546
+ {/if}
547
+
548
+ {#if currentStep === 2}
549
+ <button
550
+ type="button"
551
+ class="inline-flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/90 transition-colors cursor-pointer"
552
+ onclick={() => { currentStep = 3; }}
553
+ >
554
+ <span>下一步:校验预览</span>
555
+ <ArrowRight size={14} />
556
+ </button>
557
+ {:else if currentStep === 3}
558
+ <button
559
+ type="button"
560
+ disabled={isSubmitting || validationResult.validRows.length === 0}
561
+ class="inline-flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 cursor-pointer"
562
+ onclick={handleConfirmImport}
563
+ >
564
+ <span>{isSubmitting ? '正在提交...' : i18n.t('excel.startImport')}</span>
565
+ <Check size={14} />
566
+ </button>
567
+ {/if}
568
+ </div>
569
+ </div>
570
+ {/if}
571
+ </div>
@@ -0,0 +1,26 @@
1
+ export interface ExcelImportField {
2
+ name: string;
3
+ label: string;
4
+ required?: boolean | undefined;
5
+ type?: 'string' | 'number' | 'date' | undefined;
6
+ validator?: ((val: unknown) => string | null) | undefined;
7
+ }
8
+ export interface ExcelImportWizardProps {
9
+ fields: ExcelImportField[];
10
+ title?: string | undefined;
11
+ description?: string | undefined;
12
+ templateUrl?: string | undefined;
13
+ class?: string | undefined;
14
+ onimport?: ((result: {
15
+ validRows: Record<string, unknown>[];
16
+ errorRows: {
17
+ row: number;
18
+ errors: Record<string, string>;
19
+ data: Record<string, unknown>;
20
+ }[];
21
+ }) => Promise<void> | void) | undefined;
22
+ oncancel?: (() => void) | undefined;
23
+ }
24
+ declare const ExcelImportWizard: import("svelte").Component<ExcelImportWizardProps, {}, "">;
25
+ type ExcelImportWizard = ReturnType<typeof ExcelImportWizard>;
26
+ export default ExcelImportWizard;