Parcourir la source

pms 瑞都日报 平台井 兼容 主井施工完成 关联井未施工完成的情况

zhangcl il y a 1 semaine
Parent
commit
e4f6772c52
1 fichiers modifiés avec 60 ajouts et 18 suppressions
  1. 60 18
      src/views/pms/iotrddailyreport/FillDailyReportForm.vue

+ 60 - 18
src/views/pms/iotrddailyreport/FillDailyReportForm.vue

@@ -635,17 +635,44 @@ const currentPlatformId = ref<number>() // 当前选中的平台井ID
 
 // 页面标题计算
 const pageTitle = computed(() => {
+  // 获取要显示的井名
+  const getDisplayWellName = () => {
+    // 如果是平台井模式且有平台井数据
+    if (dailyReportData.value.platformWell === 1 &&
+      dailyReportData.value.platforms &&
+      dailyReportData.value.platforms.length > 0) {
+
+      // 检查主井是否在平台井列表中
+      const isMainWellInPlatforms = dailyReportData.value.platforms.some(
+        (platform: any) => platform.id === dailyReportData.value.taskId
+      )
+
+      // 如果主井不在平台井列表中(说明主井已施工完成),使用第一个平台井的名称
+      if (!isMainWellInPlatforms) {
+        const firstPlatformWellName = dailyReportData.value.platforms[0].wellName
+        console.log(`主井已施工完成,标题使用平台井名称: ${firstPlatformWellName}`)
+        return firstPlatformWellName
+      }
+    }
+
+    // 其他情况使用原来的井名
+    return dailyReportData.value.wellName
+  }
+
+  const displayWellName = getDisplayWellName()
+  const constructionDate = dailyReportData.value.constructionStartDate
+
   if (isApprovalMode.value) {
-    return dailyReportData.value.wellName && dailyReportData.value.constructionStartDate
-      ? `${dailyReportData.value.wellName} - ${formatDate(dailyReportData.value.constructionStartDate)} 日报审批`
+    return displayWellName && constructionDate
+      ? `${displayWellName} - ${formatDate(constructionDate)} 日报审批`
       : '日报审批'
   } else if (isDetailMode.value) {
-    return dailyReportData.value.wellName && dailyReportData.value.constructionStartDate
-      ? `${dailyReportData.value.wellName} - ${formatDate(dailyReportData.value.constructionStartDate)} 日报详情`
+    return displayWellName && constructionDate
+      ? `${displayWellName} - ${formatDate(constructionDate)} 日报详情`
       : '日报详情'
   } else {
-    return dailyReportData.value.wellName && dailyReportData.value.constructionStartDate
-      ? `${dailyReportData.value.wellName} - ${formatDate(dailyReportData.value.constructionStartDate)} 生产日报`
+    return displayWellName && constructionDate
+      ? `${displayWellName} - ${formatDate(constructionDate)} 生产日报`
       : '日报填报'
   }
 })
@@ -717,18 +744,33 @@ const initPlatformData = (reportData: any) => {
     platformWellPairs.value = []
   }
 
-  // 设置默认选中的平台井
-  if (reportData.taskId && platformOptions.value.length > 0) {
-    // 查找与 taskId 匹配的平台井
-    const defaultPlatform = platformOptions.value.find(
-      (platform: any) => platform.id === reportData.taskId
-    )
-    if (defaultPlatform) {
-      formData.value.platformId = defaultPlatform.id
-      currentPlatformId.value = defaultPlatform.id
-
-      // 加载默认平台井的数据到表单
-      loadPlatformData(defaultPlatform.id)
+  // 设置默认选中的平台井 - 修改后的逻辑
+  if (platformOptions.value.length > 0) {
+    let selectedPlatform = null
+
+    // 首先尝试查找与 taskId 匹配的平台井
+    if (reportData.taskId) {
+      selectedPlatform = platformOptions.value.find(
+        (platform: any) => platform.id === reportData.taskId
+      )
+    }
+
+    // 如果没有找到匹配的平台井,选择第一个平台井
+    if (!selectedPlatform) {
+      selectedPlatform = platformOptions.value[0]
+    }
+
+    // 设置选中的平台井
+    if (selectedPlatform) {
+      formData.value.platformId = selectedPlatform.id
+      currentPlatformId.value = selectedPlatform.id
+      // 加载平台井的数据到表单
+      loadPlatformData(selectedPlatform.id)
+
+      // 可选:在控制台输出提示信息
+      if (reportData.taskId && selectedPlatform.id !== reportData.taskId) {
+        console.log(`主井已施工完成,已自动选择第一个平台井: ${selectedPlatform.wellName}`)
+      }
     }
   }
 }