HD_wangm 4 месяцев назад
Родитель
Сommit
799f351e65
3 измененных файлов с 74 добавлено и 62 удалено
  1. 3 4
      api/dict/index.uts
  2. 2 2
      api/order/detail.uts
  3. 69 56
      pages/order/index.uvue

+ 3 - 4
api/dict/index.uts

@@ -2,17 +2,16 @@
  * 字典数据接口
  */
 import { request } from '../../utils/request'
-import type { DictDataResponse } from '../../types/dict'
 
 /**
  * 根据字典类型查询字典数据信息
  * @param dictType 字典类型
  */
-export const getDictDataByType = (dictType: string): Promise<DictDataResponse> => {
+export const getDictDataByType = (dictType: string): Promise<any> => {
     return request({
         url: `/system/dict/data/type/${dictType}`,
         method: 'GET'
-    }) as Promise<DictDataResponse>
+    })
 }
 
 // /**
@@ -35,4 +34,4 @@ export const getDictDataByType = (dictType: string): Promise<DictDataResponse> =
 //         url: `/system/dict/data/type/${dictType}`,
 //         method: 'GET'
 //     }) as Promise<SysDictData[]>
-// }
+// }

+ 2 - 2
api/order/detail.uts

@@ -9,7 +9,7 @@ import { request } from '../../utils/request'
  */
 export const getOrderInfoById = (id: string): Promise<any> => {
     return request({
-        url: `/gxt/order/${id}`,
+        url: `/mobile/order/${id}`,
         method: 'GET'
     })
 }
@@ -20,7 +20,7 @@ export const getOrderInfoById = (id: string): Promise<any> => {
  */
 export const getRepairOrderInfoById = (id: string): Promise<any> => {
     return request({
-        url: `/gxt/repairOrder/${id}`,
+        url: `/mobile/order/repairOrder/${id}`,
         method: 'GET'
     })
 }

+ 69 - 56
pages/order/index.uvue

@@ -5,7 +5,7 @@
         <view class="search-bar">
             <view class="search-box">
                 <image class="search-icon" src="/static/images/workbench/list/1.png" mode="aspectFit"></image>
-                <input class="search-input" type="text" placeholder="搜索工单编号、风机编号" v-model="keyword" @confirm="handleSearch" />
+                <input class="search-input" type="text" placeholder="搜索工单编号、风机编号" v-model="keyword" @confirm="handleSearch" @blur="handleSearchOnBlur" />
                 <text v-if="keyword.length > 0" class="clear-icon" @click="clearSearch">✕</text>
             </view>
         </view>
@@ -20,13 +20,13 @@
 			</view>
 		</view>
         <!-- 列表内容 -->
-        <common-list 
-            :dataList="dataList" 
-            :loading="loading" 
-            :refreshing="refreshing" 
-            :hasMore="hasMore" 
-            @refresh="handleRefresh" 
-            @loadMore="loadMore" 
+        <common-list
+            :dataList="dataList"
+            :loading="loading"
+            :refreshing="refreshing"
+            :hasMore="hasMore"
+            @refresh="handleRefresh"
+            @loadMore="loadMore"
             @itemClick="handleItemClick"
         >
             <template #default="{ item, index }">
@@ -47,15 +47,15 @@
 									<text class="text-xs text-gray-500">{{ getDisplayTime(item) }}</text>
 								</view>
 								<view class="info-value">
-									<button 
-										v-if="currentStatus === 'assigned'" 
-										class="btn-primary" 
+									<button
+										v-if="currentStatus === 'assigned'"
+										class="btn-primary"
 										@click="acceptOrder(item)">
 										接单
 									</button>
-									<button 
-										v-else-if="currentStatus === 'to_approve'" 
-										class="btn-primary" 
+									<button
+										v-else-if="currentStatus === 'to_approve'"
+										class="btn-primary"
 										@click="approveOrder(item)">
 										审批
 									</button>
@@ -63,7 +63,7 @@
 							</view>
 						<!-- </view> -->
 						<!-- </view> -->
-                        
+
                         <!-- <view class="item-info">
                             <view class="info-row">
                                 <view class="info-item">
@@ -97,7 +97,7 @@
 <script lang="uts">
 import { ref, onBeforeUnmount, onMounted } from 'vue'
 import type { orderInfo } from '../../types/order'
-import type { SysDictData } from '../../types/dict'
+import type { SysDictData, DictDataResponse } from '../../types/dict'
 import { getOrderList } from '../../api/order/list'
 import { getDictDataByType } from '../../api/dict/index'
 
@@ -115,21 +115,21 @@ export default {
     const total = ref<number>(0)
 	let currentStatus = ref<string>('') // 添加状态管理
     const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
-	
+
 	// 添加字典加载状态
 	const dictLoaded = ref<boolean>(false)
-	
+
 	// 获取工单状态字典列表
 	const loadStatusDictList = async (): Promise<void> => {
 	    try {
 	        const result = await getDictDataByType('gxt_work_order_status')
 	        const resultObj = result as UTSJSONObject
-	        
+
 	        if (resultObj['code'] == 200) {
 	            const data = resultObj['data'] as any[]
 	            const dictData: SysDictData[] = []
-	            
-	            if (data != null && data.length > 0) {
+
+	            if (data.length > 0) {
 	                for (let i = 0; i < data.length; i++) {
 	                    const item = data[i] as UTSJSONObject
 	                    // 只提取需要的字段
@@ -150,7 +150,7 @@ export default {
 	                    dictData.push(dictItem)
 	                }
 	            }
-	            
+
 	            statusDictList.value = dictData
 	            dictLoaded.value = true
 	        }
@@ -159,7 +159,7 @@ export default {
 	        dictLoaded.value = true
 	    }
 	}
-	
+
     // 加载列表数据
     const loadData = async (isRefresh: boolean | null): Promise<void> => {
         if (loading.value) {
@@ -177,9 +177,10 @@ export default {
             if (shouldRefresh) {
                 page.value = 1
             }
-
+			console.log("searchKeyword===" + keyword)
             // 调用 API,传递关键字参数
             const searchKeyword = keyword.value.length > 0 ? keyword.value : null
+
             const result = await getOrderList(page.value, pageSize, searchKeyword, currentStatus.value)
 
             // 提取响应数据
@@ -187,7 +188,7 @@ export default {
             const code = resultObj['code'] as number
             const responseData = resultObj['rows'] as any[]
             const responseTotal = resultObj['total'] as number
-			
+
             if (code == 200) {
                 // 将 any[] 转换为 orderInfo[]
                 const newData: orderInfo[] = []
@@ -252,18 +253,14 @@ export default {
             }, 100)
             // #endif
         }
-        
+
         // #ifdef WEB
         // Web 平台额外确保重置
         refreshing.value = false
         // #endif
     }
 
-	// 初始化
-	onMounted(() => {
-	    loadStatusDictList()
-	    loadData(true as boolean | null)
-	})
+
 
     // 辅助函数:从 any 类型提取属性
     const getOrderType = (item: any | null): string => {
@@ -295,53 +292,52 @@ export default {
         const orderInfoItem = item as orderInfo
         return orderInfoItem.assignTime
     }
-	
+
 	const getAcceptTime = (item: any | null): string|null => {
 	    if (item == null) return null
 	    const orderInfoItem = item as orderInfo
 	    return orderInfoItem.acceptTime
 	}
-	
+
 	const getCreateTime = (item: any | null): string|null => {
 	    if (item == null) return null
 	    const orderInfoItem = item as orderInfo
 	    return orderInfoItem.createTime
 	}
-	
+
 
 	// 根据状态显示不同的时间
 	const getDisplayTime = (item: any | null): string|null => {
 		if (item == null) return null
 		const orderInfoItem = item as orderInfo
-		
+
 		// 如果是"待接单"状态,显示派单时间
 		if (currentStatus.value === 'assigned') {
 			return getAssignTime(item)
 		} else if(currentStatus.value === 'to_finish') {
 			return getAcceptTime(item)
 		}
-		
+
 		// 默认显示创建时间
 		return getCreateTime(item)
 	}
 
-	
-	
+
+
 	const getWorkOrderStatus = (item: any | null): string | null => {
 	    if (item == null) return ''
 	    const orderInfoItem = item as orderInfo
 	    const rawStatus = orderInfoItem.workOrderStatus
-	    
+
 	    if (rawStatus==null) return ''
-		
+
 		// 如果字典尚未加载,返回原始值
 		    if (!dictLoaded.value) {
 		        return rawStatus
 		    }
-	    
+
 	    // 查找字典中对应的标签
 	    const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
-		console.log("==========" + dictItem)
 	    return dictItem!=null ? dictItem.dictLabel : rawStatus
 	}
 
@@ -351,12 +347,12 @@ export default {
         page.value = 1
         loadData(true)
     }
-	
+
     // 下拉刷新
     const handleRefresh = async (): Promise<void> => {
         refreshing.value = true
         await loadData(true as boolean | null)
-        
+
     }
 
     // 加载更多
@@ -371,9 +367,18 @@ export default {
     // 搜索
     const handleSearch = (): void => {
         page.value = 1
+		console.log("======搜索=====")
         loadData(true as boolean | null)
     }
 
+	// 添加防抖处理,避免频繁搜索
+	let searchTimer: number | null = null
+
+	const handleSearchOnBlur = (): void => {
+		handleSearch()
+	}
+
+
     // 点击列表项
     const handleItemClick = (item: any | null, index: number): void => {
         if (item == null) return
@@ -383,7 +388,7 @@ export default {
             url: `/pages/order/detail/index?id=${orderItem.id}&orderType=${orderItem.orderType}`
         })
     }
-    
+
     // 接单操作
     const acceptOrder = (item: any | null): void => {
         if (item == null) return
@@ -395,7 +400,7 @@ export default {
             icon: 'success'
         })
     }
-    
+
     // 审批操作
     const approveOrder = (item: any | null): void => {
         if (item == null) return
@@ -407,7 +412,7 @@ export default {
             icon: 'success'
         })
     }
-    
+
     // 查看工单详情
     const showWorkOrderDetail = (item: any | null): void => {
         if (item == null) return
@@ -416,19 +421,26 @@ export default {
             url: `/pages/workbench/detail/index?id=${orderItem.id}`
         })
     }
-    
+
     // 清空搜索
     const clearSearch = (): void => {
         keyword.value = ""
         page.value = 1
         loadData(true)
     }
+
+	// 初始化
+	onMounted(() => {
+	    loadStatusDictList()
+	    loadData(true as boolean | null)
+	})
     // 组件卸载前清理
     onBeforeUnmount(() => {
         refreshing.value = false
         loading.value = false
     })
 
+
     // 返回模板可直接使用的变量/方法
     return {
         dataList,
@@ -453,7 +465,8 @@ export default {
         handleItemClick,
         acceptOrder,
         approveOrder,
-        clearSearch
+        clearSearch,
+		handleSearchOnBlur
     }
 }}
 </script>
@@ -488,26 +501,26 @@ export default {
             font-size: 28rpx;
             color: #333333;
         }
-        
+
         .clear-icon {
             margin-left: 12rpx;
             font-size: 28rpx;
             color: #999999;
         }
     }
-	
+
 	.status-bar{
 		padding-bottom: 10px;
 		padding-left:30rpx;
 		background-color: #d7eafe;
 	}
-	
+
 	.status-box {
 		flex-direction: row;
 		align-items: center;
 		height: 72rpx;
 		flex: 1;
-		
+
 		.status-txt{
 			padding: 8px 12px;
 			text-align: center;
@@ -517,13 +530,13 @@ export default {
 			font-size: 28rpx;
 			// cursor: pointer;
 		}
-		
+
 		.stauts-sel{
 			background-color: #007AFF;
 			color: #fff;
 		}
 	}
-	
+
 
     .list-item {
         margin: 24rpx 30rpx;
@@ -609,4 +622,4 @@ export default {
 	    // padding-left: 1rem;
 	    // padding-right: 1rem;
 	}
-</style>
+</style>