Browse Source

工单列表状态切换

HD_wangm 5 months ago
parent
commit
747e35c2e2
2 changed files with 26 additions and 15 deletions
  1. 24 13
      pages/order/index.uvue
  2. 2 2
      types/order.uts

+ 24 - 13
pages/order/index.uvue

@@ -11,8 +11,11 @@
 
 
 		<view class="status-bar">
 		<view class="status-bar">
 			<view class="status-box">
 			<view class="status-box">
-				<text class="status-txt" :class="{'stauts-sel':ix == 0}">全部</text>
-				<text class="status-txt" :class="{'stauts-sel':ix == 1}">待接单</text>
+				<text class="status-txt" :class="{'stauts-sel': currentStatus === ''}" @click="switchStatus('')">全部</text>
+				<text class="status-txt" :class="{'stauts-sel': currentStatus === 'assigned'}" @click="switchStatus('assigned')">待接单</text>
+				<text class="status-txt" :class="{'stauts-sel': currentStatus === 'to_finish'}" @click="switchStatus('to_finish')">待结单</text>
+				<text class="status-txt" :class="{'stauts-sel': currentStatus === 'to_approve'}" @click="switchStatus('to_approve')">待审批</text>
+				<text class="status-txt" :class="{'stauts-sel': currentStatus === 'completed'}" @click="switchStatus('completed')">已完成</text>
 			</view>
 			</view>
 		</view>
 		</view>
         <!-- 列表内容 -->
         <!-- 列表内容 -->
@@ -78,7 +81,7 @@
     const loading = ref<boolean>(false)
     const loading = ref<boolean>(false)
     const refreshing = ref<boolean>(false)
     const refreshing = ref<boolean>(false)
     const total = ref<number>(0)
     const total = ref<number>(0)
-	const ix = ref<number>(1)
+	const currentStatus = ref<string>('') // 添加状态管理
 
 
     // 辅助函数:从 any 类型提取属性
     // 辅助函数:从 any 类型提取属性
     const getOrderType = (item: any | null): string => {
     const getOrderType = (item: any | null): string => {
@@ -117,6 +120,13 @@
         return orderInfoItem.assignTime
         return orderInfoItem.assignTime
     }
     }
 
 
+    // 切换状态
+    const switchStatus = (status: string): void => {
+        currentStatus.value = status
+        page.value = 1
+        loadData(true)
+    }
+
     // 加载列表数据
     // 加载列表数据
     const loadData = async (isRefresh: boolean | null): Promise<void> => {
     const loadData = async (isRefresh: boolean | null): Promise<void> => {
         if (loading.value) {
         if (loading.value) {
@@ -135,9 +145,9 @@
                 page.value = 1
                 page.value = 1
             }
             }
 
 
-            // 调用 API
+            // 调用 API,传递状态参数
             const searchKeyword = keyword.value.length > 0 ? keyword.value : null
             const searchKeyword = keyword.value.length > 0 ? keyword.value : null
-            const result = await getOrderList(page.value, pageSize, searchKeyword)
+            const result = await getOrderList(page.value, pageSize, searchKeyword, currentStatus.value || null)
 
 
             // 提取响应数据
             // 提取响应数据
             const resultObj = result as UTSJSONObject
             const resultObj = result as UTSJSONObject
@@ -153,8 +163,8 @@
                     const orderItem: orderInfo = {
                     const orderItem: orderInfo = {
 						orderType: item['orderType'] as Number,
 						orderType: item['orderType'] as Number,
                         id: item['id'] as Number,
                         id: item['id'] as Number,
-                        teamLeaderName: item['teamLeaderName'] as string | '',
-                        acceptUserName: item['acceptUserName'] as string | '',
+                        teamLeaderName: item['teamLeaderName'] as string | null,
+                        acceptUserName: item['acceptUserName'] as string | null,
                         acceptTime: item['acceptTime'] as string | null,
                         acceptTime: item['acceptTime'] as string | null,
                         assignTime: item['assignTime'] as string | null,
                         assignTime: item['assignTime'] as string | null,
                         assignUserName: item['assignUserName'] as string | null,
                         assignUserName: item['assignUserName'] as string | null,
@@ -173,6 +183,7 @@
                     newData.push(orderItem)
                     newData.push(orderItem)
                 }
                 }
 
 
+                // 不再在前端过滤,直接使用API返回的数据
                 if (shouldRefresh) {
                 if (shouldRefresh) {
                     dataList.value = newData
                     dataList.value = newData
                 } else {
                 } else {
@@ -239,9 +250,9 @@
     // 点击列表项
     // 点击列表项
     const handleItemClick = (item: any | null, index: number): void => {
     const handleItemClick = (item: any | null, index: number): void => {
         if (item == null) return
         if (item == null) return
-        const contractorItem = item as ContractorInfo
+        const orderItem = item as orderInfo
         uni.navigateTo({
         uni.navigateTo({
-            url: `/pages/workbench/detail/index?id=${contractorItem.id}`
+            url: `/pages/workbench/detail/index?id=${orderItem.id}`
         })
         })
     }
     }
 
 
@@ -300,17 +311,17 @@
 		flex: 1;
 		flex: 1;
 		
 		
 		.status-txt{
 		.status-txt{
-			padding: 8px;
-			width: 70px;
+			padding: 8px 12px;
 			text-align: center;
 			text-align: center;
 			margin-right: 12rpx;
 			margin-right: 12rpx;
 			border-radius: 36rpx;
 			border-radius: 36rpx;
 			background-color: #fff;
 			background-color: #fff;
 			font-size: 28rpx;
 			font-size: 28rpx;
+			cursor: pointer;
 		}
 		}
 		
 		
 		.stauts-sel{
 		.stauts-sel{
-			background-color: blue;
+			background-color: #007AFF;
 			color: #fff;
 			color: #fff;
 		}
 		}
 	}
 	}
@@ -390,4 +401,4 @@
             }
             }
         }
         }
     }
     }
-</style>
+</style>

+ 2 - 2
types/order.uts

@@ -3,8 +3,8 @@
 export type orderInfo = {
 export type orderInfo = {
 	orderType: Number
 	orderType: Number
     id: Number
     id: Number
-    teamLeaderName: string | ''
-    acceptUserName: string | ''
+    teamLeaderName: string | null
+    acceptUserName: string | null
     acceptTime: string | null
     acceptTime: string | null
     assignTime: string | null
     assignTime: string | null
     assignUserName: string | null
     assignUserName: string | null