|
|
@@ -9,6 +9,7 @@ import dayjs from 'dayjs'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
defineOptions({ name: 'FillOrderInfo' })
|
|
|
+const emit = defineEmits<{ success: [] }>()
|
|
|
|
|
|
interface OperationRouteInfo {
|
|
|
rawId: string
|
|
|
@@ -41,6 +42,7 @@ interface WellNameOption {
|
|
|
}
|
|
|
|
|
|
interface FillAttribute {
|
|
|
+ id?: number
|
|
|
defaultValue: string | number | null
|
|
|
name: string
|
|
|
fillContent: string | number | null
|
|
|
@@ -87,13 +89,17 @@ const sumList = ref<FillAttribute[]>([])
|
|
|
const reportDetails = ref<ReportDetail[]>([])
|
|
|
const reportDetailsLoading = ref(false)
|
|
|
const deviceAttrsLoading = ref(false)
|
|
|
+const submitLoading = ref(false)
|
|
|
const fillFormRef = ref<FormInstance>()
|
|
|
const fillFormModel = computed(() => ({
|
|
|
nonSumList: nonSumList.value,
|
|
|
reportDetails: reportDetails.value
|
|
|
}))
|
|
|
const fillStatus = computed(() => routeInfo.orderStatus)
|
|
|
-const isFormDisabled = computed(() => fillStatus.value === '1')
|
|
|
+const isFormDisabled = computed(() => {
|
|
|
+ const currentDevice = deviceFillList.value[selectedDeviceIndex.value]
|
|
|
+ return fillStatus.value === '1' || currentDevice?.isFill === '1' || submitLoading.value
|
|
|
+})
|
|
|
|
|
|
const keys = [
|
|
|
'repairTime',
|
|
|
@@ -561,7 +567,66 @@ const loadReportDetails = async (device: DeviceFillInfo) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const buildSubmitInfo = () => {
|
|
|
+ const device = selectedDevice.value
|
|
|
+ if (!device) return undefined
|
|
|
+
|
|
|
+ const createTime = formatCreateTime(device.createTime)
|
|
|
+ const createReqVO = [...nonSumList.value, ...sumList.value].map((attribute) => ({
|
|
|
+ ...attribute,
|
|
|
+ modelId: attribute.id,
|
|
|
+ id: device.orderId,
|
|
|
+ pointName: attribute.name,
|
|
|
+ createTime,
|
|
|
+ userId: device.userId,
|
|
|
+ deptId: device.deptId,
|
|
|
+ deviceCategoryId: device.deviceCategoryId,
|
|
|
+ deviceId: device.deviceId,
|
|
|
+ deviceCode: device.deviceCode
|
|
|
+ }))
|
|
|
+
|
|
|
+ return {
|
|
|
+ createReqVO,
|
|
|
+ reportDetails: reportDetails.value.map((detail) => ({
|
|
|
+ ...detail,
|
|
|
+ taskId: taskId.value
|
|
|
+ }))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const saveFillInfo = async () => {
|
|
|
+ if (submitLoading.value) return false
|
|
|
+
|
|
|
+ const submitInfo = buildSubmitInfo()
|
|
|
+ if (!submitInfo) {
|
|
|
+ ElMessage.error('未获取到当前填报信息')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('运行记录填报提交信息:', submitInfo)
|
|
|
+ submitLoading.value = true
|
|
|
+
|
|
|
+ try {
|
|
|
+ await IotOpeationFillApi.insertLog(submitInfo)
|
|
|
+
|
|
|
+ if (selectedDevice.value) {
|
|
|
+ selectedDevice.value.isFill = '1'
|
|
|
+ }
|
|
|
+
|
|
|
+ ElMessage.success('保存成功')
|
|
|
+ emit('success')
|
|
|
+ return true
|
|
|
+ } catch (error) {
|
|
|
+ console.error('保存运行记录填报失败:', error)
|
|
|
+ ElMessage.error('保存失败,请稍后重试')
|
|
|
+ return false
|
|
|
+ } finally {
|
|
|
+ submitLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const handleConfirm = async () => {
|
|
|
+ if (submitLoading.value) return
|
|
|
if (!fillFormRef.value) return
|
|
|
|
|
|
try {
|
|
|
@@ -580,21 +645,14 @@ const handleConfirm = async () => {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- previewSubmit()
|
|
|
-}
|
|
|
-
|
|
|
-const previewSubmit = () => {
|
|
|
- console.log('表单校验及超限确认通过,预览数据:', {
|
|
|
- nonSumList: nonSumList.value,
|
|
|
- reportDetails: reportDetails.value,
|
|
|
- taskId: taskId.value
|
|
|
- })
|
|
|
- ElMessage.success('校验已通过,当前为预览效果,未调用提交接口')
|
|
|
+ await saveFillInfo()
|
|
|
}
|
|
|
|
|
|
-const confirmRdExceededSubmit = () => {
|
|
|
- rdConfirmVisible.value = false
|
|
|
- previewSubmit()
|
|
|
+const confirmRdExceededSubmit = async () => {
|
|
|
+ const saved = await saveFillInfo()
|
|
|
+ if (saved) {
|
|
|
+ rdConfirmVisible.value = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const clearFillForm = async () => {
|
|
|
@@ -1095,8 +1153,16 @@ watch(() => route.params.id, storeRouteInfo, { immediate: true })
|
|
|
</div>
|
|
|
|
|
|
<div v-if="showFormActions" class="form-actions">
|
|
|
- <el-button size="default" @click="clearFillForm">清空</el-button>
|
|
|
- <el-button size="default" type="primary" @click="handleConfirm">确定</el-button>
|
|
|
+ <el-button size="default" :disabled="submitLoading" @click="clearFillForm">
|
|
|
+ 清空
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ size="default"
|
|
|
+ type="primary"
|
|
|
+ :loading="submitLoading"
|
|
|
+ @click="handleConfirm">
|
|
|
+ 确定
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -1110,6 +1176,9 @@ watch(() => route.params.id, storeRouteInfo, { immediate: true })
|
|
|
width="540px"
|
|
|
append-to-body
|
|
|
destroy-on-close
|
|
|
+ :close-on-click-modal="!submitLoading"
|
|
|
+ :close-on-press-escape="!submitLoading"
|
|
|
+ :show-close="!submitLoading"
|
|
|
class="rd-limit-dialog">
|
|
|
<p class="rd-confirm-description">以下数据超过建议上限,请确认是否继续提交。</p>
|
|
|
|
|
|
@@ -1141,8 +1210,14 @@ watch(() => route.params.id, storeRouteInfo, { immediate: true })
|
|
|
</div>
|
|
|
|
|
|
<template #footer>
|
|
|
- <el-button size="default" @click="rdConfirmVisible = false">返回修改</el-button>
|
|
|
- <el-button size="default" type="primary" @click="confirmRdExceededSubmit">
|
|
|
+ <el-button size="default" :disabled="submitLoading" @click="rdConfirmVisible = false">
|
|
|
+ 返回修改
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ size="default"
|
|
|
+ type="primary"
|
|
|
+ :loading="submitLoading"
|
|
|
+ @click="confirmRdExceededSubmit">
|
|
|
确认提交
|
|
|
</el-button>
|
|
|
</template>
|