From 5ceca957811a0da3741cf4957e6f1fcfca807be6 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期五, 26 十二月 2025 23:42:00 +0800
Subject: [PATCH] feat:增加显示强制完成按钮控制
---
app/pagesTask/detail.vue | 655 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 589 insertions(+), 66 deletions(-)
diff --git a/app/pagesTask/detail.vue b/app/pagesTask/detail.vue
index 6e0fdee..9077526 100644
--- a/app/pagesTask/detail.vue
+++ b/app/pagesTask/detail.vue
@@ -5,6 +5,9 @@
<uni-icons type="arrowleft" size="20"></uni-icons>
</view>
<view class="title">浠诲姟璇︽儏</view>
+ <view class="edit-btn" @click="handleEdit" v-if="taskDetail && !isTaskFinished">
+ <uni-icons type="compose" size="20" color="#007AFF"></uni-icons>
+ </view>
</view>
<scroll-view class="detail-content" scroll-y="true" v-if="taskDetail">
@@ -64,6 +67,17 @@
{{ isAssigneeReady(assignee) ? '宸插氨缁�' : '鏈氨缁�' }}
</view>
</view>
+ </view>
+ <!-- 褰撳墠鐧诲綍浜烘槸璇ユ墽琛屼汉涓旀湭灏辩华鏃舵樉绀哄氨缁寜閽� -->
+ <view
+ v-if="showAssigneeReadyFeature() && isAssigneeSelf(assignee) && !isAssigneeReady(assignee) && taskDetail.taskStatus === 'PENDING'"
+ class="assignee-ready-btn"
+ :data-user-id="assignee.userId || assignee.oaUserId"
+ :data-user-name="assignee.userName"
+ :data-index="index"
+ @click="handleReadyClick"
+ >
+ 鐐瑰嚮灏辩华
</view>
</view>
</view>
@@ -249,6 +263,23 @@
</view>
</view>
+ <!-- 鍙栨秷淇℃伅锛堜粎鍦ㄤ换鍔″凡鍙栨秷涓旀湁鍙栨秷鍘熷洜鏃舵樉绀猴級 -->
+ <view class="detail-section" v-if="taskDetail.taskStatus === 'CANCELLED' && taskDetail.emergencyInfo && taskDetail.emergencyInfo.cancelReason">
+ <view class="section-title">鍙栨秷淇℃伅</view>
+ <view class="info-item">
+ <view class="label">鍙栨秷鍘熷洜</view>
+ <view class="value">{{ getCancelReasonLabel(taskDetail.emergencyInfo.cancelReason) }}</view>
+ </view>
+ <view class="info-item" v-if="taskDetail.emergencyInfo.cancelBy">
+ <view class="label">鍙栨秷浜�</view>
+ <view class="value">{{ taskDetail.emergencyInfo.cancelBy }}</view>
+ </view>
+ <view class="info-item" v-if="taskDetail.emergencyInfo.cancelTime">
+ <view class="label">鍙栨秷鏃堕棿</view>
+ <view class="value">{{ formatTime(taskDetail.emergencyInfo.cancelTime) }}</view>
+ </view>
+ </view>
+
<!-- 鏀粯璁板綍鏄庣粏 -->
<view class="detail-section" v-if="paymentInfo && paymentInfo.paidPayments && paymentInfo.paidPayments.length > 0">
<view class="section-title">鏀粯璁板綍</view>
@@ -356,24 +387,76 @@
<text>鍔犺浇涓�...</text>
</view>
+ <!-- 寮哄埗瀹屾垚瀵硅瘽妗� -->
+ <uni-popup ref="forceCompletePopup" type="center" :is-mask-click="false">
+ <view class="force-complete-dialog">
+ <view class="dialog-title">璇疯緭鍏ユ椂闂�</view>
+ <view class="time-picker-item">
+ <view class="time-label">杞繍寮�濮嬫椂闂�</view>
+ <picker
+ mode="date"
+ :value="getDateFromDateTime(forceCompleteForm.actualStartTime)"
+ @change="selectStartDate"
+ >
+ <view class="picker-value">{{ getDateFromDateTime(forceCompleteForm.actualStartTime) || '璇烽�夋嫨鏃ユ湡' }}</view>
+ </picker>
+ <picker
+ mode="time"
+ :value="getTimeFromDateTime(forceCompleteForm.actualStartTime)"
+ @change="selectStartTime"
+ >
+ <view class="picker-value">{{ getTimeFromDateTime(forceCompleteForm.actualStartTime) || '璇烽�夋嫨鏃堕棿' }}</view>
+ </picker>
+ </view>
+ <view class="time-picker-item">
+ <view class="time-label">杞繍缁撴潫鏃堕棿</view>
+ <picker
+ mode="date"
+ :value="getDateFromDateTime(forceCompleteForm.actualEndTime)"
+ @change="selectEndDate"
+ >
+ <view class="picker-value">{{ getDateFromDateTime(forceCompleteForm.actualEndTime) || '璇烽�夋嫨鏃ユ湡' }}</view>
+ </picker>
+ <picker
+ mode="time"
+ :value="getTimeFromDateTime(forceCompleteForm.actualEndTime)"
+ @change="selectEndTime"
+ >
+ <view class="picker-value">{{ getTimeFromDateTime(forceCompleteForm.actualEndTime) || '璇烽�夋嫨鏃堕棿' }}</view>
+ </picker>
+ </view>
+ <view class="dialog-buttons">
+ <button class="cancel-btn" @click="closeForceCompleteDialog">鍙栨秷</button>
+ <button class="confirm-btn" @click="confirmForceComplete">纭畾</button>
+ </view>
+ </view>
+ </uni-popup>
+
+ <!-- 鍙栨秷鍘熷洜閫夋嫨瀵硅瘽妗� -->
+ <uni-popup ref="cancelPopup" type="center" :is-mask-click="false">
+ <view class="cancel-dialog">
+ <view class="dialog-title">璇烽�夋嫨鍙栨秷鍘熷洜</view>
+ <picker mode="selector" :range="cancelReasonList" range-key="label" @change="selectCancelReason">
+ <view class="reason-picker">
+ <view class="picker-label">鍙栨秷鍘熷洜</view>
+ <view class="picker-value">
+ {{ selectedCancelReasonLabel }}
+ </view>
+ <uni-icons type="arrowright" size="16"></uni-icons>
+ </view>
+ </picker>
+ <view class="dialog-buttons">
+ <button class="cancel-btn" @click="closeCancelDialog">鍙栨秷</button>
+ <button class="confirm-btn" @click="confirmCancelTask">纭畾</button>
+ </view>
+ </view>
+ </uni-popup>
+
<!-- 鎿嶄綔鎸夐挳鍖哄煙 -->
<view class="action-buttons" v-if="taskDetail">
- <!-- 寰呭鐞嗙姸鎬�: 鏄剧ず缂栬緫銆佸嚭鍙戙�佸彇娑� -->
+ <!-- 寰呭鐞嗙姸鎬�: 鏄剧ず鍑哄彂銆佸彇娑堛�佸己鍒跺畬鎴� -->
<template v-if="taskDetail.taskStatus === 'PENDING'">
- <button
- class="action-btn edit"
- @click="handleEdit"
- >
- 淇敼
- </button>
<template v-if="isCurrentUserAssignee()">
- <button
- v-if="showAssigneeReadyFeature() && isMultipleAssignees() && !isCurrentUserReady()"
- class="action-btn primary"
- @click="handleReadyAction()"
- >
- 灏辩华
- </button>
<button
class="action-btn primary"
@click="handleDepartAction()"
@@ -386,17 +469,18 @@
>
鍙栨秷
</button>
+ <button
+ v-if="showForceCompleteFeature() && taskDetail.taskStatus === 'PENDING'"
+ class="action-btn force-complete"
+ @click="showForceCompleteTimeDialog()"
+ >
+ 寮哄埗瀹屾垚
+ </button>
</template>
</template>
- <!-- 鍑哄彂涓姸鎬�: 鏄剧ず缂栬緫銆佸凡鍒拌揪銆佸己鍒剁粨鏉� -->
+ <!-- 鍑哄彂涓姸鎬�: 鏄剧ず宸插埌杈俱�佸己鍒剁粨鏉� -->
<template v-else-if="taskDetail.taskStatus === 'DEPARTING'">
- <button
- class="action-btn edit"
- @click="handleEdit"
- >
- 淇敼
- </button>
<template v-if="isCurrentUserAssignee()">
<button
class="action-btn primary"
@@ -413,14 +497,8 @@
</template>
</template>
- <!-- 宸插埌杈剧姸鎬�: 鏄剧ず缂栬緫銆佸凡杩旂▼ -->
+ <!-- 宸插埌杈剧姸鎬�: 鏄剧ず宸茶繑绋� -->
<template v-else-if="taskDetail.taskStatus === 'ARRIVED'">
- <button
- class="action-btn edit"
- @click="handleEdit"
- >
- 淇敼
- </button>
<template v-if="isCurrentUserAssignee()">
<button
class="action-btn primary"
@@ -431,14 +509,8 @@
</template>
</template>
- <!-- 杩旂▼涓姸鎬�: 鏄剧ず缂栬緫銆佸凡瀹屾垚 -->
+ <!-- 杩旂▼涓姸鎬�: 鏄剧ず宸插畬鎴� -->
<template v-else-if="taskDetail.taskStatus === 'RETURNING'">
- <button
- class="action-btn edit"
- @click="handleEdit"
- >
- 淇敼
- </button>
<template v-if="isCurrentUserAssignee()">
<button
class="action-btn primary"
@@ -467,6 +539,7 @@
import { getTask, changeTaskStatus, setAssigneeReady, checkTaskConsentAttachment } from '@/api/task'
import { checkVehicleActiveTasks } from '@/api/task'
import { getPaymentInfo } from '@/api/payment'
+ import { getDicts } from '@/api/dict'
import { formatDateTime } from '@/utils/common'
import { validateTaskForDepart, validateTaskForSettlement, getTaskVehicleId, checkTaskCanDepart } from '@/utils/taskValidator'
import AttachmentUpload from './components/AttachmentUpload.vue'
@@ -480,7 +553,15 @@
return {
taskDetail: null,
taskId: null,
- paymentInfo: null // 鏀粯淇℃伅
+ paymentInfo: null, // 鏀粯淇℃伅
+ cancelReasonList: [], // 鍙栨秷鍘熷洜鍒楄〃
+ showCancelDialog: false, // 鏄剧ず鍙栨秷鍘熷洜瀵硅瘽妗�
+ selectedCancelReason: '', // 閫変腑鐨勫彇娑堝師鍥�
+ showForceCompleteDialog: false, // 鏄剧ず寮哄埗瀹屾垚瀵硅瘽妗�
+ forceCompleteForm: {
+ actualStartTime: '',
+ actualEndTime: ''
+ }
}
},
computed: {
@@ -503,7 +584,17 @@
}
return [baseClass, roleClasses[userType] || '']
}
- }, // 鏄剧ず浠诲姟绫诲瀷
+ },
+
+ // 鑾峰彇閫変腑鐨勫彇娑堝師鍥犳爣绛撅紙鐢ㄤ簬寮圭獥鏄剧ず锛�
+ selectedCancelReasonLabel() {
+ if (!this.selectedCancelReason || !this.cancelReasonList.length) {
+ return '璇烽�夋嫨'
+ }
+ const reason = this.cancelReasonList.find(r => r.value === this.selectedCancelReason)
+ return reason ? reason.label : '璇烽�夋嫨'
+ },
+ // 鏄剧ず浠诲姟绫诲瀷
displayTaskType() {
if (!this.taskDetail || !this.taskDetail.taskType) {
return '鏈缃�'
@@ -581,6 +672,7 @@
onLoad(options) {
this.taskId = options.id
this.loadTaskDetail()
+ this.loadCancelReasonDict() // 鍔犺浇鍙栨秷鍘熷洜瀛楀吀
},
onShow() {
// 姣忔椤甸潰鏄剧ず鏃堕噸鏂板姞杞芥暟鎹紝纭繚浠庣紪杈戦〉闈㈣繑鍥炲悗鑳界湅鍒版渶鏂版暟鎹�
@@ -810,10 +902,8 @@
break;
case 'cancel':
- // 鍙栨秷 -> 浜屾纭鍚庣姸鎬佸彉涓哄凡鍙栨秷
- this.$modal.confirm('纭畾瑕佸彇娑堟浠诲姟鍚楋紵').then(() => {
- this.updateTaskStatus('CANCELLED', '浠诲姟宸插彇娑�')
- }).catch(() => {});
+ // 鍙栨秷 -> 鏄剧ず鍙栨秷鍘熷洜閫夋嫨瀵硅瘽妗�
+ this.showCancelReasonDialog();
break;
case 'arrive':
@@ -964,16 +1054,27 @@
title: '妫�鏌ラ檮浠�...'
});
- const response = await checkTaskConsentAttachment(this.taskId);
+ // 娉ㄦ剰锛氳繖閲屼細琚姹傛嫤鎴櫒澶勭悊锛宑ode !== 200 鏃朵細 reject
+ const response = await checkTaskConsentAttachment(this.taskId).catch(err => {
+ // 鎷︽埅鍣� reject 鐨勬儏鍐碉紝杩斿洖涓�涓粯璁ゅ璞�
+ console.log('璇锋眰琚嫤鎴櫒 reject锛宔rr:', err);
+ return { code: -1, msg: '鏈笂浼犵煡鎯呭悓鎰忎功' };
+ });
uni.hideLoading();
+ console.log('妫�鏌ラ檮浠剁粨鏋�:', response);
- if (response.code === 200) {
+ // 鍚庡彴杩斿洖 code: 200 琛ㄧず宸蹭笂浼狅紝code: -1 琛ㄧず鏈笂浼�
+ if (response && response.code === 200) {
// 宸蹭笂浼犵煡鎯呭悓鎰忎功锛岀户缁洿鏂扮姸鎬�
+ console.log('宸蹭笂浼犵煡鎯呭悓鎰忎功锛岀户缁畬鎴愪换鍔�');
this.getLocationAndUpdateStatus(status, remark);
} else {
- // 鏈笂浼犵煡鎯呭悓鎰忎功锛屾樉绀烘彁绀�
- this.$modal.confirm('浠诲姟鏈笂浼犵煡鎯呭悓鎰忎功锛屾棤娉曞畬鎴愪换鍔°�傛槸鍚︾幇鍦ㄥ幓涓婁紶锛�').then(() => {
+ // 鏈笂浼犵煡鎯呭悓鎰忎功鎴栧叾浠栭敊璇紝闃绘瀹屾垚
+ const message = (response && response.msg) || '浠诲姟鏈笂浼犵煡鎯呭悓鎰忎功锛屾棤娉曞畬鎴愪换鍔�';
+ console.log('鏈笂浼犵煡鎯呭悓鎰忎功锛岄樆姝㈠畬鎴�');
+
+ this.$modal.confirm(message + '銆傛槸鍚︾幇鍦ㄥ幓涓婁紶锛�').then(() => {
// 婊氬姩鍒伴檮浠朵笂浼犲尯鍩�
this.$nextTick(() => {
uni.pageScrollTo({
@@ -985,17 +1086,15 @@
}
} catch (error) {
uni.hideLoading();
- console.error('妫�鏌ラ檮浠跺け璐�:', error);
+ console.error('妫�鏌ラ檮浠跺紓甯�:', error);
- // 濡傛灉妫�鏌ュけ璐ワ紝璇㈤棶鐢ㄦ埛鏄惁缁х画
- this.$modal.confirm('妫�鏌ラ檮浠剁姸鎬佸け璐ワ紝鏄惁缁х画瀹屾垚浠诲姟锛�').then(() => {
- this.getLocationAndUpdateStatus(status, remark);
- }).catch(() => {});
+ // 濡傛灉妫�鏌ュけ璐ワ紙缃戠粶寮傚父绛夛級锛屼笉鍏佽瀹屾垚浠诲姟
+ this.$modal.showToast('妫�鏌ラ檮浠剁姸鎬佸け璐ワ紝鏃犳硶瀹屾垚浠诲姟');
}
},
// 鑾峰彇浣嶇疆淇℃伅骞舵洿鏂扮姸鎬�
- getLocationAndUpdateStatus(status, remark) {
+ getLocationAndUpdateStatus(status, remark, cancelReason) {
const that = this
// 浣跨敤uni.getLocation鑾峰彇GPS浣嶇疆
@@ -1022,6 +1121,11 @@
heading: res.direction || res.heading
}
+ // 濡傛灉鏈夊彇娑堝師鍥狅紝娣诲姞鍒拌姹傛暟鎹腑
+ if (cancelReason) {
+ statusData.cancelReason = cancelReason
+ }
+
changeTaskStatus(that.taskId, statusData).then(response => {
that.$modal.showToast('鐘舵�佹洿鏂版垚鍔�')
// 閲嶆柊鍔犺浇浠诲姟璇︽儏
@@ -1039,6 +1143,11 @@
const statusData = {
taskStatus: status,
remark: remark
+ }
+
+ // 濡傛灉鏈夊彇娑堝師鍥狅紝娣诲姞鍒拌姹傛暟鎹腑
+ if (cancelReason) {
+ statusData.cancelReason = cancelReason
}
changeTaskStatus(that.taskId, statusData).then(response => {
@@ -1313,9 +1422,14 @@
console.log('闄勪欢鍒犻櫎鎴愬姛:', attachmentId)
},
- // 鏄惁鏄剧ず鈥滃氨缁�濆姛鑳斤紙閰嶇疆寮�鍏筹級
+ // 鏄惁鏄剧ず"灏辩华"鍔熻兘锛堥厤缃紑鍏筹級
showAssigneeReadyFeature() {
return !!(config && config.features && config.features.showAssigneeReadyButton)
+ },
+
+ // 鏄惁鏄剧ず"寮哄埗瀹屾垚"鍔熻兘锛堥厤缃紑鍏筹級
+ showForceCompleteFeature() {
+ return !!(config && config.features && config.features.showForceCompleteButton)
},
// 褰撳墠鐢ㄦ埛鏄惁涓鸿鎵ц浜�
@@ -1323,18 +1437,53 @@
const userId = this.$store && this.$store.state && this.$store.state.user && this.$store.state.user.userId
return assignee && (assignee.userId === userId || assignee.oaUserId === userId)
},
-
- // 鎵ц浜虹偣鍑烩�滃氨缁��
- markAssigneeReady(assignee) {
- if (!assignee || !this.taskDetail) {
- this.$modal.showToast('鎵ц浜烘垨浠诲姟淇℃伅涓嶅瓨鍦�')
+
+ // 澶勭悊灏辩华鎸夐挳鐐瑰嚮锛堥�氳繃data灞炴�ц幏鍙栨墽琛屼汉淇℃伅锛�
+ handleReadyClick(e) {
+ const dataset = e.currentTarget.dataset
+ const index = dataset.index
+ console.log('handleReadyClick - dataset:', dataset)
+ console.log('handleReadyClick - index:', index)
+
+ if (index === undefined || index === null) {
+ this.$modal.showToast('鏃犳硶鑾峰彇鎵ц浜虹储寮�')
return
}
+
+ const assignee = this.taskDetail.assignees[index]
+ console.log('handleReadyClick - assignee:', assignee)
+
+ if (!assignee) {
+ this.$modal.showToast('鎵ц浜轰俊鎭笉瀛樺湪')
+ return
+ }
+
+ this.markAssigneeReady(assignee)
+ },
+
+ // 鎵ц浜虹偣鍑�"灏辩华"
+ markAssigneeReady(assignee) {
+ console.log('markAssigneeReady 琚皟鐢紝鍙傛暟:', assignee)
+ console.log('taskDetail:', this.taskDetail)
+
+ if (!this.taskDetail) {
+ this.$modal.showToast('浠诲姟淇℃伅涓嶅瓨鍦�')
+ return
+ }
+
+ if (!assignee) {
+ this.$modal.showToast('鎵ц浜轰俊鎭笉瀛樺湪')
+ return
+ }
+
const userId = assignee.userId || assignee.oaUserId
+ console.log('鎵ц浜篒D:', userId)
+
if (!userId) {
this.$modal.showToast('鏃犳硶璇嗗埆鎵ц浜篒D')
return
}
+
this.$modal.showLoading && this.$modal.showLoading('鎻愪氦涓�...')
setAssigneeReady(this.taskId).then(() => {
this.$modal.hideLoading && this.$modal.hideLoading()
@@ -1470,6 +1619,229 @@
return 'payment-' + (key !== null && key !== undefined ? key : index);
},
+ // 鍔犺浇鍙栨秷鍘熷洜瀛楀吀
+ loadCancelReasonDict() {
+ // 浠庡悗绔幏鍙栧彇娑堝師鍥犲瓧鍏�
+ getDicts('task_cancel_reason').then(response => {
+ if (response.code === 200 && response.data) {
+ this.cancelReasonList = response.data.map(item => ({
+ value: item.dictValue,
+ label: item.dictLabel
+ }))
+ }
+ }).catch(error => {
+ console.error('鍔犺浇鍙栨秷鍘熷洜瀛楀吀澶辫触:', error)
+ })
+ },
+
+ // 鏄剧ず鍙栨秷鍘熷洜瀵硅瘽妗�
+ showCancelReasonDialog() {
+ this.selectedCancelReason = ''
+ this.$refs.cancelPopup.open()
+ },
+
+ // 纭鍙栨秷浠诲姟
+ confirmCancelTask() {
+ if (!this.selectedCancelReason) {
+ this.$modal.showToast('璇烽�夋嫨鍙栨秷鍘熷洜')
+ return
+ }
+
+ this.$refs.cancelPopup.close()
+
+ // 璋冪敤鏇存柊鐘舵�佹柟娉曪紝浼犻�掑彇娑堝師鍥�
+ this.updateTaskStatusWithCancelReason('CANCELLED', '浠诲姟宸插彇娑�', this.selectedCancelReason)
+ },
+
+ // 鍙栨秷瀵硅瘽妗嗗叧闂�
+ closeCancelDialog() {
+ this.$refs.cancelPopup.close()
+ this.selectedCancelReason = ''
+ },
+
+ // 閫夋嫨鍙栨秷鍘熷洜
+ selectCancelReason(e) {
+ const index = parseInt(e.detail.value)
+ if (this.cancelReasonList && this.cancelReasonList[index]) {
+ this.selectedCancelReason = this.cancelReasonList[index].value
+ }
+ },
+
+ // 甯﹀彇娑堝師鍥犵殑鐘舵�佹洿鏂�
+ updateTaskStatusWithCancelReason(status, remark, cancelReason) {
+ this.getLocationAndUpdateStatus(status, remark, cancelReason)
+ },
+
+ // 鏍规嵁鍙栨秷鍘熷洜value鑾峰彇label
+ getCancelReasonLabel(value) {
+ if (!value || !this.cancelReasonList.length) {
+ return value || '鏈煡'
+ }
+ const reason = this.cancelReasonList.find(r => r.value === value)
+ return reason ? reason.label : value
+ },
+
+ // 鏄剧ず寮哄埗瀹屾垚鏃堕棿瀵硅瘽妗�
+ showForceCompleteTimeDialog() {
+ // 鏍¢獙浠诲姟鏄惁婊¤冻寮哄埗瀹屾垚鏉′欢
+ const validation = this.validateForceComplete()
+ if (!validation.valid) {
+ this.$modal.showToast(validation.message)
+ return
+ }
+
+ // 閲嶇疆琛ㄥ崟
+ const now = new Date()
+ const nowDateStr = this.formatDateForPicker(now)
+ const nowTimeStr = this.formatTimeForPicker(now)
+
+ // 寮�濮嬫椂闂达細浼樺厛浣跨敤棰勭害鏃堕棿锛屽鏋滄病鏈夊垯浣跨敤褰撳墠鏃堕棿
+ let startTimeStr = nowDateStr + ' ' + nowTimeStr
+ if (this.taskDetail && this.taskDetail.plannedStartTime) {
+ const plannedTime = new Date(this.taskDetail.plannedStartTime)
+ const year = plannedTime.getFullYear()
+ // 妫�鏌ユ槸鍚︽槸鏈夋晥鏃堕棿锛堟帓闄�1900銆�1970绛夋棤鏁堝勾浠斤級
+ if (year > 2000) {
+ const plannedDateStr = this.formatDateForPicker(plannedTime)
+ const plannedTimeStr = this.formatTimeForPicker(plannedTime)
+ startTimeStr = plannedDateStr + ' ' + plannedTimeStr
+ }
+ }
+
+ this.forceCompleteForm = {
+ actualStartTime: startTimeStr,
+ actualEndTime: nowDateStr + ' ' + nowTimeStr
+ }
+
+ this.$refs.forceCompletePopup.open()
+ },
+
+ // 鏍¢獙鏄惁鍙互寮哄埗瀹屾垚
+ validateForceComplete() {
+ if (!this.taskDetail) {
+ return { valid: false, message: '浠诲姟淇℃伅涓嶅瓨鍦�' }
+ }
+
+ // 妫�鏌ユ槸鍚︽湁鎵ц浜�
+ if (!this.taskDetail.assignees || this.taskDetail.assignees.length === 0) {
+ return { valid: false, message: '璇峰厛鍒嗛厤鎵ц浜�' }
+ }
+
+ // 妫�鏌ユ槸鍚︽湁杞﹁締
+ if (!this.taskDetail.assignedVehicles || this.taskDetail.assignedVehicles.length === 0) {
+ return { valid: false, message: '璇峰厛鍒嗛厤鎵ц杞﹁締' }
+ }
+
+ return { valid: true }
+ },
+
+ // 鍏抽棴寮哄埗瀹屾垚瀵硅瘽妗�
+ closeForceCompleteDialog() {
+ this.$refs.forceCompletePopup.close()
+ },
+
+ // 纭寮哄埗瀹屾垚
+ confirmForceComplete() {
+ // 鏍¢獙鏃堕棿
+ if (!this.forceCompleteForm.actualStartTime || !this.forceCompleteForm.actualEndTime) {
+ this.$modal.showToast('璇烽�夋嫨寮�濮嬪拰缁撴潫鏃堕棿')
+ return
+ }
+
+ const startTime = new Date(this.forceCompleteForm.actualStartTime)
+ const endTime = new Date(this.forceCompleteForm.actualEndTime)
+
+ if (startTime >= endTime) {
+ this.$modal.showToast('缁撴潫鏃堕棿蹇呴』澶т簬寮�濮嬫椂闂�')
+ return
+ }
+
+ this.$refs.forceCompletePopup.close()
+
+ // 璋冪敤API鏇存柊浠诲姟
+ this.forceCompleteTask()
+ },
+
+ // 寮哄埗瀹屾垚浠诲姟
+ forceCompleteTask() {
+ uni.showLoading({
+ title: '澶勭悊涓�...'
+ })
+
+ const statusData = {
+ taskStatus: 'COMPLETED',
+ actualStartTime: this.forceCompleteForm.actualStartTime,
+ actualEndTime: this.forceCompleteForm.actualEndTime,
+ remark: '寮哄埗瀹屾垚浠诲姟'
+ }
+
+ changeTaskStatus(this.taskId, statusData).then(response => {
+ uni.hideLoading()
+ this.$modal.showToast('浠诲姟宸插畬鎴�')
+ // 閲嶆柊鍔犺浇浠诲姟璇︽儏
+ this.loadTaskDetail()
+ }).catch(error => {
+ uni.hideLoading()
+ console.error('寮哄埗瀹屾垚浠诲姟澶辫触:', error)
+ this.$modal.showToast('鎿嶄綔澶辫触锛岃閲嶈瘯')
+ })
+ },
+
+ // 閫夋嫨寮�濮嬫棩鏈�
+ selectStartDate(e) {
+ const date = e.detail.value
+ const time = this.getTimeFromDateTime(this.forceCompleteForm.actualStartTime) || '00:00'
+ this.forceCompleteForm.actualStartTime = date + ' ' + time
+ },
+
+ // 閫夋嫨寮�濮嬫椂闂�
+ selectStartTime(e) {
+ const time = e.detail.value
+ const date = this.getDateFromDateTime(this.forceCompleteForm.actualStartTime) || this.formatDateForPicker(new Date())
+ this.forceCompleteForm.actualStartTime = date + ' ' + time
+ },
+
+ // 閫夋嫨缁撴潫鏃ユ湡
+ selectEndDate(e) {
+ const date = e.detail.value
+ const time = this.getTimeFromDateTime(this.forceCompleteForm.actualEndTime) || '00:00'
+ this.forceCompleteForm.actualEndTime = date + ' ' + time
+ },
+
+ // 閫夋嫨缁撴潫鏃堕棿
+ selectEndTime(e) {
+ const time = e.detail.value
+ const date = this.getDateFromDateTime(this.forceCompleteForm.actualEndTime) || this.formatDateForPicker(new Date())
+ this.forceCompleteForm.actualEndTime = date + ' ' + time
+ },
+
+ // 浠庢棩鏈熸椂闂村瓧绗︿覆涓彁鍙栨棩鏈�
+ getDateFromDateTime(dateTimeStr) {
+ if (!dateTimeStr) return ''
+ return dateTimeStr.split(' ')[0] || ''
+ },
+
+ // 浠庢棩鏈熸椂闂村瓧绗︿覆涓彁鍙栨椂闂�
+ getTimeFromDateTime(dateTimeStr) {
+ if (!dateTimeStr) return ''
+ return dateTimeStr.split(' ')[1] || ''
+ },
+
+ // 鏍煎紡鍖栨棩鏈熶负 picker 闇�瑕佺殑鏍煎紡 (YYYY-MM-DD)
+ formatDateForPicker(date) {
+ const year = date.getFullYear()
+ const month = String(date.getMonth() + 1).padStart(2, '0')
+ const day = String(date.getDate()).padStart(2, '0')
+ return `${year}-${month}-${day}`
+ },
+
+ // 鏍煎紡鍖栨椂闂翠负 picker 闇�瑕佺殑鏍煎紡 (HH:mm)
+ formatTimeForPicker(date) {
+ const hour = String(date.getHours()).padStart(2, '0')
+ const minute = String(date.getMinutes()).padStart(2, '0')
+ return `${hour}:${minute}`
+ },
+
}
}
</script>
@@ -1498,9 +1870,19 @@
}
.title {
+ flex: 1;
font-size: 36rpx;
font-weight: bold;
color: #333;
+ }
+
+ .edit-btn {
+ width: 60rpx;
+ height: 60rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
}
}
@@ -1598,6 +1980,9 @@
}
.assignee-role {
+ display: flex;
+ align-items: center;
+
.role-tag {
display: inline-block;
padding: 4rpx 12rpx;
@@ -1618,15 +2003,6 @@
}
}
- .assignee-ready-btn {
- margin-left: 12rpx;
- padding: 8rpx 16rpx;
- font-size: 24rpx;
- border-radius: 6rpx;
- background-color: #34C759;
- color: #fff;
- border: none;
- }
.ready-badge {
display: inline-block;
margin-left: 12rpx;
@@ -1643,6 +2019,17 @@
}
}
}
+ }
+
+ .assignee-ready-btn {
+ margin-left: 12rpx;
+ padding: 8rpx 16rpx;
+ font-size: 24rpx;
+ border-radius: 6rpx;
+ background-color: #34C759;
+ color: #fff;
+ border: none;
+ flex-shrink: 0;
}
}
}
@@ -1836,6 +2223,11 @@
color: white;
}
+ &.force-complete {
+ background-color: #5856d6;
+ color: white;
+ }
+
&:first-child {
margin-left: 0;
}
@@ -1867,5 +2259,136 @@
margin-left: 10rpx;
vertical-align: middle;
}
+
+ // 鍙栨秷鍘熷洜瀵硅瘽妗嗘牱寮�
+ .cancel-dialog {
+ width: 600rpx;
+ background-color: white;
+ border-radius: 20rpx;
+ padding: 40rpx;
+
+ .dialog-title {
+ font-size: 32rpx;
+ font-weight: bold;
+ text-align: center;
+ margin-bottom: 30rpx;
+ color: #333;
+ }
+
+ .reason-picker {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 20rpx 30rpx;
+ background-color: #f5f5f5;
+ border-radius: 10rpx;
+ margin-bottom: 30rpx;
+
+ .picker-label {
+ font-size: 28rpx;
+ color: #666;
+ }
+
+ .picker-value {
+ flex: 1;
+ text-align: right;
+ font-size: 28rpx;
+ color: #333;
+ margin: 0 10rpx;
+ }
+ }
+
+ .dialog-buttons {
+ display: flex;
+ gap: 20rpx;
+
+ button {
+ flex: 1;
+ height: 80rpx;
+ border-radius: 10rpx;
+ font-size: 30rpx;
+ border: none;
+
+ &.cancel-btn {
+ background-color: #f0f0f0;
+ color: #666;
+ }
+
+ &.confirm-btn {
+ background-color: #007AFF;
+ color: white;
+ }
+ }
+ }
+ }
+
+ // 寮哄埗瀹屾垚瀵硅瘽妗嗘牱寮�
+ .force-complete-dialog {
+ width: 600rpx;
+ background-color: white;
+ border-radius: 20rpx;
+ padding: 40rpx;
+
+ .dialog-title {
+ font-size: 32rpx;
+ font-weight: bold;
+ text-align: center;
+ margin-bottom: 30rpx;
+ color: #333;
+ }
+
+ .time-picker-item {
+ margin-bottom: 30rpx;
+
+ .time-label {
+ font-size: 28rpx;
+ color: #333;
+ margin-bottom: 15rpx;
+ font-weight: 500;
+ }
+
+ picker {
+ display: inline-block;
+ width: 48%;
+
+ &:first-of-type {
+ margin-right: 4%;
+ }
+
+ .picker-value {
+ padding: 20rpx;
+ background-color: #f5f5f5;
+ border-radius: 10rpx;
+ font-size: 26rpx;
+ color: #333;
+ text-align: center;
+ }
+ }
+ }
+
+ .dialog-buttons {
+ display: flex;
+ gap: 20rpx;
+ margin-top: 40rpx;
+
+ button {
+ flex: 1;
+ height: 80rpx;
+ border-radius: 10rpx;
+ font-size: 30rpx;
+ border: none;
+
+ &.cancel-btn {
+ background-color: #f0f0f0;
+ color: #666;
+ }
+
+ &.confirm-btn {
+ background-color: #5856d6;
+ color: white;
+ }
+ }
+ }
+ }
}
</style>
\ No newline at end of file
--
Gitblit v1.9.1