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/order-detail.vue |  200 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 124 insertions(+), 76 deletions(-)

diff --git a/eims-ui-mobile/src/pages/maint/order-detail.vue b/eims-ui-mobile/src/pages/maint/order-detail.vue
index 2539593..6672463 100644
--- a/eims-ui-mobile/src/pages/maint/order-detail.vue
+++ b/eims-ui-mobile/src/pages/maint/order-detail.vue
@@ -1,25 +1,26 @@
 <route lang="json5" type="page">
 {
+  layout: 'default',
   needLogin: true,
-  style: {
-    navigationBarTitleText: '宸ュ崟鏄庣粏',
-    navigationStyle: 'custom',
-    navigationBarBackgroundColor: '#4D80F0',
-  },
+  style: { navigationBarTitleText: '宸ュ崟鏄庣粏', navigationStyle: 'custom' },
 }
 </route>
 <template>
-  <view class="bg-base h-[100vh]">
+  <view class="bg-base container" safeAreaInsetTopBottom>
     <wd-navbar
-      title="宸ュ崟鏄庣粏"
+      title="淇濆吇宸ュ崟"
       left-arrow
       @click-left="goBack"
       right-text="鎻愪氦"
       @click-right="handleClickRight"
       custom-style="background: #4D80F0;"
       safeAreaInsetTop
-    ></wd-navbar>
-
+    >
+      <template #right>
+        <text v-if="isLineOrRepair()" class="text-white">鎻愪氦</text>
+        <text v-else-if="isLeader()" class="text-white">楠岃瘉</text>
+      </template>
+    </wd-navbar>
     <wd-form ref="form" :model="order" :rules="rules">
       <wd-cell-group custom-class="group" title="璁惧淇℃伅" border>
         <wd-cell title="璁惧鍚嶇О" title-width="200rpx" is-link>
@@ -40,24 +41,12 @@
         <wd-cell title="璁″垝淇濆吇鏃ユ湡" title-width="200rpx" is-link>
           <text>{{ order?.planTime }}</text>
         </wd-cell>
-        <wd-datetime-picker
-          label="淇濆吇寮�濮嬫椂闂�"
-          label-width="200rpx"
-          placeholder="璇烽�夋嫨鏃堕棿"
-          prop="startTime"
-          v-model="startTime"
-          @open="openStartTime"
-          @confirm="handleStartTime"
-        />
-        <wd-datetime-picker
-          label="淇濆吇缁撴潫鏃堕棿"
-          label-width="200rpx"
-          placeholder="璇烽�夋嫨鏃堕棿"
-          prop="endTime"
-          v-model="endTime"
-          @open="openEndTime"
-          @confirm="handleEndTime"
-        />
+        <wd-cell title="淇濆吇寮�濮嬫椂闂�" title-width="200rpx" is-link>
+          <text>{{ order?.startTime }}</text>
+        </wd-cell>
+        <wd-cell title="淇濆吇瀹屾垚鏃堕棿" title-width="200rpx" is-link>
+          <text>{{ order?.endTime }}</text>
+        </wd-cell>
 
         <wd-textarea
           label="宸ヤ綔鎻忚堪"
@@ -72,7 +61,6 @@
         />
         <wd-cell title="淇濆吇鍥剧墖" title-width="200rpx" prop="fileList">
           <wd-upload
-            :auto-upload="false"
             :file-list="fileList"
             @change="handleFileChange"
           ></wd-upload>
@@ -89,25 +77,54 @@
           clearable
         />
       </wd-cell-group>
+      <view class="h-[2px] w-full bg-base"></view>
+      <!--鏄惁鏄剧ず绠$悊鍛橀獙璇佹寜閽� (宸ュ崟鐘舵�佷负2-寰呴獙璇�  涓旂櫥褰曚汉role-leader绠$悊鍛樿鑹�)-->
+      <wd-cell
+        title="楠岃瘉閫氳繃(绠$悊鍛�)"
+        title-width="200px"
+        v-if="order.status === '2' && isLeader()"
+      >
+        <view style="text-align: right">
+          <wd-switch v-model="isVerify" />
+        </view>
+      </wd-cell>
+
+      <!--鏄惁鏄剧ず鎿嶄綔宸ヤ繚鍏诲畬鎴� (宸ュ崟鐘舵�佷负1-淇濆吇涓� 涓旂櫥褰曚汉role-鎿嶄綔宸ヨ鑹�)-->
+      <wd-cell
+        title="淇濆吇瀹屾垚(鎿嶄綔宸�)"
+        title-width="200px"
+        v-if="order.status === '1' && isLineOrRepair()"
+      >
+        <view style="text-align: right">
+          <wd-switch v-model="isFinish" />
+        </view>
+      </wd-cell>
     </wd-form>
+    <view class="h-[100rpx]"></view>
   </view>
 </template>
 
 <script setup lang="ts">
 import { getMaintOrder, updateMaintOrder } from '@/service/maint'
-import { formatDate } from '@/utils/DateUtils'
-import { reactive } from 'vue'
+import { reactive, onMounted } from 'vue'
 import { FormRules } from 'wot-design-uni/components/wd-form/types'
 import { useToast, useMessage } from 'wot-design-uni'
+import { isLeader, isLineOrRepair } from '@/utils/RoleUtils'
+const toast = useToast()
 const message = useMessage()
 
 const fileList = ref<[]>()
-const startTime = ref<number>(0)
-const endTime = ref<number>(0)
+
+// 绠$悊鍛橀獙鏄惁閫氳繃
+const isVerify = ref(false)
+// 鎿嶄綔宸ヤ繚鍏绘槸瀹屾垚
+const isFinish = ref(false)
 
 interface MaintOrder {
   id: string
   equName: string
+  assetNo: string
+  status: string
   maintCode: string
   maintName: string
   planTime: string
@@ -115,11 +132,14 @@
   endTime?: string
   maintDesc: string
   remark: string
+  picture: string
 }
 
 const order = reactive<MaintOrder>({
   id: '',
   equName: '',
+  assetNo: '',
+  status: '',
   maintCode: '',
   maintName: '',
   planTime: '',
@@ -149,23 +169,6 @@
     },
   ],
 }
-function openStartTime() {
-  if (startTime.value === 0) {
-    startTime.value = Date.now()
-  }
-}
-function openEndTime() {
-  if (endTime.value === 0) {
-    endTime.value = Date.now()
-  }
-}
-
-function handleStartTime(value) {
-  order.startTime = formatDate(new Date(value.value))
-}
-function handleEndTime(value) {
-  order.endTime = formatDate(new Date(value.value))
-}
 
 function handleFileChange({ fileList }) {}
 
@@ -173,56 +176,101 @@
   getMaintOrder(id)
     .then((res: any) => {
       Object.assign(order, res)
-      startTime.value = new Date(order.startTime).getTime()
-      endTime.value = new Date(order.endTime).getTime()
     })
     .catch((res) => {})
 }
 
-function updateOrder(resolve: any) {
-  updateMaintOrder(order)
+function updateOrder(data: any, resolve: any) {
+  updateMaintOrder(data)
     .then((res: any) => {
       resolve(true)
+      toastSucces()
+      uni.$emit('maint-order-refresh')
     })
     .catch((res) => {
       console.error(res)
+    })
+}
+function toastSucces() {
+  toast.success('鎿嶄綔鎴愬姛')
+}
+
+function handleSubmit(data: any) {
+  message
+    .confirm({
+      msg: '纭畾鎻愪氦锛�',
+      title: '鎻愮ず',
+      beforeConfirm: ({ resolve }) => {
+        updateOrder(data, resolve)
+      },
+    })
+    .then(() => {
+      goBack()
+    })
+    .catch((error) => {
+      console.log(error)
     })
 }
 
 const goBack = () => {
   uni.navigateBack()
 }
-
 function handleClickRight() {
-  message
-    .confirm({
-      msg: '纭畾鎻愪氦锛�',
-      title: '鎻愮ず',
-      beforeConfirm: ({ resolve }) => {
-        updateOrder(resolve)
-      },
-    })
-    .then(() => {})
-    .catch((error) => {
-      console.log(error)
-    })
+  // 绠$悊鍛樿鑹� 涓斿緟楠岃瘉鐘舵��
+  if (isLeader()) {
+    switch (order.status) {
+      case '0':
+      case '1':
+        toast.warning('褰撳墠宸ュ崟绛夊緟鎿嶄綔宸ヤ繚鍏荤姸鎬侊紝涓嶅彲鎿嶄綔')
+        break
+      case '2':
+        // 鍕鹃�夐獙璇侊紝鍙彁浜�
+        if (isVerify.value) {
+          // 淇敼宸ュ崟鐘舵�佷负宸插畬鎴�
+          const data: any = Object.assign({}, { id: order.id, status: order.status })
+          data.status = '3'
+          handleSubmit(data)
+        } else {
+          toast.warning('璇烽�夋嫨鏄惁楠岃瘉閫氳繃')
+        }
+        break
+      case '3':
+        toast.warning('褰撳墠宸ュ崟瀹屾垚鐘舵�侊紝涓嶅彲鎿嶄綔')
+        break
+    }
+  } else if (isLineOrRepair()) {
+    switch (order.status) {
+      case '0':
+        break
+      case '1':
+        {
+          const data = Object.assign({}, order)
+          // 鍕鹃�夊伐鍗曞畬鎴愶紝鏀瑰彉鐘舵��
+          if (isFinish.value) {
+            // 淇敼宸ュ崟鐘舵�佷负寰呴獙璇�
+            data.status = '2'
+          }
+          handleSubmit(data)
+        }
+        break
+      case '2':
+        toast.warning('褰撳墠宸ュ崟绛夊緟绠$悊楠岃瘉鐘舵�侊紝涓嶅彲鎿嶄綔')
+        break
+      case '3':
+        toast.warning('褰撳墠宸ュ崟瀹屾垚鐘舵�侊紝涓嶅彲鎿嶄綔')
+        break
+    }
+  }
 }
 
+onMounted(() => {})
 onLoad((options) => {
   initMaintOrder(options.id)
 })
 </script>
 
 <style scoped lang="scss">
-:deep(.wd-navbar__text) {
-  font-size: 26rpx;
-  color: white;
-}
-
-:deep(.wd-icon-arrow-left:before),
-:deep(.wd-navbar__title) {
-  color: white;
-  font-weight: bold !important;
-  font-size: 32rpx;
+.container {
+  height: 100vh;
 }
 </style>

--
Gitblit v1.9.3