From fd047fa7234dc11643dab8ecbf38e8d7a8ba0854 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期六, 22 十一月 2025 23:48:12 +0800
Subject: [PATCH] feat:修改任务

---
 app/pages/task/create-emergency.vue | 1635 +++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 1,118 insertions(+), 517 deletions(-)

diff --git a/app/pages/task/create-emergency.vue b/app/pages/task/create-emergency.vue
index cefe5b2..ef16aec 100644
--- a/app/pages/task/create-emergency.vue
+++ b/app/pages/task/create-emergency.vue
@@ -4,27 +4,58 @@
       <view class="back-btn" @click="goBack">
         <uni-icons type="arrowleft" size="20"></uni-icons>
       </view>
-      <view class="title">鍒涘缓闈炴�ユ晳杞繍浠诲姟</view>
+      <view class="title">鍒涘缓杞繍浠诲姟</view>
+      <view class="smart-parse-btn" @click="showSmartParsePopup">
+        <uni-icons type="compose" size="20" color="#007AFF"></uni-icons>
+        <text>鏅鸿兘璇嗗埆</text>
+      </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">
+        <OrganizationSelector 
+          v-model="selectedOrganizationId"
+          :required="true"
+          :auto-select-user-dept="true"
+          @change="onOrganizationChange"
+        />
+      </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 +78,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 +92,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 +101,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 +111,7 @@
       </view>
       
       <view class="form-item">
-        <view class="form-label">鎮h�呭鍚�</view>
+        <view class="form-label required">鎮h�呭鍚�</view>
         <input 
           class="form-input" 
           placeholder="璇疯緭鍏ユ偅鑰呭鍚�" 
@@ -130,149 +143,52 @@
         />
       </view>
       
-      <view class="form-item">
-        <view class="form-label">鐥呮儏</view>
-        <view class="disease-container">
-          <view class="disease-tags" v-if="selectedDiseases.length > 0">
-            <view 
-              class="disease-tag" 
-              v-for="(disease, index) in selectedDiseases" 
-              :key="index"
-            >
-              <text class="disease-name">{{ disease.icdName }}</text>
-              <uni-icons 
-                type="closeempty" 
-                size="16" 
-                color="#fff"
-                @click="removeDisease(index)"
-              ></uni-icons>
-            </view>
-          </view>
-          <view class="add-disease-btn" @click="showDiseaseSelector">
-            <uni-icons type="plusempty" size="20" color="#007AFF"></uni-icons>
-            <text>娣诲姞鐥呮儏</text>
-          </view>
-          <textarea 
-            class="form-textarea" 
-            placeholder="鍏朵粬鐥呮儏鎻忚堪锛堥�夊~锛�" 
-            v-model="taskForm.patient.condition"
-            style="margin-top: 20rpx;"
-          />
-        </view>
-      </view>
+      <DiseaseSelector
+        v-model="selectedDiseases"
+        :other-description.sync="taskForm.patient.condition"
+      />
       
       <view class="form-section-title">杞嚭鍖婚櫌淇℃伅</view>
-      <view class="form-item">
-        <view class="form-label">鍖婚櫌鍚嶇О</view>
-        <view class="hospital-search-container">
-          <input 
-            class="form-input" 
-            placeholder="璇疯緭鍏ュ尰闄㈠悕绉版垨鍦板潃鎼滅储" 
-            v-model="hospitalOutSearchKeyword"
-            @input="onHospitalOutSearch"
-            @focus="showHospitalOutResults = true"
-          />
-          <view class="search-results" v-if="showHospitalOutResults && hospitalOutResults.length > 0">
-            <view 
-              class="search-result-item" 
-              v-for="hospital in hospitalOutResults" 
-              :key="hospital.hospId"
-              @click="selectHospitalOut(hospital)"
-            >
-              <view class="hospital-name">{{ hospital.hospName }}</view>
-              <view class="hospital-address">{{ hospital.hospAddress }}</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>
-      
-      <view class="form-item">
-        <view class="form-label">搴婂彿</view>
-        <input 
-          class="form-input" 
-          placeholder="璇疯緭鍏ュ簥鍙�" 
-          v-model="taskForm.hospitalOut.bedNumber"
-        />
-      </view>
-      
-      <view class="form-item">
-        <view class="form-label">杞嚭鍦板潃</view>
-        <view class="form-input picker-input disabled">
-          {{ taskForm.hospitalOut.address || '閫夋嫨鍖婚櫌鍚庤嚜鍔ㄥ~鍏�' }}
-        </view>
-      </view>
+      <HospitalSelector
+        label="鍖婚櫌鍚嶇О"
+        address-label="杞嚭鍦板潃"
+        :required="true"
+        :department-required="true"
+        v-model="taskForm.hospitalOut"
+        :dept-id="selectedOrganizationId"
+        :region="selectedRegion"
+        :department-options="departmentOptions"
+        @change="onHospitalOutChange"
+        @address-selected="onHospitalOutAddressSelected"
+      />
       
       <view class="form-section-title">杞叆鍖婚櫌淇℃伅</view>
-      <view class="form-item">
-        <view class="form-label">鍖婚櫌鍚嶇О</view>
-        <view class="hospital-search-container">
-          <input 
-            class="form-input" 
-            placeholder="璇疯緭鍏ュ尰闄㈠悕绉版垨鍦板潃鎼滅储" 
-            v-model="hospitalInSearchKeyword"
-            @input="onHospitalInSearch"
-            @focus="showHospitalInResults = true"
-          />
-          <view class="search-results" v-if="showHospitalInResults && hospitalInResults.length > 0">
-            <view 
-              class="search-result-item" 
-              v-for="hospital in hospitalInResults" 
-              :key="hospital.hospId"
-              @click="selectHospitalIn(hospital)"
-            >
-              <view class="hospital-name">{{ hospital.hospName }}</view>
-              <view class="hospital-address">{{ hospital.hospAddress }}</view>
-            </view>
-          </view>
-        </view>
-      </view>
+      <HospitalSelector
+        label="鍖婚櫌鍚嶇О"
+        address-label="杞叆鍦板潃"
+        :required="true"
+        :department-required="true"
+        v-model="taskForm.hospitalIn"
+        :dept-id="selectedOrganizationId"
+        :region="selectedRegion"
+        :department-options="departmentOptions"
+        @change="onHospitalInChange"
+        @address-selected="onHospitalInAddressSelected"
+      />
       
       <view class="form-item">
-        <view class="form-label">绉戝</view>
-        <input 
-          class="form-input" 
-          placeholder="璇疯緭鍏ョ瀹�" 
-          v-model="taskForm.hospitalIn.department"
-        />
-      </view>
-      
-      <view class="form-item">
-        <view class="form-label">搴婂彿</view>
-        <input 
-          class="form-input" 
-          placeholder="璇疯緭鍏ュ簥鍙�" 
-          v-model="taskForm.hospitalIn.bedNumber"
-        />
-      </view>
-      
-      <view class="form-item">
-        <view class="form-label">杞叆鍦板潃</view>
-        <view class="form-input picker-input disabled">
-          {{ taskForm.hospitalIn.address || '閫夋嫨鍖婚櫌鍚庤嚜鍔ㄥ~鍏�' }}
-        </view>
-      </view>
-      
-      <view class="form-item">
-        <view class="form-label">杞繍鍏噷鏁�</view>
+        <view class="form-label required">杞繍鍏噷鏁�</view>
         <input 
           class="form-input" 
           type="digit" 
           placeholder="璇疯緭鍏ヨ浆杩愬叕閲屾暟" 
           v-model="taskForm.transferDistance"
+          @blur="onDistanceChange"
         />
       </view>
       
       <view class="form-item">
-        <view class="form-label">鎴愪氦浠�</view>
+        <view class="form-label required">鎴愪氦浠�</view>
         <input 
           class="form-input" 
           type="digit" 
@@ -311,14 +227,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 +256,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 
@@ -365,65 +281,34 @@
       </view>
     </uni-popup>
     
-    <!-- 鐥呮儏閫夋嫨寮圭獥 -->
-    <uni-popup ref="diseasePopup" type="bottom" :safe-area="true">
-      <view class="disease-selector-popup">
+   <!-- 鏅鸿兘璇嗗埆寮圭獥 -->
+    <uni-popup ref="smartParsePopup" type="bottom" :safe-area="true">
+      <view class="smart-parse-popup">
         <view class="popup-header">
-          <view class="popup-title">閫夋嫨鐥呮儏锛圛CD-10锛�</view>
-          <view class="popup-close" @click="closeDiseaseSelector">
+          <view class="popup-title">鏅鸿兘璇嗗埆</view>
+          <view class="popup-close" @click="closeSmartParsePopup">
             <uni-icons type="closeempty" size="24" color="#333"></uni-icons>
           </view>
         </view>
         
-        <view class="search-box">
-          <uni-icons type="search" size="18" color="#999"></uni-icons>
-          <input 
-            class="search-input" 
-            placeholder="鎼滅储鐤剧梾鍚嶇О銆佺紪鐮佹垨鍔╄鐮�" 
-            v-model="diseaseSearchKeyword"
-            @input="onDiseaseSearch"
+        <view class="parse-content">
+          <view class="parse-tip">
+            <uni-icons type="info" size="18" color="#007AFF"></uni-icons>
+            <text>绮樿创鎴栬緭鍏ユ枃鏈紝濡傦細"鎮h�呭紶涓夛紝鐢佃瘽13800138000锛屼粠骞垮窞鏌愭煇鍖婚櫌杞叆娣卞湷鏌愭煇涓績锛岃垂鐢骏680"</text>
+          </view>
+          <textarea
+            class="parse-textarea"
+            placeholder="璇峰湪姝ょ矘璐存垨杈撳叆杞繍淇℃伅..."
+            v-model="rawText"
+            :maxlength="-1"
           />
         </view>
         
-        <scroll-view class="disease-list-popup" scroll-y="true">
-          <view 
-            class="disease-item-popup" 
-            v-for="disease in diseaseSearchResults" 
-            :key="disease.id"
-            @click="toggleDiseaseSelection(disease)"
-          >
-            <view class="disease-info">
-              <view class="disease-name-row">
-                <text class="disease-name">{{ disease.icdName }}</text>
-                <text class="disease-code">[{{ disease.icdCode }}]</text>
-              </view>
-              <view class="disease-detail-row" v-if="disease.sm">
-                <text class="disease-desc">{{ disease.sm }}</text>
-              </view>
-            </view>
-            <uni-icons 
-              v-if="isDiseaseSelected(disease.id)" 
-              type="checkmarkempty" 
-              size="24" 
-              color="#007AFF"
-            ></uni-icons>
-            <view v-else class="checkbox-empty"></view>
-          </view>
-          
-          <view class="no-data" v-if="diseaseSearchResults.length === 0 && diseaseSearchKeyword">
-            <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>
-          </view>
-        </scroll-view>
-        
         <view class="popup-footer">
-          <button class="cancel-btn" @click="closeDiseaseSelector">鍙栨秷</button>
-          <button class="confirm-btn" @click="confirmDiseaseSelection">纭畾(宸查�墈{ tempSelectedDiseases.length }})</button>
+          <button class="cancel-btn" @click="closeSmartParsePopup">鍙栨秷</button>
+          <button class="confirm-btn" @click="parseFreeText" :disabled="parseLoading">
+            {{ parseLoading ? '璇嗗埆涓�...' : '寮�濮嬭瘑鍒�' }}
+          </button>
         </view>
       </view>
     </uni-popup>
@@ -435,46 +320,51 @@
 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 { searchHospitals } from "@/api/hospital"
-import { listUser } from "@/api/system/user"
+import { listAvailableVehicles, getUserBoundVehicle } from "@/api/vehicle"
+import { calculateDistance, baiduDistanceByAddress, baiduPlaceSuggestion } from "@/api/map"
+import { searchHospitals, getFrequentOutHospitals, getFrequentInHospitals, searchHospitalsByDeptRegion } from "@/api/hospital"
+import { listBranchUsers } from "@/api/system/user"
 import { searchIcd10 } from "@/api/icd10"
+import { calculateTransferPrice } from "@/api/price"
+import { checkVehicleActiveTasks } from "@/api/task"
+
+import { getDicts } from "@/api/dict"
+import { getServiceOrdAreaTypes, getServiceOrderTypes, getHospitalDepartments } from "@/api/dictionary"
+import { listBranchCompany, getDept } from "@/api/system/dept"
 import MapSelector from '@/components/map-selector.vue'
+import OrganizationSelector from '@/components/OrganizationSelector.vue'
+import HospitalSelector from '@/components/HospitalSelector.vue'
+import DiseaseSelector from '@/components/DiseaseSelector.vue'
 
 export default {
   components: {
     uniDatetimePicker,
     uniPopup,
-    MapSelector
+    MapSelector,
+    OrganizationSelector,
+    HospitalSelector,
+    DiseaseSelector
   },
   data() {
     return {
       selectedVehicle: '',
       selectedVehicleId: null,
-      selectedOrganization: '',
-      selectedEmergencyTaskType: '',
+      selectedOrganizationId: null, // 褰掑睘鏈烘瀯ID锛堥儴闂↖D锛�
+      selectedOrganizationServiceOrderClass: '', // 褰掑睘鏈烘瀯鐨勬湇鍔″崟缂栫爜
+      selectedRegion: '', // 浠庡綊灞炴満鏋勪腑鎻愬彇鐨勫湴鍩熶俊鎭紙濡傦細骞垮窞銆佹繁鍦崇瓑锛�
+      selectedEmergencyTaskType: '', // 閫変腑鐨勪换鍔$被鍨嬫枃鏈�
+      selectedEmergencyTaskTypeId: null, // 閫変腑鐨勪换鍔$被鍨婭D
+      selectedDocumentType: '', // 閫変腑鐨勫崟鎹被鍨嬫枃鏈�
+      selectedDocumentTypeId: null, // 閫変腑鐨勫崟鎹被鍨婭D
       mapSelectorType: '',
-      // 鍖婚櫌鎼滅储鐩稿叧
-      hospitalOutSearchKeyword: '',
-      hospitalOutResults: [],
-      showHospitalOutResults: false,
-      hospitalInSearchKeyword: '',
-      hospitalInResults: [],
-      showHospitalInResults: false,
-      searchTimer: null,
       // 浜哄憳閫夋嫨鐩稿叧
       selectedStaff: [], // 宸查�夋嫨鐨勪汉鍛樺垪琛�
       allStaffList: [], // 鎵�鏈変汉鍛樺垪琛�
       filteredStaffList: [], // 杩囨护鍚庣殑浜哄憳鍒楄〃
       staffSearchKeyword: '', // 浜哄憳鎼滅储鍏抽敭璇�
-      staffFilterType: 'all', // 浜哄憳绛涢�夌被鍨嬶細all/driver/nurse
+      staffFilterType: 'driver', // 浜哄憳绛涢�夌被鍨嬶細driver/doctor/nurse锛岄粯璁ら�変腑鍙告満
       // 鐥呮儏閫夋嫨鐩稿叧
       selectedDiseases: [], // 宸查�夋嫨鐨勭梾鎯呭垪琛�
-      tempSelectedDiseases: [], // 涓存椂閫夋嫨鐨勭梾鎯呭垪琛紙鐢ㄤ簬寮圭獥锛�
-      diseaseSearchKeyword: '', // 鐥呮儏鎼滅储鍏抽敭璇�
-      diseaseSearchResults: [], // 鐥呮儏鎼滅储缁撴灉
-      diseaseSearchTimer: null, // 鐥呮儏鎼滅储闃叉姈瀹氭椂鍣�
       taskForm: {
         transferTime: '',
         patient: {
@@ -486,14 +376,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,45 +396,116 @@
       },
       vehicles: [],
       vehicleOptions: [],
-      organizations: ['骞垮窞鍒嗗叕鍙�', '娣卞湷鍒嗗叕鍙�', '鐝犳捣鍒嗗叕鍙�', '浣涘北鍒嗗叕鍙�'],
-      emergencyTaskTypes: ['鎬ユ晳杞繍', '鑸┖杞繍'],
+
+      emergencyTaskTypes: [], // 浠诲姟绫诲瀷鍒楄〃锛堜粠 SQL Server 鍔ㄦ�佸姞杞斤級
+      emergencyTaskTypeOptions: [], // 浠诲姟绫诲瀷閫夐」锛堢敤浜巔icker鏄剧ず锛�
+      documentTypes: [], // 鍗曟嵁绫诲瀷鍒楄〃
+      documentTypeOptions: [], // 鍗曟嵁绫诲瀷閫夐」锛堢敤浜巔icker鏄剧ず锛�
+      departmentOptions: [], // 绉戝瀛楀吀鏁版嵁
       loading: false,
       addressCoordinates: {
         hospitalOutAddress: null,
         hospitalInAddress: null
-      }
+      },
+      // 鏅鸿兘璇嗗埆鐩稿叧
+      rawText: '',
+      parseLoading: false
     }
   },
   computed: {
     ...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.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 => {
-        const vehicleList = response.data || response.rows || []
+      // 鏍规嵁鐢ㄦ埛鏈夋潈闄愮鐞嗙殑鍒嗗叕鍙革紝鏌ヨ鎵�鏈夊彲鐢ㄨ溅杈�
+      return listAvailableVehicles(null, 'EMERGENCY').then(response => {
+        const vehicleList = response.data || []
         this.vehicleOptions = vehicleList.map(vehicle => ({
           id: vehicle.vehicleId,
           name: vehicle.vehicleNo,
           type: vehicle.vehicleType,
-          status: vehicle.status
+          status: vehicle.status,
+          deptNames: vehicle.deptNames || [] // 杞﹁締褰掑睘鐨勫涓垎鍏徃
         }))
+        // 鍙樉绀鸿溅鐗屽彿锛屼笉鏄剧ず鍒嗗叕鍙�
         this.vehicles = this.vehicleOptions.map(v => v.name)
-      }).catch(() => {
+        console.log('鍔犺浇鍙敤杞﹁締鏁伴噺:', this.vehicles.length)
+      }).catch(error => {
+        console.error('鍔犺浇杞﹁締鍒楄〃澶辫触:', error)
         this.vehicles = []
       })
     },
@@ -551,141 +516,198 @@
       this.selectedVehicleId = this.vehicleOptions[index]?.id
     },
     
-    onOrganizationChange(e) {
-      this.selectedOrganization = this.organizations[e.detail.value]
+    onOrganizationChange(orgData) {
+      // orgData 鍖呭惈锛歞eptId, deptName, serviceOrderClass, region
+      this.selectedOrganizationId = orgData.deptId
+      this.selectedOrganizationServiceOrderClass = orgData.serviceOrderClass
+      this.selectedRegion = orgData.region
+      
+      console.log('閫変腑褰掑睘鏈烘瀯:', orgData.deptName, '閮ㄩ棬ID:', orgData.deptId, '鏈嶅姟鍗曠紪鐮�:', orgData.serviceOrderClass, '鍦板煙:', orgData.region)
+    },
+    replaceRegion(region){
+		return region.replace(/(鍒嗗叕鍙竱鎬诲叕鍙竱鎬婚儴)$/g, '').trim();
+	},
+    
+    // 鍔犺浇绉戝鏁版嵁锛堜粠 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 "鍙告満";
+      }
     },
     
-    // 杞嚭鍖婚櫌鎼滅储
-    onHospitalOutSearch(e) {
-      const keyword = e.detail.value
-      this.hospitalOutSearchKeyword = keyword
-      
-      // 闃叉姈澶勭悊
-      if (this.searchTimer) {
-        clearTimeout(this.searchTimer)
-      }
-      
-      if (!keyword || keyword.trim() === '') {
-        this.hospitalOutResults = []
-        return
-      }
-      
-      this.searchTimer = setTimeout(() => {
-        this.searchHospitalOut(keyword)
-      }, 300)
-    },
-    
-    // 鎼滅储杞嚭鍖婚櫌
-    searchHospitalOut(keyword) {
-      searchHospitals(keyword).then(response => {
-        this.hospitalOutResults = response.data || []
-        this.showHospitalOutResults = true
+    // 鍔犺浇鍗曟嵁绫诲瀷鏁版嵁
+    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.hospitalOutResults = []
+        console.error('鍔犺浇鍗曟嵁绫诲瀷澶辫触:', error)
+        this.documentTypes = []
+        this.documentTypeOptions = []
       })
     },
     
-    // 閫夋嫨杞嚭鍖婚櫌
-    selectHospitalOut(hospital) {
-      this.taskForm.hospitalOut.name = hospital.hospName
-      this.taskForm.hospitalOut.address = hospital.hospAddress
-      this.hospitalOutSearchKeyword = hospital.hospName
-      this.showHospitalOutResults = false
-      this.hospitalOutResults = []
+    // 鍗曟嵁绫诲瀷閫夋嫨
+    onDocumentTypeChange(e) {
+      const index = e.detail.value
+      const selected = this.documentTypeOptions[index]
+      this.selectedDocumentType = selected.text
+      this.selectedDocumentTypeId = selected.id
+    },
+    
+    // 杞嚭鍖婚櫌鍙樺寲
+    onHospitalOutChange(hospitalData) {
+      console.log('杞嚭鍖婚櫌鍙樺寲:', hospitalData)
+      // 缁勪欢宸茬粡閫氳繃 v-model 鏇存柊浜� taskForm.hospitalOut
       
-      // 濡傛灉鏈塆PS鍧愭爣锛屼繚瀛樹笅鏉�
-      // 娉ㄦ剰锛欻ospData琛ㄤ腑鍙兘娌℃湁GPS鍧愭爣锛岄渶瑕佹牴鎹湴鍧�杩涜鍦扮悊缂栫爜
-      // 杩欓噷鍏堢疆涓簄ull锛屽悗缁彲浠ラ�氳繃鍦板潃瑙f瀽鑾峰彇
-      this.addressCoordinates.hospitalOutAddress = null
-      
-      // 濡傛灉涓や釜鍖婚櫌閮藉凡閫夋嫨锛岃嚜鍔ㄨ绠楄窛绂�
+      // 濡傛灉杞叆鍦板潃宸插~鍐�,鑷姩璁$畻璺濈
       if (this.taskForm.hospitalIn.address) {
-        // 杩欓噷鍙互璋冪敤鍦板潃瑙f瀽鍜岃窛绂昏绠�
-        // 鏆傛椂鐣欑┖锛岀敱鐢ㄦ埛鎵嬪姩杈撳叆璺濈
+        // 濡傛灉涓や釜閮戒笉鏄�"瀹朵腑",浣跨敤鍖婚櫌璺濈璁$畻
+        if (hospitalData.name !== '瀹朵腑' && this.taskForm.hospitalIn.name !== '瀹朵腑') {
+          this.calculateHospitalDistance()
+        } else {
+          // 鏈変竴涓槸"瀹朵腑",浣跨敤鍦板潃璁$畻
+          this.calculateDistanceByManualAddress()
+        }
       }
     },
     
-    // 杞叆鍖婚櫌鎼滅储
-    onHospitalInSearch(e) {
-      const keyword = e.detail.value
-      this.hospitalInSearchKeyword = keyword
-      
-      // 闃叉姈澶勭悊
-      if (this.searchTimer) {
-        clearTimeout(this.searchTimer)
+    // 杞嚭鍖婚櫌鍦板潃閫夋嫨锛堝綋閫夋嫨"瀹朵腑"鏃朵娇鐢ㄧ櫨搴﹀湴鍥惧湴鍧�寤鸿锛�
+    onHospitalOutAddressSelected(data) {
+      // data 鍖呭惈锛歛ddress, location
+      if (data.location) {
+        this.addressCoordinates.hospitalOutAddress = data.location
+        
+        // 濡傛灉杞叆鍦板潃涔熷凡濉啓,鑷姩璁$畻璺濈
+        if (this.taskForm.hospitalIn.address) {
+          this.calculateDistanceByManualAddress()
+        }
       }
-      
-      if (!keyword || keyword.trim() === '') {
-        this.hospitalInResults = []
-        return
-      }
-      
-      this.searchTimer = setTimeout(() => {
-        this.searchHospitalIn(keyword)
-      }, 300)
     },
     
-    // 鎼滅储杞叆鍖婚櫌
-    searchHospitalIn(keyword) {
-      searchHospitals(keyword).then(response => {
-        this.hospitalInResults = response.data || []
-        this.showHospitalInResults = true
-      }).catch(error => {
-        console.error('鎼滅储鍖婚櫌澶辫触:', error)
-        this.hospitalInResults = []
-      })
-    },
-    
-    // 閫夋嫨杞叆鍖婚櫌
-    selectHospitalIn(hospital) {
-      this.taskForm.hospitalIn.name = hospital.hospName
-      this.taskForm.hospitalIn.address = hospital.hospAddress
-      this.hospitalInSearchKeyword = hospital.hospName
-      this.showHospitalInResults = false
-      this.hospitalInResults = []
+    // 杞叆鍖婚櫌鍙樺寲
+    onHospitalInChange(hospitalData) {
+      console.log('杞叆鍖婚櫌鍙樺寲:', hospitalData)
+      // 缁勪欢宸茬粡閫氳繃 v-model 鏇存柊浜� taskForm.hospitalIn
       
-      // 濡傛灉鏈塆PS鍧愭爣锛屼繚瀛樹笅鏉�
-      this.addressCoordinates.hospitalInAddress = null
-      
-      // 濡傛灉涓や釜鍖婚櫌閮藉凡閫夋嫨锛岃嚜鍔ㄨ绠楄窛绂�
+      // 濡傛灉杞嚭鍦板潃宸插~鍐�,鑷姩璁$畻璺濈
       if (this.taskForm.hospitalOut.address) {
-        // 杩欓噷鍙互璋冪敤鍦板潃瑙f瀽鍜岃窛绂昏绠�
-        // 鏆傛椂鐣欑┖锛岀敱鐢ㄦ埛鎵嬪姩杈撳叆璺濈
+        // 濡傛灉涓や釜閮戒笉鏄�"瀹朵腑",浣跨敤鍖婚櫌璺濈璁$畻
+        if (hospitalData.name !== '瀹朵腑' && this.taskForm.hospitalOut.name !== '瀹朵腑') {
+          this.calculateHospitalDistance()
+        } else {
+          // 鏈変竴涓槸"瀹朵腑",浣跨敤鍦板潃璁$畻
+          this.calculateDistanceByManualAddress()
+        }
+      }
+    },
+    
+    // 杞叆鍖婚櫌鍦板潃閫夋嫨锛堝綋閫夋嫨"瀹朵腑"鏃朵娇鐢ㄧ櫨搴﹀湴鍥惧湴鍧�寤鸿锛�
+    onHospitalInAddressSelected(data) {
+      // data 鍖呭惈锛歛ddress, location
+      if (data.location) {
+        this.addressCoordinates.hospitalInAddress = data.location
+        
+        // 濡傛灉杞嚭鍦板潃涔熷凡濉啓,鑷姩璁$畻璺濈
+        if (this.taskForm.hospitalOut.address) {
+          this.calculateDistanceByManualAddress()
+        }
       }
     },
     
     // 鍒濆鍖栭�変腑鐨勪汉鍛橈紙榛樿鍖呭惈褰撳墠鐢ㄦ埛锛�
     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]
     },
     
     // 鍔犺浇褰撳墠鐢ㄦ埛鎵�鍦ㄥ垎鍏徃鐨勬墍鏈変汉鍛�
     loadDeptStaff() {
-      const deptId = this.currentUser.deptId
-      if (!deptId) {
-        console.error('鏃犳硶鑾峰彇褰撳墠鐢ㄦ埛鎵�鍦ㄩ儴闂�')
-        return
-      }
+      console.log('寮�濮嬪姞杞戒汉鍛樺垪琛�')
       
-      // 鏌ヨ褰撳墠閮ㄩ棬涓嬬殑鎵�鏈夌敤鎴凤紙鍙告満銆佹姢澹級
-      const queryParams = {
-        deptId: deptId,
-        status: '0' // 鍙煡璇㈡甯哥姸鎬佺殑鐢ㄦ埛
-      }
-      
-      listUser(queryParams).then(response => {
-        const userList = response.rows || response.data || []
+      // 璋冪敤鏂版帴鍙o紝鑷姩鏍规嵁褰撳墠鐢ㄦ埛鐨刼aOrderClass鑾峰彇鍒嗗叕鍙镐笅鐨勭敤鎴�
+      listBranchUsers().then(response => {
+        console.log('浜哄憳鍒楄〃API鍝嶅簲:', response)
+        const userList = response.data || []
+        console.log('瑙f瀽鍑虹殑鐢ㄦ埛鍒楄〃:', userList, '鏁伴噺:', userList.length)
+        
         this.allStaffList = userList.map(user => ({
           userId: user.userId,
           nickName: user.nickName,
@@ -696,6 +718,8 @@
           // 鏍规嵁宀椾綅鍚嶇О鎴栬鑹插悕绉板垽鏂被鍨�
           type: this.getUserType(user)
         }))
+        
+        console.log('澶勭悊鍚庣殑浜哄憳鍒楄〃:', this.allStaffList, '鏁伴噺:', this.allStaffList.length)
         
         // 鍒濆鍖栬繃婊ゅ垪琛�
         this.filterStaffList()
@@ -709,17 +733,26 @@
     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('鎶ゅ+')) {
+      if (postName.includes('鎶ゅ+') || roleName.includes('鎶ゅ+') || deptName.includes('鎶ゅ+')) {
         return 'nurse'
       }
-      // 鍏朵粬绫诲瀷
-      return 'other'
+      // 鍒ゆ柇鏄惁涓哄尰鐢�
+      if (postName.includes('鍖荤敓') || roleName.includes('鍖荤敓') || deptName.includes('鍖荤敓') ) {
+        return 'doctor'
+      }
+      if( deptName.includes("鍖绘姢")){
+        return 'doctor'
+      }
+      
+      // 鍏朵粬绫诲瀷锛岄粯璁や负鍙告満
+      return 'driver'
     },
     
     // 鏄剧ず浜哄憳閫夋嫨寮圭獥
@@ -732,7 +765,7 @@
     closeStaffSelector() {
       this.$refs.staffPopup.close()
       this.staffSearchKeyword = ''
-      this.staffFilterType = 'all'
+      this.staffFilterType = 'driver' // 閲嶇疆涓洪粯璁ょ殑鍙告満绫诲瀷
     },
     
     // 浜哄憳鎼滅储
@@ -749,14 +782,19 @@
     
     // 杩囨护浜哄憳鍒楄〃
     filterStaffList() {
+      console.log('寮�濮嬭繃婊や汉鍛樺垪琛紝鍘熷鏁伴噺:', this.allStaffList.length)
       let list = [...this.allStaffList]
       
       // 鎸夌被鍨嬭繃婊�
       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')
       }
+      
+      console.log('鎸夌被鍨嬭繃婊ゅ悗:', this.staffFilterType, '鏁伴噺:', list.length)
       
       // 鎸夊叧閿瘝鎼滅储
       if (this.staffSearchKeyword && this.staffSearchKeyword.trim() !== '') {
@@ -767,7 +805,10 @@
         })
       }
       
+      console.log('鎸夊叧閿瘝杩囨护鍚庯紝鏁伴噺:', list.length)
+      
       this.filteredStaffList = list
+      // console.log('鏈�缁堣繃婊ょ粨鏋�:', this.filteredStaffList)
     },
     
     // 鍒囨崲浜哄憳閫変腑鐘舵��
@@ -814,94 +855,137 @@
     addStaff() {
       this.showStaffSelector()
     },
-    
-    // ==================== 鐥呮儏閫夋嫨鐩稿叧鏂规硶 ====================
-    
-    // 鏄剧ず鐥呮儏閫夋嫨寮圭獥
-    showDiseaseSelector() {
-      // 鍒濆鍖栦复鏃堕�夋嫨鍒楄〃锛堝鍒跺綋鍓嶅凡閫夋嫨鐨勭梾鎯咃級
-      this.tempSelectedDiseases = [...this.selectedDiseases]
-      this.diseaseSearchKeyword = ''
-      this.diseaseSearchResults = []
-      this.$refs.diseasePopup.open()
-    },
-    
-    // 鍏抽棴鐥呮儏閫夋嫨寮圭獥
-    closeDiseaseSelector() {
-      this.$refs.diseasePopup.close()
-      this.diseaseSearchKeyword = ''
-      this.diseaseSearchResults = []
-      this.tempSelectedDiseases = []
-    },
-    
-    // 鐥呮儏鎼滅储
-    onDiseaseSearch(e) {
-      const keyword = e.detail.value
-      this.diseaseSearchKeyword = keyword
+    calculateDistanceByManualAddress() {
+      const fromAddress = this.taskForm.hospitalOut.address
+      const toAddress = this.taskForm.hospitalIn.address
       
-      // 闃叉姈澶勭悊
-      if (this.diseaseSearchTimer) {
-        clearTimeout(this.diseaseSearchTimer)
-      }
-      
-      if (!keyword || keyword.trim() === '') {
-        this.diseaseSearchResults = []
+      if (!fromAddress || !toAddress) {
         return
       }
       
-      this.diseaseSearchTimer = setTimeout(() => {
-        this.searchDiseaseByKeyword(keyword)
-      }, 300)
+      console.log('璁$畻鎵嬪姩杈撳叆鍦板潃璺濈:', fromAddress, '->', toAddress)
+      
+      // 鏄剧ず鍔犺浇鎻愮ず
+      uni.showLoading({
+        title: '璁$畻璺濈涓�...'
+      })
+      
+      // 璋冪敤鐧惧害鍦板浘API璁$畻璺濈
+      const region = this.selectedRegion || '骞垮窞'
+      baiduDistanceByAddress(fromAddress, region, toAddress, region)
+        .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}鍏噷`)
+            
+            // 璺濈璁$畻鎴愬姛鍚庯紝鑷姩璁$畻鎴愪氦浠�
+            this.calculatePrice()
+          } else {
+            console.error('璺濈璁$畻澶辫触:', response.msg)
+            this.$modal.showToast('璺濈璁$畻澶辫触,璇锋墜鍔ㄨ緭鍏�')
+          }
+        })
+        .catch(error => {
+          uni.hideLoading()
+          console.error('璺濈璁$畻澶辫触:', error)
+          this.$modal.showToast('璺濈璁$畻澶辫触,璇锋墜鍔ㄨ緭鍏�')
+        })
     },
     
-    // 鏍规嵁鍏抽敭璇嶆悳绱㈢梾鎯�
-    searchDiseaseByKeyword(keyword) {
-      searchIcd10(keyword).then(response => {
-        this.diseaseSearchResults = response.data || []
+    // 璺濈杈撳叆妗嗗け鐒︽椂瑙﹀彂鎴愪氦浠疯绠�
+    onDistanceChange() {
+      this.calculatePrice()
+    },
+    
+    // 璁$畻鎴愪氦浠�
+    calculatePrice() {
+      const fromAddress = this.taskForm.hospitalOut.address
+      const toAddress = this.taskForm.hospitalIn.address
+      const distance = this.taskForm.transferDistance
+      
+      // 濡傛灉鍦板潃鎴栬窛绂讳笉瀹屾暣锛屼笉杩涜璁$畻
+      if (!fromAddress || !toAddress || !distance || parseFloat(distance) <= 0) {
+        console.log('鍦板潃鎴栬窛绂讳俊鎭笉瀹屾暣锛岃烦杩囨垚浜や环璁$畻')
+        return
+      }
+      
+      console.log('寮�濮嬭绠楁垚浜や环:', fromAddress, '->', toAddress, '璺濈:', distance)
+      
+      // 璋冪敤鎴愪氦浠疯绠楁帴鍙�
+      calculateTransferPrice({
+        fromAddress: fromAddress,
+        toAddress: toAddress,
+        distance: parseFloat(distance),
+        region: this.selectedRegion || ''
+      }).then(response => {
+        if (response.code === 200 && response.data) {
+          const price = response.data.price
+          
+          // 鍙湁褰撹繑鍥炵殑浠锋牸澶т簬0鏃讹紝鎵嶈嚜鍔ㄥ~鍏呮垚浜や环
+          if (price && price > 0) {
+            this.taskForm.price = price.toFixed(2)
+            console.log('鎴愪氦浠疯绠楁垚鍔�:', price)
+            this.$modal.showToast(`鎴愪氦浠�: 楼${price.toFixed(2)}`)
+          } else {
+            console.log('鎴愪氦浠蜂负0锛屼笉鑷姩濉厖')
+          }
+        } else {
+          console.log('鎴愪氦浠疯绠楀け璐ワ紝淇濇寔鎵嬪姩杈撳叆')
+        }
       }).catch(error => {
-        console.error('鎼滅储鐥呮儏澶辫触:', error)
-        this.diseaseSearchResults = []
+        console.error('鎴愪氦浠疯绠楀け璐�:', error)
+        // 璁$畻澶辫触鏃朵笉鎻愮ず鐢ㄦ埛锛屽厑璁哥敤鎴锋墜鍔ㄨ緭鍏�
       })
     },
-    
-    // 鍒囨崲鐥呮儏閫変腑鐘舵��
-    toggleDiseaseSelection(disease) {
-      const index = this.tempSelectedDiseases.findIndex(d => d.id === disease.id)
+    // 鎵嬪姩杈撳叆鍦板潃鏃惰绠楄窛绂�
+    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')
       
-      if (index > -1) {
-        // 宸查�変腑锛岀Щ闄�
-        this.tempSelectedDiseases.splice(index, 1)
-      } else {
-        // 鏈�変腑锛屾坊鍔�
-        this.tempSelectedDiseases.push({
-          id: disease.id,
-          icdCode: disease.icdCode,
-          icdName: disease.icdName,
-          sm: disease.sm
-        })
-      }
-    },
-    
-    // 鍒ゆ柇鐥呮儏鏄惁宸查�変腑
-    isDiseaseSelected(diseaseId) {
-      return this.tempSelectedDiseases.some(d => d.id === diseaseId)
-    },
-    
-    // 纭鐥呮儏閫夋嫨
-    confirmDiseaseSelection() {
-      // 灏嗕复鏃堕�夋嫨鐨勭梾鎯呭鍒跺埌姝e紡鍒楄〃
-      this.selectedDiseases = [...this.tempSelectedDiseases]
-      this.closeDiseaseSelector()
-    },
-    
-    // 绉婚櫎鐥呮儏
-    removeDisease(index) {
-      this.selectedDiseases.splice(index, 1)
+      // 鏍煎紡鍖栦负 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.selectedOrganizationId) {
+        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 +1004,28 @@
         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
+      }
+      
+      if (!this.taskForm.transferDistance) {
+        this.$modal.showToast('璇疯緭鍏ヨ浆杩愬叕閲屾暟')
+        return false
+      }
+      
+      if (!this.taskForm.price) {
+        this.$modal.showToast('璇疯緭鍏ユ垚浜や环')
         return false
       }
       
@@ -932,8 +1036,14 @@
       // 鍚堝苟鐥呮儏淇℃伅锛氶�変腑鐨処CD-10鐤剧梾 + 鍏朵粬鎻忚堪
       let conditionText = ''
       if (this.selectedDiseases.length > 0) {
-        const diseaseNames = this.selectedDiseases.map(d => `${d.icdName}(${d.icdCode})`).join('銆�')
-        conditionText = diseaseNames
+        // 杩囨护鎺夌梾鎯呭悕绉颁负绌虹殑椤癸紝骞舵瀯寤虹梾鎯呭瓧绗︿覆
+        const diseaseNames = this.selectedDiseases
+          .filter(d => d.icdName && d.icdName.trim())
+          .map(d => `${d.icdName}(${d.icdCode})`)
+          .join('銆�')
+        if (diseaseNames) {
+          conditionText = diseaseNames
+        }
       }
       if (this.taskForm.patient.condition && this.taskForm.patient.condition.trim()) {
         if (conditionText) {
@@ -945,34 +1055,63 @@
       
       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.filter(d => d.id !== null).map(d => d.id),
+        // 灏嗚浆鍑哄尰闄㈠湴鍧�浣滀负鍑哄彂鍦帮紝杞叆鍖婚櫌鍦板潃浣滀负鐩殑鍦�
+        departureAddress: this.taskForm.hospitalOut.address || '',
+        destinationAddress: this.taskForm.hospitalIn.address || '',
         patient: {
           ...this.taskForm.patient,
           condition: conditionText, // 浣跨敤鍚堝苟鍚庣殑鐥呮儏淇℃伅
-          diseases: this.selectedDiseases.map(d => ({
-            icdId: d.id,
-            icdCode: d.icdCode,
-            icdName: d.icdName
-          }))
+          diseases: this.selectedDiseases
+            .filter(d => d.icdName && d.icdName.trim())
+            .map(d => ({
+              icdId: d.id,
+              icdCode: d.icdCode,
+              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
@@ -990,9 +1129,18 @@
         addTask(submitData).then(response => {
           this.loading = false
           this.$modal.showToast('浠诲姟鍒涘缓鎴愬姛')
+          
+          // 寤惰繜璺宠浆锛岃鐢ㄦ埛鐪嬪埌鎴愬姛鎻愮ず
           setTimeout(() => {
-            this.$tab.navigateTo('/pages/task/index')
-          }, 1500)
+            // 璺宠浆鍒颁换鍔″垪琛ㄥ苟瑙﹀彂鍒锋柊
+            uni.switchTab({
+              url: '/pages/task/index',
+              success: () => {
+                // 浣跨敤浜嬩欢鎬荤嚎閫氱煡浠诲姟鍒楄〃椤甸潰鍒锋柊
+                uni.$emit('refreshTaskList')
+              }
+            })
+          }, 1000)
         }).catch(error => {
           this.loading = false
           console.error('浠诲姟鍒涘缓澶辫触:', error)
@@ -1001,8 +1149,436 @@
       }).catch(() => {})
     },
     
-    goBack() {
+   goBack() {
       uni.navigateBack()
+    },
+    
+    // ==================== 鏅鸿兘璇嗗埆鐩稿叧鏂规硶 ====================
+    
+    // 鏄剧ず鏅鸿兘璇嗗埆寮圭獥
+    showSmartParsePopup() {
+      this.rawText = ''
+      this.$refs.smartParsePopup.open()
+    },
+    
+    // 鍏抽棴鏅鸿兘璇嗗埆寮圭獥
+    closeSmartParsePopup() {
+      this.$refs.smartParsePopup.close()
+      this.rawText = ''
+    },
+    
+    // 瑙f瀽鑷敱鏂囨湰骞跺~鍏呰〃鍗�
+    parseFreeText() {
+      const text = (this.rawText || '').trim()
+      if (!text) {
+        this.$modal.showToast('璇峰厛绮樿创鎴栬緭鍏ユ枃鏈�')
+        return
+      }
+      this.parseLoading = true
+
+      const result = {
+        patientName: this.extractPatientName(text),
+        phone: this.extractPhone(text),
+        hospitalOutName: this.extractHospital(text, 'out'),
+        hospitalInName: this.extractHospital(text, 'in'),
+        departmentOut: this.extractDepartment(text, 'out'),
+        departmentIn: this.extractDepartment(text, 'in'),
+        price: this.extractPrice(text)
+      }
+
+      // 搴旂敤鍩虹瀛楁
+      if (result.patientName) this.taskForm.patient.name = result.patientName
+      if (result.phone) this.taskForm.patient.phone = result.phone
+      if (result.price) this.taskForm.price = result.price
+      
+      // 搴旂敤绉戝淇℃伅锛堝尮閰� departmentOptions 涓殑鏁版嵁锛�
+      if (result.departmentOut) {
+        const deptOut = this.matchDepartment(result.departmentOut)
+        if (deptOut) {
+          this.taskForm.hospitalOut.department = deptOut.text
+          this.taskForm.hospitalOut.departmentId = deptOut.id
+        }
+      }
+      if (result.departmentIn) {
+        const deptIn = this.matchDepartment(result.departmentIn)
+        if (deptIn) {
+          this.taskForm.hospitalIn.department = deptIn.text
+          this.taskForm.hospitalIn.departmentId = deptIn.id
+        }
+      }
+
+      // 澶勭悊鍖婚櫌鍚嶇О 鈫� 绮剧‘鍖归厤鍖婚櫌骞惰ˉ鍏ㄥ湴鍧�涓嶪D锛堜笉闄愬埗鍒嗗叕鍙稿尯鍩燂級
+      Promise.all([
+        this.findHospitalByName(result.hospitalOutName, 'out', false),
+        this.findHospitalByName(result.hospitalInName, 'in', false)
+      ])
+      .then(([outHosp, inHosp]) => {
+        if (outHosp) {
+          this.taskForm.hospitalOut.id = outHosp.hospId
+          this.taskForm.hospitalOut.name = outHosp.hospName
+          if (outHosp.hospName !== '瀹朵腑') {
+            this.taskForm.hospitalOut.address = this.buildFullAddress(outHosp)
+            this.taskForm.hospitalOut.city = outHosp.hopsCity || ''
+            this.hospitalOutSearchKeyword = outHosp.hospName
+          } else {
+            this.taskForm.hospitalOut.address = ''
+            this.taskForm.hospitalOut.department = '鍏跺畠'
+            this.hospitalOutSearchKeyword = '瀹朵腑'
+          }
+        } else if (result.hospitalOutName) {
+          this.taskForm.hospitalOut.name = result.hospitalOutName
+          this.hospitalOutSearchKeyword = result.hospitalOutName
+        }
+
+        if (inHosp) {
+          this.taskForm.hospitalIn.id = inHosp.hospId
+          this.taskForm.hospitalIn.name = inHosp.hospName
+          if (inHosp.hospName !== '瀹朵腑') {
+            this.taskForm.hospitalIn.address = this.buildFullAddress(inHosp)
+            this.taskForm.hospitalIn.city = inHosp.hopsCity || ''
+            this.hospitalInSearchKeyword = inHosp.hospName
+          } else {
+            this.taskForm.hospitalIn.address = ''
+            this.taskForm.hospitalIn.department = '鍏跺畠'
+            this.hospitalInSearchKeyword = '瀹朵腑'
+          }
+        } else if (result.hospitalInName) {
+          this.taskForm.hospitalIn.name = result.hospitalInName
+          this.hospitalInSearchKeyword = result.hospitalInName
+        }
+
+        // 鑻ヤ袱绔湴鍧�瀹屾暣锛岃嚜鍔ㄨ绠楄窛绂讳笌鎴愪氦浠�
+        if (this.taskForm.hospitalOut.address && this.taskForm.hospitalIn.address &&
+            this.taskForm.hospitalOut.name !== '瀹朵腑' && this.taskForm.hospitalIn.name !== '瀹朵腑') {
+          this.calculateHospitalDistance()
+        }
+      })
+      .catch(err => {
+        console.error('鍖婚櫌鍖归厤澶辫触:', err)
+      })
+      .finally(() => {
+        this.parseLoading = false
+        this.closeSmartParsePopup()
+        this.$modal.showToast('璇嗗埆瀹屾垚锛岃鏍稿鑷姩濉厖缁撴灉')
+      })
+    },
+
+    // 鎻愬彇鎵嬫満鍙凤紙浼樺厛鍖归厤绉诲姩鍙凤紝娆″尮閰嶅骇鏈猴級
+    extractPhone(text) {
+      // 鍏堝幓闄ゆ枃鏈腑鐨勭┖鏍硷紝鍐嶈繘琛屽尮閰�
+      const cleanText = text.replace(/\s+/g, '')
+      
+      // 鍖归厤11浣嶆墜鏈哄彿锛堟敮鎸佸師鏂囨湰涓湁绌烘牸鐨勬儏鍐碉級
+      const mobile = cleanText.match(/(?<!\d)(1[3-9]\d{9})(?!\d)/)
+      if (mobile) return mobile[1]
+      
+      // 鍖归厤搴ф満鍙凤紙鏀寔甯﹀尯鍙峰拰杩炲瓧绗︼級
+      const landline = cleanText.match(/0\d{2,3}-?\d{7,8}/)
+      if (landline) return landline[0]
+      
+      // 鍏滃簳锛氬湪鍘熸枃鏈腑鏌ユ壘甯︾┖鏍肩殑鎵嬫満鍙锋牸寮忥紙濡傦細182 8569 1756锛�
+      const mobileWithSpace = text.match(/(?:鐢佃瘽|鎵嬫満|鑱旂郴|tel|phone)[锛�:\s]*([1][3-9][\d\s]{9,15})/i)
+      if (mobileWithSpace) {
+        const cleanMobile = mobileWithSpace[1].replace(/\s+/g, '')
+        if (/^1[3-9]\d{9}$/.test(cleanMobile)) {
+          return cleanMobile
+        }
+      }
+      
+      // 鏈�鍚庡皾璇曪細鐩存帴鏌ユ壘浠绘剰甯︾┖鏍肩殑11浣嶆暟瀛楃粍鍚�
+      const anyMobile = text.match(/([1][3-9][\d\s]{9,15})/)
+      if (anyMobile) {
+        const cleanAny = anyMobile[1].replace(/\s+/g, '')
+        if (/^1[3-9]\d{9}$/.test(cleanAny)) {
+          return cleanAny
+        }
+      }
+      
+      return ''
+    },
+
+    // 鎻愬彇鎮h�呭鍚嶏紙甯歌鍏抽敭璇嶅墠缂�锛�
+    extractPatientName(text) {
+      const m = text.match(/(?:鎮h�厊鐥呬汉|濮撳悕|鑱旂郴浜�)[锛�: ]?\s*([\u4e00-\u9fa5]{2,4})/)
+      return m ? m[1] : ''
+    },
+
+    // 鎻愬彇鎴愪氦浠凤紙鏀寔锟�/鍏�/RMB绛夛級
+    extractPrice(text) {
+      const m1 = text.match(/(?:鎴愪氦浠穦浠锋牸|璐圭敤|鏀惰垂|鎬讳环|鍏�)[锛�: ]?\s*(?:锟楼|RMB|浜烘皯甯�)?\s*([0-9]+(?:\.[0-9]{1,2})?)/i)
+      if (m1) return parseFloat(m1[1]).toFixed(2)
+      const m2 = text.match(/(?:锟楼)\s*([0-9]+(?:\.[0-9]{1,2})?)/)
+      if (m2) return parseFloat(m2[1]).toFixed(2)
+      const m3 = text.match(/([0-9]+(?:\.[0-9]{1,2})?)\s*(?:鍏億浜烘皯甯亅RMB)/i)
+      if (m3) return parseFloat(m3[1]).toFixed(2)
+      return ''
+    },
+
+    // 鎻愬彇鍖婚櫌鍚嶇О锛堝熀浜庤涔夋爣璁帮紝鏀寔绠�绉板"鐪佸尰"锛�
+    extractHospital(text, type) {
+      // 鍏堝皾璇曡涔夋爣璁版彁鍙�
+      const outReg = /(?:杞嚭|鏉ヨ嚜|浠�)[锛�: ]?\s*([^\s锛�,銆傦紱;杞琞+?(?:鍖婚櫌|涓績|鍗敓闄鎬ユ晳涓績|瀹朵腑|鐪佸尰|甯傚尰|鍖哄尰|鍘垮尰|浜烘皯鍖婚櫌|涓尰闄濡囧辜|鍎跨鍖婚櫌))/
+      const inReg  = /(?:杞叆|鑷硘鍓嶅線|鍒皘鍘诲線|杞洖)[锛�: ]?\s*([^\s锛�,銆傦紱;杞琞+?(?:鍖婚櫌|涓績|鍗敓闄鎬ユ晳涓績|瀹朵腑|鐪佸尰|甯傚尰|鍖哄尰|鍘垮尰|浜烘皯鍖婚櫌|涓尰闄濡囧辜|鍎跨鍖婚櫌))/
+      const reg = type === 'out' ? outReg : inReg
+      const m = text.match(reg)
+      if (m) {
+        // 鍘婚櫎鍙兘鍖呭惈鐨勬ゼ鏍嬨�佹ゼ灞傘�佺瀹ょ瓑淇℃伅
+        let hospitalName = m[1]
+        // 鍘婚櫎妤兼爧淇℃伅锛堝锛氫笢涓�鍙锋ゼ銆丄鏍嬬瓑锛�
+        hospitalName = hospitalName.replace(/[涓滆タ鍗楀寳涓璢?[涓�浜屼笁鍥涗簲鍏竷鍏節鍗�0-9]+鍙�?妤�.*/g, '')
+        // 鍘婚櫎妤煎眰淇℃伅锛堝锛氬洓妤笺��3F绛夛級
+        hospitalName = hospitalName.replace(/[涓�浜屼笁鍥涗簲鍏竷鍏節鍗�0-9]+[妤煎眰F].*/g, '')
+        return hospitalName.trim()
+      }
+      
+      // 鏃犺涔夋爣璁版椂锛屽厹搴曟彁鍙栭涓�"鍚尰闄�/涓績/瀹朵腑/绠�绉�"鐨勭墖娈�
+      const any = text.match(/([^\s锛�,銆傦紱;杞琞+?(?:鍖婚櫌|涓績|鍗敓闄鎬ユ晳涓績|瀹朵腑|鐪佸尰|甯傚尰|鍖哄尰|鍘垮尰|浜烘皯鍖婚櫌|涓尰闄濡囧辜|鍎跨鍖婚櫌))/g)
+      if (any && any.length > 0) {
+        if (type === 'out') {
+          let name = any[0]
+          name = name.replace(/[涓滆タ鍗楀寳涓璢?[涓�浜屼笁鍥涗簲鍏竷鍏節鍗�0-9]+鍙�?妤�.*/g, '')
+          name = name.replace(/[涓�浜屼笁鍥涗簲鍏竷鍏節鍗�0-9]+[妤煎眰F].*/g, '')
+          return name.trim()
+        }
+        if (type === 'in') {
+          let name = any[1] || any[0]
+          name = name.replace(/[涓滆タ鍗楀寳涓璢?[涓�浜屼笁鍥涗簲鍏竷鍏節鍗�0-9]+鍙�?妤�.*/g, '')
+          name = name.replace(/[涓�浜屼笁鍥涗簲鍏竷鍏節鍗�0-9]+[妤煎眰F].*/g, '')
+          return name.trim()
+        }
+      }
+      return ''
+    },
+    
+    // 鍖归厤绉戝锛堜紭鍏堜娇鐢� departmentOptions 涓殑鏁版嵁锛�
+    matchDepartment(deptName) {
+      if (!deptName || !this.departmentOptions || this.departmentOptions.length === 0) {
+        return null
+      }
+      
+      const normalized = deptName.trim().toUpperCase()
+      
+      // 1. 绮剧‘鍖归厤锛堜笉鍖哄垎澶у皬鍐欙級
+      let matched = this.departmentOptions.find(d => 
+        d.text.toUpperCase() === normalized
+      )
+      if (matched) return matched
+      
+      // 2. 鍖呭惈鍖归厤锛堢瀹ゅ悕鍖呭惈璇嗗埆鍒扮殑鍏抽敭璇嶏級
+      matched = this.departmentOptions.find(d => 
+        d.text.toUpperCase().includes(normalized) || 
+        normalized.includes(d.text.toUpperCase())
+      )
+      if (matched) return matched
+      
+      // 3. 妯$硦鍖归厤锛堝幓闄�"绉�"銆�"瀹�"绛夊悗缂�鍐嶅尮閰嶏級
+      const cleanedInput = normalized.replace(/[绉戝閮╙/g, '')
+      matched = this.departmentOptions.find(d => {
+        const cleanedDept = d.text.toUpperCase().replace(/[绉戝閮╙/g, '')
+        return cleanedDept === cleanedInput || 
+               cleanedDept.includes(cleanedInput) || 
+               cleanedInput.includes(cleanedDept)
+      })
+      if (matched) return matched
+      
+      return null
+    },
+    
+    // 鎻愬彇绉戝淇℃伅
+    extractDepartment(text, type) {
+      // 甯歌绉戝鍏抽敭璇嶏紙浣滀负鍏滃簳鏂规锛�
+      const departments = [
+        'ICU', 'NICU', 'PICU', 'CCU', 'EICU',
+        '閲嶇棁鐩戞姢瀹�', '鎬ヨ瘖绉�', '闂ㄨ瘖', '浣忛櫌閮�',
+        '鍐呯', '澶栫', '濡囦骇绉�', '鍎跨', '楠ㄧ', '绁炵粡绉�',
+        '蹇冨唴绉�', '蹇冨绉�', '鍛煎惛绉�', '娑堝寲绉�', '鑲惧唴绉�',
+        '琛�娑茬', '鑲跨槫绉�', '鎰熸煋绉�', '鐨偆绉�', '鐪肩',
+        '鑰抽蓟鍠夌', '鍙h厰绉�', '涓尰绉�', '搴峰绉�', '绮剧绉�',
+        '娉屽翱绉�', '鍐呭垎娉岀', '椋庢箍绉�', '鏅绉�', '鑳稿绉�',
+        '绁炵粡澶栫', '鏁村舰绉�', '鐑т激绉�', '楹婚唹绉�', '鏀惧皠绉�',
+        '妫�楠岀', '鐥呯悊绉�', '鑽墏绉�', '钀ュ吇绉�'
+      ]
+      
+      // 浼樺厛灏濊瘯浠� departmentOptions 涓尮閰�
+      if (this.departmentOptions && this.departmentOptions.length > 0) {
+        // 鏋勫缓 departmentOptions 鐨勫尮閰嶆ā寮忥紙鎸夐暱搴﹀�掑簭锛�
+        const optionTexts = this.departmentOptions.map(d => d.text).sort((a, b) => b.length - a.length)
+        const optionPattern = optionTexts.map(t => t.replace(/[()锛堬級]/g, '\\$&')).join('|')
+        
+        if (optionPattern) {
+          const regex = new RegExp(`(${optionPattern})`, 'gi')
+          const matches = text.match(regex)
+          
+          if (matches && matches.length > 0) {
+            // 濡傛灉鏄浆鍑猴紝鍙栫涓�涓瀹わ紱濡傛灉鏄浆鍏ワ紝鍙栨渶鍚庝竴涓瀹�
+            return type === 'out' ? matches[0] : matches[matches.length - 1]
+          }
+        }
+      }
+      
+      // 鍏滃簳锛氫娇鐢ㄩ粯璁ょ瀹ゅ垪琛ㄥ尮閰�
+      const sortedDepts = departments.sort((a, b) => b.length - a.length)
+      const deptPattern = sortedDepts.join('|')
+      
+      const regex = new RegExp(`(${deptPattern})`, 'g')
+      const matches = text.match(regex)
+      
+      if (matches && matches.length > 0) {
+        // 濡傛灉鏄浆鍑猴紝鍙栫涓�涓瀹わ紱濡傛灉鏄浆鍏ワ紝鍙栨渶鍚庝竴涓瀹�
+        return type === 'out' ? matches[0] : matches[matches.length - 1]
+      }
+      
+      return ''
+    },
+
+    // 閫氳繃鍚嶇О鍖归厤鍖婚櫌锛坮estrictRegion=false 鏃跺叏灞�鏌ヨ锛�
+    findHospitalByName(name, type, restrictRegion = true) {
+      if (!name) return Promise.resolve(null)
+      const normalized = name.trim()
+
+      // 鐗规畩澶勭悊"瀹朵腑"
+      if (normalized === '瀹朵腑') {
+        // 鏌ヨ鍖婚櫌搴撲腑鐨�"瀹朵腑"璁板綍
+        const deptId = this.selectedOrganizationId || null
+        const queryPromise = restrictRegion && deptId
+          ? searchHospitalsByDeptRegion('瀹朵腑', deptId, 50)
+          : searchHospitals('瀹朵腑', null, 50)
+        
+        return queryPromise.then(res => {
+          const list = res.data || []
+          // 鏌ユ壘鍚嶇О涓�"瀹朵腑"鐨勫尰闄㈣褰�
+          const homeHospital = list.find(h => h.hospName === '瀹朵腑')
+          if (homeHospital) {
+            return homeHospital
+          }
+          // 濡傛灉娌℃湁鎵惧埌锛岃繑鍥為粯璁ょ粨鏋�
+          return {
+            hospId: null,
+            hospName: '瀹朵腑',
+            hopsCity: '',
+            hospAddress: ''
+          }
+        }).catch(() => {
+          // 鏌ヨ澶辫触锛岃繑鍥為粯璁ょ粨鏋�
+          return {
+            hospId: null,
+            hospName: '瀹朵腑',
+            hopsCity: '',
+            hospAddress: ''
+          }
+        })
+      }
+
+      // restrictRegion=false 鏃惰蛋鍏ㄩ噺鏌ヨ锛泃rue 涓旀湁 deptId 鏃惰蛋鍖哄煙鎺ュ彛
+      const deptId = this.selectedOrganizationId || null
+      const queryPromise = (restrictRegion && deptId)
+        ? searchHospitalsByDeptRegion(normalized, deptId, 50)
+        : searchHospitals(normalized, null, 50)
+
+      return queryPromise.then(res => {
+        const list = res.data || []
+        if (!list.length) return null
+        
+        // 鑷姩閫夋嫨绗竴涓潪"瀹朵腑"鐨勫尯闄紝濡傛灉鍏ㄦ槸"瀹朵腑"鍒欓�夌涓�涓�
+        const best = this.pickBestHospitalMatch(list, normalized)
+        return best || null
+      })
+    },
+
+    // 鍦ㄥ�欓�変腑閫夋嫨鏈�浼樺尮閰嶏紙鏀寔绠�绉板尮閰嶃�佸寘鍚笌闀垮害鎺ヨ繎锛�
+    pickBestHospitalMatch(list, name) {
+      const n = name.trim()
+      
+      // 杩囨护鎺�"瀹朵腑"锛屼紭鍏堥�夋嫨鐪熷疄鍖婚櫌
+      const realHospitals = list.filter(h => h.hospName !== '瀹朵腑')
+      const searchList = realHospitals.length > 0 ? realHospitals : list
+      
+      // 1. 瀹屽叏鐩哥瓑锛堟寮忓悕锛�
+      let best = searchList.find(h => (h.hospName || '').trim() === n)
+      if (best) return best
+      // 2. 瀹屽叏鐩哥瓑锛堢畝绉帮級
+      best = searchList.find(h => (h.hospShort || '').trim() === n)
+      if (best) return best
+      // 3. 鍖呭惈锛堟寮忓悕锛�
+      best = searchList.find(h => (h.hospName || '').includes(n) || n.includes((h.hospName || '')))
+      if (best) return best
+      // 4. 鍖呭惈锛堢畝绉帮級
+      best = searchList.find(h => (h.hospShort || '').includes(n) || n.includes((h.hospShort || '')))
+      if (best) return best
+      // 5. 闀垮害鏈�鎺ヨ繎
+      best = [...searchList].sort((a, b) => {
+        const da = Math.abs((a.hospName || '').length - n.length)
+        const db = Math.abs((b.hospName || '').length - n.length)
+        return da - db
+      })[0]
+      
+      // 濡傛灉娌℃湁鎵惧埌浠讳綍鍖归厤锛岃繑鍥炵涓�涓�
+      return best || searchList[0] || null
+    },
+    
+    // 鍚堝苟鍖婚櫌鍦板潃锛堢渷 + 甯� + 鍖� + 璇︾粏鍦板潃锛�
+    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}鍏噷`)
+            
+            // 璺濈璁$畻鎴愬姛鍚庯紝鑷姩璁$畻鎴愪氦浠�
+            this.calculatePrice()
+          } else {
+            console.error('璺濈璁$畻澶辫触:', response.msg)
+            this.$modal.showToast('璺濈璁$畻澶辫触锛岃鎵嬪姩杈撳叆')
+          }
+        })
+        .catch(error => {
+          uni.hideLoading()
+          console.error('璺濈璁$畻澶辫触:', error)
+          this.$modal.showToast('璺濈璁$畻澶辫触锛岃鎵嬪姩杈撳叆')
+        })
     }
   }
 }
@@ -1032,9 +1608,24 @@
     }
     
     .title {
+      flex: 1;
       font-size: 36rpx;
       font-weight: bold;
       color: #333;
+    }
+    
+    .smart-parse-btn {
+      display: flex;
+      flex-direction: column;
+      align-items: center;
+      justify-content: center;
+      padding: 10rpx 20rpx;
+      
+      text {
+        font-size: 22rpx;
+        color: #007AFF;
+        margin-top: 4rpx;
+      }
     }
   }
   
@@ -1059,6 +1650,13 @@
         font-size: 28rpx;
         margin-bottom: 15rpx;
         color: #333;
+        
+        &.required::before {
+          content: '*';
+          color: #ff4d4f;
+          margin-right: 4rpx;
+          font-weight: bold;
+        }
       }
       
       .hospital-search-container {
@@ -1094,9 +1692,60 @@
               color: #333;
               font-weight: bold;
               margin-bottom: 8rpx;
+              
+              .hospital-short {
+                display: block;
+                font-size: 22rpx;
+                color: #999;
+                font-weight: normal;
+                margin-top: 6rpx;
+              }
             }
             
             .hospital-address {
+              font-size: 24rpx;
+              color: #999;
+            }
+          }
+        }
+      }
+      
+      .address-input-container {
+        position: relative;
+        
+        .address-suggestions {
+          position: absolute;
+          top: 75rpx;
+          left: 0;
+          right: 0;
+          max-height: 400rpx;
+          background-color: white;
+          border: 1rpx solid #eee;
+          border-radius: 10rpx;
+          box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
+          z-index: 100;
+          overflow-y: auto;
+          
+          .address-suggestion-item {
+            padding: 20rpx 30rpx;
+            border-bottom: 1rpx solid #f0f0f0;
+            
+            &:last-child {
+              border-bottom: none;
+            }
+            
+            &:active {
+              background-color: #f5f5f5;
+            }
+            
+            .suggestion-name {
+              font-size: 28rpx;
+              color: #333;
+              font-weight: bold;
+              margin-bottom: 8rpx;
+            }
+            
+            .suggestion-address {
               font-size: 24rpx;
               color: #999;
             }
@@ -1411,8 +2060,8 @@
   }
 }
 
-// 鐥呮儏閫夋嫨寮圭獥鏍峰紡
-.disease-selector-popup {
+// 鏅鸿兘璇嗗埆寮圭獥鏍峰紡
+.smart-parse-popup {
   background-color: white;
   border-radius: 20rpx 20rpx 0 0;
   max-height: 80vh;
@@ -1438,89 +2087,36 @@
     }
   }
   
-  .search-box {
-    display: flex;
-    align-items: center;
-    margin: 20rpx 30rpx;
-    padding: 15rpx 20rpx;
-    background-color: #f5f5f5;
-    border-radius: 10rpx;
-    flex-shrink: 0;
-    
-    .search-input {
-      flex: 1;
-      margin-left: 10rpx;
-      font-size: 28rpx;
-    }
-  }
-  
-  .disease-list-popup {
+  .parse-content {
     flex: 1;
+    padding: 30rpx;
     overflow-y: auto;
-    padding: 0 30rpx;
     
-    .disease-item-popup {
+    .parse-tip {
       display: flex;
-      justify-content: space-between;
-      align-items: center;
-      padding: 25rpx 20rpx;
-      border-bottom: 1rpx solid #f0f0f0;
-      
-      &:active {
-        background-color: #f5f5f5;
-      }
-      
-      .disease-info {
-        flex: 1;
-        
-        .disease-name-row {
-          display: flex;
-          align-items: center;
-          margin-bottom: 8rpx;
-          
-          .disease-name {
-            font-size: 30rpx;
-            font-weight: bold;
-            color: #333;
-            margin-right: 15rpx;
-          }
-          
-          .disease-code {
-            font-size: 24rpx;
-            color: #007AFF;
-            background-color: #e6f2ff;
-            padding: 4rpx 12rpx;
-            border-radius: 6rpx;
-          }
-        }
-        
-        .disease-detail-row {
-          .disease-desc {
-            font-size: 24rpx;
-            color: #999;
-            line-height: 1.5;
-          }
-        }
-      }
-      
-      .checkbox-empty {
-        width: 40rpx;
-        height: 40rpx;
-        border: 2rpx solid #ddd;
-        border-radius: 50%;
-      }
-    }
-    
-    .no-data {
-      text-align: center;
-      padding: 100rpx 0;
-      color: #999;
+      align-items: flex-start;
+      padding: 20rpx;
+      background-color: #f0f7ff;
+      border-radius: 10rpx;
+      margin-bottom: 20rpx;
       
       text {
-        display: block;
-        margin-top: 20rpx;
-        font-size: 28rpx;
+        flex: 1;
+        margin-left: 10rpx;
+        font-size: 24rpx;
+        color: #666;
+        line-height: 1.6;
       }
+    }
+    
+    .parse-textarea {
+      width: 100%;
+      min-height: 300rpx;
+      padding: 20rpx;
+      border: 1rpx solid #eee;
+      border-radius: 10rpx;
+      font-size: 28rpx;
+      line-height: 1.6;
     }
   }
   
@@ -1546,6 +2142,11 @@
     .confirm-btn {
       background-color: #007AFF;
       color: white;
+      
+      &[disabled] {
+        background-color: #ccc;
+        color: #999;
+      }
     }
   }
 }

--
Gitblit v1.9.1