فهرست منبع

🐛 fix(日报填报): 修正油耗信息初始化逻辑

- 填报时使用 reportFuels,并将中航北斗油耗自动写入实际油耗
- 根据实际油耗重新汇总当日油耗
- 查看详情时使用 reportedFuels 展示已填报数据
Zimo 15 ساعت پیش
والد
کامیت
b1e24d7a22
2فایلهای تغییر یافته به همراه28 افزوده شده و 36 حذف شده
  1. 5 5
      src/views/oli-connection/monitoring-board/index.vue
  2. 23 31
      src/views/pms/iotrddailyreport/FillDailyReportForm.vue

+ 5 - 5
src/views/oli-connection/monitoring-board/index.vue

@@ -1,15 +1,15 @@
 <script setup lang="ts">
+import { IotDeviceApi } from '@/api/pms/device'
+import * as DeptApi from '@/api/system/dept'
 import { useUserStore } from '@/store/modules/user'
 import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
 import { rangeShortcuts } from '@/utils/formatTime'
-import * as DeptApi from '@/api/system/dept'
 import { handleTree } from '@/utils/tree'
-import { IotDeviceApi } from '@/api/pms/device'
+import { Crop, FullScreen } from '@element-plus/icons-vue'
+import { useFullscreen } from '@vueuse/core'
+import dayjs from 'dayjs'
 import { EChartsOption } from 'echarts'
 import chart from './chart.vue'
-import dayjs from 'dayjs'
-import { useFullscreen } from '@vueuse/core'
-import { Crop, FullScreen } from '@element-plus/icons-vue'
 
 defineOptions({ name: 'MonitoringBoard' })
 

+ 23 - 31
src/views/pms/iotrddailyreport/FillDailyReportForm.vue

@@ -1,15 +1,15 @@
 <script lang="ts" setup>
-import { IotRdDailyReportApi } from '@/api/pms/iotrddailyreport'
-import { FormInstance, FormRules } from 'element-plus'
-import { CircleCheck, Plus, Delete } from '@element-plus/icons-vue'
-import { calculateDuration, formatDateNoTime, formatT } from '@/utils/formatTime'
-import { getStrDictOptions } from '@/utils/dict'
 import { IotDailyReportAttrsApi } from '@/api/pms/iotdailyreportattrs'
+import { IotRdDailyReportApi } from '@/api/pms/iotrddailyreport'
 import { useTableComponents } from '@/components/ZmTable/useTableComponents'
-import dayjs from 'dayjs'
+import { getStrDictOptions } from '@/utils/dict'
+import { calculateDuration, formatDateNoTime, formatT } from '@/utils/formatTime'
+import { CircleCheck, Delete, Plus } from '@element-plus/icons-vue'
 import { useDebounceFn } from '@vueuse/core'
-import { cloneDeep } from 'lodash-es'
+import dayjs from 'dayjs'
+import { FormInstance, FormRules } from 'element-plus'
 import { Base64 } from 'js-base64'
+import { cloneDeep } from 'lodash-es'
 
 const NON_PROD_FIELDS = [
   { key: 'repairTime', label: '设备故障' },
@@ -238,33 +238,25 @@ function initPlatformData(reportId: number, sourceData: any) {
 // const dailyFuel = ref(0)
 
 const initDailyFuel = () => {
-  const propVal = data.value.dailyFuel
-
-  const hasPropValue = propVal !== undefined && propVal !== null && !isNaN(propVal)
-
-  if (hasPropValue) {
-    // dailyFuel.value = propVal
-    form.value.dailyFuel = propVal
-  } else {
-    const list1 = data.value.reportFuels || []
-    const list2 = data.value.reportedFuels || []
-
-    const validList = list1.length > 0 ? list1 : list2.length > 0 ? list2 : []
-
-    form.value.reportFuels = validList.map((v) => ({
+  if (formType.value === 'edit') {
+    form.value.reportFuels = (data.value.reportFuels || []).map((v) => ({
       ...v,
-      customFuel: Number(
-        Number(true ? (v.customFuel ?? 0) : (v.customFuel ?? v.zhbdFuel ?? 0)).toFixed(2)
-      )
+      customFuel: Number(Number(v.zhbdFuel ?? 0).toFixed(2))
     }))
-
-    let total = 0
-    form.value.reportFuels.forEach((item) => {
-      total += item.customFuel
-    })
-    // dailyFuel.value = total
-    form.value.dailyFuel = total
+    form.value.dailyFuel = form.value.reportFuels.reduce(
+      (total, item) => total + item.customFuel,
+      0
+    )
+    return
   }
+
+  form.value.reportFuels = data.value.reportedFuels || []
+
+  const propVal = data.value.dailyFuel
+  const hasPropValue = propVal !== undefined && propVal !== null && !isNaN(propVal)
+  form.value.dailyFuel = hasPropValue
+    ? propVal
+    : form.value.reportFuels.reduce((total, item) => total + Number(item.customFuel || 0), 0)
 }
 
 function getReportDetailDuration(row: ReportDetail) {