From 0a27a9c0f9e1213dff16162d73a03dba0473b96e Mon Sep 17 00:00:00 2001
From: baoshiwei <baoshiwei@shlanbao.cn>
Date: 星期五, 27 六月 2025 11:06:36 +0800
Subject: [PATCH] refactor(lb-eims):优化维护计划生成订单功能

---
 eims-ui-mobile/src/pages/maint/maint-order.vue |  135 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 107 insertions(+), 28 deletions(-)

diff --git a/eims-ui-mobile/src/pages/maint/maint-order.vue b/eims-ui-mobile/src/pages/maint/maint-order.vue
index 88398ec..f314dca 100644
--- a/eims-ui-mobile/src/pages/maint/maint-order.vue
+++ b/eims-ui-mobile/src/pages/maint/maint-order.vue
@@ -12,6 +12,7 @@
     v-model="dataList"
     @query="queryList"
     :auto="false"
+    refresher-only
     show-refresher-update-time
   >
     <template #top>
@@ -25,7 +26,7 @@
         safeAreaInsetTop
       >
         <template #right>
-          <text v-if="isOperatorOrRepair()" class="text-white">鎻愪氦</text>
+          <text v-if="maintSt.status === '0'" class="text-white">鎻愪氦</text>
         </template>
       </wd-navbar>
       <wd-cell>
@@ -37,10 +38,13 @@
       <wd-card type="rectangle">
         <template #title>
           <view class="flex justify-between">
-            <view class="flex items-center menu-title-box">
-              <view class="menu-indicator"></view>
-              <view class="ml-1 text-lg align-center">{{ maintSt.equName }}</view>
-              <view class="text-color-gray ml-2 text-sm">{{ maintSt.assetNo }}</view>
+            <view class="items-center menu-title-box">
+
+              <view class="flex justify-center ml-1 items-center align-center">
+                <view class="menu-indicator"></view>
+                <view class="ml-1"> {{ maintSt.equName }} </view>
+              </view>
+              <view class="text-color-gray ml-2 text-xs">{{ maintSt.assetNo }}</view>
             </view>
 
             <view class="flex items-center">
@@ -48,26 +52,32 @@
             </view>
           </view>
         </template>
-        <view class="flex h-[140rpx]" items-center>
+        <view class="flex" items-center>
           <image class="slot-img text-center" src="/static/images/camera.png" />
           <view class="flex-1">
             <view class="text-color-gray text-sm mt-1 flex">
               <text class="mr-3">宸ュ崟鎬绘暟: {{ maintSt.orderCount }}</text>
               |
-              <text class="mx-3">宸插畬鎴�: {{ maintSt.wcCount }}</text>
-            </view>
-            <view class="text-color-gray text-sm mt-2 flex">
-              <text class="mr-3">寰呬繚鍏�: {{ maintSt.dbyCount }}</text>
+              <text class="mx-3">宸插畬鎴�: {{ maintSt.dyzCount }}</text>
               |
-              <text class="mx-3">淇濆吇涓�: {{ maintSt.byCount }}</text>
-              |
-              <text class="ml-3">寰呴獙璇�: {{ maintSt.dyzCount }}</text>
+              <text class="mx-3">寰呬繚鍏�: {{ maintSt.dbyCount }}</text>
             </view>
+<!--            <view class="text-color-gray text-sm mt-2 flex">-->
+<!--              <text class="mr-3">寰呬繚鍏�: {{ maintSt.dbyCount }}</text>-->
+<!--              |-->
+<!--              <text class="mx-3">淇濆吇涓�: {{ maintSt.byCount }}</text>-->
+<!--&lt;!&ndash;              |&ndash;&gt;-->
+<!--&lt;!&ndash;              <text class="ml-3">寰呴獙璇�: {{ maintSt.dyzCount }}</text>&ndash;&gt;-->
+<!--            </view>-->
             <view class="text-color-gray text-sm mt-2 flex">
               <text>鐘舵�侊細</text>
               <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>
+              <template v-else-if="maintSt.status === '2'">
+                <wd-icon class="icon-color-warning" name="check-outline" size="34rpx"></wd-icon>
+                <text class="ml-1">宸茬‘璁�</text>
               </template>
               <template v-else>
                 <wd-icon class="icon-color-base" name="detection" size="40rpx"></wd-icon>
@@ -136,6 +146,9 @@
 
         <!-- 姝f枃鍖哄煙 -->
         <view v-else class="mt-2">
+          <wd-upload v-model:file-list="item.fileList" :action="VITE_UPLOAD_BASEURL" @success="handleUploadSuccess" >
+            <wd-button>涓婁紶鍥剧墖</wd-button>
+          </wd-upload>
           <!-- 淇濆吇璇存槑鍖哄煙 -->
           <view v-if="item.maintFun === '1'" class="mt-2">
             <wd-input
@@ -166,7 +179,7 @@
             >
               <wd-input
                 v-model="part.name"
-                label="鍚嶇О"
+                label="鍚嶇О锛�"
                 label-width="100rpx"
                 placeholder="澶囦欢鍚嶇О"
 
@@ -174,7 +187,8 @@
               />
               <wd-input
                 v-model="part.quantity"
-                label="鏁伴噺" label-width="100rpx"
+                label="鏁伴噺锛�"
+                label-width="100rpx"
                 placeholder="鏁伴噺" type="number" :maxlength="5" />
             </view>
           </view>
@@ -205,11 +219,16 @@
         placeholder="璇疯緭鍏ョ壒璁颁簨椤�"
         clearable
       />
+      <!-- 鏂板纭瀹屾垚鎸夐挳 -->
+      <view class="flex justify-around">
+        <wd-button type="primary" style="margin: 20px" block v-if="maintSt.status === '0'" @click="handleClickRight">鎻愪氦</wd-button>
+        <wd-button type="success" style="margin: 20px" block v-if="isLeader() && maintSt.status === '1'" @click="handleComplete">纭瀹屾垚</wd-button>
+      </view>
     </view>
     <!-- 鏂板鎻愪氦鎸夐挳 -->
-    <view class="flex justify-center mt-4">
-      <wd-button type="primary" block size="large" @click="handleClickRight">鎻愪氦</wd-button>
-    </view>
+<!--    <view class="flex justify-center mt-4">-->
+<!--      <wd-button type="primary" block size="large" @click="handleClickRight">鎻愪氦</wd-button>-->
+<!--    </view>-->
   </z-paging>
 
   <!-- 澶囦欢閫夋嫨寮瑰嚭灞� -->
@@ -246,11 +265,12 @@
 import { getMaintSt, getMaintStOrderList, updateMaintOrder, updateMaintSt, updateMaintOrderBatch } from '@/service/maint'
 import { ref, reactive } from 'vue'
 import { useToast, useMessage } from 'wot-design-uni'
-import { isLeader, isOperatorOrRepair } from '@/utils/RoleUtils'
+import { isLeader, isLineOrRepair } from '@/utils/RoleUtils'
 import { formatDate } from '@/utils/DateUtils'
 import { useUserStore } from "@/store";
 import { getSpareList } from '@/service/spare'
-
+import { getEnvBaseUploadUrl } from "@/utils";
+const VITE_UPLOAD_BASEURL = `${getEnvBaseUploadUrl()}`
 const message = useMessage()
 const toast = useToast()
 const userStore = useUserStore()
@@ -283,18 +303,26 @@
   dyzCount: null,
   specialNote: '',
 })
-const queryList = (pageNum?: number, pageSize?: number) => {
+const queryList = () => {
   const params: QueryParams = {
-    pageNum,
-    pageSize: 30,
     maintCode: maintCode.value,
   }
   getMaintStOrderList(params)
     .then((res: any) => {
+      // 灏嗘瘡涓�椤圭殑picture杞崲涓篺ileList鏁扮粍
+      res.rows.forEach((item: any) => {
+        item.fileList = item.picture?.split(',').map((url: string) => {
+          return {
+            url: url,
+          }
+        })
+      })
+      console.log(res)
       // 璇峰嬁鍦ㄧ綉缁滆姹傚洖璋冧腑缁檇ataList璧嬪�硷紒锛佸彧闇�瑕佽皟鐢╟omplete灏卞彲浠ヤ簡
-      paging.value.completeByTotal(res.rows, res.total)
+      paging.value.complete(res.rows)
     })
     .catch((res) => {
+      console.error(res)
       // 濡傛灉璇锋眰澶辫触鍐檖aging.value.complete(false)锛屼細鑷姩灞曠ず閿欒椤甸潰
       // 娉ㄦ剰锛屾瘡娆¢兘闇�瑕佸湪catch涓啓杩欏彞璇濆緢楹荤儲锛寊-paging鎻愪緵浜嗘柟妗堝彲浠ュ叏灞�缁熶竴澶勭悊
       // 鍦ㄥ簳灞傜殑缃戠粶璇锋眰鎶涘嚭寮傚父鏃讹紝鍐檜ni.$emit('z-paging-error-emit');鍗冲彲
@@ -340,7 +368,7 @@
 }
 
 function loadSpareParts(value?: string) {
-  getSpareList({ name: value }).then((res: any) => {
+  getSpareList({ name: value, pageNum: 1, pageSize: 10 }).then((res: any) => {
     sparePartsList.value = res.rows
 
   })
@@ -372,6 +400,7 @@
 function confirmSpareSelection() {
   closeSparePopup()
 }
+
 
 function addOtherSparePart() {
   dataList.value[selectedPartIndex.value].spareParts.push({
@@ -474,6 +503,15 @@
     return false
   }
 
+  // 灏唖ubmitList涓瘡涓�椤圭殑fileList杞崲涓轰互閫楀彿鍒嗗壊鐨勫瓧绗︿覆
+  submitList.forEach((item) => {
+
+    console.log('item.fileList', item.fileList)
+    const map = item.fileList?.map((file) => file.url)
+    console.log('map', map)
+    item.picture = map?.join(',')
+  })
+
 
   const data: any = Object.assign(
     {},
@@ -498,7 +536,8 @@
           .then((res: any) => {
             resolve(true)
             if (res?.code === 200) {
-              reloadData()
+              uni.$emit('maint-st-refresh')
+              goBack()
               toastSucces()
             }
           })
@@ -526,9 +565,8 @@
 }
 
 function handleClickRight() {
-  if(isOperatorOrRepair()){
+
     handleUpdateMaintSt()
-  }
 
 }
 
@@ -604,6 +642,47 @@
     });
 }
 
+/**
+ * 纭瀹屾垚鎸夐挳鐐瑰嚮浜嬩欢
+ */
+function handleComplete() {
+  if (!isLeader()) {
+    toast.info('鏃犳潈闄愭搷浣�');
+    return;
+  }
+  const now = new Date();
+  const data: any = Object.assign(
+    {},
+    {
+      id: maintSt.id,
+      status: '2',
+      verifyUser: userStore?.userInfo?.userId ,
+      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')}`
+    },
+  )
+  updateMaintSt(data)
+    .then((res: any) => {
+      if (res?.code === 200) {
+        uni.$emit('maint-st-refresh')
+        goBack()
+        toastSucces()
+      }
+    })
+    .catch((res) => {
+      console.error(res)
+    })
+}
+function handleUploadSuccess({ file, fileList }) {
+  console.log('handleUploadSuccess', file)
+  // 鍒ゆ柇 file.response鏄笉鏄� 瀵硅薄锛屼笉鏄璞″皢json瀛楃涓茶浆鎹负瀵硅薄
+  if (typeof file.response === 'string') {
+    file.response = JSON.parse(file.response)
+    console.log('file.response', file.response)
+    file.ossId = file.response.data.ossId
+    file.url = file.response.data.url
+  }
+}
+
 // 鏂板鏂规硶锛氳幏鍙栫姸鎬佹枃鏈�
 function getStatusText(maintFun: string): string {
   switch (maintFun) {

--
Gitblit v1.9.3