|
@@ -1,15 +1,15 @@
|
|
|
<script lang="ts" setup>
|
|
<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 { IotDailyReportAttrsApi } from '@/api/pms/iotdailyreportattrs'
|
|
|
|
|
+import { IotRdDailyReportApi } from '@/api/pms/iotrddailyreport'
|
|
|
import { useTableComponents } from '@/components/ZmTable/useTableComponents'
|
|
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 { 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 { Base64 } from 'js-base64'
|
|
|
|
|
+import { cloneDeep } from 'lodash-es'
|
|
|
|
|
|
|
|
const NON_PROD_FIELDS = [
|
|
const NON_PROD_FIELDS = [
|
|
|
{ key: 'repairTime', label: '设备故障' },
|
|
{ key: 'repairTime', label: '设备故障' },
|
|
@@ -238,33 +238,25 @@ function initPlatformData(reportId: number, sourceData: any) {
|
|
|
// const dailyFuel = ref(0)
|
|
// const dailyFuel = ref(0)
|
|
|
|
|
|
|
|
const initDailyFuel = () => {
|
|
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,
|
|
...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) {
|
|
function getReportDetailDuration(row: ReportDetail) {
|