| | |
| | | return; |
| | | } |
| | | emit('getSmallPieceData', 1); |
| | | optimizeData.value.glassDetails = []; |
| | | xGrid.value.getTableData().fullData.forEach(items=>{ |
| | | let rackNoValue = 0; |
| | | if (items.rackNo !== undefined && items.rackNo !== null && items.rackNo !== '') { |
| | |
| | | dialogVisible.value[3] = newValue; |
| | | } |
| | | if (props.CheckboxChangeData!=null && props.CheckboxChangeData.length>0){ |
| | | optimizeData.value.materialDetails = []; |
| | | props.CheckboxChangeData.forEach(items=>{ |
| | | const detail={ |
| | | width :null, |
| | |
| | | const grindingTrimming = res.data.grindingTrimming; |
| | | optimizeState.value=res.data.optimizeState; |
| | | |
| | | // 加载磨量配置 |
| | | loadGrindingConfiguration().then((grindConfig) => { |
| | | console.log("加载的磨量配置:", grindConfig); |
| | | |
| | | data = data.map(item => { |
| | | // 保留从后端返回的原始磨量值,如果存在的话 |
| | | const originalLongGrind1 = item.longGrind1; |
| | | const originalLongGrind2 = item.longGrind2; |
| | | const originalShortGrind1 = item.shortGrind1; |
| | | const originalShortGrind2 = item.shortGrind2; |
| | | |
| | | // 如果没有原始磨量值,则初始化为0 |
| | | item.longGrind1 = originalLongGrind1 !== undefined && originalLongGrind1 !== null ? |
| | | parseFloat(originalLongGrind1) : 0; |
| | | item.longGrind2 = originalLongGrind2 !== undefined && originalLongGrind2 !== null ? |
| | | parseFloat(originalLongGrind2) : 0; |
| | | item.shortGrind1 = originalShortGrind1 !== undefined && originalShortGrind1 !== null ? |
| | | parseFloat(originalShortGrind1) : 0; |
| | | item.shortGrind2 = originalShortGrind2 !== undefined && originalShortGrind2 !== null ? |
| | | parseFloat(originalShortGrind2) : 0; |
| | | |
| | | // 处理 grindingTrimming 数据(如果存在) |
| | | let processedGrindConfig = null; |
| | | if(grindingTrimming!==null && grindingTrimming.length > 0){ |
| | | // 处理 grindingTrimming 数据,去除双引号 |
| | | const formattedData = grindingTrimming.map(item => { |
| | | const formattedItem = {}; |
| | | for (const key in item) { |
| | |
| | | } |
| | | return formattedItem; |
| | | }); |
| | | processedGrindConfig = formattedData[0]; |
| | | } |
| | | |
| | | // 如果有自动填充配置,使用它来设置磨量 |
| | | if(formattedData[0].autoFillEdge==="true"){ |
| | | const minAutoLenght = parseFloat(formattedData[0].minAutoLenght) || 0; |
| | | const leftEdge = parseFloat(formattedData[0].leftEdge) || 0; |
| | | const rightEdge = parseFloat(formattedData[0].rightEdge) || 0; |
| | | const upEdge = parseFloat(formattedData[0].upEdge) || 0; |
| | | const downEdge = parseFloat(formattedData[0].downEdge) || 0; |
| | | data = data.map(item => { |
| | | // 直接将 grindingTrimming 中的磨量信息写到表中 |
| | | if (processedGrindConfig) { |
| | | // 使用 grindingTrimming 中的配置设置磨量 |
| | | const leftEdge = parseFloat(processedGrindConfig.leftEdge) || 0; |
| | | const rightEdge = parseFloat(processedGrindConfig.rightEdge) || 0; |
| | | const upEdge = parseFloat(processedGrindConfig.upEdge) || 0; |
| | | const downEdge = parseFloat(processedGrindConfig.downEdge) || 0; |
| | | |
| | | if(item.width >= minAutoLenght){ |
| | | item.longGrind1 = leftEdge; |
| | | item.longGrind2 = rightEdge; |
| | | } |
| | | if(item.height >= minAutoLenght){ |
| | | item.shortGrind1 = upEdge; |
| | | item.shortGrind2 = downEdge; |
| | | } |
| | | } |
| | | } else if(grindConfig) { |
| | | // 使用从 getConfiguration 接口加载的配置 |
| | | if(grindConfig.autoFillEdge==="true"){ |
| | | const minAutoLenght = parseFloat(grindConfig.minAutoLenght) || 0; |
| | | const leftEdge = parseFloat(grindConfig.leftEdge) || 0; |
| | | const rightEdge = parseFloat(grindConfig.rightEdge) || 0; |
| | | const upEdge = parseFloat(grindConfig.upEdge) || 0; |
| | | const downEdge = parseFloat(grindConfig.downEdge) || 0; |
| | | item.longGrind1 = leftEdge; // 长磨1 |
| | | item.longGrind2 = rightEdge; // 长磨2 |
| | | item.shortGrind1 = upEdge; // 短磨1 |
| | | item.shortGrind2 = downEdge; // 短磨2 |
| | | |
| | | if(item.width >= minAutoLenght){ |
| | | item.longGrind1 = leftEdge; |
| | | item.longGrind2 = rightEdge; |
| | | // 如果启用了自动填充功能,根据尺寸判断是否应用磨量 |
| | | if(processedGrindConfig.autoFillEdge === "true"){ |
| | | const minAutoLength = parseFloat(processedGrindConfig.minAutoLenght) || 0; |
| | | |
| | | // 如果宽度小于最小自动长度,不应用左右磨量 |
| | | if(item.width < minAutoLength){ |
| | | item.longGrind1 = 0; |
| | | item.longGrind2 = 0; |
| | | } |
| | | if(item.height >= minAutoLenght){ |
| | | item.shortGrind1 = upEdge; |
| | | item.shortGrind2 = downEdge; |
| | | |
| | | // 如果高度小于最小自动长度,不应用上下磨量 |
| | | if(item.height < minAutoLength){ |
| | | item.shortGrind1 = 0; |
| | | item.shortGrind2 = 0; |
| | | } |
| | | } |
| | | }else { |
| | | // 即使没有启用自动填充,也应该应用默认的磨量值 |
| | | item.longGrind1 = parseFloat(grindConfig.leftEdge) || 0; |
| | | item.longGrind2 = parseFloat(grindConfig.rightEdge) || 0; |
| | | item.shortGrind1 = parseFloat(grindConfig.upEdge) || 0; |
| | | item.shortGrind2 = parseFloat(grindConfig.downEdge) || 0; |
| | | } |
| | | // 如果没有 grindingTrimming 数据,初始化为0 |
| | | item.longGrind1 = item.longGrind1 !== undefined && item.longGrind1 !== null ? |
| | | parseFloat(item.longGrind1) : 0; |
| | | item.longGrind2 = item.longGrind2 !== undefined && item.longGrind2 !== null ? |
| | | parseFloat(item.longGrind2) : 0; |
| | | item.shortGrind1 = item.shortGrind1 !== undefined && item.shortGrind1 !== null ? |
| | | parseFloat(item.shortGrind1) : 0; |
| | | item.shortGrind2 = item.shortGrind2 !== undefined && item.shortGrind2 !== null ? |
| | | parseFloat(item.shortGrind2) : 0; |
| | | } |
| | | |
| | | item.height=parseFloat(item.height.toFixed(2)) |
| | |
| | | return item; |
| | | }); |
| | | |
| | | console.log("处理后的数据:", data); |
| | | |
| | | xGrid.value.loadData(data); |
| | | gridOptions.data = data; |
| | | projectName.value = data[0].project_name; |
| | | quantitys.value=res.data.project.glass_total |
| | | areas.value=res.data.project.glass_total_area |
| | | }); |
| | | |
| | | // 更新 optimizeData 中的磨量配置 |
| | | updateOptimizeDataWithGrindingConfig(processedGrindConfig); |
| | | } else { |
| | | ElMessage.warning(res.msg); |
| | | } |
| | |
| | | }); |
| | | }; |
| | | |
| | | const updateOptimizeDataWithGrindingConfig = (grindConfig) => { |
| | | if (grindConfig) { |
| | | // 更新 optimizeData 中的磨量配置 |
| | | optimizeData.value.grindingConfig = { |
| | | leftEdge: parseFloat(grindConfig.leftEdge) || 0, |
| | | upEdge: parseFloat(grindConfig.upEdge) || 0, |
| | | rightEdge: parseFloat(grindConfig.rightEdge) || 0, |
| | | downEdge: parseFloat(grindConfig.downEdge) || 0, |
| | | autoFillEdge: grindConfig.autoFillEdge === "true", |
| | | minAutoLength: parseFloat(grindConfig.minAutoLenght) || 0 |
| | | }; |
| | | } |
| | | }; |
| | | |
| | | const firstLoading = async() => { |
| | | request.post(`/glassOptimize/selectOptimizeParms/${username}`).then((res) => { |
| | |
| | | });*/ |
| | | }; |
| | | |
| | | const grindingConfig = ref(null); |
| | | |
| | | const loadGrindingConfiguration = async () => { |
| | | return new Promise((resolve) => { |
| | |
| | | } |
| | | return formattedItem; |
| | | }); |
| | | // 保存磨量配置 |
| | | grindingConfig.value = formattedData[0]; |
| | | resolve(formattedData[0]); |
| | | } else { |
| | | // 提供默认配置 |
| | | resolve({ |
| | | const defaultConfig = { |
| | | leftEdge: '0', |
| | | upEdge: '0', |
| | | rightEdge: '0', |
| | |
| | | quickEdge: '1', |
| | | autoFillEdge: 'false', |
| | | minAutoLenght: '0' |
| | | }); |
| | | }; |
| | | grindingConfig.value = defaultConfig; |
| | | resolve(defaultConfig); |
| | | } |
| | | } else { |
| | | ElMessage.warning(res.msg); |
| | | // 提供默认配置 |
| | | resolve({ |
| | | const defaultConfig = { |
| | | leftEdge: '0', |
| | | upEdge: '0', |
| | | rightEdge: '0', |
| | |
| | | quickEdge: '1', |
| | | autoFillEdge: 'false', |
| | | minAutoLenght: '0' |
| | | }); |
| | | }; |
| | | grindingConfig.value = defaultConfig; |
| | | resolve(defaultConfig); |
| | | } |
| | | }).catch(() => { |
| | | // 提供默认配置 |
| | | resolve({ |
| | | const defaultConfig = { |
| | | leftEdge: '0', |
| | | upEdge: '0', |
| | | rightEdge: '0', |
| | |
| | | quickEdge: '1', |
| | | autoFillEdge: 'false', |
| | | minAutoLenght: '0' |
| | | }); |
| | | }; |
| | | grindingConfig.value = defaultConfig; |
| | | resolve(defaultConfig); |
| | | }); |
| | | }); |
| | | }; |