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 | 209 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 198 insertions(+), 11 deletions(-)
diff --git a/app/pages/task/index.vue b/app/pages/task/index.vue
index 0358e7f..36fdbb6 100644
--- a/app/pages/task/index.vue
+++ b/app/pages/task/index.vue
@@ -112,7 +112,10 @@
<view class="task-main" @click="viewTaskDetail(task)">
<!-- 浠诲姟澶撮儴锛氭爣棰樺拰鐘舵�佹爣绛� -->
<view class="task-header">
- <view class="task-title">{{ getTaskTypeText(task.taskType) }} - {{ task.vehicle }}</view>
+ <view class="task-title">
+ {{ getTaskTypeText(task.taskType) }} - {{ task.vehicle }}
+ <text v-if="task.isHeadPush === '1'" class="head-push-tag">鎬�</text>
+ </view>
<view class="task-status" :class="task.taskStatus === 'PENDING' ? 'status-pending' : task.taskStatus === 'DEPARTING' ? 'status-departing' : task.taskStatus === 'ARRIVED' ? 'status-arrived' : task.taskStatus === 'RETURNING' ? 'status-returning' : task.taskStatus === 'COMPLETED' ? 'status-completed' : task.taskStatus === 'CANCELLED' ? 'status-cancelled' : task.taskStatus === 'IN_PROGRESS' ? 'status-in-progress' : 'status-default'">
{{ getStatusText(task.taskStatus) }}
</view>
@@ -120,7 +123,7 @@
<!-- 浠诲姟缂栧彿鍗曠嫭涓�琛� -->
<view class="task-code-row">
- <text class="task-code">{{ task.taskCode }}</text>
+ <text class="task-code">{{ task.showTaskCode }}</text>
</view>
<!-- 浠诲姟璇︾粏淇℃伅 -->
@@ -210,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>
@@ -221,6 +232,7 @@
import { listTask, changeTaskStatus } from '@/api/task'
import { mapState } from 'vuex'
import { formatDateTime } from '@/utils/common'
+ import { checkTaskCanDepart } from '@/utils/taskValidator'
export default {
components: {
@@ -247,7 +259,13 @@
// 浠诲姟鍒楄〃
taskList: [],
loading: false,
- refreshing: false
+ refreshing: false,
+
+ // 鍒嗛〉鐩稿叧
+ currentPage: 1,
+ pageSize: 10,
+ total: 0,
+ hasMore: true
}
},
computed: {
@@ -296,7 +314,7 @@
// 搴旂敤浠诲姟缂栧彿绛涢�� - 浣跨敤taskCode鑰屼笉鏄痶askNo
if (this.searchForm.taskNo) {
filtered = filtered.filter(task =>
- task.taskCode && task.taskCode.includes(this.searchForm.taskNo)
+ task.showTaskCode && task.showTaskCode.includes(this.searchForm.taskNo)
);
}
@@ -338,6 +356,12 @@
onPullDownRefresh() {
this.refreshList()
},
+ // 鐩戝惉婊氬姩鍒板簳閮ㄤ簨浠�
+ onReachBottom() {
+ if (this.hasMore && !this.loading) {
+ this.loadMore()
+ }
+ },
methods: {
// 澶勭悊鍒锋柊浜嬩欢
handleRefreshEvent() {
@@ -348,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 = '鏈垎閰嶈溅杈�'
@@ -385,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('鍔犺浇鏇村浠诲姟澶辫触')
})
},
@@ -456,18 +545,92 @@
// 璺宠浆鍒颁换鍔¤鎯呴〉闈� - 浣跨敤uni.navigateTo
uni.navigateTo({
- url: `/pages/task/detail?id=${task.taskId}`
+ url: `/pagesTask/detail?id=${task.taskId}`
});
},
// 澶勭悊浠诲姟鎿嶄綔
- handleTaskAction(task, action) {
+ async handleTaskAction(task, action) {
switch (action) {
case 'depart':
// 鍑哄彂 -> 鐘舵�佸彉涓哄嚭鍙戜腑
- this.$modal.confirm('纭畾瑕佸嚭鍙戝悧锛�').then(() => {
- this.updateTaskStatus(task.taskId, 'DEPARTING', '浠诲姟宸插嚭鍙�')
- }).catch(() => {});
+ // 鏄剧ず鍔犺浇鎻愮ず
+ uni.showLoading({
+ title: '妫�鏌ヤ换鍔$姸鎬�...'
+ });
+
+ try {
+ // 璋冪敤宸ュ叿绫绘鏌ヤ换鍔℃槸鍚﹀彲浠ュ嚭鍙戯紙鍖呭惈鍩烘湰鏍¢獙鍜屽啿绐佹鏌ワ級
+ const checkResult = await checkTaskCanDepart(task)
+
+ uni.hideLoading();
+
+ console.log('鍑哄彂妫�鏌ョ粨鏋�:', checkResult);
+ console.log('valid:', checkResult.valid);
+ console.log('conflicts:', checkResult.conflicts);
+
+ if (!checkResult.valid) {
+ // 鏍¢獙澶辫触锛屾樉绀烘彁绀轰俊鎭苟鎻愪緵璺宠浆閫夐」
+ const conflicts = checkResult.conflicts || [];
+ const conflictInfo = conflicts.length > 0 ? conflicts[0] : null;
+
+ console.log('鍐茬獊淇℃伅:', conflictInfo);
+
+ // 濡傛灉鏈夊啿绐佷换鍔′俊鎭紝鎻愪緵璺宠浆鎸夐挳
+ if (conflictInfo && conflictInfo.taskId) {
+ console.log('鏄剧ず甯﹁烦杞寜閽殑寮圭獥锛屼换鍔D:', conflictInfo.taskId);
+
+ const conflictTaskId = conflictInfo.taskId;
+ const message = checkResult.message || conflictInfo.message || '瀛樺湪鍐茬獊浠诲姟';
+
+ uni.showModal({
+ title: '鎻愮ず',
+ content: message,
+ confirmText: '鍘诲鐞�',
+ cancelText: '鐭ラ亾浜�',
+ success: function(res) {
+ console.log('寮圭獥鐐瑰嚮缁撴灉:', res);
+ if (res.confirm) {
+ // 鐢ㄦ埛鐐瑰嚮"鐜板湪鍘诲鐞�"锛岃烦杞埌鍐茬獊浠诲姟璇︽儏椤�
+ console.log('鍑嗗璺宠浆鍒颁换鍔¤鎯呴〉:', conflictTaskId);
+ uni.navigateTo({
+ url: `/pagesTask/detail?id=${conflictTaskId}`
+ });
+ }
+ },
+ fail: function(err) {
+ console.error('鏄剧ず寮圭獥澶辫触:', err);
+ }
+ });
+ } else {
+ // 娌℃湁鍐茬獊浠诲姟ID锛屽彧鏄剧ず鎻愮ず
+ console.log('鏄剧ず鏅�氭彁绀哄脊绐�');
+ uni.showModal({
+ title: '鎻愮ず',
+ content: checkResult.message || '浠诲姟鏍¢獙澶辫触',
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�',
+ fail: function(err) {
+ console.error('鏄剧ず寮圭獥澶辫触:', err);
+ }
+ });
+ }
+ return;
+ }
+
+ // 鎵�鏈夋鏌ラ�氳繃锛屽彲浠ュ嚭鍙�
+ this.$modal.confirm('纭畾瑕佸嚭鍙戝悧锛�').then(() => {
+ this.updateTaskStatus(task.taskId, 'DEPARTING', '浠诲姟宸插嚭鍙�')
+ }).catch(() => {});
+
+ } catch (error) {
+ uni.hideLoading();
+ console.error('妫�鏌ヤ换鍔$姸鎬佸け璐�:', error);
+ // 妫�鏌ュけ璐ユ椂锛屼粛鐒跺厑璁稿嚭鍙�
+ this.$modal.confirm('妫�鏌ヤ换鍔$姸鎬佸け璐ワ紝鏄惁缁х画鍑哄彂锛�').then(() => {
+ this.updateTaskStatus(task.taskId, 'DEPARTING', '浠诲姟宸插嚭鍙�')
+ }).catch(() => {});
+ }
break;
case 'cancel':
@@ -636,6 +799,17 @@
* {
-ms-overflow-style: none; /* IE 10+ */
}
+ }
+
+ // 鎬婚儴鎺ㄩ�佹爣璁版牱寮�
+ .head-push-tag {
+ color: #ff0000;
+ font-size: 24rpx;
+ font-weight: bold;
+ margin-left: 10rpx;
+ padding: 2rpx 8rpx;
+ border: 1rpx solid #ff0000;
+ border-radius: 4rpx;
}
// 浠诲姟鍒楄〃鍖哄煙
@@ -991,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