Pārlūkot izejas kodu

工分复评修改

ouyj 3 mēneši atpakaļ
vecāks
revīzija
7751342994
1 mainītis faili ar 83 papildinājumiem un 2 dzēšanām
  1. 83 2
      ygtx-ui/src/views/gxt/orderScore/index.vue

+ 83 - 2
ygtx-ui/src/views/gxt/orderScore/index.vue

@@ -827,7 +827,7 @@
                   :min="0.01"
                   :max="100"
                   :step="0.01"
-                  @change="updateReviewTotalScore(scope.row)"/>
+                  @input="onReviewScoreInputChange(scope.row)"/>
               </template>
             </el-table-column>
             <!-- 额外工分和工单得分 - 仅当维修工单且有额外工作总结时显示 -->
@@ -1487,6 +1487,49 @@ const isCurrentUserInScoreList = computed(() => {
 const showModifyReason = ref(false);
 const showFeedbackReason = ref(false);
 
+// 方法:检查复评得分是否与自评得分不同
+function checkReviewScoreChanged() {
+  if (!reviewForm.value || !reviewForm.value.scorePersonList) {
+    return false;
+  }
+  
+  return reviewForm.value.scorePersonList.some(person => {
+    const selfScore = person.selfScore !== null && person.selfScore !== undefined && person.selfScore !== '' 
+      ? parseFloat(person.selfScore) 
+      : null;
+    const reviewScore = person.reviewScore !== null && person.reviewScore !== undefined && person.reviewScore !== '' 
+      ? parseFloat(person.reviewScore) 
+      : null;
+    
+    // 如果自评得分和复评得分都存在且不相等,则返回true
+    if (selfScore !== null && reviewScore !== null) {
+      return Math.abs(selfScore - reviewScore) > 0.005; // 使用容差避免浮点数精度问题
+    }
+    
+    // 如果自评得分存在但复评得分不存在,或反之,也认为是不同
+    return (selfScore !== null && reviewScore === null) || (selfScore === null && reviewScore !== null);
+  });
+}
+
+// 方法:检查分项完成系数是否发生变化(仅适用于维保工单)
+function checkItemCompletionFactorChanged() {
+  if (!reviewForm.value || reviewForm.value.orderType !== 2) {
+    // 不是维保工单,不需要检查分项完成系数
+    return false;
+  }
+  
+  const currentFactor = reviewForm.value.itemCompletionFactor;
+  const initialFactor = reviewForm.value.initialItemCompletionFactor;
+  
+  if (currentFactor == null || initialFactor == null) {
+    // 如果任一值为null,认为没有变化
+    return false;
+  }
+  
+  // 比较分项完成系数是否发生变化
+  return Math.abs(parseFloat(currentFactor) - parseFloat(initialFactor)) > 0.005;
+}
+
 // 控制反馈按钮状态
 const showMaintenanceFeedback = ref(false);
 const showCompletionFactorFeedback = ref(false);
@@ -1844,6 +1887,33 @@ function updateReviewTotalScore(row) {
   }
 }
 
+// 防抖定时器
+let debounceTimer = null;
+
+/** 复评得分变化处理(带防抖) */
+function onReviewScoreInputChange(row) {
+  // 清除之前的定时器
+  if (debounceTimer) {
+    clearTimeout(debounceTimer);
+  }
+  
+  // 设置新的定时器
+  debounceTimer = setTimeout(() => {
+    updateReviewTotalScore(row);
+    
+    // 检查是否需要显示修改理由
+    const shouldShowModifyReason = checkReviewScoreChanged() || checkItemCompletionFactorChanged();
+    
+    if (shouldShowModifyReason && !showModifyReason.value) {
+      // 需要显示修改理由,且当前未显示
+      showModifyReason.value = true;
+    } else if (!shouldShowModifyReason && showModifyReason.value) {
+      // 不需要显示修改理由,但当前显示着
+      showModifyReason.value = false;
+    }
+  }, 300); // 300ms 防抖延迟
+}
+
 /** 处理额外工作总结变化 */
 function handleExtraWorkChange() {
   // 如果额外工作总结为空,清空额外工分和总分的值
@@ -2069,8 +2139,19 @@ function handleReview(row) {
     // 重置编辑状态
     isMaintenanceTypeEditable.value = false;
     isItemCompletionFactorEditable.value = false;
-    showModifyReason.value = false;
     showReturnReason.value = false;
+    showModifyReason.value = false;
+    
+    // 检查是否需要显示修改理由 - 检查复评得分是否与自评得分不同或分项完成系数是否变化
+    // 在数据加载完成后检查是否需要显示修改理由
+   /* const shouldShowModifyReason = checkReviewScoreChanged() || checkItemCompletionFactorChanged();
+    
+    if (shouldShowModifyReason && !showModifyReason.value) {
+      showModifyReason.value = true;
+    } else if (!shouldShowModifyReason && showModifyReason.value) {
+      // 如果不需要显示修改理由,但当前显示着,则隐藏
+      showModifyReason.value = false;
+    }*/
 
     // 如果是维保工单,根据风机型号获取维保类型选项
     if (row.orderType === 2) {