From 668e570bd1db6bd00e4293b6977e6d3d051053ce Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期四, 27 十一月 2025 00:07:46 +0800
Subject: [PATCH] feat: 修改app录入界面及车辆用户同步

---
 app/pages/task/detail.vue |  674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 657 insertions(+), 17 deletions(-)

diff --git a/app/pages/task/detail.vue b/app/pages/task/detail.vue
index 8598db2..fcbd8d7 100644
--- a/app/pages/task/detail.vue
+++ b/app/pages/task/detail.vue
@@ -135,7 +135,7 @@
         </view>
         <view class="info-item" v-if="taskDetail.emergencyInfo.patientCondition">
           <view class="label">鐥呮儏鎻忚堪</view>
-          <view class="value">{{ taskDetail.emergencyInfo.patientCondition }}</view>
+          <view class="value" style="white-space: pre-line;">{{ taskDetail.emergencyInfo.patientCondition }}</view>
         </view>
       </view>
       
@@ -189,10 +189,69 @@
           <view class="value">{{ taskDetail.emergencyInfo.transferDistance }}鍏噷</view>
         </view>
         <view class="info-item" v-if="taskDetail.emergencyInfo.transferPrice">
-          <view class="label">杞繍璐圭敤</view>
+          <view class="label">鍩虹璐圭敤</view>
           <view class="value">锟{ taskDetail.emergencyInfo.transferPrice }}</view>
         </view>
+        <view class="info-item" v-if="paymentInfo">
+          <view class="label">闄勫姞璐圭敤</view>
+          <view class="value">锟{ paymentInfo.additionalAmount || 0 }}</view>
+        </view>
+        <view class="info-item" v-if="paymentInfo">
+          <view class="label">鎬昏垂鐢�</view>
+          <view class="value" style="color: #e54d42; font-weight: bold;">锟{ paymentInfo.totalAmount || 0 }}</view>
+        </view>
+        <view class="info-item" v-if="paymentInfo && paymentInfo.paidAmount > 0">
+          <view class="label">宸叉敮浠�</view>
+          <view class="value" style="color: #34C759;">锟{ paymentInfo.paidAmount }}</view>
+        </view>
+        <view class="info-item" v-if="paymentInfo && paymentInfo.paidAmount > 0">
+          <view class="label">鍓╀綑鏈粯</view>
+          <view class="value" style="color: #ff9900; font-weight: bold;">锟{ getRemainingAmount() }}</view>
+        </view>
       </view>
+      
+      <!-- 鏀粯璁板綍鏄庣粏 -->
+      <view class="detail-section" v-if="paymentInfo && paymentInfo.paidPayments && paymentInfo.paidPayments.length > 0">
+        <view class="section-title">鏀粯璁板綍</view>
+        <view 
+          class="payment-record-item" 
+          v-for="payment in paymentInfo.paidPayments" 
+          :key="payment.id"
+        >
+          <view class="payment-header">
+            <view 
+              class="payment-method-tag" 
+              :class="[
+                payment.paymentMethod === '1' ? 'method-cash' : '',
+                payment.paymentMethod === '2' ? 'method-bank' : '',
+                payment.paymentMethod === '3' ? 'method-wechat' : '',
+                payment.paymentMethod === '4' ? 'method-alipay' : '',
+                payment.paymentMethod === '5' ? 'method-pos' : '',
+                payment.paymentMethod === '6' ? 'method-account' : '',
+                payment.paymentMethod === '7' ? 'method-yyt' : ''
+              ]"
+            >
+              {{ getPaymentMethodLabel(payment.paymentMethod) }}
+            </view>
+            <view class="payment-amount">锟{ payment.settlementAmount }}</view>
+          </view>
+          <view class="payment-time" v-if="payment.payTime">
+            {{ formatPaymentTime(payment.payTime) }}
+          </view>
+          <view class="payment-remark" v-if="payment.remark">
+            澶囨敞锛歿{ payment.remark }}
+          </view>
+        </view>
+      </view>
+      
+      <!-- 闄勪欢淇℃伅 -->
+      <AttachmentUpload 
+        :taskId="taskId" 
+        title="浠诲姟闄勪欢"
+        :readonly="isTaskFinished"
+        @uploaded="onAttachmentUploaded"
+        @deleted="onAttachmentDeleted"
+      />
       
       <!-- 绂忕杞︿换鍔$壒鏈変俊鎭� -->
       <view class="detail-section" v-if="taskDetail.taskType === 'WELFARE' && taskDetail.welfareInfo">
@@ -260,8 +319,14 @@
     
     <!-- 鎿嶄綔鎸夐挳鍖哄煙 -->
     <view class="action-buttons" v-if="taskDetail">
-      <!-- 寰呭鐞嗙姸鎬�: 鏄剧ず鍑哄彂銆佸彇娑� -->
+      <!-- 寰呭鐞嗙姸鎬�: 鏄剧ず缂栬緫銆佸嚭鍙戙�佸彇娑� -->
       <template v-if="taskDetail.taskStatus === 'PENDING'">
+        <button 
+          class="action-btn edit" 
+          @click="handleEdit"
+        >
+          淇敼
+        </button>
         <button 
           class="action-btn primary" 
           @click="handleTaskAction('depart')"
@@ -276,8 +341,14 @@
         </button>
       </template>
       
-      <!-- 鍑哄彂涓姸鎬�: 鏄剧ず宸插埌杈俱�佸己鍒剁粨鏉� -->
+      <!-- 鍑哄彂涓姸鎬�: 鏄剧ず缂栬緫銆佸凡鍒拌揪銆佸己鍒剁粨鏉� -->
       <template v-else-if="taskDetail.taskStatus === 'DEPARTING'">
+        <button 
+          class="action-btn edit" 
+          @click="handleEdit"
+        >
+          淇敼
+        </button>
         <button 
           class="action-btn primary" 
           @click="handleTaskAction('arrive')"
@@ -292,8 +363,14 @@
         </button>
       </template>
       
-      <!-- 宸插埌杈剧姸鎬�: 鏄剧ず宸茶繑绋� -->
+      <!-- 宸插埌杈剧姸鎬�: 鏄剧ず缂栬緫銆佸凡杩旂▼ -->
       <template v-else-if="taskDetail.taskStatus === 'ARRIVED'">
+        <button 
+          class="action-btn edit" 
+          @click="handleEdit"
+        >
+          淇敼
+        </button>
         <button 
           class="action-btn primary" 
           @click="handleTaskAction('return')"
@@ -302,8 +379,14 @@
         </button>
       </template>
       
-      <!-- 杩旂▼涓姸鎬�: 鏄剧ず宸插畬鎴� -->
+      <!-- 杩旂▼涓姸鎬�: 鏄剧ず缂栬緫銆佸凡瀹屾垚 -->
       <template v-else-if="taskDetail.taskStatus === 'RETURNING'">
+        <button 
+          class="action-btn edit" 
+          @click="handleEdit"
+        >
+          淇敼
+        </button>
         <button 
           class="action-btn primary" 
           @click="handleTaskAction('complete')"
@@ -312,23 +395,46 @@
         </button>
       </template>
       
-      <!-- 宸插畬鎴�/宸插彇娑�: 涓嶆樉绀烘寜閽� -->
+      <!-- 宸插畬鎴�/宸插彇娑�: 涓嶆樉绀烘寜閽紝浣嗗鏋滄槸杞繍浠诲姟鍒欐樉绀虹粨绠楁寜閽� -->
+      
+      <!-- 杞繍浠诲姟鐨勭粨绠楁寜閽細浠呭畬鎴�/鍙栨秷鐘舵�佷笉鏄剧ず -->
+      <button 
+        v-if="taskDetail.taskType === 'EMERGENCY_TRANSFER' && !isTaskFinished"
+        class="action-btn settlement" 
+        @click="handleSettlement"
+      >
+        缁撶畻
+      </button>
     </view>
   </view>
 </template>
 
 <script>
   import { getTask, changeTaskStatus } from '@/api/task'
+  import { checkVehicleActiveTasks } from '@/api/task'
+  import { getPaymentInfo } from '@/api/payment'
   import { formatDateTime } from '@/utils/common'
+  import AttachmentUpload from '@/components/AttachmentUpload.vue'
   
   export default {
+    components: {
+      AttachmentUpload
+    },
     data() {
       return {
         taskDetail: null,
-        taskId: null
+        taskId: null,
+        paymentInfo: null // 鏀粯淇℃伅
       }
     },
     computed: {
+      // 鍒ゆ柇浠诲姟鏄惁宸茬粨鏉燂紙宸插畬鎴愭垨宸插彇娑堬級
+      isTaskFinished() {
+        if (!this.taskDetail || !this.taskDetail.taskStatus) {
+          return false
+        }
+        return ['COMPLETED', 'CANCELLED'].includes(this.taskDetail.taskStatus)
+      },
       // 鏄剧ず浠诲姟绫诲瀷
       displayTaskType() {
         if (!this.taskDetail || !this.taskDetail.taskType) {
@@ -388,6 +494,12 @@
       this.taskId = options.id
       this.loadTaskDetail()
     },
+    onShow() {
+      // 姣忔椤甸潰鏄剧ず鏃堕噸鏂板姞杞芥暟鎹紝纭繚浠庣紪杈戦〉闈㈣繑鍥炲悗鑳界湅鍒版渶鏂版暟鎹�
+      if (this.taskId) {
+        this.loadTaskDetail()
+      }
+    },
     methods: {
       // 鍔犺浇浠诲姟璇︽儏
       loadTaskDetail() {
@@ -399,15 +511,73 @@
         getTask(this.taskId).then(response => {
           this.taskDetail = response.data || response
           // 璋冭瘯锛氭墦鍗拌繑鍥炵殑鏁版嵁
-          // console.log('浠诲姟璇︽儏瀹屾暣鏁版嵁:', JSON.stringify(this.taskDetail, null, 2))
-          // console.log('浠诲姟绫诲瀷瀛楁鍊�:', this.taskDetail.taskType)
-          // console.log('浠诲姟鐘舵�佸瓧娈靛��:', this.taskDetail.taskStatus)
-          // console.log('鍑哄彂鍦板潃:', this.taskDetail.departureAddress)
-          // console.log('鐩殑鍦板潃:', this.taskDetail.destinationAddress)
+          console.log('浠诲姟璇︽儏瀹屾暣鏁版嵁:', JSON.stringify(this.taskDetail, null, 2))
+          console.log('浠诲姟绫诲瀷瀛楁鍊�:', this.taskDetail.taskType)
+          console.log('浠诲姟鐘舵�佸瓧娈靛��:', this.taskDetail.taskStatus)
+          console.log('鍑哄彂鍦板潃:', this.taskDetail.departureAddress)
+          console.log('鐩殑鍦板潃:', this.taskDetail.destinationAddress)
+          console.log('杞繍浠诲姟淇℃伅 (emergencyInfo):', this.taskDetail.emergencyInfo)
+          
+          // 濡傛灉鏄浆杩愪换鍔★紝鍔犺浇鏀粯淇℃伅
+          if (this.taskDetail.taskType === 'EMERGENCY_TRANSFER') {
+            this.loadPaymentInfo()
+          }
         }).catch(error => {
           console.error('鍔犺浇浠诲姟璇︽儏澶辫触:', error)
           this.$modal.showToast('鍔犺浇浠诲姟璇︽儏澶辫触')
         })
+      },
+      
+      // 鍔犺浇鏀粯淇℃伅
+      loadPaymentInfo() {
+        getPaymentInfo(this.taskId).then(res => {
+          this.paymentInfo = res.data
+          console.log('鏀粯淇℃伅:', this.paymentInfo)
+        }).catch(err => {
+          console.error('鍔犺浇鏀粯淇℃伅澶辫触', err)
+        })
+      },
+      
+      // 鏍规嵁鏀粯鏂瑰紡瀛楀吀鍊艰幏鍙栨樉绀烘爣绛�
+      getPaymentMethodLabel(dictValue) {
+        const methodMap = {
+          '1': '鐜伴噾',
+          '2': '閾惰杞处',
+          '3': '寰俊鏀粯',
+          '4': '鏀粯瀹�',
+          '5': 'POS鏀舵',
+          '6': '鎸傝处',
+          '7': '鏄撳尰閫氭寕璐�',
+          '8': '閫�娆�',
+          '9': '绉垎'
+        }
+        return methodMap[dictValue] || dictValue
+      },
+      
+      // 鏍煎紡鍖栨敮浠樻椂闂�
+      formatPaymentTime(time) {
+        if (!time) return '鏈煡'
+        const date = new Date(time)
+        const year = date.getFullYear()
+        const month = String(date.getMonth() + 1).padStart(2, '0')
+        const day = String(date.getDate()).padStart(2, '0')
+        const hour = String(date.getHours()).padStart(2, '0')
+        const minute = String(date.getMinutes()).padStart(2, '0')
+        return `${year}-${month}-${day} ${hour}:${minute}`
+      },
+      
+      // 璁$畻鍓╀綑鏈粯閲戦
+      getRemainingAmount() {
+        if (!this.paymentInfo) {
+          return '0.00'
+        }
+        const total = parseFloat(this.paymentInfo.totalAmount || 0)
+        const paid = parseFloat(this.paymentInfo.paidAmount || 0)
+        const remaining = total - paid
+        console.log('鎬婚噾棰�:', total.toFixed(2))
+        console.log('宸蹭粯閲戦:', paid.toFixed(2))
+        console.log('鍓╀綑鏈粯閲戦:', remaining.toFixed(2))
+        return remaining > 0 ? remaining.toFixed(2) : '0.00'
       },
       
       // 鑾峰彇杞﹁締淇℃伅
@@ -454,6 +624,41 @@
         uni.navigateBack()
       },
       
+      // 澶勭悊缂栬緫鎸夐挳
+      handleEdit() {
+        if (!this.taskDetail) {
+          this.$modal.showToast('浠诲姟淇℃伅涓嶅瓨鍦�')
+          return
+        }
+        
+        // 妫�鏌ヤ换鍔$姸鎬侊紝宸插畬鎴愭垨宸插彇娑堢殑浠诲姟涓嶈兘缂栬緫
+        if (this.isTaskFinished) {
+          this.$modal.showToast('宸插畬鎴愭垨宸插彇娑堢殑浠诲姟涓嶈兘缂栬緫')
+          return
+        }
+        
+        const taskType = this.taskDetail.taskType
+        const taskId = this.taskDetail.taskId
+        
+        // 鏍规嵁浠诲姟绫诲瀷璺宠浆鍒颁笉鍚岀殑缂栬緫椤甸潰
+        if (taskType === 'EMERGENCY_TRANSFER') {
+          // 杞繍浠诲姟锛氳烦杞埌杞繍浠诲姟缂栬緫椤甸潰
+          uni.navigateTo({
+            url: `/pages/task/edit-emergency?id=${taskId}`
+          })
+        } else if (taskType === 'WELFARE') {
+          // 绂忕杞︿换鍔★細璺宠浆鍒扮绁楄溅缂栬緫椤甸潰
+          uni.navigateTo({
+            url: `/pages/task/edit-welfare?id=${taskId}`
+          })
+        } else {
+          // 鍏朵粬浠诲姟锛氳烦杞埌閫氱敤浠诲姟缂栬緫椤甸潰
+          uni.navigateTo({
+            url: `/pages/task/edit?id=${taskId}`
+          })
+        }
+      },
+      
       // 鑾峰彇鐘舵�佹枃鏈�
       getStatusText(status) {
         const statusMap = {
@@ -480,14 +685,19 @@
         return typeMap[type] || '鏈煡绫诲瀷'
       },
       
+      // 澶勭悊缁撶畻
+      handleSettlement() {
+        uni.navigateTo({
+          url: '/pages/task/settlement?taskId=' + this.taskId
+        })
+      },
+      
       // 澶勭悊浠诲姟鎿嶄綔
       handleTaskAction(action) {
         switch (action) {
           case 'depart':
-            // 鍑哄彂 -> 鐘舵�佸彉涓哄嚭鍙戜腑
-            this.$modal.confirm('纭畾瑕佸嚭鍙戝悧锛�').then(() => {
-              this.updateTaskStatus('DEPARTING', '浠诲姟宸插嚭鍙�')
-            }).catch(() => {});
+            // 鍑哄彂 -> 妫�鏌ヨ溅杈嗘槸鍚︽湁鍏朵粬姝e湪杩涜涓殑浠诲姟
+            this.checkVehicleAndDepart();
             break;
             
           case 'cancel':
@@ -525,6 +735,82 @@
             }).catch(() => {});
             break;
         }
+      },
+      
+      // 妫�鏌ヨ溅杈嗙姸鎬佸苟鍑哄彂
+      checkVehicleAndDepart() {
+        // 鑾峰彇浠诲姟杞﹁締ID
+        const vehicleId = this.getVehicleId();
+        if (!vehicleId) {
+          this.$modal.showToast('鏈壘鍒颁换鍔¤溅杈嗕俊鎭�');
+          return;
+        }
+        
+        // 鏄剧ず鍔犺浇鎻愮ず
+        uni.showLoading({
+          title: '妫�鏌ヨ溅杈嗙姸鎬�...'
+        });
+        
+        checkVehicleActiveTasks(vehicleId).then(response => {
+          uni.hideLoading();
+          
+          const activeTasks = response.data || [];
+          
+          // 杩囨护鎺夊綋鍓嶄换鍔℃湰韬�
+          const otherActiveTasks = activeTasks.filter(task => task.taskId !== this.taskId);
+          
+          if (otherActiveTasks.length > 0) {
+            // 杞﹁締鏈夊叾浠栨鍦ㄨ繘琛屼腑鐨勪换鍔�
+            const task = otherActiveTasks[0];
+            const taskStatus = this.getStatusText(task.taskStatus);
+            const message = `璇ヨ溅杈嗗凡鏈夋鍦ㄨ浆杩愪腑鐨勪换鍔★紒
+
+浠诲姟鍗曞彿锛�${task.taskCode}
+浠诲姟鐘舵�侊細${taskStatus}
+
+璇峰厛瀹屾垚褰撳墠浠诲姟鍚庡啀鍑哄彂鏂颁换鍔°�俙;
+            
+            uni.showModal({
+              title: '鎻愮ず',
+              content: message,
+              showCancel: false,
+              confirmText: '鎴戠煡閬撲簡'
+            });
+            return;
+          }
+          
+          // 杞﹁締娌℃湁鍏朵粬姝e湪杩涜涓殑浠诲姟锛屽彲浠ュ嚭鍙�
+          this.$modal.confirm('纭畾瑕佸嚭鍙戝悧锛�').then(() => {
+            this.updateTaskStatus('DEPARTING', '浠诲姟宸插嚭鍙�')
+          }).catch(() => {});
+          
+        }).catch(error => {
+          uni.hideLoading();
+          console.error('妫�鏌ヨ溅杈嗙姸鎬佸け璐�:', error);
+          // 妫�鏌ュけ璐ユ椂锛屼粛鐒跺厑璁稿嚭鍙�
+          this.$modal.confirm('妫�鏌ヨ溅杈嗙姸鎬佸け璐ワ紝鏄惁缁х画鍑哄彂锛�').then(() => {
+            this.updateTaskStatus('DEPARTING', '浠诲姟宸插嚭鍙�')
+          }).catch(() => {});
+        });
+      },
+      
+      // 鑾峰彇浠诲姟杞﹁締ID
+      getVehicleId() {
+        if (!this.taskDetail) {
+          return null;
+        }
+        console.log("taskDetail assignedVehicles",this.taskDetail.assignedVehicles); 
+        // 浠庤溅杈嗗垪琛ㄤ腑鑾峰彇绗竴涓溅杈嗙殑ID锛堝悗绔繑鍥炵殑瀛楁鍚嶆槸assignedVehicles锛�
+        if (this.taskDetail.assignedVehicles && this.taskDetail.assignedVehicles.length > 0) {
+          return this.taskDetail.assignedVehicles[0].vehicleId;
+        }
+        
+        // 鎴栬�呬粠鍗曚釜杞﹁締瀵硅薄鑾峰彇
+        if (this.taskDetail.vehicleId) {
+          return this.taskDetail.vehicleId;
+        }
+        
+        return null;
       },
       
       // 鏇存柊浠诲姟鐘舵��
@@ -592,6 +878,264 @@
             })
           }
         })
+      },
+      
+      // 鍔犺浇闄勪欢鍒楄〃
+      loadAttachmentList() {
+        if (!this.taskId) {
+          return
+        }
+        
+        getAttachmentList(this.taskId).then(response => {
+          this.attachmentList = response.data || response || []
+        }).catch(error => {
+          console.error('鍔犺浇闄勪欢鍒楄〃澶辫触:', error)
+        })
+      },
+      
+      // 鏄剧ず涓婁紶瀵硅瘽妗�
+      showUploadDialog() {
+        this.selectedCategoryIndex = 0
+        this.tempImagePath = null
+        this.$refs.uploadPopup.open()
+      },
+      
+      // 鍏抽棴涓婁紶瀵硅瘽妗�
+      closeUploadDialog() {
+        this.$refs.uploadPopup.close()
+      },
+      
+      // 鍒嗙被閫夋嫨鍙樺寲
+      onCategoryChange(e) {
+        this.selectedCategoryIndex = e.detail.value
+      },
+      
+      // 閫夋嫨鍥剧墖
+      chooseImage() {
+        const that = this
+        uni.chooseImage({
+          count: 1,
+          sizeType: ['compressed'],
+          sourceType: ['album', 'camera'],
+          success: function(res) {
+            that.tempImagePath = res.tempFilePaths[0]
+          },
+          fail: function(err) {
+            console.error('閫夋嫨鍥剧墖澶辫触:', err)
+            that.$modal.showToast('閫夋嫨鍥剧墖澶辫触')
+          }
+        })
+      },
+      
+      // 纭涓婁紶
+      confirmUpload() {
+        if (!this.tempImagePath) {
+          this.$modal.showToast('璇峰厛閫夋嫨鍥剧墖')
+          return
+        }
+        
+        const that = this
+        const category = this.categoryList[this.selectedCategoryIndex].value
+        
+        // 寰俊灏忕▼搴忕幆澧冿細鍏堣幏鍙朅ccessToken锛屽啀涓婁紶鍒板井淇℃湇鍔″櫒锛屾渶鍚庢彁浜ediaId鍒板悗绔�
+        // #ifdef MP-WEIXIN
+        if (this.isWechatMiniProgram) {
+          uni.showLoading({
+            title: '涓婁紶涓�...'
+          })
+          
+          // 绗竴姝ワ細浠庡悗绔幏鍙朅ccessToken
+          getWechatAccessToken().then(tokenResponse => {
+            // 鎺ュ彛杩斿洖鏍煎紡锛歿"msg":"token鍊�","code":200}
+            console.log('鑾峰彇AccessToken鎴愬姛:', tokenResponse)
+            const accessToken = tokenResponse.msg || tokenResponse.data || tokenResponse
+            if (!accessToken) {
+              uni.hideLoading()
+              that.$modal.showToast('鑾峰彇AccessToken澶辫触')
+              console.error('鑾峰彇AccessToken澶辫触锛屽搷搴旀暟鎹�:', tokenResponse)
+              return
+            }
+            
+            console.log('鑾峰彇鍒癆ccessToken:', accessToken)
+            
+            // 绗簩姝ワ細涓婁紶鍒板井淇℃湇鍔″櫒
+            const uploadUrl = `https://api.weixin.qq.com/cgi-bin/media/upload?access_token=${accessToken}&type=image`
+            
+            uni.uploadFile({
+              url: uploadUrl,
+              filePath: that.tempImagePath,
+              name: 'media',
+              success: function(res) {
+                console.log('寰俊涓婁紶鍝嶅簲:', res)
+                try {
+                  const data = JSON.parse(res.data)
+                  if (data.media_id) {
+                    // 绗笁姝ワ細鎻愪氦mediaId鍒板悗绔�
+                    uploadAttachmentFromWechat(that.taskId, data.media_id, category).then(response => {
+                      uni.hideLoading()
+                      that.$modal.showToast('涓婁紶鎴愬姛')
+                      that.closeUploadDialog()
+                      that.loadAttachmentList()
+                    }).catch(error => {
+                      uni.hideLoading()
+                      console.error('鎻愪氦mediaId澶辫触:', error)
+                      that.$modal.showToast('涓婁紶澶辫触锛�' + (error.msg || '璇烽噸璇�'))
+                    })
+                  } else {
+                    uni.hideLoading()
+                    const errMsg = data.errmsg || '鏈煡閿欒'
+                    console.error('寰俊杩斿洖閿欒:', data)
+                    that.$modal.showToast('寰俊涓婁紶澶辫触锛�' + errMsg)
+                  }
+                } catch (e) {
+                  uni.hideLoading()
+                  console.error('瑙f瀽寰俊鍝嶅簲澶辫触:', e, res.data)
+                  that.$modal.showToast('涓婁紶澶辫触锛氬搷搴旇В鏋愰敊璇�')
+                }
+              },
+              fail: function(err) {
+                uni.hideLoading()
+                console.error('涓婁紶鍒板井淇″け璐�:', err)
+                that.$modal.showToast('涓婁紶澶辫触锛�' + (err.errMsg || '璇锋鏌ョ綉缁�'))
+              }
+            })
+          }).catch(error => {
+            uni.hideLoading()
+            console.error('鑾峰彇AccessToken澶辫触:', error)
+            that.$modal.showToast('鑾峰彇AccessToken澶辫触')
+          })
+          return
+        }
+        // #endif
+        
+        // 闈炲井淇″皬绋嬪簭鐜锛氱洿鎺ヤ笂浼犲埌鍚庣鏈嶅姟鍣�
+        uni.showLoading({
+          title: '涓婁紶涓�...'
+        })
+        
+        uni.uploadFile({
+          url: that.$baseUrl + '/task/attachment/upload/' + that.taskId,
+          filePath: that.tempImagePath,
+          name: 'file',
+          formData: {
+            'category': category
+          },
+          header: {
+            'Authorization': 'Bearer ' + uni.getStorageSync('token')
+          },
+          success: function(uploadRes) {
+            uni.hideLoading()
+            
+            if (uploadRes.statusCode === 200) {
+              const result = JSON.parse(uploadRes.data)
+              if (result.code === 200) {
+                that.$modal.showToast('涓婁紶鎴愬姛')
+                that.closeUploadDialog()
+                that.loadAttachmentList()
+              } else {
+                that.$modal.showToast(result.msg || '涓婁紶澶辫触')
+              }
+            } else {
+              that.$modal.showToast('涓婁紶澶辫触')
+            }
+          },
+          fail: function(err) {
+            uni.hideLoading()
+            console.error('涓婁紶澶辫触:', err)
+            that.$modal.showToast('涓婁紶澶辫触')
+          }
+        })
+      },
+      
+      // 鏌ョ湅闄勪欢
+      viewAttachment(item) {
+        // 濡傛灉鏄浘鐗囷紝浣跨敤鍥剧墖棰勮
+        const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp']
+        const fileExt = item.fileName.split('.').pop().toLowerCase()
+        
+        if (imageTypes.includes(fileExt)) {
+          // 鏋勫缓鍥剧墖璁块棶鍦板潃
+          // 濡傛灉鏄痜ilePath鏄畬鏁磋矾寰勶紝闇�瑕侀�氳繃涓嬭浇鎺ュ彛璁块棶
+          const imageUrl = this.$baseUrl + '/task/attachment/download/' + item.attachmentId
+          
+          // 寰俊灏忕▼搴忎腑棰勮鍥剧墖
+          // #ifdef MP-WEIXIN
+          // 寰俊灏忕▼搴忛渶瑕佸厛涓嬭浇鍒版湰鍦板啀棰勮
+          uni.showLoading({ title: '鍔犺浇涓�...' })
+          uni.downloadFile({
+            url: imageUrl,
+            success: function(res) {
+              uni.hideLoading()
+              if (res.statusCode === 200) {
+                uni.previewImage({
+                  urls: [res.tempFilePath],
+                  current: res.tempFilePath
+                })
+              } else {
+                uni.showToast({ title: '鍔犺浇鍥剧墖澶辫触', icon: 'none' })
+              }
+            },
+            fail: function() {
+              uni.hideLoading()
+              uni.showToast({ title: '涓嬭浇澶辫触', icon: 'none' })
+            }
+          })
+          // #endif
+          
+          // 闈炲井淇″皬绋嬪簭鐜锛岀洿鎺ラ瑙�
+          // #ifndef MP-WEIXIN
+          uni.previewImage({
+            urls: [imageUrl],
+            current: imageUrl
+          })
+          // #endif
+        } else {
+          this.$modal.showToast('浠呮敮鎸侀瑙堝浘鐗�')
+        }
+      },
+      
+      // 鍒犻櫎闄勪欢
+      deleteAttachment(attachmentId, index) {
+        const that = this
+        this.$modal.confirm('纭畾瑕佸垹闄よ闄勪欢鍚楋紵').then(() => {
+          deleteAttachment(attachmentId).then(response => {
+            that.$modal.showToast('鍒犻櫎鎴愬姛')
+            that.attachmentList.splice(index, 1)
+          }).catch(error => {
+            console.error('鍒犻櫎闄勪欢澶辫触:', error)
+            that.$modal.showToast('鍒犻櫎澶辫触')
+          })
+        }).catch(() => {})
+      },
+      
+      // 鑾峰彇鍒嗙被鍚嶇О
+      getCategoryName(category) {
+        const item = this.categoryList.find(c => c.value === category)
+        return item ? item.label : '鏈垎绫�'
+      },
+      
+      // 鏍煎紡鍖栨椂闂�
+      formatTime(time) {
+        if (!time) return ''
+        return formatDateTime(time, 'YYYY-MM-DD HH:mm')
+      },
+      
+      // 鏍煎紡鍖栨枃浠跺ぇ灏�
+      formatFileSize(size) {
+        if (!size) return '0B'
+        if (size < 1024) return size + 'B'
+        if (size < 1024 * 1024) return (size / 1024).toFixed(2) + 'KB'
+        return (size / 1024 / 1024).toFixed(2) + 'MB'
+      },
+      
+      // 闄勪欢涓婁紶鎴愬姛鍥炶皟
+      onAttachmentUploaded(response) {
+        console.log('闄勪欢涓婁紶鎴愬姛:', response)
+      },
+      
+      // 闄勪欢鍒犻櫎鎴愬姛鍥炶皟
+      onAttachmentDeleted(attachmentId) {
+        console.log('闄勪欢鍒犻櫎鎴愬姛:', attachmentId)
       }
     }
   }
@@ -647,6 +1191,18 @@
         color: #333;
         border-bottom: 1rpx solid #f0f0f0;
         padding-bottom: 10rpx;
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        
+        .upload-btn {
+          font-size: 24rpx;
+          padding: 8rpx 20rpx;
+          background-color: #007AFF;
+          color: white;
+          border-radius: 8rpx;
+          border: none;
+        }
       }
       
       .info-item {
@@ -697,6 +1253,80 @@
       }
     }
     
+    // 鏀粯璁板綍鏍峰紡
+    .payment-record-item {
+      background-color: #f9f9f9;
+      border-radius: 10rpx;
+      padding: 20rpx;
+      margin-bottom: 20rpx;
+      
+      &:last-child {
+        margin-bottom: 0;
+      }
+      
+      .payment-header {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        margin-bottom: 15rpx;
+        
+        .payment-method-tag {
+          display: inline-block;
+          padding: 6rpx 16rpx;
+          border-radius: 6rpx;
+          font-size: 24rpx;
+          color: white;
+          font-weight: 500;
+          
+          &.method-cash {
+            background-color: #34C759;
+          }
+          
+          &.method-bank {
+            background-color: #5AC8FA;
+          }
+          
+          &.method-wechat {
+            background-color: #09BB07;
+          }
+          
+          &.method-alipay {
+            background-color: #1677FF;
+          }
+          
+          &.method-pos {
+            background-color: #FF9500;
+          }
+          
+          &.method-account {
+            background-color: #FF9500;
+          }
+          
+          &.method-yyt {
+            background-color: #AF52DE;
+          }
+        }
+        
+        .payment-amount {
+          font-size: 32rpx;
+          font-weight: bold;
+          color: #34C759;
+        }
+      }
+      
+      .payment-time {
+        font-size: 24rpx;
+        color: #999;
+        margin-bottom: 10rpx;
+      }
+      
+      .payment-remark {
+        font-size: 24rpx;
+        color: #666;
+        line-height: 1.5;
+      }
+    }
+    
     .loading {
       display: flex;
       flex-direction: column;
@@ -730,6 +1360,11 @@
         background-color: #f0f0f0;
         color: #333;
         
+        &.edit {
+          background-color: #ff9500;
+          color: white;
+        }
+        
         &.primary {
           background-color: #007AFF;
           color: white;
@@ -740,6 +1375,11 @@
           color: white;
         }
         
+        &.settlement {
+          background-color: #34C759;
+          color: white;
+        }
+        
         &:first-child {
           margin-left: 0;
         }

--
Gitblit v1.9.1