| | |
| | | try { |
| | | clearLoading.value = true |
| | | const response = await deviceInteractionApi.executeOperation({ |
| | | deviceId: loadDeviceId.value, |
| | | id: loadDeviceId.value, |
| | | operation: 'clearPlc', |
| | | params: {} |
| | | }) |
| | |
| | | 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') || |
| | |
| | | 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 |
| | | } |
| | | }) |
| | | |
| | | // 如果没有找到表头,尝试使用第一行作为表头(索引方式) |
| | | 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 padTwoZero = (num) => num.toString().padStart(2, '0') |
| | | // 解析数据行 |
| | | const result = [] |
| | | for (let i = 1; i < jsonData.length; i++) { |
| | |
| | | |
| | | 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 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 && !height && !thickness && !quantity) { |
| | | if (!glassId && !width && !length && !thickness && !quantity) { |
| | | continue |
| | | } |
| | | |
| | |
| | | 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}${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, |
| | | width: parseNumber(width), |
| | | height: parseNumber(height), |
| | | length: parseNumber(length), |
| | | 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中没有则为空 |
| | | }) |
| | | } |
| | | } |