From 46d143d1d6fe8f286399f4d027c9a86adf7cd7fc Mon Sep 17 00:00:00 2001
From: baoshiwei <baoshiwei@shlanbao.cn>
Date: 星期三, 09 七月 2025 08:50:01 +0800
Subject: [PATCH] feat(inspection,maintenance): - 实现保养工单批量确认功能 - 在点检记录确认时增加时间限制,距离上次更新时间两小时内不允许确认

---
 eims-ui-mobile/src/pages/maint/maint-st.vue      |   51 +++++++++++++++++++++++++
 eims-ui-mobile/src/pages/inspect/insp-record.vue |   16 ++++++++
 2 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/eims-ui-mobile/src/pages/inspect/insp-record.vue b/eims-ui-mobile/src/pages/inspect/insp-record.vue
index 9d0ffab..aa5832a 100644
--- a/eims-ui-mobile/src/pages/inspect/insp-record.vue
+++ b/eims-ui-mobile/src/pages/inspect/insp-record.vue
@@ -147,6 +147,7 @@
       <!--      </wd-cell>-->
       <view class="w-full h-[1px] bg-base"></view>
       <wd-input
+        v-if="inspSt.status !== '0'"
         label="杩愯鏃堕棿"
         label-width="200rpx"
         clearable
@@ -156,6 +157,7 @@
         size="large"
       />
       <wd-input
+        v-if="inspSt.status !== '0'"
         label="鏁呴殰鏃堕棿"
         label-width="200rpx"
         clearable
@@ -386,6 +388,20 @@
     message.alert('璇峰~鍐欒繍琛屾鏁板拰鏁呴殰娆℃暟!')
     return false
   }
+  // 濡傛灉褰撳墠鏃堕棿璺濅笂娆℃柊鏃堕棿涓ゅ皬鏃朵互鍐呭垯涓嶅厑璁哥‘璁�
+  console.log('inspSt.updateTime', inspSt.updateTime)
+  console.log('new Date().getTime()', new Date().getTime())
+  console.log('inspSt.updateTime', new Date(inspSt.updateTime).getTime())
+  console.log('new Date().getTime() - new Date(inspSt.updateTime).getTime()', new Date().getTime() - new Date(inspSt.updateTime).getTime())
+  console.log("2 * 60 * 60 * 1000", 2 * 60 * 60 * 1000)
+  console.log('new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000', new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000)
+  if (
+    new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000
+  ) {
+    console.log("new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000",new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000)
+    message.alert('鐐规涓ゅ皬鏃朵互鍐呬笉鍏佽纭!')
+    return false
+  }
   const now = new Date();
   const data: any = Object.assign(
     {},
diff --git a/eims-ui-mobile/src/pages/maint/maint-st.vue b/eims-ui-mobile/src/pages/maint/maint-st.vue
index 26848fd..0adacf7 100644
--- a/eims-ui-mobile/src/pages/maint/maint-st.vue
+++ b/eims-ui-mobile/src/pages/maint/maint-st.vue
@@ -85,6 +85,17 @@
         </view>
       </wd-card>
     </view>
+
+    <wd-fab
+      v-if="status === '1' && isLeader()"
+      :draggable="true"
+      type="success"
+      position="left-bottom"
+      :expandable="false"
+      inactiveIcon="check"
+      @click="handleBatchComplete"
+      direction="top"
+    />
   </z-paging>
 </template>
 
@@ -92,6 +103,11 @@
 import { ref, computed } from 'vue'
 import { getMaintStList } from '@/service/maint'
 import dayjs from 'dayjs'
+import { updateMaintSt } from '@/service/maint'
+import { useUserStore } from "@/store";
+import { isLeader } from '@/utils/RoleUtils'
+import { useToast } from 'wot-design-uni'
+
 const searchValue = ref<string>('')
 /**
  * 鍏朵粬椤甸潰浼犺繃鏉ョ殑鏁版嵁
@@ -257,6 +273,41 @@
   paging.value.reload()
 }
 
+const userStore = useUserStore()
+const toast = useToast()
+
+async function handleBatchComplete() {
+  console.log('handleBatchComplete', dataList.value.length)
+  if (!isLeader()) {
+    toast.info('鏃犳潈闄愭搷浣�')
+    return
+  }
+  // 濡傛灉寰呯‘璁ゅ伐鍗曞垪琛ㄤ负绌猴紝鍒欐彁绀虹敤鎴锋棤寰呯‘璁ゅ伐鍗�
+  if (dataList.value.length < 1) {
+    toast.info('鏃犲緟纭宸ュ崟')
+    return
+  }
+  const now = new Date()
+  const verifyTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`
+
+  // 鍋囪 dataList 鏄綋鍓嶅緟纭鐨勫伐鍗曞垪琛�
+  const promises = dataList.value.map(item => {
+    return updateMaintSt({
+      id: item.id,
+      status: '2',
+      verifyUser: userStore?.userInfo?.userId,
+      verifyTime
+    })
+  })
+
+  try {
+    await Promise.all(promises)
+    toast.success('涓�閿‘璁ゅ畬鎴�')
+    reloadData() // 鍒锋柊鍒楄〃
+  } catch (e) {
+    toast.error('閮ㄥ垎宸ュ崟纭澶辫触锛岃閲嶈瘯')
+  }
+}
 
 onLoad((options) => {
   Object.assign(option, options)

--
Gitblit v1.9.3