| | |
| | | try { |
| | | clearLoading.value = true |
| | | const response = await deviceInteractionApi.executeOperation({ |
| | | deviceId: loadDeviceId.value, |
| | | id: loadDeviceId.value, |
| | | operation: 'clearPlc', |
| | | params: {} |
| | | }) |
| | |
| | | headerStr === '客户名称') { |
| | | headerMap.customerName = index |
| | | } |
| | | // 层号 |
| | | else if (headerStr.includes('层号') || headerStr.includes('layer') || |
| | | headerStr === '层') { |
| | | headerMap.layer = index |
| | | } |
| | | // 工程号 |
| | | else if (headerStr.includes('工程号') || headerStr.includes('engineeringid') || |
| | | headerStr.includes('engineering') || headerStr === '工程id') { |
| | | headerMap.engineeringId = index |
| | | } |
| | | }) |
| | | |
| | | // 如果没有找到表头,尝试使用第一行作为表头(索引方式) |
| | |
| | | const flowCardId = row[headerMap.flowCardId] ? String(row[headerMap.flowCardId]).trim() : '' |
| | | const productName = row[headerMap.productName] ? String(row[headerMap.productName]).trim() : '' |
| | | const customerName = row[headerMap.customerName] ? String(row[headerMap.customerName]).trim() : '' |
| | | const layer = row[headerMap.layer] ? String(row[headerMap.layer]).trim() : '' |
| | | const engineeringId = row[headerMap.engineeringId] ? String(row[headerMap.engineeringId]).trim() : '' |
| | | |
| | | // 跳过空行 |
| | | if (!glassId && !width && !length && !thickness && !quantity) { |
| | |
| | | return isNaN(num) ? '0' : String(num) |
| | | } |
| | | |
| | | // 处理数量:如果数量大于1,需要生成多条记录 |
| | | // 处理数量:根据数量生成多条记录,每条记录都要补齐序号 |
| | | const qty = parseInt(quantity) || 1 |
| | | for (let j = 0; j < qty; j++) { |
| | | // 如果数量大于1,为每条记录生成唯一的玻璃ID(追加序号) |
| | | const finalGlassId = qty > 1 ? `${glassId}${padTwoZero(j + 1)}` : glassId |
| | | // 为每条记录生成唯一的玻璃ID(追加序号,即使数量为1也要补齐) |
| | | // 例如:glassId="1", quantity=2 -> "101", "102" |
| | | // glassId="2", quantity=1 -> "201" |
| | | const finalGlassId = `${glassId}${padTwoZero(j + 1)}` |
| | | |
| | | result.push({ |
| | | glassId: finalGlassId, |
| | |
| | | thickness: parseNumber(thickness), |
| | | quantity: '1', // 每条记录数量为1 |
| | | filmsId: filmsId, |
| | | flowCardId: flowCardId || finalGlassId, |
| | | flowCardId: flowCardId || '', // 如果Excel中没有流程卡ID,传空字符串让后端生成 |
| | | productName: productName, |
| | | customerName: customerName |
| | | customerName: customerName, |
| | | layer: layer || '', // 层号,如果Excel中没有则为空 |
| | | engineeringId: engineeringId || '' // 工程号,如果Excel中没有则为空 |
| | | }) |
| | | } |
| | | } |