From b30c1ebb0e46e734e70f8731484764f449f48818 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期三, 24 十二月 2025 00:04:30 +0800
Subject: [PATCH] feat:已完成时,增加知情同意书的上传判断
---
app/pages/index.vue | 146 +++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 131 insertions(+), 15 deletions(-)
diff --git a/app/pages/index.vue b/app/pages/index.vue
index d86d564..7f37adb 100644
--- a/app/pages/index.vue
+++ b/app/pages/index.vue
@@ -237,12 +237,13 @@
<script>
import { mapState } from "vuex";
-import { getMyTasks, changeTaskStatus } from "@/api/task";
+import { getMyTasks, changeTaskStatus, checkTaskConsentAttachment } from "@/api/task";
import { getUserProfile } from "@/api/system/user";
import { getUserBoundVehicle } from "@/api/vehicle";
import { getUnreadCount } from "@/api/message";
import { formatDateTime } from "@/utils/common";
import subscribeManager from "@/utils/subscribe";
+import { checkTaskCanDepart } from "@/utils/taskValidator";
export default {
data() {
@@ -510,7 +511,9 @@
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 || "鏈煡缂栧彿",
@@ -611,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":
@@ -665,12 +748,8 @@
case "complete":
// 宸插畬鎴� -> 鐘舵�佸彉涓哄凡瀹屾垚
- this.$modal
- .confirm("纭浠诲姟宸插畬鎴愶紵")
- .then(() => {
- this.updateTaskStatus(task.taskId, "COMPLETED", "浠诲姟宸插畬鎴�");
- })
- .catch(() => {});
+ // 闇�瑕佹鏌ユ槸鍚︿笂浼犱簡鐭ユ儏鍚屾剰涔�
+ this.checkConsentAttachmentAndThen(task.taskId, "COMPLETED", "浠诲姟宸插畬鎴�");
break;
}
},
@@ -680,6 +759,43 @@
// 鑾峰彇GPS浣嶇疆淇℃伅
this.getLocationAndUpdateStatus(taskId, status, remark);
},
+
+ // 妫�鏌ョ煡鎯呭悓鎰忎功闄勪欢骞舵洿鏂扮姸鎬�
+ async checkConsentAttachmentAndThen(taskId, status, remark) {
+ try {
+ uni.showLoading({
+ title: '妫�鏌ラ檮浠�...'
+ });
+
+ const response = await checkTaskConsentAttachment(taskId);
+
+ uni.hideLoading();
+
+ if (response.code === 200) {
+ // 宸蹭笂浼犵煡鎯呭悓鎰忎功锛岀户缁洿鏂扮姸鎬�
+ this.$modal
+ .confirm("纭浠诲姟宸插畬鎴愶紵")
+ .then(() => {
+ this.updateTaskStatus(taskId, status, remark);
+ })
+ .catch(() => {});
+ } else {
+ // 鏈笂浼犵煡鎯呭悓鎰忎功锛屾樉绀烘彁绀�
+ this.$modal.confirm('浠诲姟鏈笂浼犵煡鎯呭悓鎰忎功锛屾棤娉曞畬鎴愪换鍔°�傛槸鍚︾幇鍦ㄥ幓涓婁紶锛�').then(() => {
+ // 璺宠浆鍒颁换鍔¤鎯呴〉涓婁紶闄勪欢
+ this.$tab.navigateTo(`/pagesTask/detail?id=${taskId}`);
+ }).catch(() => {});
+ }
+ } catch (error) {
+ uni.hideLoading();
+ console.error('妫�鏌ラ檮浠跺け璐�:', error);
+
+ // 濡傛灉妫�鏌ュけ璐ワ紝璇㈤棶鐢ㄦ埛鏄惁缁х画
+ this.$modal.confirm('妫�鏌ラ檮浠剁姸鎬佸け璐ワ紝鏄惁缁х画瀹屾垚浠诲姟锛�').then(() => {
+ this.updateTaskStatus(taskId, status, remark);
+ }).catch(() => {});
+ }
+ },
// 鑾峰彇浣嶇疆淇℃伅骞舵洿鏂扮姸鎬�
getLocationAndUpdateStatus(taskId, status, remark) {
--
Gitblit v1.9.1