From 0a3eed02e78dfeeb7763a4b62992eefcd1f5a0ca Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期二, 23 十二月 2025 23:33:34 +0800
Subject: [PATCH] feat: 优化状态变更时实时推送
---
app/pages/index.vue | 198 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 163 insertions(+), 35 deletions(-)
diff --git a/app/pages/index.vue b/app/pages/index.vue
index 6579435..46ca76b 100644
--- a/app/pages/index.vue
+++ b/app/pages/index.vue
@@ -101,7 +101,8 @@
<view class="task-header">
<view class="task-title">
{{ getTaskTypeText(task.type) }} - {{ task.vehicle }}
- <text v-if="task.isHeadPush === '1'" class="head-push-tag">鎬�</text>
+ <text v-if="task.emergencyInfo && task.emergencyInfo.serviceOrdVip === '1'" class="vip-tag">VIP</text>
+ <text v-if="task.emergencyInfo && task.emergencyInfo.fromHq2Is === '1'" class="hq-tag">骞挎��</text>
</view>
<view
class="task-status"
@@ -127,9 +128,10 @@
</view>
</view>
- <!-- 浠诲姟缂栧彿鍗曠嫭涓�琛� -->
+ <!-- 浠诲姟缂栧彿鍜屽紑濮嬫椂闂村湪鍚屼竴琛屾樉绀猴紝浣嗗垎寮�涓�浜� -->
<view class="task-code-row">
<text class="task-code">{{ task.showTaskCode }}</text>
+ <text class="task-time">{{ task.startTime }}</text>
</view>
<!-- 浠诲姟璇︾粏淇℃伅 -->
@@ -137,18 +139,18 @@
<view class="info-row">
<view class="info-item">
<view class="label">鍑哄彂鍦�:</view>
- <view class="value">{{ task.startLocation }}</view>
+ <view class="value">{{ getStartLocationDisplay(task) }}</view>
</view>
- <view class="info-item">
- <view class="label">鐩殑鍦�:</view>
- <view class="value">{{ task.endLocation }}</view>
- </view>
+
</view>
<view class="info-row">
<view class="info-item">
- <view class="label">鍑哄彂鏃堕棿:</view>
- <view class="value">{{ task.startTime }}</view>
+ <view class="label">鐩殑鍦�:</view>
+ <view class="value">{{ getEndLocationDisplay(task) }}</view>
</view>
+ </view>
+ <view class="info-row">
+
<view class="info-item">
<view class="label">鎵ц浜哄憳:</view>
<view class="value">{{ task.assignee }}</view>
@@ -241,6 +243,7 @@
import { getUnreadCount } from "@/api/message";
import { formatDateTime } from "@/utils/common";
import subscribeManager from "@/utils/subscribe";
+import { checkTaskCanDepart } from "@/utils/taskValidator";
export default {
data() {
@@ -505,14 +508,12 @@
type: task.taskType,
vehicle: vehicleInfo,
vehicleList: task.assignedVehicles || [],
- startLocation: this.formatAddress(
- task.departureAddress || task.startLocation || "鏈缃�"
- ),
- endLocation: this.formatAddress(
- task.destinationAddress || task.endLocation || "鏈缃�"
- ),
+ startLocation: task.departureAddress || task.startLocation || "鏈缃�",
+ endLocation: task.destinationAddress || task.endLocation || "鏈缃�",
startTime: task.plannedStartTime
- ? formatDateTime(task.plannedStartTime, "YYYY-MM-DD HH:mm")
+ ? (task.plannedStartTime.startsWith('1900') || task.plannedStartTime.startsWith('1970')
+ ? '鏈垎閰嶆椂闂�'
+ : formatDateTime(task.plannedStartTime, "YYYY-MM-DD HH:mm"))
: "鏈缃�",
assignee: task.assigneeName || "鏈垎閰�",
taskNo: task.taskCode || "鏈煡缂栧彿",
@@ -555,6 +556,33 @@
return address;
},
+ // 鑾峰彇鍑哄彂鍦版樉绀哄唴瀹癸紙杞繍浠诲姟鏄剧ず杞嚭鍖婚櫌鍚嶇О锛�
+ getStartLocationDisplay(task) {
+ // 濡傛灉鏄浆杩愪换鍔′笖鏈塭mergencyInfo淇℃伅
+ if (task.taskType === 'EMERGENCY_TRANSFER' && task.emergencyInfo && task.emergencyInfo.hospitalOutName) {
+ return task.emergencyInfo.hospitalOutName;
+ }
+ // 鍏朵粬鎯呭喌浣跨敤鍘熸潵鐨剆tartLocation
+ return this.formatAddress(task.startLocation || "鏈缃�");
+ },
+
+ // 鑾峰彇鐩殑鍦版樉绀哄唴瀹癸紙杞繍浠诲姟鏄剧ず杞叆鍖婚櫌鍚嶇О鎴栬缁嗗湴鍧�锛�
+ getEndLocationDisplay(task) {
+ // 濡傛灉鏄浆杩愪换鍔′笖鏈塭mergencyInfo淇℃伅
+ if (task.taskType === 'EMERGENCY_TRANSFER' && task.emergencyInfo) {
+ // 浼樺厛鏄剧ず杞叆鍖婚櫌鍚嶇О
+ if (task.emergencyInfo.hospitalInName) {
+ if(task.emergencyInfo.hospitalInName.includes("瀹朵腑")){
+ return task.emergencyInfo.destinationAddress;
+ }
+ return task.emergencyInfo.hospitalInName;
+ }
+
+ }
+ // 鍏朵粬鎯呭喌浣跨敤鍘熸潵鐨別ndLocation
+ return this.formatAddress(task.endLocation || "鏈缃�");
+ },
+
// 杞崲鐘舵�佹牸寮忥紙灏嗘暟鎹簱鐘舵�佽浆鎹负UI浣跨敤鐨勭姸鎬侊級
convertStatus(dbStatus) {
const statusMap = {
@@ -586,16 +614,96 @@
},
// 澶勭悊浠诲姟鎿嶄綔
- 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":
@@ -824,17 +932,6 @@
* {
-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;
}
// 鐢ㄦ埛淇℃伅鍖哄煙
@@ -1115,13 +1212,22 @@
}
}
- // 浠诲姟缂栧彿鍗曠嫭涓�琛�
+ // 浠诲姟缂栧彿鍜屾椂闂村湪鍚屼竴琛屾樉绀�
.task-code-row {
margin-bottom: 15rpx;
padding: 10rpx 0;
border-bottom: 1rpx dashed #e0e0e0;
+ display: flex;
+ justify-content: space-between;
.task-code {
+ font-size: 28rpx;
+ color: #333;
+ font-weight: 500;
+ font-family: monospace;
+ }
+
+ .task-time {
font-size: 28rpx;
color: #333;
font-weight: 500;
@@ -1220,6 +1326,28 @@
color: #666;
}
}
+
+ .vip-tag {
+ display: inline-block;
+ padding: 2rpx 8rpx;
+ font-size: 20rpx;
+ color: #fff;
+ background-color: #ff0000;
+ border-radius: 4rpx;
+ margin-left: 10rpx;
+ vertical-align: middle;
+ }
+
+ .hq-tag {
+ display: inline-block;
+ padding: 2rpx 8rpx;
+ font-size: 20rpx;
+ color: #fff;
+ background-color: #5856d6;
+ border-radius: 4rpx;
+ margin-left: 10rpx;
+ vertical-align: middle;
+ }
}
}
</style>
\ No newline at end of file
--
Gitblit v1.9.1