|
@@ -470,6 +470,7 @@
|
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
|
class="fuel-consumption-el-table"
|
|
class="fuel-consumption-el-table"
|
|
|
table-layout="fixed"
|
|
table-layout="fixed"
|
|
|
|
|
+ :key="fuelTableKey"
|
|
|
>
|
|
>
|
|
|
<!-- 车辆编码 -->
|
|
<!-- 车辆编码 -->
|
|
|
<el-table-column
|
|
<el-table-column
|
|
@@ -529,6 +530,7 @@
|
|
|
@blur="handleCustomFuelChange(scope.row)"
|
|
@blur="handleCustomFuelChange(scope.row)"
|
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
|
size="small"
|
|
size="small"
|
|
|
|
|
+ @focus="handleFuelInputFocus(scope.row)"
|
|
|
/>
|
|
/>
|
|
|
<!-- 只读模式下显示数值 -->
|
|
<!-- 只读模式下显示数值 -->
|
|
|
<span v-else>
|
|
<span v-else>
|
|
@@ -714,6 +716,8 @@ const formLoading = ref(false)
|
|
|
const formRef = ref()
|
|
const formRef = ref()
|
|
|
const id = params.id // 瑞都日报id
|
|
const id = params.id // 瑞都日报id
|
|
|
|
|
|
|
|
|
|
+const fuelTableKey = ref(0) // 用于强制重新渲染表格
|
|
|
|
|
+
|
|
|
// 添加一个新的响应式变量用于输入
|
|
// 添加一个新的响应式变量用于输入
|
|
|
const dailyFuelInput = ref('')
|
|
const dailyFuelInput = ref('')
|
|
|
|
|
|
|
@@ -782,6 +786,15 @@ const pageTitle = computed(() => {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+// 处理输入框获取焦点事件
|
|
|
|
|
+const handleFuelInputFocus = (fuelItem: any) => {
|
|
|
|
|
+ // 如果 customFuel 是空的,确保它显示默认值
|
|
|
|
|
+ if (!fuelItem.customFuel || fuelItem.customFuel === '') {
|
|
|
|
|
+ const zhbdValue = parseFloat(fuelItem.zhbdFuel);
|
|
|
|
|
+ fuelItem.customFuel = !isNaN(zhbdValue) ? formatNumber(zhbdValue, 2) : '0.00';
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 模式提示信息
|
|
// 模式提示信息
|
|
|
const modeNotice = computed(() => {
|
|
const modeNotice = computed(() => {
|
|
|
if (isApprovalMode.value) {
|
|
if (isApprovalMode.value) {
|
|
@@ -1382,11 +1395,11 @@ const submitForm = async () => {
|
|
|
// 在填报模式下也提交审批意见字段
|
|
// 在填报模式下也提交审批意见字段
|
|
|
opinion: isEditMode.value ? approvalForm.opinion : undefined,
|
|
opinion: isEditMode.value ? approvalForm.opinion : undefined,
|
|
|
// 将油耗数据格式化为后端需要的格式
|
|
// 将油耗数据格式化为后端需要的格式
|
|
|
- reportFuels: formData.value.reportFuels.map(fuel => ({
|
|
|
|
|
|
|
+ /* reportFuels: formData.value.reportFuels.map(fuel => ({
|
|
|
...fuel,
|
|
...fuel,
|
|
|
// 确保 customFuel 是数字格式
|
|
// 确保 customFuel 是数字格式
|
|
|
customFuel: fuel.customFuel ? parseFloat(fuel.customFuel) : null
|
|
customFuel: fuel.customFuel ? parseFloat(fuel.customFuel) : null
|
|
|
- })),
|
|
|
|
|
|
|
+ })), */
|
|
|
// 确保当日油耗是数字格式
|
|
// 确保当日油耗是数字格式
|
|
|
dailyFuel: formData.value.dailyFuel ? parseFloat(formData.value.dailyFuel) : 0
|
|
dailyFuel: formData.value.dailyFuel ? parseFloat(formData.value.dailyFuel) : 0
|
|
|
}
|
|
}
|
|
@@ -1415,6 +1428,12 @@ const submitForm = async () => {
|
|
|
bizId: pair.reportId // 替换 bizId 为当前平台井的 reportId
|
|
bizId: pair.reportId // 替换 bizId 为当前平台井的 reportId
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
|
|
+ // 车辆油耗:复制并修改 reportId 为当前 pair 的 reportId
|
|
|
|
|
+ platformData.reportFuels = (baseData.reportFuels || []).map(reportFuel => ({
|
|
|
|
|
+ ...reportFuel, // 深拷贝单个油耗
|
|
|
|
|
+ reportId: pair.reportId // 替换 reportId 为当前平台井的 reportId
|
|
|
|
|
+ }))
|
|
|
|
|
+
|
|
|
// 重新构建 dynamicFields(如果需要)
|
|
// 重新构建 dynamicFields(如果需要)
|
|
|
const dynamicFields = {}
|
|
const dynamicFields = {}
|
|
|
if (platformData.extProperty && platformData.extProperty.length > 0) {
|
|
if (platformData.extProperty && platformData.extProperty.length > 0) {
|
|
@@ -1897,7 +1916,7 @@ const initFormData = (reportData: any) => {
|
|
|
let customFuelValue;
|
|
let customFuelValue;
|
|
|
|
|
|
|
|
// 如果 customFuel 不为空,确保它是字符串格式并已正确格式化
|
|
// 如果 customFuel 不为空,确保它是字符串格式并已正确格式化
|
|
|
- if (fuel.customFuel !== null && fuel.customFuel !== undefined) {
|
|
|
|
|
|
|
+ if (fuel.customFuel !== null && fuel.customFuel !== undefined && fuel.customFuel !== '') {
|
|
|
const numValue = parseFloat(fuel.customFuel);
|
|
const numValue = parseFloat(fuel.customFuel);
|
|
|
customFuelValue = !isNaN(numValue) ? formatNumber(numValue, 2) : '0.00';
|
|
customFuelValue = !isNaN(numValue) ? formatNumber(numValue, 2) : '0.00';
|
|
|
} else {
|
|
} else {
|
|
@@ -1935,6 +1954,13 @@ onMounted(async () => {
|
|
|
const response = await IotRdDailyReportApi.getIotRdDailyReport(id)
|
|
const response = await IotRdDailyReportApi.getIotRdDailyReport(id)
|
|
|
dailyReportData.value = response || {}
|
|
dailyReportData.value = response || {}
|
|
|
initFormData(dailyReportData.value)
|
|
initFormData(dailyReportData.value)
|
|
|
|
|
+
|
|
|
|
|
+ // 确保油耗数据在初始化后立即渲染
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+ // 强制更新油耗数据
|
|
|
|
|
+ if (formData.value.reportFuels && formData.value.reportFuels.length > 0) {
|
|
|
|
|
+ formData.value.reportFuels = [...formData.value.reportFuels]
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('初始化数据失败:', error)
|
|
console.error('初始化数据失败:', error)
|
|
@@ -1970,6 +1996,11 @@ const getWorkloadColumns = () => {
|
|
|
return columns;
|
|
return columns;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+// 强制刷新表格
|
|
|
|
|
+const refreshFuelTable = () => {
|
|
|
|
|
+ fuelTableKey.value += 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 计算当日油耗的默认值
|
|
// 计算当日油耗的默认值
|
|
|
const calculateDailyFuel = (reportData: any) => {
|
|
const calculateDailyFuel = (reportData: any) => {
|
|
|
let dailyFuelValue = 0
|
|
let dailyFuelValue = 0
|
|
@@ -2055,35 +2086,12 @@ const calculateAndUpdateDailyFuel = () => {
|
|
|
|
|
|
|
|
// 添加计算属性:获取油耗数据显示数据源
|
|
// 添加计算属性:获取油耗数据显示数据源
|
|
|
const fuelConsumptionData = computed(() => {
|
|
const fuelConsumptionData = computed(() => {
|
|
|
- // 如果是详情或审批模式
|
|
|
|
|
- if (isDetailMode.value || isApprovalMode.value) {
|
|
|
|
|
- // 如果 reportedFuels 存在且有值,则使用 reportedFuels
|
|
|
|
|
- if (dailyReportData.value.reportedFuels &&
|
|
|
|
|
- Array.isArray(dailyReportData.value.reportedFuels) &&
|
|
|
|
|
- dailyReportData.value.reportedFuels.length > 0) {
|
|
|
|
|
- return dailyReportData.value.reportedFuels;
|
|
|
|
|
- }
|
|
|
|
|
- // 否则返回空数组(隐藏区域)
|
|
|
|
|
- return [];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 如果是编辑模式
|
|
|
|
|
- if (isEditMode.value) {
|
|
|
|
|
- // 如果 reportedFuels 存在且有值,则使用 reportedFuels
|
|
|
|
|
- if (dailyReportData.value.reportedFuels &&
|
|
|
|
|
- Array.isArray(dailyReportData.value.reportedFuels) &&
|
|
|
|
|
- dailyReportData.value.reportedFuels.length > 0) {
|
|
|
|
|
- return dailyReportData.value.reportedFuels;
|
|
|
|
|
- }
|
|
|
|
|
- // 否则使用 reportFuels
|
|
|
|
|
- return dailyReportData.value.reportFuels || [];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 默认返回空数组
|
|
|
|
|
- return [];
|
|
|
|
|
|
|
+ // 所有模式都统一使用 formData.value.reportFuels 作为数据源
|
|
|
|
|
+ // 因为 formData.value.reportFuels 在 initFormData 中已经正确处理了所有情况
|
|
|
|
|
+ return formData.value.reportFuels || [];
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-// 添加计算属性:判断是否显示油耗信息区域
|
|
|
|
|
|
|
+// 判断是否显示油耗信息区域
|
|
|
const showFuelConsumption = computed(() => {
|
|
const showFuelConsumption = computed(() => {
|
|
|
const data = fuelConsumptionData.value;
|
|
const data = fuelConsumptionData.value;
|
|
|
return data && Array.isArray(data) && data.length > 0;
|
|
return data && Array.isArray(data) && data.length > 0;
|