diff --git a/src/views/emis/emisTmsCostFee/BatchImportCostFee.vue b/src/views/emis/emisTmsCostFee/BatchImportCostFee.vue index 606ef36f..7bd5bc85 100644 --- a/src/views/emis/emisTmsCostFee/BatchImportCostFee.vue +++ b/src/views/emis/emisTmsCostFee/BatchImportCostFee.vue @@ -265,18 +265,21 @@ export default { // const header = this.getHeaderRow(worksheet) // 标题 const results = XLSX.utils.sheet_to_json(worksheet) - - // 标题头 - that.dynamicCol=[]; - for (var key in results[0]) { - that.dynamicCol.push( - { - label:key, - prop:key - } - ); + that.dynamicCol = []; + const keysSet = new Set(); // 用Set存储key,自动去重 + // 遍历所有results中的对象 + for (const item of results) { + // 遍历当前对象的每个key + for (const key in item) { + // 添加到Set(重复的key会被自动忽略) + keysSet.add(key); + } } - + // 将Set转换为数组,并映射为目标格式 + that.dynamicCol = Array.from(keysSet).map(key => ({ + label: key, + prop: key + })); // 转换费用类型 that.feeItemMap=new Map();; for(let i=0;i