From 5f2ee03958a1a16dc27195c76ea7cffb422c95d1 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期五, 19 十二月 2025 22:40:34 +0800
Subject: [PATCH] feat: 任务修改接口,删除一些不要的字段同步
---
app/pages/task/index.vue | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 101 insertions(+), 3 deletions(-)
diff --git a/app/pages/task/index.vue b/app/pages/task/index.vue
index 559b246..36fdbb6 100644
--- a/app/pages/task/index.vue
+++ b/app/pages/task/index.vue
@@ -213,6 +213,14 @@
<uni-icons type="info" size="40" color="#ccc"></uni-icons>
<text>鏆傛棤浠诲姟鏁版嵁</text>
</view>
+ <!-- 鍔犺浇鏇村鎻愮ず -->
+ <view class="load-more" v-if="filteredTaskList.length > 0 && hasMore">
+ <uni-icons type="spinner-cycle" size="20" color="#999"></uni-icons>
+ <text>姝e湪鍔犺浇鏇村鏁版嵁...</text>
+ </view>
+ <view class="load-more no-more" v-else-if="filteredTaskList.length > 0 && !hasMore">
+ <text>娌℃湁鏇村鏁版嵁浜�</text>
+ </view>
</view>
</scroll-view>
</view>
@@ -251,7 +259,13 @@
// 浠诲姟鍒楄〃
taskList: [],
loading: false,
- refreshing: false
+ refreshing: false,
+
+ // 鍒嗛〉鐩稿叧
+ currentPage: 1,
+ pageSize: 10,
+ total: 0,
+ hasMore: true
}
},
computed: {
@@ -342,6 +356,12 @@
onPullDownRefresh() {
this.refreshList()
},
+ // 鐩戝惉婊氬姩鍒板簳閮ㄤ簨浠�
+ onReachBottom() {
+ if (this.hasMore && !this.loading) {
+ this.loadMore()
+ }
+ },
methods: {
// 澶勭悊鍒锋柊浜嬩欢
handleRefreshEvent() {
@@ -352,16 +372,27 @@
// 鍔犺浇浠诲姟鍒楄〃
loadTaskList() {
this.loading = true
+ // 閲嶇疆鍒嗛〉鍙傛暟
+ this.currentPage = 1
+ this.hasMore = true
+ this.taskList = []
+
// 鍚庣浼氳嚜鍔ㄨ幏鍙栧綋鍓嶇敤鎴蜂俊鎭紝瀹炵幇缁煎悎鏌ヨ
// 缁煎悎鏌ヨ锛氬綋鍓嶇敤鎴锋墍鍦ㄦ満鏋勪换鍔� + 褰撳墠鐢ㄦ埛鍒涘缓鐨勪换鍔� + 鍒嗛厤缁欏綋鍓嶇敤鎴风殑浠诲姟
const queryParams = {
- pageNum: 1,
- pageSize: 100
+ pageNum: this.currentPage,
+ pageSize: this.pageSize,
+ orderByColumn: 'create_time',
+ isAsc: 'desc'
}
listTask(queryParams).then(response => {
this.loading = false
const data = response.data || response.rows || []
+ // 璁剧疆鎬绘暟鍜屾槸鍚︽湁鏇村鏁版嵁
+ this.total = response.total || data.length || 0
+ this.hasMore = data.length === this.pageSize
+
this.taskList = data.map(task => {
// 浠巃ssignedVehicles鏁扮粍涓幏鍙栬溅杈嗕俊鎭�
let vehicleInfo = '鏈垎閰嶈溅杈�'
@@ -389,6 +420,60 @@
this.loading = false
console.error('鍔犺浇浠诲姟鍒楄〃澶辫触:', error)
this.$modal.showToast('鍔犺浇浠诲姟鍒楄〃澶辫触')
+ })
+ },
+
+ // 鍔犺浇鏇村鏁版嵁
+ loadMore() {
+ if (!this.hasMore || this.loading) return
+
+ this.loading = true
+ this.currentPage++
+
+ const queryParams = {
+ pageNum: this.currentPage,
+ pageSize: this.pageSize,
+ orderByColumn: 'create_time',
+ isAsc: 'desc'
+ }
+
+ listTask(queryParams).then(response => {
+ this.loading = false
+ const data = response.data || response.rows || []
+ // 鏇存柊鏄惁鏈夋洿澶氭暟鎹�
+ this.hasMore = data.length === this.pageSize
+
+ const newTasks = data.map(task => {
+ // 浠巃ssignedVehicles鏁扮粍涓幏鍙栬溅杈嗕俊鎭�
+ let vehicleInfo = '鏈垎閰嶈溅杈�'
+ if (task.assignedVehicles && task.assignedVehicles.length > 0) {
+ // 濡傛灉鏈夊涓溅杈�,鏄剧ず绗竴涓�,骞舵爣娉ㄦ暟閲�
+ const firstVehicle = task.assignedVehicles[0]
+ vehicleInfo = firstVehicle.vehicleNo || '鏈煡杞︾墝'
+ if (task.assignedVehicles.length > 1) {
+ vehicleInfo += ` 绛�${task.assignedVehicles.length}杈哷
+ }
+ }
+
+ return {
+ ...task,
+ // 鏍煎紡鍖栨樉绀哄瓧娈� - 浣跨敤鍚庣杩斿洖鐨刟ssignedVehicles鏁版嵁
+ vehicle: vehicleInfo,
+ vehicleList: task.assignedVehicles || [],
+ startLocation: this.formatAddress(task.departureAddress || task.startLocation || '鏈缃�'),
+ endLocation: this.formatAddress(task.destinationAddress || task.endLocation || '鏈缃�'),
+ startTime: task.plannedStartTime ? formatDateTime(task.plannedStartTime, 'YYYY-MM-DD HH:mm') : '鏈缃�',
+ assignee: task.assigneeName || '鏈垎閰�'
+ }
+ })
+
+ // 灏嗘柊鏁版嵁杩藉姞鍒扮幇鏈夊垪琛ㄤ腑
+ this.taskList = [...this.taskList, ...newTasks]
+ }).catch(error => {
+ this.loading = false
+ this.currentPage-- // 鍑洪敊鏃跺洖閫�椤电爜
+ console.error('鍔犺浇鏇村浠诲姟澶辫触:', error)
+ this.$modal.showToast('鍔犺浇鏇村浠诲姟澶辫触')
})
},
@@ -1080,5 +1165,18 @@
margin-top: 20rpx;
}
}
+
+ .load-more {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ padding: 20rpx 0;
+ color: #999;
+ font-size: 28rpx;
+
+ &.no-more {
+ color: #666;
+ }
+ }
}
</style>
\ No newline at end of file
--
Gitblit v1.9.1