From 7fe7b6182c2d407d28c2c9da1c070c3ce964e3e7 Mon Sep 17 00:00:00 2001
From: zhuguifei <zhuguifei@zhuguifeideiMac.local>
Date: 星期二, 20 五月 2025 10:49:14 +0800
Subject: [PATCH] 1.移动端添加自定义navbar导航栏

---
 eims-ui-mobile/src/pages/maint/maint-order.vue |  207 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 163 insertions(+), 44 deletions(-)

diff --git a/eims-ui-mobile/src/pages/maint/maint-order.vue b/eims-ui-mobile/src/pages/maint/maint-order.vue
index bcfcb64..7f2da57 100644
--- a/eims-ui-mobile/src/pages/maint/maint-order.vue
+++ b/eims-ui-mobile/src/pages/maint/maint-order.vue
@@ -1,16 +1,19 @@
 <route lang="json5" type="page">
 {
+  layout: 'default',
   needLogin: true,
-  style: {
-    navigationBarTitleText: '淇濆吇宸ュ崟',
-    navigationStyle: 'custom',
-    navigationBarBackgroundColor: '#4D80F0',
-  },
+  style: { navigationBarTitleText: '淇濆吇宸ュ崟', navigationStyle: 'custom' },
 }
 </route>
 
 <template>
-  <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time>
+  <z-paging
+    ref="paging"
+    v-model="dataList"
+    @query="queryList"
+    :auto="false"
+    show-refresher-update-time
+  >
     <template #top>
       <wd-navbar
         title="淇濆吇宸ュ崟"
@@ -20,7 +23,11 @@
         @click-right="handleClickRight"
         custom-style="background: #4D80F0;"
         safeAreaInsetTop
-      ></wd-navbar>
+      >
+        <template #right>
+          <text v-if="isOperatorOrRepair()" class="text-white">鎻愪氦</text>
+        </template>
+      </wd-navbar>
       <wd-cell>
         <template #title>
           <text class="text-color-gray">璁惧</text>
@@ -41,7 +48,7 @@
             </view>
           </view>
         </template>
-        <view class="flex h-[100rpx]" items-center>
+        <view class="flex h-[140rpx]" items-center>
           <image class="slot-img text-center" src="/static/images/camera.png" />
           <view class="flex-1">
             <view class="text-color-gray text-xs mt-1 flex">
@@ -58,7 +65,7 @@
             </view>
             <view class="text-color-gray text-xs mt-2 flex">
               <text>鐘舵�侊細</text>
-              <template v-if="maintSt.orderCount === maintSt.wcCount">
+              <template v-if="maintSt.status === '1'">
                 <wd-icon class="icon-color-success" name="check-outline" size="34rpx"></wd-icon>
                 <text class="ml-1">宸插畬鎴�</text>
               </template>
@@ -66,6 +73,10 @@
                 <wd-icon class="icon-color-base" name="detection" size="40rpx"></wd-icon>
                 <text class="ml-1">杩涜涓�</text>
               </template>
+            </view>
+
+            <view class="text-color-gray text-xs mt-2 flex">
+              鍒涘缓鏃堕棿: {{ maintSt.createTime }}
             </view>
           </view>
         </view>
@@ -85,10 +96,9 @@
           <view class="flex justify-between">
             <view class="flex items-center menu-title-box">
               <view class="menu-indicator"></view>
-              <view class="ml-1 text-sm align-center w-[50%]">
+              <view class="ml-1 text-sm align-center">
                 <wd-text :text="item.maintName" :lines="1"></wd-text>
               </view>
-              <view class="text-color-gray ml-2 text-mini">{{ item.maintCode }}</view>
             </view>
 
             <view class="flex items-center w-[20%] justify-end">
@@ -98,9 +108,10 @@
             </view>
           </view>
         </template>
-        <view class="flex h-[140rpx]" items-center>
+        <view class="flex h-[200rpx]" items-center>
           <image class="slot-img text-center" src="/static/ico/ico-platform.png" />
           <view class="flex-1 text-color-gray text-xs flex-row">
+            <view class="mr-3 mt-2">淇濆吇鍗曞彿: {{ item.maintCode }}</view>
             <view class="mr-3 mt-2">璁″垝淇濆吇鏃ユ湡: {{ item.planTime }}</view>
             <view class="mr-3 mt-2">淇濆吇寮�濮嬫椂闂�: {{ item.startTime }}</view>
             <view class="mr-3 mt-2">淇濆吇缁撴潫鏃堕棿: {{ item.endTime }}</view>
@@ -129,14 +140,24 @@
           </view>
           <!--鎿嶄綔宸ユ垨缁翠慨宸ヨ鑹�-->
           <template v-if="isOperatorOrRepair()">
-            <wd-button
-              v-if="item.status === '0'"
-              size="small"
-              icon="edit-outline"
-              @click.stop="handleStartMaint(item)"
-            >
-              寮�濮嬩繚鍏�
-            </wd-button>
+            <view class="flex flex-col justify-between"  v-if="item.status === '0'">
+              <wd-button
+                size="small"
+                icon="edit-outline"
+                @click.stop="handleStartMaint(item)"
+              >
+                寮�濮嬩繚鍏�
+              </wd-button>
+
+              <wd-button
+                class="mt-3"
+                size="small"
+                icon="edit-outline"
+                @click.stop="handleMaintFinish(item)"
+              >
+                涓�閿繚鍏�
+              </wd-button>
+            </view>
             <wd-button
               v-if="item.status === '1'"
               size="small"
@@ -167,20 +188,10 @@
 
           <!--绠$悊鍛樿鑹�-->
           <template v-else-if="isLeader()">
-            <wd-button
-              v-if="item.status === '0'"
-              size="small"
-              icon="warn-bold"
-              disabled
-            >
+            <wd-button v-if="item.status === '0'" size="small" icon="warn-bold" disabled>
               寰呬繚鍏�
             </wd-button>
-            <wd-button
-              v-if="item.status === '1'"
-              size="small"
-              icon="warn-bold"
-              disabled
-            >
+            <wd-button v-if="item.status === '1'" size="small" icon="warn-bold" disabled>
               淇濆吇涓�
             </wd-button>
 
@@ -226,14 +237,17 @@
 </template>
 <script setup lang="ts">
 import type { MaintStVO } from '@/service/maint.d'
-import { getMaintSt, getMaintStOrderList, updateMaintOrder } from '@/service/maint'
+import { getMaintSt, getMaintStOrderList, updateMaintOrder, updateMaintSt } from '@/service/maint'
 import { ref, reactive } from 'vue'
 import { useToast, useMessage } from 'wot-design-uni'
 import { isLeader, isOperatorOrRepair } from '@/utils/RoleUtils'
+import { formatDate } from '@/utils/DateUtils'
 const message = useMessage()
+const toast = useToast()
 
 const paging = ref(null)
 const dataList = ref([])
+const maintStId = ref('')
 
 interface QueryParams {
   pageNum: number
@@ -247,6 +261,7 @@
   equName: '',
   assetNo: '',
   planTime: '',
+  createTime: '',
   orderCount: null,
   wcCount: null,
   dbyCount: null,
@@ -260,17 +275,27 @@
     pageSize,
     maintCode: maintCode.value,
   }
-
   getMaintStOrderList(params)
     .then((res: any) => {
       // 璇峰嬁鍦ㄧ綉缁滆姹傚洖璋冧腑缁檇ataList璧嬪�硷紒锛佸彧闇�瑕佽皟鐢╟omplete灏卞彲浠ヤ簡
-      paging.value.complete(res.rows)
+      paging.value.completeByTotal(res.rows, res.total)
     })
     .catch((res) => {
       // 濡傛灉璇锋眰澶辫触鍐檖aging.value.complete(false)锛屼細鑷姩灞曠ず閿欒椤甸潰
       // 娉ㄦ剰锛屾瘡娆¢兘闇�瑕佸湪catch涓啓杩欏彞璇濆緢楹荤儲锛寊-paging鎻愪緵浜嗘柟妗堝彲浠ュ叏灞�缁熶竴澶勭悊
       // 鍦ㄥ簳灞傜殑缃戠粶璇锋眰鎶涘嚭寮傚父鏃讹紝鍐檜ni.$emit('z-paging-error-emit');鍗冲彲
       paging.value.complete(false)
+    })
+}
+function initMaintSt(id: any) {
+  getMaintSt(id)
+    .then((res: any) => {
+      Object.assign(maintSt, res)
+      paging.value.reload()
+    })
+    .catch((res) => {
+      console.error(res)
+      toast.error(res?.data?.msg || '璇锋眰澶辫触')
     })
 }
 
@@ -284,15 +309,44 @@
   })
 }
 
+/**
+ * 寮�濮嬩繚鍏�
+ * @param item
+ */
 function handleStartMaint(item) {
+  // 纭寮�濮嬩慨鏀圭姸鎬佷负1-淇濆吇涓�
+  const data = Object.assign({}, item)
+  data.status = '1'
   message
     .confirm({
       msg: '纭畾寮�濮嬩繚鍏伙紵',
       title: '鎻愮ず',
       beforeConfirm: ({ resolve }) => {
-        // 纭寮�濮嬩慨鏀圭姸鎬佷负1-淇濆吇涓�
-        const data = Object.assign({}, item)
-        data.status = '1'
+        updateOrder(data, resolve)
+      },
+    })
+    .then(() => {})
+    .catch((error) => {
+      console.log(error)
+    })
+}
+
+
+/**
+ * 涓�閿繚鍏�
+ * @param item
+ */
+function handleMaintFinish(item) {
+  // 涓�閿繚鍏�
+  const data = Object.assign({}, item)
+  data.status = '2'
+  data.startTime = formatDate(new Date())
+  data.endTime = formatDate(new Date())
+  message
+    .confirm({
+      msg: '纭畾浣跨敤涓�閿繚鍏伙紵',
+      title: '鎻愮ず',
+      beforeConfirm: ({ resolve }) => {
         updateOrder(data, resolve)
       },
     })
@@ -308,25 +362,91 @@
  * @param resolve
  */
 function updateOrder(data: any, resolve: any) {
+
   updateMaintOrder(data)
     .then((res: any) => {
       resolve(true)
       if (res?.code === 200) {
         reloadData()
+        // 淇濆吇鐘舵�佹墠闇�瑕佽烦杞�
+        if(data?.status === '1'){
+          goToOrderDetail(data)
+        }
       }
     })
     .catch((res) => {
       console.error(res)
     })
 }
-function reloadData() {
-  paging.value.reload()
+
+function handleUpdateMaintSt() {
+  if (maintSt.orderCount !== maintSt.wcCount) {
+    toast.info('璇峰厛瀹屾垚鎵�鏈変繚鍏婚」锛�')
+    return false
+  }
+
+  const data: any = Object.assign(
+    {},
+    {
+      id: maintSt.id,
+      orderCount: maintSt.orderCount,
+      wcCount: maintSt.wcCount,
+      status: maintSt.status,
+      specialNote: maintSt.specialNote,
+    },
+  )
+  if (data.orderCount === data.wcCount) {
+    data.status = '1'
+  }
+  message
+    .confirm({
+      msg: '纭畾鏇存柊宸ュ崟姹囨�绘暟鎹紵',
+      title: '鎻愮ず',
+      beforeConfirm: ({ resolve }) => {
+        updateMaintSt(data)
+          .then((res: any) => {
+            resolve(true)
+            if (res?.code === 200) {
+              reloadData()
+              toastSucces()
+            }
+          })
+          .catch((res) => {
+            console.error(res)
+          })
+      },
+    })
+    .then(() => {})
+    .catch((error) => {
+      console.log(error)
+    })
 }
+
+function toastSucces() {
+  toast.success('鎿嶄綔鎴愬姛')
+}
+
+function reloadData() {
+  initMaintSt(maintStId.value)
+}
+
 const goBack = () => {
   uni.navigateBack()
 }
 
-function handleClickRight() {}
+function handleClickRight() {
+  if(isOperatorOrRepair()){
+    handleUpdateMaintSt()
+  }
+
+}
+
+onLoad(() => {
+  uni.$on('maint-order-refresh', reloadData)
+})
+onUnload(() => {
+  uni.$off('maint-order-refresh', reloadData)
+})
 
 /**
  * 鏌ヨ淇濆吇鏄庣粏闇�瑕佺殑code
@@ -334,9 +454,8 @@
 const maintCode = computed(() => `${maintSt.equId}_${maintSt.planTime}`)
 
 onLoad((options) => {
-  const itemString = decodeURIComponent(options.maintSt)
-  const item = JSON.parse(itemString)
-  Object.assign(maintSt, item)
+  maintStId.value = options.id
+  reloadData()
 })
 </script>
 

--
Gitblit v1.9.3