Przeglądaj źródła

生产日报瑞鹰当前井深同步调整

Zimo 14 godzin temu
rodzic
commit
2542d4951e
2 zmienionych plików z 55 dodań i 21 usunięć
  1. 33 14
      pages/recordFilling/detail.vue
  2. 22 7
      pages/ruiying/components/form.vue

+ 33 - 14
pages/recordFilling/detail.vue

@@ -236,12 +236,15 @@
                   returnType="timestamp"
                   v-model="detail.reportDate"
                   :border="false"
-                  :disabled="!isView" />
+                  :disabled="!isView"
+                  @change="inputCurrentDepth(item.nonSumList)" />
               </uni-forms-item>
               <uni-forms-item :label="`${$t('ruiDu.timeNode')}:`" required>
                 <view
                   @click="
-                    !isView ? undefined : handleClickTimeRangeItem(index)
+                    !isView
+                      ? undefined
+                      : handleClickTimeRangeItem(index, item.nonSumList)
                   ">
                   <view
                     class="time-range-item"
@@ -278,9 +281,7 @@
                   v-bind="defaultProps"
                   :disabled="!isView"
                   v-model.number="detail.currentDepth"
-                  @input="
-                    val => inputCurrentDepth(item.nonSumList, val, index)
-                  " />
+                  @input="val => inputCurrentDepth(item.nonSumList)" />
               </uni-forms-item>
               <uni-forms-item
                 label="详情"
@@ -376,8 +377,11 @@ const endDefaultTime = ref("08:00");
 
 const reportDetailIndex = ref(0);
 
-const handleClickTimeRangeItem = index => {
+const aaaList = ref();
+
+const handleClickTimeRangeItem = (index, list) => {
   reportDetailIndex.value = index;
+  aaaList.value = list;
   reportDetailsTimeRangeRef.value.open();
 };
 
@@ -405,6 +409,7 @@ const reportDetailsTimeRange = data => {
   reportDetails.value[reportDetailIndex.value].endTime = data[1];
 
   calculateDuration(reportDetails.value[reportDetailIndex.value]);
+  inputCurrentDepth(aaaList.value ?? []);
 };
 
 const reportDetails = ref([]);
@@ -438,14 +443,28 @@ const removeReportDetailRow = index => {
 const taskId = ref(undefined);
 const taskOptions = ref([]);
 
-const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(
-  list,
-  val,
-  index
-) {
-  if (reportDetails.value && index === reportDetails.value.length - 1) {
-    const currentDepth = list.find(item => item.description === "currentDepth");
-    if (currentDepth) currentDepth.fillContent = val;
+const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(list) {
+  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 = list.find(
+      item => item?.description === "currentDepth"
+    );
+    if (currentDepth) currentDepth.fillContent = latestDetail.currentDepth;
   }
 }, 300);
 

+ 22 - 7
pages/ruiying/components/form.vue

@@ -348,14 +348,28 @@ const reportDetailsTimeRange = data => {
   form.value.reportDetails[reportDetailIndex.value].endTime = data[1];
 
   calculateDuration(form.value.reportDetails[reportDetailIndex.value]);
+  inputCurrentDepth();
 };
 
-const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(val, index) {
-  if (
-    form.value.reportDetails &&
-    index === form.value.reportDetails.length - 1
-  ) {
-    form.value.currentDepth = val;
+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>
@@ -540,7 +554,8 @@ const inputCurrentDepth = useDebounceFn(function inputCurrentDepth(val, index) {
             returnType="timestamp"
             v-model="item.reportDate"
             :border="false"
-            :disabled="disabled('edit')" />
+            :disabled="disabled('edit')"
+            @change="inputCurrentDepth()" />
         </uni-forms-item>
         <uni-forms-item :label="`${$t('ruiDu.timeNode')}:`" required>
           <view