Procházet zdrojové kódy

添加工单列表关键字查询,工单状态字典获取

HD_wangm před 4 měsíci
rodič
revize
babb9b5ba9
5 změnil soubory, kde provedl 214 přidání a 23 odebrání
  1. 38 0
      api/dict/index.uts
  2. 6 5
      api/order/list.uts
  3. 143 17
      pages/order/index.uvue
  4. 26 0
      types/dict.uts
  5. 1 1
      types/order.uts

+ 38 - 0
api/dict/index.uts

@@ -0,0 +1,38 @@
+/**
+ * 字典数据接口
+ */
+import { request } from '../../utils/request'
+import type { DictDataResponse } from '../../types/dict'
+
+/**
+ * 根据字典类型查询字典数据信息
+ * @param dictType 字典类型
+ */
+export const getDictDataByType = (dictType: string): Promise<DictDataResponse> => {
+    return request<DictDataResponse>({
+        url: `/system/dict/data/type/${dictType}`,
+        method: 'GET'
+    })
+}
+
+/**
+ * 根据字典类型查询字典数据信息(返回AjaxResult格式)
+ * @param dictType 字典类型
+ */
+export const getDictDataByTypeAjax = (dictType: string): Promise<AjaxResult> => {
+    return request<AjaxResult>({
+        url: `/system/dict/data/type/${dictType}`,
+        method: 'GET'
+    })
+}
+
+/**
+ * 根据字典类型查询字典数据列表
+ * @param dictType 字典类型
+ */
+export const getDictDataList = (dictType: string): Promise<SysDictData[]> => {
+    return request<SysDictData[]>({
+        url: `/system/dict/data/type/${dictType}`,
+        method: 'GET'
+    })
+}

+ 6 - 5
api/order/list.uts

@@ -7,14 +7,15 @@ import { request } from '../../utils/request'
  * 获取工单列表
  * @param page 页码
  * @param rows 每页数量
- * @param workOrderProjectNo 工单编号(可选
+ * @param keyword 关键字(可选,支持工单编号和风机编号查询
  * @param status 工单状态(可选)
  */
-export const getOrderList = (page: number, rows: number, workOrderProjectNo: string | null, status: string | null = null): Promise<any> => {
+export const getOrderList = (page: number, rows: number, keyword: string | null, status: string | null = null): Promise<any> => {
     let url = `/mobile/order/list?pageNum=${page}&pageSize=${rows}`
-    if (workOrderProjectNo != null && workOrderProjectNo.length > 0) {
-        url += `&repairOrder.workOrderProjectNo=${workOrderProjectNo}`
-		url += `&workOrder.workOrderProjectNo=${workOrderProjectNo}`
+    if (keyword != null && keyword.length > 0) {
+        // 支持工单编号和风机编号查询
+        url += `&keyword=${encodeURIComponent(keyword)}`
+        // url += `&pcsDeviceName=${encodeURIComponent(keyword)}`
     }
     // 添加状态筛选参数
     if (status != null && status.length > 0) {

+ 143 - 17
pages/order/index.uvue

@@ -5,7 +5,8 @@
         <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" />
+                <text v-if="keyword && keyword.length > 0" class="clear-icon" @click="clearSearch">✕</text>
             </view>
         </view>
 
@@ -32,22 +33,48 @@
                 <view class="list-item">
                     <view class="item-container">
                         <view class="item-header">
-                            <image class="location-icon" src="/static/images/workbench/list/2.png" mode="aspectFit"></image>
+                            <!-- <image class="location-icon" src="/static/images/workbench/list/2.png" mode="aspectFit"></image>
                             <text class="item-title">{{ getOrderType(item) }}</text>
-                            <text class="detail-link">类型 ›</text>
+                            <text class="detail-link">类型 ›</text> -->
+							<text class="item-title">{{ getWorkOrderProjectNo(item) }}-{{ getPcsDeviceName(item) }}{{ getOrderType(item) }}</text>
+							<text class="info-value">{{ getWorkOrderStatus(item) }}</text>
                         </view>
-                        <text class="item-address">{{ getWorkOrderProjectNo(item) }}</text>
-                        <view class="item-info">
+						<view class="info-row"></view>
+						<view class="flex justify-between items-center">
+						<!-- <view class="item-info">
+							<view class="info-row">
+								<view class="info-item"> -->
+									<text class="text-xs text-gray-500">{{ getDisplayTime(item) }}</text>
+								<!-- </view>
+								<view class="info-item">-->
+									<button 
+										v-if="currentStatus === 'assigned'" 
+										class="btn-primary text-xs py-1 px-3" 
+										@click="acceptOrder(item)">
+										接单
+									</button>
+									<button 
+										v-else-if="currentStatus === 'to_approve'" 
+										class="btn-primary text-xs py-1 px-3" 
+										@click="approveOrder(item)">
+										审批
+									</button>
+								<!-- </view>
+							</view>
+						</view> -->
+						</view>
+                        
+                        <!-- <view class="item-info">
                             <view class="info-row">
                                 <view class="info-item">
                                     <text class="info-label">工单状态</text>
                                     <text class="info-value">{{ getWorkOrderStatus(item) }}</text>
                                 </view>
-                                <view class="info-item">
-                                    <text class="info-label">场站</text>
-                                    <text class="info-value">{{ getPcsStationName(item) }}</text>
-                                </view>
-                            </view>
+								<view class="info-item">
+								    <text class="info-label">场站</text>
+								    <text class="info-value">{{ getPcsStationName(item) }}</text>
+								</view>
+							</view>
                             <view class="info-row">
                                 <view class="info-item">
                                     <text class="info-label">设备名</text>
@@ -58,7 +85,7 @@
                                     <text class="info-value">{{ getAssignTime(item) }}</text>
                                 </view>
                             </view>
-                        </view>
+                        </view> -->
                     </view>
                 </view>
             </template>
@@ -68,9 +95,11 @@
 </template>
 
 <script setup lang="uts">
-    import { ref, computed, onBeforeUnmount } from 'vue'
+    import { ref, computed, onBeforeUnmount, onMounted } from 'vue'
     import type { orderInfo, orderListResponse } from '../../types/order'
+    import type { SysDictData } from '../../types/dict'
     import { getOrderList } from '../../api/order/list'
+    import { getDictDataByType } from '../../api/dict/index'
 
     // 列表数据
     const dataList = ref<orderInfo[]>([])
@@ -82,6 +111,7 @@
     const refreshing = ref<boolean>(false)
     const total = ref<number>(0)
 	const currentStatus = ref<string>('') // 添加状态管理
+    const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
 
     // 辅助函数:从 any 类型提取属性
     const getOrderType = (item: any | null): string => {
@@ -99,7 +129,13 @@
     const getWorkOrderStatus = (item: any | null): string | null => {
         if (item == null) return ''
         const orderInfoItem = item as orderInfo
-        return orderInfoItem.workOrderStatus
+        const rawStatus = orderInfoItem.workOrderStatus
+        
+        if (!rawStatus) return ''
+        
+        // 查找字典中对应的标签
+        const dictItem = statusDictList.value.find(dict => dict.dictValue === rawStatus)
+        return dictItem ? dictItem.dictLabel : rawStatus
     }
 
     const getPcsStationName = (item: any | null): string | null=> {
@@ -119,6 +155,35 @@
         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 switchStatus = (status: string): void => {
@@ -127,6 +192,18 @@
         loadData(true)
     }
 
+    // 获取工单状态字典列表
+    const loadStatusDictList = async (): Promise<void> => {
+        try {
+            const result = await getDictDataByType('gxt_work_order_status')
+            if (result.code === 200) {
+                statusDictList.value = result.data
+            }
+        } catch (e: any) {
+            console.error('获取工单状态字典失败:', e.message)
+        }
+    }
+
     // 加载列表数据
     const loadData = async (isRefresh: boolean | null): Promise<void> => {
         if (loading.value) {
@@ -145,7 +222,7 @@
                 page.value = 1
             }
 
-            // 调用 API,传递状态参数
+            // 调用 API,传递关键字参数
             const searchKeyword = keyword.value.length > 0 ? keyword.value : null
             const result = await getOrderList(page.value, pageSize, searchKeyword, currentStatus.value || null)
 
@@ -178,7 +255,8 @@
                         pcsDeviceId: item['pcsDeviceId'] as Number | 0,
                         pcsDeviceName: item['pcsDeviceName'] as string | null,
                         brand: item['brand'] as string | null,
-                        model: item['model'] as string | null
+                        model: item['model'] as string | null,
+                        createTime: item['createTime'] as string | null
                     }
                     newData.push(orderItem)
                 }
@@ -255,7 +333,46 @@
             url: `/pages/workbench/detail/index?id=${orderItem.id}`
         })
     }
-
+    
+    // 接单操作
+    const acceptOrder = (item: any | null): void => {
+        if (item == null) return
+        const orderItem = item as orderInfo
+        console.log('接单操作:', orderItem.id)
+        // 这里可以添加实际的接单逻辑
+        uni.showToast({
+            title: '接单成功',
+            icon: 'success'
+        })
+    }
+    
+    // 审批操作
+    const approveOrder = (item: any | null): void => {
+        if (item == null) return
+        const orderItem = item as orderInfo
+        console.log('审批操作:', orderItem.id)
+        // 这里可以添加实际的审批逻辑
+        uni.showToast({
+            title: '审批成功',
+            icon: 'success'
+        })
+    }
+    
+    // 查看工单详情
+    const showWorkOrderDetail = (item: any | null): void => {
+        if (item == null) return
+        const orderItem = item as orderInfo
+        uni.navigateTo({
+            url: `/pages/workbench/detail/index?id=${orderItem.id}`
+        })
+    }
+    
+    // 清空搜索
+    const clearSearch = (): void => {
+        keyword.value = ""
+        page.value = 1
+        loadData(true)
+    }
     // 组件卸载前清理
     onBeforeUnmount(() => {
         refreshing.value = false
@@ -263,7 +380,10 @@
     })
 
     // 初始化
-    loadData(true as boolean | null)
+    onMounted(() => {
+        loadStatusDictList()
+        loadData(true as boolean | null)
+    })
 </script>
 
 <style lang="scss">
@@ -296,6 +416,12 @@
             font-size: 28rpx;
             color: #333333;
         }
+        
+        .clear-icon {
+            margin-left: 12rpx;
+            font-size: 28rpx;
+            color: #999999;
+        }
     }
 	
 	.status-bar{

+ 26 - 0
types/dict.uts

@@ -0,0 +1,26 @@
+/**
+ * 字典数据类型定义
+ */
+
+// 字典数据项
+export type SysDictData = {
+    dictCode: string | null;
+    dictSort: number | null;
+    dictLabel: string | null;
+    dictValue: string | null;
+    dictType: string | null;
+    cssClass: string | null;
+    listClass: string | null;
+    isDefault: string | null;
+    status: string | null;
+    default: boolean | null;
+    createTime: string | null;
+    remark: string | null;
+}
+
+// 字典数据响应
+export type DictDataResponse = {
+    code: number;
+    msg: string | null;
+    data: SysDictData[];
+}

+ 1 - 1
types/order.uts

@@ -1,4 +1,3 @@
-
 // 工单信息
 export type orderInfo = {
 	orderType: Number
@@ -19,6 +18,7 @@ export type orderInfo = {
     pcsDeviceName: string | null
     brand: string | null
     model: string | null
+    createTime: string | null
 }
 
 // 工单列表响应