From f08739f46afe856f60ebb1d21ab23d72947629ed Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 21 十二月 2025 00:03:12 +0800
Subject: [PATCH] feat:优化任务搜索查询 app

---
 app/pagesTask/edit-emergency.vue |  164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 163 insertions(+), 1 deletions(-)

diff --git a/app/pagesTask/edit-emergency.vue b/app/pagesTask/edit-emergency.vue
index 24f3a97..7911a84 100644
--- a/app/pagesTask/edit-emergency.vue
+++ b/app/pagesTask/edit-emergency.vue
@@ -39,6 +39,26 @@
       />
       
       <view class="form-item">
+        <view class="form-label required">浠诲姟绫诲瀷</view>
+        <picker mode="selector" :range="emergencyTaskTypeOptions" range-key="text" @change="onEmergencyTaskTypeChange">
+          <view class="form-input picker-input">
+            {{ selectedEmergencyTaskType || '璇烽�夋嫨浠诲姟绫诲瀷' }}
+            <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
+          </view>
+        </picker>
+      </view>
+      
+      <view class="form-item">
+        <view class="form-label required">鍗曟嵁绫诲瀷</view>
+        <picker mode="selector" :range="documentTypeOptions" range-key="text" @change="onDocumentTypeChange">
+          <view class="form-input picker-input">
+            {{ selectedDocumentType || '璇烽�夋嫨鍗曟嵁绫诲瀷' }}
+            <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
+          </view>
+        </picker>
+      </view>
+      
+      <view class="form-item">
         <view class="form-label required">杞繍鏃堕棿</view>
         <uni-datetime-picker 
           v-model="taskForm.transferTime" 
@@ -233,6 +253,7 @@
 import { getTask, updateTask } from "@/api/task"
 import { tiandituDistanceByAddress } from "@/api/map"
 import { calculateTransferPrice } from "@/api/price"
+import { getServiceOrdAreaTypes, getServiceOrderTypes } from "@/api/dictionary"
 import MapSelector from './components/map-selector.vue'
 import VehicleSelector from './components/VehicleSelector.vue'
 import OrganizationSelector from './components/OrganizationSelector.vue'
@@ -280,6 +301,17 @@
       departureLatitude: null,
       selectedDiseases: [], // 宸查�夋嫨鐨勭梾鎯呭垪琛紙纭繚鍒濆鍖栦负绌烘暟缁勶級
       selectedStaff: [], // 宸查�夋嫨鐨勪汉鍛樺垪琛紙纭繚鍒濆鍖栦负绌烘暟缁勶級
+      // 浠诲姟绫诲瀷鍜屽崟鎹被鍨嬬浉鍏�
+      selectedEmergencyTaskType: '', // 閫変腑鐨勪换鍔$被鍨嬫枃鏈�
+      selectedEmergencyTaskTypeId: null, // 閫変腑鐨勪换鍔$被鍨婭D
+      selectedDocumentType: '', // 閫変腑鐨勫崟鎹被鍨嬫枃鏈�
+      selectedDocumentTypeId: null, // 閫変腑鐨勫崟鎹被鍨婭D
+      pendingTaskTypeId: null, // 绛夊緟璁剧疆鐨勪换鍔$被鍨婭D
+      pendingDocumentTypeId: null, // 绛夊緟璁剧疆鐨勫崟鎹被鍨婭D
+      emergencyTaskTypes: [], // 浠诲姟绫诲瀷鍒楄〃锛堜粠 SQL Server 鍔ㄦ�佸姞杞斤級
+      emergencyTaskTypeOptions: [], // 浠诲姟绫诲瀷閫夐」锛堢敤浜巔icker鏄剧ず锛�
+      documentTypes: [], // 鍗曟嵁绫诲瀷鍒楄〃
+      documentTypeOptions: [], // 鍗曟嵁绫诲瀷閫夐」锛堢敤浜巔icker鏄剧ず锛�
       taskForm: {
         transferTime: '',
         patient: {
@@ -326,6 +358,10 @@
     if (options.id) {
       this.taskId = options.id
       this.loadTaskDetail()
+      // 鍔犺浇浠诲姟绫诲瀷鏁版嵁
+      this.loadEmergencyTaskTypes()
+      // 鍔犺浇鍗曟嵁绫诲瀷鏁版嵁
+      this.loadDocumentTypes()
     } else {
       this.$modal.showToast('浠诲姟ID涓嶈兘涓虹┖')
       setTimeout(() => {
@@ -420,6 +456,31 @@
           // 杞繍璺濈鍜屼环鏍�
           this.taskForm.transferDistance = info.transferDistance ? String(info.transferDistance) : ''
           this.taskForm.price = info.transferPrice ? String(info.transferPrice) : ''
+          
+          // 浠诲姟绫诲瀷鍜屽崟鎹被鍨�
+          if (info.taskTypeId) {
+            // 鐩存帴璁剧疆浠诲姟绫诲瀷锛屽鏋滈�夐」杩樻湭鍔犺浇瀹屾垚锛屽垯鍦ㄥ姞杞藉畬鎴愬悗鍐嶆璁剧疆
+            const taskType = this.emergencyTaskTypeOptions.find(option => option.id == info.taskTypeId)
+            if (taskType) {
+              this.selectedEmergencyTaskType = taskType.text
+              this.selectedEmergencyTaskTypeId = taskType.id
+            } else {
+              // 濡傛灉閫夐」杩樻湭鍔犺浇瀹屾垚锛屾爣璁伴渶瑕佽缃殑ID
+              this.pendingTaskTypeId = info.taskTypeId
+            }
+          }
+          
+          if (info.documentTypeId) {
+            // 鐩存帴璁剧疆鍗曟嵁绫诲瀷锛屽鏋滈�夐」杩樻湭鍔犺浇瀹屾垚锛屽垯鍦ㄥ姞杞藉畬鎴愬悗鍐嶆璁剧疆
+            const docType = this.documentTypeOptions.find(option => option.id == info.documentTypeId)
+            if (docType) {
+              this.selectedDocumentType = docType.text
+              this.selectedDocumentTypeId = docType.id
+            } else {
+              // 濡傛灉閫夐」杩樻湭鍔犺浇瀹屾垚锛屾爣璁伴渶瑕佽缃殑ID
+              this.pendingDocumentTypeId = info.documentTypeId
+            }
+          }
         } else {
           console.warn('浠诲姟璇︽儏涓病鏈塭mergencyInfo瀛楁锛屽皾璇曚粠涓诲璞¤幏鍙栨暟鎹�')
           // 鍏煎澶勭悊锛氬鏋渆mergencyInfo涓嶅瓨鍦紝灏濊瘯浠庝富瀵硅薄鑾峰彇
@@ -509,6 +570,92 @@
     // 杞﹁締閫夋嫨鍙樺寲
     onVehicleChange(vehicle) {
       console.log('閫変腑杞﹁締:', vehicle)
+    },
+    
+    // 鍔犺浇浠诲姟绫诲瀷鏁版嵁锛堜粠 SQL Server锛�
+    loadEmergencyTaskTypes() {
+      getServiceOrderTypes().then(response => {
+        const list = response.data || []
+        this.emergencyTaskTypes = list
+        this.emergencyTaskTypeOptions = list.map(item => ({
+          id: item.vID,
+          text: item.vtext
+        }))
+        
+        // 濡傛灉浠诲姟璇︽儏宸插姞杞斤紝璁剧疆褰撳墠閫変腑鐨勪换鍔$被鍨�
+        if (this.taskDetail && this.taskDetail.emergencyInfo && this.taskDetail.emergencyInfo.taskTypeId) {
+          const currentType = this.emergencyTaskTypeOptions.find(option => option.id == this.taskDetail.emergencyInfo.taskTypeId)
+          if (currentType) {
+            this.selectedEmergencyTaskType = currentType.text
+            this.selectedEmergencyTaskTypeId = currentType.id
+          }
+        }
+        
+        // 妫�鏌ユ槸鍚︽湁寰呰缃殑浠诲姟绫诲瀷ID
+        if (this.pendingTaskTypeId) {
+          const pendingType = this.emergencyTaskTypeOptions.find(option => option.id == this.pendingTaskTypeId)
+          if (pendingType) {
+            this.selectedEmergencyTaskType = pendingType.text
+            this.selectedEmergencyTaskTypeId = pendingType.id
+            this.pendingTaskTypeId = null
+          }
+        }
+      }).catch(error => {
+        console.error('鍔犺浇浠诲姟绫诲瀷澶辫触:', error)
+        this.emergencyTaskTypes = []
+        this.emergencyTaskTypeOptions = []
+      })
+    },
+    
+    // 浠诲姟绫诲瀷閫夋嫨
+    onEmergencyTaskTypeChange(e) {
+      const index = e.detail.value
+      const selected = this.emergencyTaskTypeOptions[index]
+      this.selectedEmergencyTaskType = selected.text
+      this.selectedEmergencyTaskTypeId = selected.id
+    },
+    
+    // 鍔犺浇鍗曟嵁绫诲瀷鏁版嵁
+    loadDocumentTypes() {
+      getServiceOrdAreaTypes().then(response => {
+        const list = response.data || []
+        this.documentTypes = list
+        this.documentTypeOptions = list.map(item => ({
+          id: item.vID,
+          text: item.vtext
+        }))
+        
+        // 濡傛灉浠诲姟璇︽儏宸插姞杞斤紝璁剧疆褰撳墠閫変腑鐨勫崟鎹被鍨�
+        if (this.taskDetail && this.taskDetail.emergencyInfo && this.taskDetail.emergencyInfo.documentTypeId) {
+          const currentType = this.documentTypeOptions.find(option => option.id == this.taskDetail.emergencyInfo.documentTypeId)
+          if (currentType) {
+            this.selectedDocumentType = currentType.text
+            this.selectedDocumentTypeId = currentType.id
+          }
+        }
+        
+        // 妫�鏌ユ槸鍚︽湁寰呰缃殑鍗曟嵁绫诲瀷ID
+        if (this.pendingDocumentTypeId) {
+          const pendingType = this.documentTypeOptions.find(option => option.id == this.pendingDocumentTypeId)
+          if (pendingType) {
+            this.selectedDocumentType = pendingType.text
+            this.selectedDocumentTypeId = pendingType.id
+            this.pendingDocumentTypeId = null
+          }
+        }
+      }).catch(error => {
+        console.error('鍔犺浇鍗曟嵁绫诲瀷澶辫触:', error)
+        this.documentTypes = []
+        this.documentTypeOptions = []
+      })
+    },
+    
+    // 鍗曟嵁绫诲瀷閫夋嫨
+    onDocumentTypeChange(e) {
+      const index = e.detail.value
+      const selected = this.documentTypeOptions[index]
+      this.selectedDocumentType = selected.text
+      this.selectedDocumentTypeId = selected.id
     },
     
     // 鍔犺浇鎵�鏈夋満鏋処D
@@ -815,6 +962,16 @@
         return false
       }
       
+      if (!this.selectedEmergencyTaskType) {
+        this.$modal.showToast('璇烽�夋嫨浠诲姟绫诲瀷')
+        return false
+      }
+      
+      if (!this.selectedDocumentType) {
+        this.$modal.showToast('璇烽�夋嫨鍗曟嵁绫诲瀷')
+        return false
+      }
+      
       if (!this.taskForm.patient.contact) {
         this.$modal.showToast('璇疯緭鍏ヨ仈绯讳汉')
         return false
@@ -940,6 +1097,9 @@
         deptId: this.selectedOrganizationId,
         vehicleIds: this.selectedVehicleId ? [this.selectedVehicleId] : [],
         plannedStartTime: this.taskForm.transferTime,
+        // 浠诲姟绫诲瀷鍜屽崟鎹被鍨�
+        taskTypeId: this.selectedEmergencyTaskTypeId,
+        documentTypeId: this.selectedDocumentTypeId,
         
         // 鍑哄彂鍦板湴鍧�鍜屽潗鏍囷紙浣跨敤杞嚭鍖婚櫌鍦板潃锛�
         departureAddress: this.departureAddress || this.taskForm.hospitalOut.address,
@@ -1178,6 +1338,7 @@
     }
   }
 }
+
 </script>
 
 <style lang="scss" scoped>
@@ -1389,4 +1550,5 @@
       }
     }
   }
-}
\ No newline at end of file
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.1