| | |
| | | headerStr === 'w' || headerStr === '宽度') { |
| | | headerMap.width = index |
| | | } |
| | | // 高度 |
| | | else if (headerStr.includes('高') || headerStr.includes('height') || |
| | | headerStr === 'h' || headerStr === '高度') { |
| | | headerMap.height = index |
| | | // 长度 |
| | | else if (headerStr.includes('长') || headerStr.includes('length') || |
| | | headerStr === 'l' || headerStr === '长度') { |
| | | headerMap.length = index |
| | | } |
| | | // 厚度 |
| | | else if (headerStr.includes('厚') || headerStr.includes('thickness') || |
| | |
| | | |
| | | // 如果没有找到表头,尝试使用第一行作为表头(索引方式) |
| | | if (Object.keys(headerMap).length === 0 && jsonData.length > 1) { |
| | | // 默认格式:玻璃ID, 宽, 高, 厚, 数量(按列顺序) |
| | | // 默认格式:玻璃ID, 宽, 长, 厚, 数量(按列顺序) |
| | | headerMap.glassId = 0 |
| | | headerMap.width = 1 |
| | | headerMap.height = 2 |
| | | headerMap.length = 2 |
| | | headerMap.thickness = 3 |
| | | headerMap.quantity = 4 |
| | | } |
| | |
| | | |
| | | const glassId = row[headerMap.glassId] ? String(row[headerMap.glassId]).trim() : '' |
| | | const width = row[headerMap.width] ? String(row[headerMap.width]).trim() : '' |
| | | const height = row[headerMap.height] ? String(row[headerMap.height]).trim() : '' |
| | | const length = row[headerMap.length] ? String(row[headerMap.length]).trim() : '' |
| | | const thickness = row[headerMap.thickness] ? String(row[headerMap.thickness]).trim() : '' |
| | | const quantity = row[headerMap.quantity] ? String(row[headerMap.quantity]).trim() : '' |
| | | const filmsId = row[headerMap.filmsId] ? String(row[headerMap.filmsId]).trim() : '' |
| | |
| | | const customerName = row[headerMap.customerName] ? String(row[headerMap.customerName]).trim() : '' |
| | | |
| | | // 跳过空行 |
| | | if (!glassId && !width && !height && !thickness && !quantity) { |
| | | if (!glassId && !width && !length && !thickness && !quantity) { |
| | | continue |
| | | } |
| | | |
| | |
| | | const qty = parseInt(quantity) || 1 |
| | | for (let j = 0; j < qty; j++) { |
| | | // 如果数量大于1,为每条记录生成唯一的玻璃ID(追加序号) |
| | | const finalGlassId = qty > 1 ? `${glassId}_${j + 1}` : glassId |
| | | const finalGlassId = qty > 1 ? `${glassId}${j + 1}` : glassId |
| | | |
| | | result.push({ |
| | | glassId: finalGlassId, |
| | | width: parseNumber(width), |
| | | height: parseNumber(height), |
| | | length: parseNumber(length), |
| | | thickness: parseNumber(thickness), |
| | | quantity: '1', // 每条记录数量为1 |
| | | filmsId: filmsId, |