From 2cd31915236257e325b49f2e86f6912512e1f7ce Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 02 十一月 2025 14:27:15 +0800
Subject: [PATCH] fix:app 用户登录,默认不勾选用户协议

---
 app/pages/task/create-emergency.vue |  733 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 623 insertions(+), 110 deletions(-)

diff --git a/app/pages/task/create-emergency.vue b/app/pages/task/create-emergency.vue
index cefe5b2..21fa1c0 100644
--- a/app/pages/task/create-emergency.vue
+++ b/app/pages/task/create-emergency.vue
@@ -4,27 +4,55 @@
       <view class="back-btn" @click="goBack">
         <uni-icons type="arrowleft" size="20"></uni-icons>
       </view>
-      <view class="title">鍒涘缓闈炴�ユ晳杞繍浠诲姟</view>
+      <view class="title">鍒涘缓杞繍浠诲姟</view>
     </view>
     
     <view class="form-section">
       <view class="form-item">
-        <view class="form-label">浠诲姟杞﹁締</view>
-        <picker mode="selector" :range="vehicles" @change="onVehicleChange">
+        <view class="form-label required">浠诲姟杞﹁締</view>
+        <picker mode="selector" :range="vehicles" :value="selectedVehicleIndex" @change="onVehicleChange">
           <view class="form-input picker-input">
             {{ selectedVehicle || '璇烽�夋嫨浠诲姟杞﹁締' }}
             <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
           </view>
         </picker>
       </view>
+        <view class="form-item">
+        <view class="form-label">褰掑睘鏈烘瀯</view>
+        <picker mode="selector" :range="organizations" @change="onOrganizationChange">
+          <view class="form-input picker-input">
+            {{ selectedOrganization || '璇烽�夋嫨褰掑睘鏈烘瀯' }}
+            <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="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">鎵ц浠诲姟浜哄憳</view>
         <view class="staff-list">
           <view class="staff-item" v-for="(staff, index) in selectedStaff" :key="staff.userId">
             <view class="staff-info">
               <text class="staff-name">{{ staff.nickName }}</text>
-              <text class="staff-role">({{ staff.postName || staff.roleName || '鏈煡鑱屼綅' }})</text>
+              <text class="staff-role">({{ getUserTypeName(staff.type) || '鏈煡鑱屼綅' }})</text>
             </view>
             <uni-icons 
               v-if="index > 0" 
@@ -47,28 +75,10 @@
         </view>
       </view>
       
-      <view class="form-item">
-        <view class="form-label">褰掑睘鏈烘瀯</view>
-        <picker mode="selector" :range="organizations" @change="onOrganizationChange">
-          <view class="form-input picker-input">
-            {{ selectedOrganization || '璇烽�夋嫨褰掑睘鏈烘瀯' }}
-            <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
-          </view>
-        </picker>
-      </view>
+    
       
       <view class="form-item">
-        <view class="form-label">浠诲姟绫诲瀷</view>
-        <picker mode="selector" :range="emergencyTaskTypes" @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">杞繍鏃堕棿</view>
+        <view class="form-label required">杞繍鏃堕棿</view>
         <uni-datetime-picker 
           v-model="taskForm.transferTime" 
           type="datetime" 
@@ -79,7 +89,7 @@
       
       <view class="form-section-title">鎮h�呬俊鎭�</view>
       <view class="form-item">
-        <view class="form-label">鑱旂郴浜�</view>
+        <view class="form-label required">鑱旂郴浜�</view>
         <input 
           class="form-input" 
           placeholder="璇疯緭鍏ヨ仈绯讳汉" 
@@ -88,7 +98,7 @@
       </view>
       
       <view class="form-item">
-        <view class="form-label">鑱旂郴鐢佃瘽</view>
+        <view class="form-label required">鑱旂郴鐢佃瘽</view>
         <input 
           class="form-input" 
           type="number" 
@@ -98,7 +108,7 @@
       </view>
       
       <view class="form-item">
-        <view class="form-label">鎮h�呭鍚�</view>
+        <view class="form-label required">鎮h�呭鍚�</view>
         <input 
           class="form-input" 
           placeholder="璇疯緭鍏ユ偅鑰呭鍚�" 
@@ -163,14 +173,14 @@
       
       <view class="form-section-title">杞嚭鍖婚櫌淇℃伅</view>
       <view class="form-item">
-        <view class="form-label">鍖婚櫌鍚嶇О</view>
+        <view class="form-label required">鍖婚櫌鍚嶇О</view>
         <view class="hospital-search-container">
           <input 
             class="form-input" 
             placeholder="璇疯緭鍏ュ尰闄㈠悕绉版垨鍦板潃鎼滅储" 
             v-model="hospitalOutSearchKeyword"
             @input="onHospitalOutSearch"
-            @focus="showHospitalOutResults = true"
+            @focus="onHospitalOutFocus"
           />
           <view class="search-results" v-if="showHospitalOutResults && hospitalOutResults.length > 0">
             <view 
@@ -180,19 +190,20 @@
               @click="selectHospitalOut(hospital)"
             >
               <view class="hospital-name">{{ hospital.hospName }}</view>
-              <view class="hospital-address">{{ hospital.hospAddress }}</view>
+              <view class="hospital-address">{{ buildFullAddress(hospital) }}</view>
             </view>
           </view>
         </view>
       </view>
       
       <view class="form-item">
-        <view class="form-label">绉戝</view>
-        <input 
-          class="form-input" 
-          placeholder="璇疯緭鍏ョ瀹�" 
-          v-model="taskForm.hospitalOut.department"
-        />
+        <view class="form-label required">绉戝</view>
+        <picker mode="selector" :range="departmentOptions" range-key="text" @change="onHospitalOutDepartmentChange">
+          <view class="form-input picker-input">
+            {{ taskForm.hospitalOut.department || '璇烽�夋嫨绉戝' }}
+            <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
+          </view>
+        </picker>
       </view>
       
       <view class="form-item">
@@ -213,14 +224,14 @@
       
       <view class="form-section-title">杞叆鍖婚櫌淇℃伅</view>
       <view class="form-item">
-        <view class="form-label">鍖婚櫌鍚嶇О</view>
+        <view class="form-label required">鍖婚櫌鍚嶇О</view>
         <view class="hospital-search-container">
           <input 
             class="form-input" 
             placeholder="璇疯緭鍏ュ尰闄㈠悕绉版垨鍦板潃鎼滅储" 
             v-model="hospitalInSearchKeyword"
             @input="onHospitalInSearch"
-            @focus="showHospitalInResults = true"
+            @focus="onHospitalInFocus"
           />
           <view class="search-results" v-if="showHospitalInResults && hospitalInResults.length > 0">
             <view 
@@ -230,19 +241,20 @@
               @click="selectHospitalIn(hospital)"
             >
               <view class="hospital-name">{{ hospital.hospName }}</view>
-              <view class="hospital-address">{{ hospital.hospAddress }}</view>
+              <view class="hospital-address">{{ buildFullAddress(hospital) }}</view>
             </view>
           </view>
         </view>
       </view>
       
       <view class="form-item">
-        <view class="form-label">绉戝</view>
-        <input 
-          class="form-input" 
-          placeholder="璇疯緭鍏ョ瀹�" 
-          v-model="taskForm.hospitalIn.department"
-        />
+        <view class="form-label required">绉戝</view>
+        <picker mode="selector" :range="departmentOptions" range-key="text" @change="onHospitalInDepartmentChange">
+          <view class="form-input picker-input">
+            {{ taskForm.hospitalIn.department || '璇烽�夋嫨绉戝' }}
+            <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
+          </view>
+        </picker>
       </view>
       
       <view class="form-item">
@@ -311,14 +323,14 @@
         <view class="staff-filter">
           <view 
             class="filter-item" 
-            :class="{ active: staffFilterType === 'all' }"
-            @click="filterStaff('all')"
-          >鍏ㄩ儴</view>
-          <view 
-            class="filter-item" 
             :class="{ active: staffFilterType === 'driver' }"
             @click="filterStaff('driver')"
           >鍙告満</view>
+          <view 
+            class="filter-item" 
+            :class="{ active: staffFilterType === 'doctor' }"
+            @click="filterStaff('doctor')"
+          >鍖荤敓</view>
           <view 
             class="filter-item" 
             :class="{ active: staffFilterType === 'nurse' }"
@@ -340,7 +352,7 @@
               </view>
               <view class="staff-detail-row">
                 <text class="staff-dept">{{ staff.deptName }}</text>
-                <text class="staff-post">{{ staff.postName || staff.roleName || '鏈煡鑱屼綅' }}</text>
+                <text class="staff-post">{{ staff.postName || staff.roleName  || '鏈煡鑱屼綅' }}</text>
               </view>
             </view>
             <uni-icons 
@@ -410,14 +422,9 @@
             <view v-else class="checkbox-empty"></view>
           </view>
           
-          <view class="no-data" v-if="diseaseSearchResults.length === 0 && diseaseSearchKeyword">
+          <view class="no-data" v-if="diseaseSearchResults.length === 0">
             <uni-icons type="info" size="40" color="#ccc"></uni-icons>
-            <text>鏈壘鍒扮浉鍏崇柧鐥�</text>
-          </view>
-          
-          <view class="no-data" v-if="diseaseSearchResults.length === 0 && !diseaseSearchKeyword">
-            <uni-icons type="search" size="40" color="#ccc"></uni-icons>
-            <text>璇疯緭鍏ュ叧閿瘝鎼滅储鐤剧梾</text>
+            <text>{{ diseaseSearchKeyword ? '鏈壘鍒扮浉鍏崇柧鐥�' : '鏆傛棤鐥呮儏鏁版嵁' }}</text>
           </view>
         </scroll-view>
         
@@ -435,11 +442,15 @@
 import uniDatetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue'
 import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
 import { addTask } from "@/api/task"
-import { listAvailableVehicles } from "@/api/vehicle"
-import { calculateDistance } from "@/api/map"
+import { listAvailableVehicles, getUserBoundVehicle } from "@/api/vehicle"
+import { calculateDistance, baiduDistanceByAddress } from "@/api/map"
 import { searchHospitals } from "@/api/hospital"
 import { listUser } from "@/api/system/user"
 import { searchIcd10 } from "@/api/icd10"
+
+import { getDicts } from "@/api/dict"
+import { getServiceOrdAreaTypes, getServiceOrderTypes, getHospitalDepartments } from "@/api/dictionary"
+import { listBranchCompany } from "@/api/system/dept"
 import MapSelector from '@/components/map-selector.vue'
 
 export default {
@@ -453,7 +464,12 @@
       selectedVehicle: '',
       selectedVehicleId: null,
       selectedOrganization: '',
-      selectedEmergencyTaskType: '',
+      selectedOrganizationId: null, // 褰掑睘鏈烘瀯ID锛堥儴闂↖D锛�
+      selectedRegion: '', // 浠庡綊灞炴満鏋勪腑鎻愬彇鐨勫湴鍩熶俊鎭紙濡傦細骞垮窞銆佹繁鍦崇瓑锛�
+      selectedEmergencyTaskType: '', // 閫変腑鐨勪换鍔$被鍨嬫枃鏈�
+      selectedEmergencyTaskTypeId: null, // 閫変腑鐨勪换鍔$被鍨婭D
+      selectedDocumentType: '', // 閫変腑鐨勫崟鎹被鍨嬫枃鏈�
+      selectedDocumentTypeId: null, // 閫変腑鐨勫崟鎹被鍨婭D
       mapSelectorType: '',
       // 鍖婚櫌鎼滅储鐩稿叧
       hospitalOutSearchKeyword: '',
@@ -463,12 +479,13 @@
       hospitalInResults: [],
       showHospitalInResults: false,
       searchTimer: null,
+      defaultHospitals: [], // 榛樿鐨�100鏉″尰闄㈡暟鎹�
       // 浜哄憳閫夋嫨鐩稿叧
       selectedStaff: [], // 宸查�夋嫨鐨勪汉鍛樺垪琛�
       allStaffList: [], // 鎵�鏈変汉鍛樺垪琛�
       filteredStaffList: [], // 杩囨护鍚庣殑浜哄憳鍒楄〃
       staffSearchKeyword: '', // 浜哄憳鎼滅储鍏抽敭璇�
-      staffFilterType: 'all', // 浜哄憳绛涢�夌被鍨嬶細all/driver/nurse
+      staffFilterType: 'driver', // 浜哄憳绛涢�夌被鍨嬶細driver/doctor/nurse锛岄粯璁ら�変腑鍙告満
       // 鐥呮儏閫夋嫨鐩稿叧
       selectedDiseases: [], // 宸查�夋嫨鐨勭梾鎯呭垪琛�
       tempSelectedDiseases: [], // 涓存椂閫夋嫨鐨勭梾鎯呭垪琛紙鐢ㄤ簬寮圭獥锛�
@@ -486,14 +503,18 @@
           condition: ''
         },
         hospitalOut: {
+          id: null,  // 鍖婚櫌ID
           name: '',
           department: '',
+          departmentId: null,  // 绉戝ID
           bedNumber: '',
           address: ''
         },
         hospitalIn: {
+          id: null,  // 鍖婚櫌ID
           name: '',
           department: '',
+          departmentId: null,  // 绉戝ID
           bedNumber: '',
           address: ''
         },
@@ -502,8 +523,13 @@
       },
       vehicles: [],
       vehicleOptions: [],
-      organizations: ['骞垮窞鍒嗗叕鍙�', '娣卞湷鍒嗗叕鍙�', '鐝犳捣鍒嗗叕鍙�', '浣涘北鍒嗗叕鍙�'],
-      emergencyTaskTypes: ['鎬ユ晳杞繍', '鑸┖杞繍'],
+      organizations: [], // 褰掑睘鏈烘瀯鍒楄〃锛堜粠鍚庡彴鍔犺浇鍒嗗叕鍙告暟鎹級
+      organizationOptions: [], // 褰掑睘鏈烘瀯閫夐」锛堢敤浜巔icker鏄剧ず锛�
+      emergencyTaskTypes: [], // 浠诲姟绫诲瀷鍒楄〃锛堜粠 SQL Server 鍔ㄦ�佸姞杞斤級
+      emergencyTaskTypeOptions: [], // 浠诲姟绫诲瀷閫夐」锛堢敤浜巔icker鏄剧ず锛�
+      documentTypes: [], // 鍗曟嵁绫诲瀷鍒楄〃
+      documentTypeOptions: [], // 鍗曟嵁绫诲瀷閫夐」锛堢敤浜巔icker鏄剧ず锛�
+      departmentOptions: [], // 绉戝瀛楀吀鏁版嵁
       loading: false,
       addressCoordinates: {
         hospitalOutAddress: null,
@@ -515,20 +541,82 @@
     ...mapState({
       currentUser: state => ({
         userId: state.user.userId,
-        name: state.user.name || '寮犱笁',
-        nickName: state.user.nickName || state.user.name || '寮犱笁',
+        name: state.user.nickName || '寮犱笁',
+        nickName: state.user.nickName || '寮犱笁',
         position: '鍙告満',
         deptId: state.user.deptId || 100,
-        phonenumber: state.user.phonenumber || ''
+        phonenumber: state.user.phonenumber || '',
+        branchCompanyId: state.user.branchCompanyId,
+        branchCompanyName: state.user.branchCompanyName
       })
-    })
+    }),
+    // 璁$畻杞﹁締鍦╬icker涓殑绱㈠紩锛岀敤浜庨粯璁ら�変腑
+    selectedVehicleIndex() {
+      if (!this.selectedVehicle || this.vehicles.length === 0) {
+        return 0
+      }
+      const index = this.vehicles.findIndex(v => v === this.selectedVehicle)
+      return index !== -1 ? index : 0
+    }
   },
   onLoad(options) {
-    this.getAvailableVehicles()
+    // 璁剧疆榛樿杞繍鏃堕棿涓哄綋鍓嶆椂闂�
+    this.setDefaultTransferTime()
+    
+    // 鍏堝姞杞借溅杈嗗垪琛紝鐒跺悗鍔犺浇缁戝畾杞﹁締淇℃伅
+    this.getAvailableVehicles().then(() => {
+      this.getUserBoundVehicleInfo()
+    })
     this.initSelectedStaff()
     this.loadDeptStaff()
+    // 鍔犺浇鍒嗗叕鍙告暟鎹紙浼氳嚜鍔ㄨ缃粯璁ゅ垎鍏徃骞跺姞杞藉尰闄㈠垪琛級
+    this.loadBranchCompanies()
+    // 鍔犺浇绉戝瀛楀吀鏁版嵁
+    this.loadDepartments()
+    // 鍔犺浇浠诲姟绫诲瀷鏁版嵁
+    this.loadEmergencyTaskTypes()
+    // 鍔犺浇鍗曟嵁绫诲瀷鏁版嵁
+    this.loadDocumentTypes()
   },
   methods: {
+    // 鑾峰彇鐢ㄦ埛缁戝畾鐨勮溅杈嗕俊鎭�
+    getUserBoundVehicleInfo() {
+      const userId = this.currentUser.userId
+      if (!userId) {
+        console.warn('鐢ㄦ埛ID涓嶅瓨鍦紝鏃犳硶鑾峰彇缁戝畾杞﹁締')
+        return
+      }
+      
+      getUserBoundVehicle(userId).then(response => {
+        const boundVehicle = response.data
+        
+        if (boundVehicle && boundVehicle.vehicleId) {
+          const boundVehicleNo = boundVehicle.vehicleNo
+          const boundVehicleId = boundVehicle.vehicleId
+          
+          console.log('鐢ㄦ埛缁戝畾鐨勮溅杈�:', boundVehicleNo, 'ID:', boundVehicleId)
+          
+          // 鍦ㄨ溅杈嗗垪琛ㄤ腑鏌ユ壘缁戝畾鐨勮溅杈�
+          const vehicleIndex = this.vehicleOptions.findIndex(v => 
+            v.id === boundVehicleId || v.name === boundVehicleNo
+          )
+          
+          if (vehicleIndex !== -1) {
+            // 璁剧疆榛樿閫変腑鐨勮溅杈�
+            this.selectedVehicle = this.vehicleOptions[vehicleIndex].name
+            this.selectedVehicleId = this.vehicleOptions[vehicleIndex].id
+            console.log('榛樿閫変腑杞﹁締:', this.selectedVehicle)
+          } else {
+            console.warn('缁戝畾鐨勮溅杈嗕笉鍦ㄥ彲鐢ㄨ溅杈嗗垪琛ㄤ腑')
+          }
+        } else {
+          console.log('鐢ㄦ埛鏈粦瀹氳溅杈�')
+        }
+      }).catch(error => {
+        console.error('鑾峰彇鐢ㄦ埛缁戝畾杞﹁締淇℃伅澶辫触:', error)
+      })
+    },
+    
     getAvailableVehicles() {
       const deptId = this.currentUser.deptId
       return listAvailableVehicles(deptId, 'EMERGENCY').then(response => {
@@ -552,11 +640,217 @@
     },
     
     onOrganizationChange(e) {
-      this.selectedOrganization = this.organizations[e.detail.value]
+      const index = e.detail.value
+      const selected = this.organizationOptions[index]
+      this.selectedOrganization = selected.deptName
+      this.selectedOrganizationId = selected.deptId // 淇濆瓨閮ㄩ棬ID
+      // 浠庡綊灞炴満鏋勪腑鎻愬彇鍦板煙鍏抽敭璇嶏紙鍘婚櫎"鍒嗗叕鍙�"鍚庣紑锛�
+      // 渚嬪锛�"骞垮窞鍒嗗叕鍙�" -> "骞垮窞"
+      this.selectedRegion = selected.deptName.replace(/鍒嗗叕鍙�$/g, '').trim()
+      // 閲嶆柊鍔犺浇鍖婚櫌鍒楄〃锛堝甫鍦板煙杩囨护锛�
+      this.loadDefaultHospitals()
     },
     
+    // 鍔犺浇鍒嗗叕鍙告暟鎹紙parent_id=100鐨勯儴闂級
+    loadBranchCompanies() {
+      listBranchCompany().then(response => {
+        const list = response.data || []
+        // 杩囨护鍑� parent_id = 100 鐨勯儴闂紙鍒嗗叕鍙革級
+        this.organizationOptions = list.filter(dept => dept.parentId === 100)
+        // 鐢熸垚picker鐨勬暟鎹簮锛堝彧鏄剧ず鍚嶇О锛�
+        this.organizations = this.organizationOptions.map(dept => dept.deptName)
+        
+        // 榛樿璁剧疆涓哄綋鍓嶇敤鎴风殑鍒嗗叕鍙�
+        if (this.currentUser.branchCompanyName) {
+          const index = this.organizationOptions.findIndex(
+            dept => dept.deptName === this.currentUser.branchCompanyName
+          )
+          if (index !== -1) {
+            this.selectedOrganization = this.currentUser.branchCompanyName
+            this.selectedOrganizationId = this.organizationOptions[index].deptId // 淇濆瓨閮ㄩ棬ID
+            // 鎻愬彇鍦板煙鍏抽敭璇�
+            this.selectedRegion = this.selectedOrganization.replace(/鍒嗗叕鍙�$/g, '').trim()
+            console.log('榛樿閫変腑褰掑睘鏈烘瀯:', this.selectedOrganization, '閮ㄩ棬ID:', this.selectedOrganizationId, '鍦板煙:', this.selectedRegion)
+            // 鍔犺浇鍖婚櫌鍒楄〃锛堝甫鍦板煙杩囨护锛�
+            this.loadDefaultHospitals()
+          }
+        }
+      }).catch(error => {
+        console.error('鍔犺浇鍒嗗叕鍙告暟鎹け璐�:', error)
+        this.organizationOptions = []
+        this.organizations = []
+      })
+    },
+    
+    // 鍔犺浇绉戝鏁版嵁锛堜粠 SQL Server 鍔ㄦ�佸姞杞斤級
+    loadDepartments() {
+      getHospitalDepartments().then(response => {
+        const list = response.data || [];
+        this.departmentOptions = list.map(item => ({
+          id: item.vID,
+          text: item.vtext,
+          dictValue: item.vtext  // 涓轰簡淇濇寔鍏煎鎬э紝淇濈暀dictValue瀛楁
+        }));
+        // console.log('绉戝鏁版嵁鍔犺浇鎴愬姛:', this.departmentOptions);
+      }).catch(error => {
+        console.error('鍔犺浇绉戝鏁版嵁澶辫触:', error)
+        this.departmentOptions = []
+      })
+    },
+    
+    // 鍔犺浇浠诲姟绫诲瀷鏁版嵁锛堜粠 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.emergencyTaskTypeOptions.length > 0) {
+          this.selectedEmergencyTaskType = this.emergencyTaskTypeOptions[0].text
+          this.selectedEmergencyTaskTypeId = this.emergencyTaskTypeOptions[0].id
+          console.log('榛樿閫変腑浠诲姟绫诲瀷:', this.selectedEmergencyTaskType)
+        }
+      }).catch(error => {
+        console.error('鍔犺浇浠诲姟绫诲瀷澶辫触:', error)
+        this.emergencyTaskTypes = []
+        this.emergencyTaskTypeOptions = []
+      })
+    },
+    
+    // 浠诲姟绫诲瀷閫夋嫨
     onEmergencyTaskTypeChange(e) {
-      this.selectedEmergencyTaskType = this.emergencyTaskTypes[e.detail.value]
+      const index = e.detail.value
+      const selected = this.emergencyTaskTypeOptions[index]
+      this.selectedEmergencyTaskType = selected.text
+      this.selectedEmergencyTaskTypeId = selected.id
+    },
+    getUserTypeName(staffType){
+      switch(staffType){
+        case "nurse":
+          return "鎶ゅ+";
+        case "doctor":
+          return "鍖荤敓";
+        case "driver":
+          return "鍙告満";
+        default:
+          return "鍙告満";
+      }
+    },
+    
+    // 鍔犺浇鍗曟嵁绫诲瀷鏁版嵁
+    loadDocumentTypes() {
+      getServiceOrdAreaTypes().then(response => {
+        const list = response.data || []
+        this.documentTypes = list
+        this.documentTypeOptions = list.map(item => ({
+          id: item.vID,
+          text: item.vtext
+        }))
+        
+        // 榛樿閫変腑绗竴涓崟鎹被鍨�
+        if (this.documentTypeOptions.length > 0) {
+          this.selectedDocumentType = this.documentTypeOptions[0].text
+          this.selectedDocumentTypeId = this.documentTypeOptions[0].id
+          console.log('榛樿閫変腑鍗曟嵁绫诲瀷:', this.selectedDocumentType)
+        }
+      }).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
+    },
+    
+    // 杞嚭鍖婚櫌绉戝閫夋嫨
+    onHospitalOutDepartmentChange(e) {
+      const index = e.detail.value
+      const selected = this.departmentOptions[index]
+      this.taskForm.hospitalOut.department = selected.text  // 淇濆瓨绉戝鍚嶇О
+      this.taskForm.hospitalOut.departmentId = selected.id  // 淇濆瓨绉戝ID
+    },
+    
+    // 杞叆鍖婚櫌绉戝閫夋嫨
+    onHospitalInDepartmentChange(e) {
+      const index = e.detail.value
+      const selected = this.departmentOptions[index]
+      this.taskForm.hospitalIn.department = selected.text  // 淇濆瓨绉戝鍚嶇О
+      this.taskForm.hospitalIn.departmentId = selected.id  // 淇濆瓨绉戝ID
+    },
+    
+    // 鍔犺浇榛樿鍖婚櫌鍒楄〃锛堝墠100鏉★級
+    loadDefaultHospitals() {
+      // 杞嚭鍖婚櫌锛氬彧鍔犺浇褰撳墠鍖哄煙鐨勫尰闄紙甯﹀湴鍩熻繃婊わ級
+      searchHospitals('', this.selectedRegion).then(response => {
+        this.hospitalOutResults = response.data || []
+        console.log('鍔犺浇杞嚭鍖婚櫌锛堝綋鍓嶅尯鍩燂級:', this.selectedRegion, '鏁伴噺:', this.hospitalOutResults.length)
+      }).catch(error => {
+        console.error('鍔犺浇杞嚭鍖婚櫌鍒楄〃澶辫触:', error)
+        this.hospitalOutResults = []
+      })
+      
+      // 杞叆鍖婚櫌锛氬姞杞芥墍鏈夊尰闄紙涓嶅甫鍦板煙杩囨护锛屽悗缁細鎸夊湴鍩熸帓搴忥級
+      searchHospitals('', this.selectedRegion).then(response => {
+        const allHospitals = response.data || []
+        // 灏嗗尰闄㈡寜鍦板煙鎺掑簭锛氭湰鍦板尯鍩熶紭鍏�
+        this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+        console.log('鍔犺浇杞叆鍖婚櫌锛堝叏閮ㄥ尯鍩燂級:', '鏁伴噺:', this.hospitalInResults.length)
+      }).catch(error => {
+        console.error('鍔犺浇杞叆鍖婚櫌鍒楄〃澶辫触:', error)
+        this.hospitalInResults = []
+      })
+    },
+    
+    // 鎸夊湴鍩熸帓搴忓尰闄細鏈湴鍖哄煙浼樺厛
+    sortHospitalsByRegion(hospitals) {
+      if (!this.selectedRegion || !hospitals || hospitals.length === 0) {
+        return hospitals
+      }
+      
+      const region = this.selectedRegion
+      const localHospitals = []
+      const otherHospitals = []
+      
+      hospitals.forEach(hospital => {
+        // 鍒ゆ柇鍖婚櫌鏄惁鍦ㄦ湰鍦板尯鍩燂紙鐪併�佸競銆佸尯浠讳竴鍖呭惈鍦板煙鍏抽敭璇嶏級
+        const isLocal = 
+          (hospital.hopsProvince && hospital.hopsProvince.includes(region)) ||
+          (hospital.hopsCity && hospital.hopsCity.includes(region)) ||
+          (hospital.hopsArea && hospital.hopsArea.includes(region))
+        
+        if (isLocal) {
+          localHospitals.push(hospital)
+        } else {
+          otherHospitals.push(hospital)
+        }
+      })
+      
+      // 鏈湴鍖婚櫌鍦ㄥ墠锛屽叾浠栧尰闄㈠湪鍚�
+      return [...localHospitals, ...otherHospitals]
+    },
+    
+    // 杞嚭鍖婚櫌杈撳叆妗嗚幏寰楃劍鐐�
+    onHospitalOutFocus() {
+      // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鍙樉绀哄綋鍓嶅尯鍩熺殑鍖婚櫌
+      if (!this.hospitalOutSearchKeyword || this.hospitalOutSearchKeyword.trim() === '') {
+        searchHospitals('', this.selectedRegion).then(response => {
+          this.hospitalOutResults = response.data || []
+        }).catch(error => {
+          console.error('鍔犺浇杞嚭鍖婚櫌澶辫触:', error)
+          this.hospitalOutResults = []
+        })
+      }
+      this.showHospitalOutResults = true
     },
     
     // 杞嚭鍖婚櫌鎼滅储
@@ -569,45 +863,71 @@
         clearTimeout(this.searchTimer)
       }
       
+      // 濡傛灉鍏抽敭璇嶄负绌猴紝鍙樉绀哄綋鍓嶅尯鍩熺殑鍖婚櫌
       if (!keyword || keyword.trim() === '') {
-        this.hospitalOutResults = []
+        searchHospitals('', this.selectedRegion).then(response => {
+          this.hospitalOutResults = response.data || []
+        }).catch(error => {
+          console.error('鍔犺浇杞嚭鍖婚櫌澶辫触:', error)
+          this.hospitalOutResults = []
+        })
+        this.showHospitalOutResults = true
         return
       }
       
+      // 鏈夊叧閿瘝鏃讹紝鍘绘湇鍔$鎼滅储锛堜粎闄愬綋鍓嶅尯鍩燂級
       this.searchTimer = setTimeout(() => {
         this.searchHospitalOut(keyword)
       }, 300)
     },
     
-    // 鎼滅储杞嚭鍖婚櫌
+    // 鎼滅储杞嚭鍖婚櫌锛堜粎闄愬綋鍓嶅尯鍩燂級
     searchHospitalOut(keyword) {
-      searchHospitals(keyword).then(response => {
+      // 浼犲叆鍏抽敭璇嶅拰鍦板煙杩囨护锛屽彧鎼滅储褰撳墠鍖哄煙鐨勫尰闄�
+      searchHospitals(keyword, this.selectedRegion).then(response => {
         this.hospitalOutResults = response.data || []
         this.showHospitalOutResults = true
+        console.log('鎼滅储杞嚭鍖婚櫌:', keyword, '鍖哄煙:', this.selectedRegion, '缁撴灉鏁�:', this.hospitalOutResults.length)
       }).catch(error => {
-        console.error('鎼滅储鍖婚櫌澶辫触:', error)
+        console.error('鎼滅储杞嚭鍖婚櫌澶辫触:', error)
         this.hospitalOutResults = []
       })
     },
     
     // 閫夋嫨杞嚭鍖婚櫌
     selectHospitalOut(hospital) {
+      this.taskForm.hospitalOut.id = hospital.hospId  // 淇濆瓨鍖婚櫌ID
       this.taskForm.hospitalOut.name = hospital.hospName
-      this.taskForm.hospitalOut.address = hospital.hospAddress
+      // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
+      const fullAddress = this.buildFullAddress(hospital)
+      this.taskForm.hospitalOut.address = fullAddress
       this.hospitalOutSearchKeyword = hospital.hospName
       this.showHospitalOutResults = false
       this.hospitalOutResults = []
       
-      // 濡傛灉鏈塆PS鍧愭爣锛屼繚瀛樹笅鏉�
-      // 娉ㄦ剰锛欻ospData琛ㄤ腑鍙兘娌℃湁GPS鍧愭爣锛岄渶瑕佹牴鎹湴鍧�杩涜鍦扮悊缂栫爜
-      // 杩欓噷鍏堢疆涓簄ull锛屽悗缁彲浠ラ�氳繃鍦板潃瑙f瀽鑾峰彇
-      this.addressCoordinates.hospitalOutAddress = null
+      // 淇濆瓨杞嚭鍖婚櫌鐨勫煄甯備俊鎭�
+      this.taskForm.hospitalOut.city = hospital.hopsCity || ''
       
       // 濡傛灉涓や釜鍖婚櫌閮藉凡閫夋嫨锛岃嚜鍔ㄨ绠楄窛绂�
       if (this.taskForm.hospitalIn.address) {
-        // 杩欓噷鍙互璋冪敤鍦板潃瑙f瀽鍜岃窛绂昏绠�
-        // 鏆傛椂鐣欑┖锛岀敱鐢ㄦ埛鎵嬪姩杈撳叆璺濈
+        this.calculateHospitalDistance()
       }
+    },
+    
+    // 杞叆鍖婚櫌杈撳叆妗嗚幏寰楃劍鐐�
+    onHospitalInFocus() {
+      // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鏄剧ず鎵�鏈夊尰闄紙鏈湴鍖哄煙浼樺厛锛�
+      if (!this.hospitalInSearchKeyword || this.hospitalInSearchKeyword.trim() === '') {
+        searchHospitals('', '').then(response => {
+          const allHospitals = response.data || []
+          // 鎸夊湴鍩熸帓搴忥細鏈湴鍖哄煙浼樺厛
+          this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+        }).catch(error => {
+          console.error('鍔犺浇杞叆鍖婚櫌澶辫触:', error)
+          this.hospitalInResults = []
+        })
+      }
+      this.showHospitalInResults = true
     },
     
     // 杞叆鍖婚櫌鎼滅储
@@ -620,54 +940,79 @@
         clearTimeout(this.searchTimer)
       }
       
+      // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず鎵�鏈夊尰闄紙鏈湴鍖哄煙浼樺厛锛�
       if (!keyword || keyword.trim() === '') {
-        this.hospitalInResults = []
+        searchHospitals('', '').then(response => {
+          const allHospitals = response.data || []
+          // 鎸夊湴鍩熸帓搴忥細鏈湴鍖哄煙浼樺厛
+          this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+        }).catch(error => {
+          console.error('鍔犺浇杞叆鍖婚櫌澶辫触:', error)
+          this.hospitalInResults = []
+        })
+        this.showHospitalInResults = true
         return
       }
       
+      // 鏈夊叧閿瘝鏃讹紝鍘绘湇鍔$鎼滅储锛堜笉闄愬尯鍩燂紝浣嗙粨鏋滄寜鍦板煙鎺掑簭锛�
       this.searchTimer = setTimeout(() => {
         this.searchHospitalIn(keyword)
       }, 300)
     },
     
-    // 鎼滅储杞叆鍖婚櫌
+    // 鎼滅储杞叆鍖婚櫌锛堜笉闄愬尯鍩燂紝浣嗘湰鍦板尯鍩熶紭鍏堬級
     searchHospitalIn(keyword) {
-      searchHospitals(keyword).then(response => {
-        this.hospitalInResults = response.data || []
+      // 浼犲叆鍏抽敭璇嶏紝涓嶄紶鍦板煙杩囨护锛堟悳绱㈡墍鏈夊尯鍩燂級
+      searchHospitals(keyword, '').then(response => {
+        const allHospitals = response.data || []
+        // 鎸夊湴鍩熸帓搴忥細鏈湴鍖哄煙浼樺厛
+        this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
         this.showHospitalInResults = true
+        console.log('鎼滅储杞叆鍖婚櫌:', keyword, '缁撴灉鏁�:', this.hospitalInResults.length)
       }).catch(error => {
-        console.error('鎼滅储鍖婚櫌澶辫触:', error)
+        console.error('鎼滅储杞叆鍖婚櫌澶辫触:', error)
         this.hospitalInResults = []
       })
     },
     
     // 閫夋嫨杞叆鍖婚櫌
     selectHospitalIn(hospital) {
+      this.taskForm.hospitalIn.id = hospital.hospId  // 淇濆瓨鍖婚櫌ID
       this.taskForm.hospitalIn.name = hospital.hospName
-      this.taskForm.hospitalIn.address = hospital.hospAddress
+      // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
+      const fullAddress = this.buildFullAddress(hospital)
+      this.taskForm.hospitalIn.address = fullAddress
       this.hospitalInSearchKeyword = hospital.hospName
       this.showHospitalInResults = false
       this.hospitalInResults = []
       
-      // 濡傛灉鏈塆PS鍧愭爣锛屼繚瀛樹笅鏉�
-      this.addressCoordinates.hospitalInAddress = null
+      // 淇濆瓨杞叆鍖婚櫌鐨勫煄甯備俊鎭�
+      this.taskForm.hospitalIn.city = hospital.hopsCity || ''
       
       // 濡傛灉涓や釜鍖婚櫌閮藉凡閫夋嫨锛岃嚜鍔ㄨ绠楄窛绂�
       if (this.taskForm.hospitalOut.address) {
-        // 杩欓噷鍙互璋冪敤鍦板潃瑙f瀽鍜岃窛绂昏绠�
-        // 鏆傛椂鐣欑┖锛岀敱鐢ㄦ埛鎵嬪姩杈撳叆璺濈
+        this.calculateHospitalDistance()
       }
     },
     
     // 鍒濆鍖栭�変腑鐨勪汉鍛橈紙榛樿鍖呭惈褰撳墠鐢ㄦ埛锛�
     initSelectedStaff() {
-      this.selectedStaff = [{
+      // 鏋勫缓褰撳墠鐢ㄦ埛瀵硅薄锛屽寘鍚畬鏁寸殑瑙掕壊淇℃伅
+      const currentUserStaff = {
         userId: this.currentUser.userId,
         nickName: this.currentUser.nickName,
         phonenumber: this.currentUser.phonenumber,
         postName: this.currentUser.position,
-        deptId: this.currentUser.deptId
-      }]
+        deptId: this.currentUser.deptId,
+        posts: this.currentUser.posts || [],
+        roles: this.currentUser.roles || [],
+        dept: this.currentUser.dept || null
+      }
+      
+      // 涓哄綋鍓嶇敤鎴疯缃鑹茬被鍨�
+      currentUserStaff.type = this.getUserType(currentUserStaff)
+      
+      this.selectedStaff = [currentUserStaff]
     },
     
     // 鍔犺浇褰撳墠鐢ㄦ埛鎵�鍦ㄥ垎鍏徃鐨勬墍鏈変汉鍛�
@@ -675,13 +1020,17 @@
       const deptId = this.currentUser.deptId
       if (!deptId) {
         console.error('鏃犳硶鑾峰彇褰撳墠鐢ㄦ埛鎵�鍦ㄩ儴闂�')
+        this.$modal.showToast('鏃犳硶鑾峰彇鎵�鍦ㄩ儴闂ㄤ俊鎭�')
         return
       }
       
-      // 鏌ヨ褰撳墠閮ㄩ棬涓嬬殑鎵�鏈夌敤鎴凤紙鍙告満銆佹姢澹級
+      // 鐩存帴鏌ヨ褰撳墠鐢ㄦ埛閮ㄩ棬涓嬬殑鎵�鏈夌敤鎴�
+      // 鍚庣SQL浼氳嚜鍔ㄥ鐞嗭細濡傛灉浼犲叆鐨勬槸瀛愰儴闂紝浼氭煡鎵惧叾鎵�灞炵殑鍒嗗叕鍙稿強鍏舵墍鏈夊瓙閮ㄩ棬鐨勭敤鎴�
       const queryParams = {
         deptId: deptId,
-        status: '0' // 鍙煡璇㈡甯哥姸鎬佺殑鐢ㄦ埛
+        status: '0', // 鍙煡璇㈡甯哥姸鎬佺殑鐢ㄦ埛
+        pageNum: 1,
+        pageSize: 10000 // 璁剧疆瓒冲澶х殑椤甸潰澶у皬锛岃幏鍙栨墍鏈夌敤鎴�
       }
       
       listUser(queryParams).then(response => {
@@ -709,17 +1058,22 @@
     getUserType(user) {
       const postName = user.posts && user.posts.length > 0 ? user.posts[0].postName : ''
       const roleName = user.roles && user.roles.length > 0 ? user.roles[0].roleName : ''
-      
+      const deptName = user.dept?.deptName || ''
+      // console.log("鑾峰彇鐢ㄦ埛绫诲瀷:", postName, roleName,user)
       // 鍒ゆ柇鏄惁涓哄徃鏈�
-      if (postName.includes('鍙告満') || roleName.includes('鍙告満')) {
+      if (postName.includes('鍙告満') || roleName.includes('鍙告満') || deptName.includes('杞﹂槦') || deptName.includes('鍙告満')) {
         return 'driver'
       }
+      // 鍒ゆ柇鏄惁涓哄尰鐢�
+      if (postName.includes('鍖荤敓') || roleName.includes('鍖荤敓') || deptName.includes('鍖荤敓')) {
+        return 'doctor'
+      }
       // 鍒ゆ柇鏄惁涓烘姢澹�
-      if (postName.includes('鎶ゅ+') || roleName.includes('鎶ゅ+')) {
+      if (postName.includes('鎶ゅ+') || roleName.includes('鎶ゅ+') || deptName.includes('鎶ゅ+')) {
         return 'nurse'
       }
-      // 鍏朵粬绫诲瀷
-      return 'other'
+      // 鍏朵粬绫诲瀷锛岄粯璁や负鍙告満
+      return 'driver'
     },
     
     // 鏄剧ず浜哄憳閫夋嫨寮圭獥
@@ -732,7 +1086,7 @@
     closeStaffSelector() {
       this.$refs.staffPopup.close()
       this.staffSearchKeyword = ''
-      this.staffFilterType = 'all'
+      this.staffFilterType = 'driver' // 閲嶇疆涓洪粯璁ょ殑鍙告満绫诲瀷
     },
     
     // 浜哄憳鎼滅储
@@ -754,6 +1108,8 @@
       // 鎸夌被鍨嬭繃婊�
       if (this.staffFilterType === 'driver') {
         list = list.filter(staff => staff.type === 'driver')
+      } else if (this.staffFilterType === 'doctor') {
+        list = list.filter(staff => staff.type === 'doctor')
       } else if (this.staffFilterType === 'nurse') {
         list = list.filter(staff => staff.type === 'nurse')
       }
@@ -822,7 +1178,8 @@
       // 鍒濆鍖栦复鏃堕�夋嫨鍒楄〃锛堝鍒跺綋鍓嶅凡閫夋嫨鐨勭梾鎯咃級
       this.tempSelectedDiseases = [...this.selectedDiseases]
       this.diseaseSearchKeyword = ''
-      this.diseaseSearchResults = []
+      // 榛樿鍔犺浇鎵�鏈夌梾鎯�
+      this.loadAllDiseases()
       this.$refs.diseasePopup.open()
     },
     
@@ -844,14 +1201,28 @@
         clearTimeout(this.diseaseSearchTimer)
       }
       
+      // 濡傛灉鍏抽敭璇嶄负绌猴紝鍔犺浇鎵�鏈夌梾鎯�
       if (!keyword || keyword.trim() === '') {
-        this.diseaseSearchResults = []
+        this.loadAllDiseases()
         return
       }
       
+      // 鏈夊叧閿瘝鏃惰繘琛屾悳绱�
       this.diseaseSearchTimer = setTimeout(() => {
         this.searchDiseaseByKeyword(keyword)
       }, 300)
+    },
+    
+    // 鍔犺浇鎵�鏈夌梾鎯咃紙榛樿鏄剧ず锛�
+    loadAllDiseases() {
+      // 浣跨敤绌哄瓧绗︿覆鎴栫壒娈婃爣璇嗙鏉ヨ幏鍙栨墍鏈夌梾鎯�
+      // 濡傛灉鍚庣涓嶆敮鎸佺┖鏌ヨ锛屽彲浠ヤ紶鍏ヤ竴涓�氶厤绗﹀'%'鎴栬�呬慨鏀瑰悗绔帴鍙�
+      searchIcd10('').then(response => {
+        this.diseaseSearchResults = response.data || []
+      }).catch(error => {
+        console.error('鍔犺浇鐥呮儏鍒楄〃澶辫触:', error)
+        this.diseaseSearchResults = []
+      })
     },
     
     // 鏍规嵁鍏抽敭璇嶆悳绱㈢梾鎯�
@@ -899,9 +1270,43 @@
       this.selectedDiseases.splice(index, 1)
     },
     
+    // 璁剧疆榛樿杞繍鏃堕棿涓哄綋鍓嶆椂闂�
+    setDefaultTransferTime() {
+      const now = new Date()
+      const year = now.getFullYear()
+      const month = String(now.getMonth() + 1).padStart(2, '0')
+      const day = String(now.getDate()).padStart(2, '0')
+      const hours = String(now.getHours()).padStart(2, '0')
+      const minutes = String(now.getMinutes()).padStart(2, '0')
+      const seconds = String(now.getSeconds()).padStart(2, '0')
+      
+      // 鏍煎紡鍖栦负 YYYY-MM-DD HH:mm:ss
+      this.taskForm.transferTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
+    },
+    
     validateForm() {
       if (!this.selectedVehicleId) {
         this.$modal.showToast('璇烽�夋嫨浠诲姟杞﹁締')
+        return false
+      }
+      
+      if (!this.selectedEmergencyTaskType) {
+        this.$modal.showToast('璇烽�夋嫨浠诲姟绫诲瀷')
+        return false
+      }
+      
+      if (!this.selectedDocumentType) {
+        this.$modal.showToast('璇烽�夋嫨鍗曟嵁绫诲瀷')
+        return false
+      }
+      
+      if (!this.taskForm.transferTime) {
+        this.$modal.showToast('璇烽�夋嫨杞繍鏃堕棿')
+        return false
+      }
+      
+      if (!this.taskForm.patient.contact) {
+        this.$modal.showToast('璇疯緭鍏ヨ仈绯讳汉')
         return false
       }
       
@@ -920,8 +1325,18 @@
         return false
       }
       
+      if (!this.taskForm.hospitalOut.department) {
+        this.$modal.showToast('璇烽�夋嫨杞嚭鍖婚櫌绉戝')
+        return false
+      }
+      
       if (!this.taskForm.hospitalIn.name) {
         this.$modal.showToast('璇疯緭鍏ヨ浆鍏ュ尰闄㈠悕绉�')
+        return false
+      }
+      
+      if (!this.taskForm.hospitalIn.department) {
+        this.$modal.showToast('璇烽�夋嫨杞叆鍖婚櫌绉戝')
         return false
       }
       
@@ -945,9 +1360,25 @@
       
       const submitData = {
         taskType: 'EMERGENCY_TRANSFER',
+        deptId: this.selectedOrganizationId, // 褰掑睘鏈烘瀯ID锛堥儴闂↖D锛�
         vehicleIds: this.selectedVehicleId ? [this.selectedVehicleId] : [],
-        assigneeIds: this.selectedStaff.map(staff => staff.userId), // 娣诲姞鎵ц浜哄憳ID鍒楄〃
-        transferTime: this.taskForm.transferTime,
+        assigneeIds: this.selectedStaff.map(staff => staff.userId), // 鎵ц浜哄憳ID鍒楄〃
+        assigneeId: this.selectedStaff.length > 0 ? this.selectedStaff[0].userId : null, // 涓昏鎵ц浜�
+        // 鎵ц浜哄憳璇︾粏淇℃伅锛堝寘鍚鑹茬被鍨嬶級
+        assignees: this.selectedStaff.map(staff => ({
+          userId: staff.userId,
+          userName: staff.nickName,
+          userType: staff.type // driver/doctor/nurse
+        })),
+        transferTime: this.taskForm.transferTime, // 杞繍鏃堕棿
+        plannedStartTime: this.taskForm.transferTime, // 璁″垝寮�濮嬫椂闂�
+        documentTypeId: this.selectedDocumentTypeId, // 鍗曟嵁绫诲瀷ID
+        taskTypeId: this.selectedEmergencyTaskTypeId, // 浠诲姟绫诲瀷ID
+        // 鐥呮儏ID鍒楄〃锛堢敤浜庡悓姝ヨ皟搴﹀崟鐨凮rdICD_ID鍙傛暟锛�
+        diseaseIds: this.selectedDiseases.map(d => d.id),
+        // 灏嗚浆鍑哄尰闄㈠湴鍧�浣滀负鍑哄彂鍦帮紝杞叆鍖婚櫌鍦板潃浣滀负鐩殑鍦�
+        departureAddress: this.taskForm.hospitalOut.address || '',
+        destinationAddress: this.taskForm.hospitalIn.address || '',
         patient: {
           ...this.taskForm.patient,
           condition: conditionText, // 浣跨敤鍚堝苟鍚庣殑鐥呮儏淇℃伅
@@ -957,22 +1388,33 @@
             icdName: d.icdName
           }))
         },
-        hospitalOut: this.taskForm.hospitalOut,
-        hospitalIn: this.taskForm.hospitalIn,
+        // 鍖婚櫌淇℃伅锛堝寘鍚尰闄D銆佺瀹ゅ悕绉般�佺瀹D绛夊畬鏁翠俊鎭級
+        hospitalOut: this.taskForm.hospitalOut,  // 鍖呭惈: id, name, department, departmentId, bedNumber, address
+        hospitalIn: this.taskForm.hospitalIn,    // 鍖呭惈: id, name, department, departmentId, bedNumber, address
         transferDistance: this.taskForm.transferDistance ? parseFloat(this.taskForm.transferDistance) : null,
         price: this.taskForm.price ? parseFloat(this.taskForm.price) : null
       }
       
       if (this.addressCoordinates.hospitalOutAddress) {
+        // 杞嚭鍖婚櫌GPS鍧愭爣鍐欏叆鎵╁睍琛�
         if (!submitData.hospitalOut) submitData.hospitalOut = {}
         submitData.hospitalOut.longitude = this.addressCoordinates.hospitalOutAddress.lng
         submitData.hospitalOut.latitude = this.addressCoordinates.hospitalOutAddress.lat
+        
+        // 鍚屾椂鍐欏叆涓讳换鍔¤〃鐨勫嚭鍙戝湴缁忕含搴�
+        submitData.departureLongitude = this.addressCoordinates.hospitalOutAddress.lng
+        submitData.departureLatitude = this.addressCoordinates.hospitalOutAddress.lat
       }
       
       if (this.addressCoordinates.hospitalInAddress) {
+        // 杞叆鍖婚櫌GPS鍧愭爣鍐欏叆鎵╁睍琛�
         if (!submitData.hospitalIn) submitData.hospitalIn = {}
         submitData.hospitalIn.longitude = this.addressCoordinates.hospitalInAddress.lng
         submitData.hospitalIn.latitude = this.addressCoordinates.hospitalInAddress.lat
+        
+        // 鍚屾椂鍐欏叆涓讳换鍔¤〃鐨勭洰鐨勫湴缁忕含搴�
+        submitData.destinationLongitude = this.addressCoordinates.hospitalInAddress.lng
+        submitData.destinationLatitude = this.addressCoordinates.hospitalInAddress.lat
       }
       
       return submitData
@@ -991,7 +1433,9 @@
           this.loading = false
           this.$modal.showToast('浠诲姟鍒涘缓鎴愬姛')
           setTimeout(() => {
-            this.$tab.navigateTo('/pages/task/index')
+            uni.switchTab({
+              url: '/pages/task/index'
+            })
           }, 1500)
         }).catch(error => {
           this.loading = false
@@ -1003,6 +1447,68 @@
     
     goBack() {
       uni.navigateBack()
+    },
+    
+    // 鍚堝苟鍖婚櫌鍦板潃锛堢渷 + 甯� + 鍖� + 璇︾粏鍦板潃锛�
+    buildFullAddress(hospital) {
+      const parts = []
+      if (hospital.hopsProvince) {
+        parts.push(hospital.hopsProvince)
+      }
+      if (hospital.hopsCity) {
+        parts.push(hospital.hopsCity)
+      }
+      if (hospital.hopsArea) {
+        parts.push(hospital.hopsArea)
+      }
+      if (hospital.hospAddress) {
+        parts.push(hospital.hospAddress)
+      }
+      return parts.join('')
+    },
+    
+    // 鑷姩璁$畻涓や釜鍖婚櫌涔嬮棿鐨勮窛绂�
+    calculateHospitalDistance() {
+      const fromAddress = this.taskForm.hospitalOut.address
+      const fromCity = this.taskForm.hospitalOut.city
+      const toAddress = this.taskForm.hospitalIn.address
+      const toCity = this.taskForm.hospitalIn.city
+      
+      if (!fromAddress || !toAddress) {
+        console.log('鍦板潃淇℃伅涓嶅畬鏁达紝鏃犳硶璁$畻璺濈')
+        return
+      }
+      
+      console.log('寮�濮嬭绠楄窛绂�:', fromAddress, '->', toAddress)
+      
+      // 鏄剧ず鍔犺浇鎻愮ず
+      uni.showLoading({
+        title: '璁$畻璺濈涓�...'
+      })
+      
+      // 璋冪敤鐧惧害鍦板浘API璁$畻璺濈
+      baiduDistanceByAddress(fromAddress, fromCity, toAddress, toCity)
+        .then(response => {
+          uni.hideLoading()
+          
+          if (response.code === 200 && response.data) {
+            const distanceInMeters = response.data.distance
+            // 杞崲涓哄叕閲岋紝淇濈暀1浣嶅皬鏁�
+            const distanceInKm = (distanceInMeters / 1000).toFixed(1)
+            this.taskForm.transferDistance = distanceInKm
+            
+            console.log('璺濈璁$畻鎴愬姛:', distanceInKm, 'km')
+            // this.$modal.showToast(`璺濈璁$畻鎴愬姛: ${distanceInKm}鍏噷`)
+          } else {
+            console.error('璺濈璁$畻澶辫触:', response.msg)
+            this.$modal.showToast('璺濈璁$畻澶辫触锛岃鎵嬪姩杈撳叆')
+          }
+        })
+        .catch(error => {
+          uni.hideLoading()
+          console.error('璺濈璁$畻澶辫触:', error)
+          this.$modal.showToast('璺濈璁$畻澶辫触锛岃鎵嬪姩杈撳叆')
+        })
     }
   }
 }
@@ -1059,6 +1565,13 @@
         font-size: 28rpx;
         margin-bottom: 15rpx;
         color: #333;
+        
+        &.required::before {
+          content: '*';
+          color: #ff4d4f;
+          margin-right: 4rpx;
+          font-weight: bold;
+        }
       }
       
       .hospital-search-container {

--
Gitblit v1.9.1