Przeglądaj źródła

feat(iotopeationfill): 完善运行记录填报及保存流程

- 重构运行记录填报页面为左侧列表、右侧动态表单布局
- 接入公司标识、设备列表、属性数据及已有填报值查询
- 使用 dayjs 统一处理路由时间和接口日期参数
- 支持设备切换、表单区域 loading 及独立滚动
-
Zimo 3 dni temu
rodzic
commit
8e3092e273
2 zmienionych plików z 94 dodań i 19 usunięć
  1. 1 1
      .env.local
  2. 93 18
      src/views/pms/iotopeationfill/index1.vue

+ 1 - 1
.env.local

@@ -4,7 +4,7 @@ NODE_ENV=development
 VITE_DEV=true
 
 # 请求路径  http://192.168.188.200:48080  https://iot.deepoil.cc:5443  http://172.26.0.56:48080  http://192.168.188.198:48080
-VITE_BASE_URL='https://aims.deepoil.cc'
+VITE_BASE_URL='https://iot.deepoil.cc:5443'
 
 # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
 VITE_UPLOAD_TYPE=server

+ 93 - 18
src/views/pms/iotopeationfill/index1.vue

@@ -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>