|  | @@ -58,7 +58,7 @@
 | 
	
		
			
				|  |  |              style="width: 100%"
 | 
	
		
			
				|  |  |              placeholder="请输入单价"
 | 
	
		
			
				|  |  |              @input="validateFloatInput($event, scope.row, 'unitPrice')"
 | 
	
		
			
				|  |  | -            @blur="validateAndFormatFloatOnBlur(scope.row, 'unitPrice'); handleUnitPriceChange(scope.row, scope.$index)"
 | 
	
		
			
				|  |  | +            @blur="handleUnitPriceBlur(scope.row, scope.$index)"
 | 
	
		
			
				|  |  |            />
 | 
	
		
			
				|  |  |            <span v-else>{{ formatUnitPrice(scope.row.unitPrice) }}</span>
 | 
	
		
			
				|  |  |          </template>
 | 
	
	
		
			
				|  | @@ -71,7 +71,7 @@
 | 
	
		
			
				|  |  |              style="width: 100%"
 | 
	
		
			
				|  |  |              placeholder="请输入订单数量"
 | 
	
		
			
				|  |  |              @input="validateIntegerInput($event, scope.row, 'orderQuantity')"
 | 
	
		
			
				|  |  | -            @blur="handleQuantityChange(scope.row, scope.$index)"
 | 
	
		
			
				|  |  | +            @blur="handleQuantityBlur(scope.row, scope.$index)"
 | 
	
		
			
				|  |  |            />
 | 
	
		
			
				|  |  |            <span v-else>{{ formatIntegerNumber(scope.row.orderQuantity) }}</span>
 | 
	
		
			
				|  |  |          </template>
 | 
	
	
		
			
				|  | @@ -670,6 +670,19 @@ export default {
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | +     * 处理订单数量失焦事件
 | 
	
		
			
				|  |  | +     * @description 当订单数量输入框失焦时,触发数量变更处理
 | 
	
		
			
				|  |  | +     * @param {MaterialDetailRecord} row - 行数据
 | 
	
		
			
				|  |  | +     * @param {number} index - 行索引
 | 
	
		
			
				|  |  | +     * @returns {void}
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    handleQuantityBlur(row, index) {
 | 
	
		
			
				|  |  | +      // 如果 index 无效,尝试通过 row 数据找到正确的索引
 | 
	
		
			
				|  |  | +      const actualIndex = this.findRowIndex(row, index)
 | 
	
		
			
				|  |  | +      this.handleQuantityChange(row, actualIndex)
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  |       * 处理订单数量变更
 | 
	
		
			
				|  |  |       * @description 当订单数量发生变化时,自动计算总金额和税额,并触发父组件重新计算订单总计
 | 
	
		
			
				|  |  |       * @param {MaterialDetailRecord} row - 行数据
 | 
	
	
		
			
				|  | @@ -695,6 +708,22 @@ export default {
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | +     * 处理单价失焦事件
 | 
	
		
			
				|  |  | +     * @description 当单价输入框失焦时,先格式化数值,再计算总金额和税额,并触发父组件重新计算订单总计
 | 
	
		
			
				|  |  | +     * @param {MaterialDetailRecord} row - 行数据
 | 
	
		
			
				|  |  | +     * @param {number} index - 行索引
 | 
	
		
			
				|  |  | +     * @returns {void}
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    handleUnitPriceBlur(row, index) {
 | 
	
		
			
				|  |  | +      // 先格式化数值
 | 
	
		
			
				|  |  | +      this.validateAndFormatFloatOnBlur(row, 'unitPrice')
 | 
	
		
			
				|  |  | +      // 如果 index 无效,尝试通过 row 数据找到正确的索引
 | 
	
		
			
				|  |  | +      const actualIndex = this.findRowIndex(row, index)
 | 
	
		
			
				|  |  | +      // 再处理单价变更
 | 
	
		
			
				|  |  | +      this.handleUnitPriceChange(row, actualIndex)
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  |       * 处理单价变更
 | 
	
		
			
				|  |  |       * @description 当单价发生变化时,自动计算总金额和税额,并触发父组件重新计算订单总计
 | 
	
		
			
				|  |  |       * @param {MaterialDetailRecord} row - 行数据
 | 
	
	
		
			
				|  | @@ -829,7 +858,37 @@ export default {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      getCurrentRowIndex(row) {
 | 
	
		
			
				|  |  |        return this.currentPageData.findIndex(item => item.id === row.id)
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +      * 查找行索引
 | 
	
		
			
				|  |  | +      * @description 根据行数据查找在物料明细列表中的正确索引
 | 
	
		
			
				|  |  | +      * @param {MaterialDetailRecord} row - 行数据
 | 
	
		
			
				|  |  | +      * @param {number} providedIndex - 提供的索引
 | 
	
		
			
				|  |  | +      * @returns {number} 实际索引
 | 
	
		
			
				|  |  | +      */
 | 
	
		
			
				|  |  | +     findRowIndex(row, providedIndex) {
 | 
	
		
			
				|  |  | +       // 如果提供的索引有效,直接使用
 | 
	
		
			
				|  |  | +       if (providedIndex >= 0 && providedIndex < this.materialDetails.length) {
 | 
	
		
			
				|  |  | +         return providedIndex
 | 
	
		
			
				|  |  | +       }
 | 
	
		
			
				|  |  | +       
 | 
	
		
			
				|  |  | +       // 否则通过行数据查找索引
 | 
	
		
			
				|  |  | +       const index = this.materialDetails.findIndex(item => {
 | 
	
		
			
				|  |  | +         // 优先使用 id 进行匹配
 | 
	
		
			
				|  |  | +         if (row.id && item.id) {
 | 
	
		
			
				|  |  | +           return row.id === item.id
 | 
	
		
			
				|  |  | +         }
 | 
	
		
			
				|  |  | +         // 如果没有 id,使用物料编码进行匹配
 | 
	
		
			
				|  |  | +         if (row.itemCode && item.itemCode) {
 | 
	
		
			
				|  |  | +           return row.itemCode === item.itemCode
 | 
	
		
			
				|  |  | +         }
 | 
	
		
			
				|  |  | +         // 最后使用对象引用进行匹配
 | 
	
		
			
				|  |  | +         return row === item
 | 
	
		
			
				|  |  | +       })
 | 
	
		
			
				|  |  | +       
 | 
	
		
			
				|  |  | +       return index >= 0 ? index : -1
 | 
	
		
			
				|  |  | +     }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  </script>
 |