소스 검색

pms 瑞都日报 平台井 施工完成的情况下 优化详情显示逻辑

zhangcl 1 주 전
부모
커밋
f219862470
1개의 변경된 파일48개의 추가작업 그리고 22개의 파일을 삭제
  1. 48 22
      src/views/pms/iotrddailyreport/FillDailyReportForm.vue

+ 48 - 22
src/views/pms/iotrddailyreport/FillDailyReportForm.vue

@@ -448,8 +448,8 @@
     <ContentWrap class="platform-workload-section" v-if="(isDetailMode || isApprovalMode) && dailyReportData?.platformWell === 1">
       <h2 class="text-lg font-semibold mb-4">平台井工作量</h2>
 
-      <div class="platform-workload-table" v-if="dailyReportData?.platforms && dailyReportData.platforms.length > 0">
-        <el-table :data="dailyReportData.platforms" border style="width: 100%" class="platform-workload-el-table" table-layout="fixed">
+      <div class="platform-workload-table" v-if="platformWorkloadData && platformWorkloadData.length > 0">
+        <el-table :data="platformWorkloadData" border style="width: 100%" class="platform-workload-el-table" table-layout="fixed">
           <!-- 固定列 -->
           <el-table-column prop="wellName" label="井号" align="center" :show-overflow-tooltip="true"/>
           <el-table-column label="施工状态" align="center" :show-overflow-tooltip="true">
@@ -635,21 +635,24 @@ const currentPlatformId = ref<number>() // 当前选中的平台井ID
 
 // 计算属性:显示井名(统一处理主井和平台井逻辑)
 const displayWellName = computed(() => {
-  // 如果是平台井模式且有平台井数据
-  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
+  // 如果是平台井模式
+  if (dailyReportData.value.platformWell === 1) {
+    // 确定平台井数据源:优先使用 platforms,不存在则使用 finishedPlatforms
+    const platformSource = dailyReportData.value.platforms || dailyReportData.value.finishedPlatforms
+
+    // 如果有平台井数据
+    if (platformSource && platformSource.length > 0) {
+      // 检查主井是否在平台井列表中
+      const isMainWellInPlatforms = platformSource.some(
+        (platform: any) => platform.id === dailyReportData.value.taskId
+      )
+
+      // 如果主井不在平台井列表中(说明主井已施工完成),使用第一个平台井的名称
+      if (!isMainWellInPlatforms) {
+        const firstPlatformWellName = platformSource[0].wellName
+        console.log(`主井已施工完成,井号显示使用平台井名称: ${firstPlatformWellName}`)
+        return firstPlatformWellName
+      }
     }
   }
 
@@ -710,14 +713,22 @@ const initPlatformData = (reportData: any) => {
   // 设置是否显示平台井字段
   showPlatformField.value = reportData.platformWell === 1
 
+  // 设置平台井下拉选项 - 修改后的逻辑
+  let platformSource = reportData.platforms
+
+  // 在详情或审批模式下,如果 platforms 不存在,则使用 finishedPlatforms
+  if ((isDetailMode.value || isApprovalMode.value) && (!platformSource || platformSource.length === 0)) {
+    platformSource = reportData.finishedPlatforms
+  }
+
   // 设置平台井下拉选项
-  if (reportData.platforms && Array.isArray(reportData.platforms)) {
-    platformOptions.value = reportData.platforms
+  if (platformSource && Array.isArray(platformSource)) {
+    platformOptions.value = platformSource
 
     // 初始化 platformWellPairs,确保包含所有平台井的完整数据
     if (reportData.platformWell === 1) {
       // 初始化 platformWellPairs,包含所有平台井的完整数据
-      platformWellPairs.value = reportData.platforms.map((platform: any) => {
+      platformWellPairs.value = platformSource.map((platform: any) => {
         // 查找是否已有该平台井的数据
         const existingData = reportData.platformWellPairs?.find((p: any) => p.taskId === platform.id)
 
@@ -1424,6 +1435,20 @@ const loadDynamicAttrs = async (newTechniqueIds: string[], oldTechniqueIds?: str
   }
 }
 
+// 计算属性:获取平台井工作量数据(在详情/审批模式下优先使用 platforms,不存在则使用 finishedPlatforms)
+const platformWorkloadData = computed(() => {
+  if (!dailyReportData.value) return []
+
+  // 在详情或审批模式下
+  if (isDetailMode.value || isApprovalMode.value) {
+    // 优先使用 platforms,如果不存在则使用 finishedPlatforms
+    return dailyReportData.value.platforms || dailyReportData.value.finishedPlatforms || []
+  }
+
+  // 其他模式只使用 platforms
+  return dailyReportData.value.platforms || []
+})
+
 // 在 watch 监听平台井选择变化的部分附近,添加施工工艺转换函数
 // 添加施工工艺数值到标签的转换函数
 const convertTechniqueIdsToLabels = (techniqueIds: number[]): string[] => {
@@ -1675,12 +1700,13 @@ onMounted(async () => {
 
 // 详细 审批 平台井 获取工作量列配置
 const getWorkloadColumns = () => {
-  if (!dailyReportData.value.platforms) return [];
+  const dataSource = platformWorkloadData.value
+  if (!dataSource || dataSource.length === 0) return []
 
   const columns = [];
   const addedIdentifiers = new Set();
 
-  dailyReportData.value.platforms.forEach(platform => {
+  dataSource.forEach(platform => {
     if (platform.extProperty && Array.isArray(platform.extProperty)) {
       platform.extProperty.forEach(extProp => {
         if (!addedIdentifiers.has(extProp.identifier)) {