haiwei-ui 1.1.4 → 1.1.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haiwei-ui",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "HaiWei前端组件库",
5
5
  "author": "Eric",
6
6
  "license": "ISC",
@@ -154,6 +154,11 @@
154
154
  <el-checkbox v-model="row.required" :disabled="!row.targetColumn" size="mini" />
155
155
  </template>
156
156
  </el-table-column>
157
+ <el-table-column prop="deduplicate" label="去重" width="60" align="center">
158
+ <template v-slot="{ row }">
159
+ <el-checkbox v-model="row.deduplicate" :disabled="!row.targetColumn" size="mini" />
160
+ </template>
161
+ </el-table-column>
157
162
  </el-table>
158
163
  </div>
159
164
 
@@ -185,9 +190,18 @@
185
190
  <el-descriptions-item label="原始总行数">
186
191
  <el-tag type="info" size="small">{{ parseResult.basicInfo.totalRows }}</el-tag>
187
192
  </el-descriptions-item>
193
+ <el-descriptions-item label="有效数据行数">
194
+ <el-tag type="info" size="small">{{ originalDataRows }}</el-tag>
195
+ </el-descriptions-item>
188
196
  <el-descriptions-item label="确认导入总行数">
189
197
  <el-tag type="success" size="small">{{ confirmImportTotalRows }}</el-tag>
190
198
  </el-descriptions-item>
199
+ <el-descriptions-item label="移除重复行数">
200
+ <el-tag v-if="model.deduplicate && removedDuplicateRows > 0" type="warning" size="small">
201
+ {{ removedDuplicateRows }}
202
+ </el-tag>
203
+ <el-tag v-else type="info" size="small">0</el-tag>
204
+ </el-descriptions-item>
191
205
  <el-descriptions-item label="已配置映射">
192
206
  <el-tag type="success" size="small">{{ getMappedColumnsCount() }}列</el-tag>
193
207
  </el-descriptions-item>
@@ -337,10 +351,33 @@ export default {
337
351
 
338
352
  return allData
339
353
  },
340
- // 确认导入的总行数
354
+ // 原始数据行数(去重前的行数)
355
+ originalDataRows() {
356
+ if (!this.parseResult || !this.parseResult.previewData) {
357
+ return 0
358
+ }
359
+
360
+ // 获取有效的列映射(有目标字段的映射)
361
+ const validMappings = this.columnMapping.filter(mapping => mapping.targetColumn)
362
+
363
+ if (validMappings.length === 0) {
364
+ return 0
365
+ }
366
+
367
+ // 只统计有有效映射的数据行
368
+ return this.parseResult.previewData.length
369
+ },
370
+ // 确认导入的总行数(去重后的行数)
341
371
  confirmImportTotalRows() {
342
372
  return this.deduplicatedPreviewData.length
343
373
  },
374
+ // 移除的重复行数
375
+ removedDuplicateRows() {
376
+ if (!this.model.deduplicate) {
377
+ return 0
378
+ }
379
+ return Math.max(0, this.originalDataRows - this.confirmImportTotalRows)
380
+ },
344
381
  // 确认导入的列(只显示已配置映射的字段)
345
382
  confirmImportColumns() {
346
383
  const validMappings = this.columnMapping.filter(mapping => mapping.targetColumn)
@@ -511,7 +548,8 @@ export default {
511
548
  this.columnMapping = this.parseResult.columns.map(col => ({
512
549
  excelColumn: col,
513
550
  targetColumn: this.findBestMatch(col),
514
- required: false
551
+ required: false,
552
+ deduplicate: true // 默认勾选去重
515
553
  }))
516
554
  },
517
555
 
@@ -616,19 +654,19 @@ export default {
616
654
  return allAddModels
617
655
  },
618
656
 
619
- // 通用的去重方法,可用于数据和模型 - 按所有已配置映射的字段组合去重
657
+ // 通用的去重方法,可用于数据和模型 - 按勾选了去重的字段进行组合去重
620
658
  deduplicateModels(models) {
621
659
  if (!models || models.length === 0) {
622
660
  return []
623
661
  }
624
662
 
625
- // 获取所有已配置的目标字段
626
- const targetFields = this.columnMapping
627
- .filter(mapping => mapping.targetColumn)
663
+ // 获取勾选了去重的目标字段
664
+ const deduplicateFields = this.columnMapping
665
+ .filter(mapping => mapping.targetColumn && mapping.deduplicate)
628
666
  .map(mapping => mapping.targetColumn)
629
667
 
630
- // 如果没有目标字段,无法去重
631
- if (targetFields.length === 0) {
668
+ // 如果没有勾选去重的字段,返回原始数据
669
+ if (deduplicateFields.length === 0) {
632
670
  return models
633
671
  }
634
672
 
@@ -637,13 +675,13 @@ export default {
637
675
  const deduplicatedItems = []
638
676
 
639
677
  for (const item of models) {
640
- // 生成组合键:将所有目标字段的值拼接成一个字符串
678
+ // 生成组合键:将所有勾选了去重的字段的值拼接成一个字符串
641
679
  const keyParts = []
642
680
  let hasEmptyKey = false
643
681
 
644
- for (const field of targetFields) {
682
+ for (const field of deduplicateFields) {
645
683
  const value = item[field]
646
- // 如果任何一个关键字段为空,跳过该行的去重检查
684
+ // 如果任何一个去重字段为空,跳过该行的去重检查
647
685
  if (value === null || value === undefined || value === '') {
648
686
  hasEmptyKey = true
649
687
  break
@@ -651,7 +689,7 @@ export default {
651
689
  keyParts.push(`${field}:${value}`)
652
690
  }
653
691
 
654
- // 如果有空的关键字段,直接添加到结果中(不参与去重)
692
+ // 如果有空的去重字段,直接添加到结果中(不参与去重)
655
693
  if (hasEmptyKey) {
656
694
  deduplicatedItems.push(item)
657
695
  continue
@@ -673,7 +711,8 @@ export default {
673
711
  const removedCount = originalCount - deduplicatedCount
674
712
 
675
713
  if (removedCount > 0) {
676
- this._success(`数据去重:原始 ${originalCount} 条,去重后 ${deduplicatedCount} 条,移除 ${removedCount} 条重复数据(按所有已配置字段组合去重)`)
714
+ const fieldLabels = deduplicateFields.map(field => this.getTargetColumnLabel(field)).join('、')
715
+ this._success(`数据去重:原始 ${originalCount} 条,去重后 ${deduplicatedCount} 条,移除 ${removedCount} 条重复数据(按 ${fieldLabels} 字段组合去重)`)
677
716
  }
678
717
 
679
718
  return deduplicatedItems