Przeglądaj źródła

生产动态拆分当前井深同步问题

Zimo 7 godzin temu
rodzic
commit
185cbc82e6

+ 35 - 6
src/views/pms/iotopeationfill/index1.vue

@@ -292,6 +292,7 @@
                           class="w-full!"
                           value-format="x"
                           :disabled="fillStatus === '1'"
+                          @change="inputCurrentDepth()"
                         />
                       </el-form-item>
                     </template>
@@ -316,7 +317,7 @@
                           format="HH:mm"
                           value-format="HH:mm"
                           class="w-full!"
-                          @change="calculateDuration(row)"
+                          @change="acalculateDuration(row)"
                           :disabled="fillStatus === '1'"
                         />
                       </el-form-item>
@@ -341,7 +342,7 @@
                           format="HH:mm"
                           value-format="HH:mm"
                           class="w-full!"
-                          @change="calculateDuration(row)"
+                          @change="acalculateDuration(row)"
                           :disabled="fillStatus === '1'"
                         />
                       </el-form-item>
@@ -396,7 +397,7 @@
                           class="!w-full"
                           align="left"
                           placeholder="请输入结束井深"
-                          @input="(val) => inputCurrentDepth(val, $index)"
+                          @input="() => inputCurrentDepth()"
                           :disabled="fillStatus === '1'"
                         >
                           <template #suffix> m </template>
@@ -556,13 +557,41 @@ const removeProductionStatusRow = (index: number) => {
   reportDetails.value.splice(index, 1)
 }
 
-const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(val: any, index: number) {
-  if (reportDetails.value && index === reportDetails.value.length - 1) {
+const acalculateDuration = (row: any) => {
+  calculateDuration(row)
+  inputCurrentDepth()
+}
+
+const inputCurrentDepth = useDebounceFn(function inputCurrentDepth() {
+  const details = reportDetails.value
+
+  if (Array.isArray(details) && details.length > 0) {
+    const latestDetail = details.reduce((prev, current) => {
+      const currentFullTime = dayjs(current.reportDate)
+        .hour(parseInt(current.endTime.split(':')[0]))
+        .minute(parseInt(current.endTime.split(':')[1]))
+        .valueOf()
+
+      const prevFullTime = dayjs(prev.reportDate)
+        .hour(parseInt(prev.endTime.split(':')[0]))
+        .minute(parseInt(prev.endTime.split(':')[1]))
+        .valueOf()
+
+      return currentFullTime >= prevFullTime ? current : prev
+    })
+
     const currentDepth = attrList.value.find((item) => item.description === 'currentDepth')
-    if (currentDepth) currentDepth.fillContent = val
+    if (currentDepth) currentDepth.fillContent = latestDetail.currentDepth
   }
 }, 300)
 
+// const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(val: any, index: number) {
+//   if (reportDetails.value && index === reportDetails.value.length - 1) {
+//     const currentDepth = attrList.value.find((item) => item.description === 'currentDepth')
+//     if (currentDepth) currentDepth.fillContent = val
+//   }
+// }, 300)
+
 const showDepth = computed(() => {
   return attrList.value.some((item) => item.description === 'currentDepth')
 })

+ 28 - 6
src/views/pms/iotrydailyreport/ry-form.vue

@@ -439,9 +439,30 @@ const orange = computed(() => {
   return false
 })
 
-const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(val: any, index: number) {
-  if (form.value.reportDetails && index === form.value.reportDetails.length - 1) {
-    form.value.currentDepth = val
+const acalculateDuration = (row: any) => {
+  calculateDuration(row)
+  inputCurrentDepth()
+}
+
+const inputCurrentDepth = useDebounceFn(function inputCurrentDepth() {
+  const details = form.value.reportDetails
+
+  if (Array.isArray(details) && details.length > 0) {
+    const latestDetail = details.reduce((prev, current) => {
+      const currentFullTime = dayjs(current.reportDate)
+        .hour(parseInt(current.endTime.split(':')[0]))
+        .minute(parseInt(current.endTime.split(':')[1]))
+        .valueOf()
+
+      const prevFullTime = dayjs(prev.reportDate)
+        .hour(parseInt(prev.endTime.split(':')[0]))
+        .minute(parseInt(prev.endTime.split(':')[1]))
+        .valueOf()
+
+      return currentFullTime >= prevFullTime ? current : prev
+    })
+
+    form.value.currentDepth = latestDetail.currentDepth
   }
 }, 300)
 </script>
@@ -716,6 +737,7 @@ const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(val: any, ind
                       class="w-full!"
                       value-format="x"
                       :disabled="isMainFieldDisabled"
+                      @change="inputCurrentDepth()"
                     />
                   </el-form-item>
                 </template>
@@ -740,7 +762,7 @@ const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(val: any, ind
                       format="HH:mm"
                       value-format="HH:mm"
                       class="w-full!"
-                      @change="calculateDuration(row)"
+                      @change="acalculateDuration(row)"
                       :disabled="isMainFieldDisabled"
                     />
                   </el-form-item>
@@ -765,7 +787,7 @@ const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(val: any, ind
                       format="HH:mm"
                       value-format="HH:mm"
                       class="w-full!"
-                      @change="calculateDuration(row)"
+                      @change="acalculateDuration(row)"
                       :disabled="isMainFieldDisabled"
                     />
                   </el-form-item>
@@ -817,7 +839,7 @@ const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(val: any, ind
                       align="left"
                       placeholder="请输入结束井深"
                       :disabled="isMainFieldDisabled"
-                      @input="(val) => inputCurrentDepth(val, $index)"
+                      @input="() => inputCurrentDepth()"
                     >
                       <template #suffix> m </template>
                     </el-input-number>