From f67945d53b20f6a45ae50b27d74c966eb1355bb4 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 16 十一月 2025 22:53:54 +0800
Subject: [PATCH] feat: 增加分段GPS计算行程距离
---
app/pages/task/create-emergency.vue | 1390 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 1,293 insertions(+), 97 deletions(-)
diff --git a/app/pages/task/create-emergency.vue b/app/pages/task/create-emergency.vue
index a056049..6cd7631 100644
--- a/app/pages/task/create-emergency.vue
+++ b/app/pages/task/create-emergency.vue
@@ -5,6 +5,10 @@
<uni-icons type="arrowleft" size="20"></uni-icons>
</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">
@@ -18,7 +22,7 @@
</picker>
</view>
<view class="form-item">
- <view class="form-label">褰掑睘鏈烘瀯</view>
+ <view class="form-label required">褰掑睘鏈烘瀯</view>
<picker mode="selector" :range="organizations" @change="onOrganizationChange">
<view class="form-input picker-input">
{{ selectedOrganization || '璇烽�夋嫨褰掑睘鏈烘瀯' }}
@@ -78,7 +82,7 @@
<view class="form-item">
- <view class="form-label">杞繍鏃堕棿</view>
+ <view class="form-label required">杞繍鏃堕棿</view>
<uni-datetime-picker
v-model="taskForm.transferTime"
type="datetime"
@@ -189,7 +193,10 @@
:key="hospital.hospId"
@click="selectHospitalOut(hospital)"
>
- <view class="hospital-name">{{ hospital.hospName }}</view>
+ <view class="hospital-name">
+ {{ hospital.hospName }}
+ <text class="hospital-short" v-if="hospital.hospShort">{{ hospital.hospShort }}</text>
+ </view>
<view class="hospital-address">{{ buildFullAddress(hospital) }}</view>
</view>
</view>
@@ -198,12 +205,21 @@
<view class="form-item">
<view class="form-label required">绉戝</view>
- <picker mode="selector" :range="departmentOptions" range-key="text" @change="onHospitalOutDepartmentChange">
+ <picker
+ v-if="taskForm.hospitalOut.name !== '瀹朵腑'"
+ 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 v-else class="form-input picker-input disabled">
+ 鍏跺畠
+ </view>
</view>
<view class="form-item">
@@ -217,7 +233,26 @@
<view class="form-item">
<view class="form-label">杞嚭鍦板潃</view>
- <view class="form-input picker-input disabled">
+ <view class="address-input-container" v-if="taskForm.hospitalOut.name === '瀹朵腑'">
+ <input
+ class="form-input"
+ placeholder="璇疯緭鍏ヨ缁嗗湴鍧�"
+ v-model="taskForm.hospitalOut.address"
+ @input="onAddressOutInput"
+ @focus="onAddressOutFocus"
+ />
+ <view class="address-suggestions" v-if="showAddressOutSuggestions && addressOutSuggestions.length > 0">
+ <view
+ class="address-suggestion-item"
+ v-for="(item, index) in addressOutSuggestions"
+ :key="index"
+ @click="selectAddressOut(item)">
+ <view class="suggestion-name">{{ item.name }}</view>
+ <view class="suggestion-address">{{ item.district }}{{ item.address }}</view>
+ </view>
+ </view>
+ </view>
+ <view v-else class="form-input picker-input disabled">
{{ taskForm.hospitalOut.address || '閫夋嫨鍖婚櫌鍚庤嚜鍔ㄥ~鍏�' }}
</view>
</view>
@@ -240,7 +275,10 @@
:key="hospital.hospId"
@click="selectHospitalIn(hospital)"
>
- <view class="hospital-name">{{ hospital.hospName }}</view>
+ <view class="hospital-name">
+ {{ hospital.hospName }}
+ <text class="hospital-short" v-if="hospital.hospShort">{{ hospital.hospShort }}</text>
+ </view>
<view class="hospital-address">{{ buildFullAddress(hospital) }}</view>
</view>
</view>
@@ -249,12 +287,21 @@
<view class="form-item">
<view class="form-label required">绉戝</view>
- <picker mode="selector" :range="departmentOptions" range-key="text" @change="onHospitalInDepartmentChange">
+ <picker
+ v-if="taskForm.hospitalIn.name !== '瀹朵腑'"
+ 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 v-else class="form-input picker-input disabled">
+ 鍏跺畠
+ </view>
</view>
<view class="form-item">
@@ -268,23 +315,43 @@
<view class="form-item">
<view class="form-label">杞叆鍦板潃</view>
- <view class="form-input picker-input disabled">
+ <view class="address-input-container" v-if="taskForm.hospitalIn.name === '瀹朵腑'">
+ <input
+ class="form-input"
+ placeholder="璇疯緭鍏ヨ缁嗗湴鍧�"
+ v-model="taskForm.hospitalIn.address"
+ @input="onAddressInInput"
+ @focus="onAddressInFocus"
+ />
+ <view class="address-suggestions" v-if="showAddressInSuggestions && addressInSuggestions.length > 0">
+ <view
+ class="address-suggestion-item"
+ v-for="(item, index) in addressInSuggestions"
+ :key="index"
+ @click="selectAddressIn(item)">
+ <view class="suggestion-name">{{ item.name }}</view>
+ <view class="suggestion-address">{{ item.district }}{{ item.address }}</view>
+ </view>
+ </view>
+ </view>
+ <view v-else 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"
@@ -377,6 +444,38 @@
</view>
</uni-popup>
+ <!-- 鏅鸿兘璇嗗埆寮圭獥 -->
+ <uni-popup ref="smartParsePopup" type="bottom" :safe-area="true">
+ <view class="smart-parse-popup">
+ <view class="popup-header">
+ <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="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>
+
+ <view class="popup-footer">
+ <button class="cancel-btn" @click="closeSmartParsePopup">鍙栨秷</button>
+ <button class="confirm-btn" @click="parseFreeText" :disabled="parseLoading">
+ {{ parseLoading ? '璇嗗埆涓�...' : '寮�濮嬭瘑鍒�' }}
+ </button>
+ </view>
+ </view>
+ </uni-popup>
+
<!-- 鐥呮儏閫夋嫨寮圭獥 -->
<uni-popup ref="diseasePopup" type="bottom" :safe-area="true">
<view class="disease-selector-popup">
@@ -443,14 +542,16 @@
import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
import { addTask } from "@/api/task"
import { listAvailableVehicles, getUserBoundVehicle } from "@/api/vehicle"
-import { calculateDistance } from "@/api/map"
-import { searchHospitals } from "@/api/hospital"
-import { listUser } from "@/api/system/user"
+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 } from "@/api/system/dept"
+import { listBranchCompany, getDept } from "@/api/system/dept"
import MapSelector from '@/components/map-selector.vue'
export default {
@@ -465,6 +566,7 @@
selectedVehicleId: null,
selectedOrganization: '',
selectedOrganizationId: null, // 褰掑睘鏈烘瀯ID锛堥儴闂↖D锛�
+ selectedOrganizationServiceOrderClass: '', // 褰掑睘鏈烘瀯鐨勬湇鍔″崟缂栫爜
selectedRegion: '', // 浠庡綊灞炴満鏋勪腑鎻愬彇鐨勫湴鍩熶俊鎭紙濡傦細骞垮窞銆佹繁鍦崇瓑锛�
selectedEmergencyTaskType: '', // 閫変腑鐨勪换鍔$被鍨嬫枃鏈�
selectedEmergencyTaskTypeId: null, // 閫変腑鐨勪换鍔$被鍨婭D
@@ -480,6 +582,12 @@
showHospitalInResults: false,
searchTimer: null,
defaultHospitals: [], // 榛樿鐨�100鏉″尰闄㈡暟鎹�
+ // 鍦板潃鎼滅储鎻愮ず鐩稿叧
+ addressOutSuggestions: [], // 杞嚭鍦板潃鎻愮ず鍒楄〃
+ showAddressOutSuggestions: false,
+ addressInSuggestions: [], // 杞叆鍦板潃鎻愮ず鍒楄〃
+ showAddressInSuggestions: false,
+ addressSearchTimer: null, // 鍦板潃鎼滅储闃叉姈瀹氭椂鍣�
// 浜哄憳閫夋嫨鐩稿叧
selectedStaff: [], // 宸查�夋嫨鐨勪汉鍛樺垪琛�
allStaffList: [], // 鎵�鏈変汉鍛樺垪琛�
@@ -534,7 +642,10 @@
addressCoordinates: {
hospitalOutAddress: null,
hospitalInAddress: null
- }
+ },
+ // 鏅鸿兘璇嗗埆鐩稿叧
+ rawText: '',
+ parseLoading: false
}
},
computed: {
@@ -560,6 +671,9 @@
}
},
onLoad(options) {
+ // 璁剧疆榛樿杞繍鏃堕棿涓哄綋鍓嶆椂闂�
+ this.setDefaultTransferTime()
+
// 鍏堝姞杞借溅杈嗗垪琛紝鐒跺悗鍔犺浇缁戝畾杞﹁締淇℃伅
this.getAvailableVehicles().then(() => {
this.getUserBoundVehicleInfo()
@@ -615,17 +729,21 @@
},
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 = []
})
},
@@ -641,13 +759,17 @@
const selected = this.organizationOptions[index]
this.selectedOrganization = selected.deptName
this.selectedOrganizationId = selected.deptId // 淇濆瓨閮ㄩ棬ID
- // 浠庡綊灞炴満鏋勪腑鎻愬彇鍦板煙鍏抽敭璇嶏紙鍘婚櫎"鍒嗗叕鍙�"鍚庣紑锛�
- // 渚嬪锛�"骞垮窞鍒嗗叕鍙�" -> "骞垮窞"
- this.selectedRegion = selected.deptName.replace(/鍒嗗叕鍙�$/g, '').trim()
+ this.selectedOrganizationServiceOrderClass = selected.serviceOrderClass || '' // 淇濆瓨鏈嶅姟鍗曠紪鐮�
+ // 浠庡綊灞炴満鏋勪腑鎻愬彇鍦板煙鍏抽敭璇嶏紙鍘婚櫎鈥滃垎鍏徃鈥濆悗缂�锛�
+ // 渚嬪锛氣�滃箍宸炲垎鍏徃鈥� -> 鈥滃箍宸炩��
+ //濡傛灉鍑虹幇骞垮窞鎬诲叕鍙革紝涔熻鍘婚櫎鈥滄�诲叕鍙糕�濆悗缂�
+ this.selectedRegion = this.replaceRegion(selected.deptName);
// 閲嶆柊鍔犺浇鍖婚櫌鍒楄〃锛堝甫鍦板煙杩囨护锛�
this.loadDefaultHospitals()
},
-
+ replaceRegion(region){
+ return region.replace(/(鍒嗗叕鍙竱鎬诲叕鍙竱鎬婚儴)$/g, '').trim();
+ },
// 鍔犺浇鍒嗗叕鍙告暟鎹紙parent_id=100鐨勯儴闂級
loadBranchCompanies() {
listBranchCompany().then(response => {
@@ -665,9 +787,10 @@
if (index !== -1) {
this.selectedOrganization = this.currentUser.branchCompanyName
this.selectedOrganizationId = this.organizationOptions[index].deptId // 淇濆瓨閮ㄩ棬ID
+ this.selectedOrganizationServiceOrderClass = this.organizationOptions[index].serviceOrderClass || '' // 淇濆瓨鏈嶅姟鍗曠紪鐮�
// 鎻愬彇鍦板煙鍏抽敭璇�
- this.selectedRegion = this.selectedOrganization.replace(/鍒嗗叕鍙�$/g, '').trim()
- console.log('榛樿閫変腑褰掑睘鏈烘瀯:', this.selectedOrganization, '閮ㄩ棬ID:', this.selectedOrganizationId, '鍦板煙:', this.selectedRegion)
+ this.selectedRegion =this.replaceRegion(this.selectedOrganization);
+ console.log('榛樿閫変腑褰掑睘鏈烘瀯:', this.selectedOrganization, '閮ㄩ棬ID:', this.selectedOrganizationId, '鏈嶅姟鍗曠紪鐮�:', this.selectedOrganizationServiceOrderClass, '鍦板煙:', this.selectedRegion)
// 鍔犺浇鍖婚櫌鍒楄〃锛堝甫鍦板煙杩囨护锛�
this.loadDefaultHospitals()
}
@@ -729,7 +852,7 @@
switch(staffType){
case "nurse":
return "鎶ゅ+";
- case "doctor":
+ case "doctor":
return "鍖荤敓";
case "driver":
return "鍙告満";
@@ -785,25 +908,147 @@
this.taskForm.hospitalIn.departmentId = selected.id // 淇濆瓨绉戝ID
},
- // 鍔犺浇榛樿鍖洪櫌鍒楄〃锛堝墠100鏉★級
+ // 鍔犺浇榛樿鍖婚櫌鍒楄〃锛堝父鐢ㄥ尰闄級
loadDefaultHospitals() {
- // 浼犲叆绌哄瓧绗︿覆鎴栫壒娈婃爣璇嗚幏鍙栧墠100鏉★紝鍚屾椂浼犲叆鍦板煙杩囨护
+ // 妫�鏌ユ槸鍚︽湁褰掑睘鏈烘瀯ID
+ if (!this.selectedOrganizationId) {
+ console.warn('鏈�夋嫨褰掑睘鏈烘瀯锛屾棤娉曞姞杞藉尰闄㈠垪琛�')
+ return
+ }
+
+ // 杞嚭鍖婚櫌锛氭牴鎹綊灞炴満鏋勭殑鍖哄煙閰嶇疆鍔犺浇
+ this.loadHospitalsByDeptRegion('out')
+
+ // 杞叆鍖婚櫌锛氭牴鎹綊灞炴満鏋勭殑鍖哄煙閰嶇疆鍔犺浇
+ this.loadHospitalsByDeptRegion('in')
+ },
+
+ // 闄嶇骇鍔犺浇鍖婚櫌锛堟寜鍦板煙杩囨护锛�
+ loadDefaultHospitalsByRegion() {
+ // 杞嚭鍖婚櫌锛氬彧鍔犺浇褰撳墠鍖哄煙鐨勫尰闄紙甯﹀湴鍩熻繃婊わ級
searchHospitals('', this.selectedRegion).then(response => {
- this.defaultHospitals = response.data || []
- // 鍚屾椂鍒濆鍖栦袱涓悳绱㈢粨鏋滀负榛樿鏁版嵁
- this.hospitalOutResults = [...this.defaultHospitals]
- this.hospitalInResults = [...this.defaultHospitals]
+ this.hospitalOutResults = response.data || []
+ console.log('鍔犺浇杞嚭鍖婚櫌锛堝綋鍓嶅尯鍩燂級:', this.selectedRegion, '鏁伴噺:', this.hospitalOutResults.length)
}).catch(error => {
- console.error('鍔犺浇榛樿鍖洪櫌鍒楄〃澶辫触:', error)
- this.defaultHospitals = []
+ console.error('鍔犺浇杞嚭鍖婚櫌鍒楄〃澶辫触:', error)
+ this.hospitalOutResults = []
})
+
+ // 杞叆鍖婚櫌锛氬姞杞芥墍鏈夊尰闄紙涓嶅甫鍦板煙杩囨护锛屽悗缁細鎸夊湴鍩熸帓搴忥級
+ searchHospitals('', '').then(response => {
+ const allHospitals = response.data || []
+ // 灏嗗尰闄㈡寜鍦板煙鎺掑簭锛氭湰鍦板尯鍩熶紭鍏�
+ this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+ console.log('鍔犺浇杞叆鍖婚櫌锛堝叏閮ㄥ尯鍩燂級:', '鏁伴噺:', this.hospitalInResults.length)
+ }).catch(error => {
+ console.error('鍔犺浇杞叆鍖婚櫌鍒楄〃澶辫触:', error)
+ this.hospitalInResults = []
+ })
+ },
+
+ // 鏍规嵁閮ㄩ棬鍖哄煙閰嶇疆鍔犺浇鍖婚櫌
+ loadHospitalsByDeptRegion(type) {
+ const deptId = this.selectedOrganizationId
+ if (!deptId) {
+ console.warn('閮ㄩ棬ID涓嶅瓨鍦�')
+ return
+ }
+
+ // 璋冪敤鍚庣鎺ュ彛锛屾牴鎹儴闂ㄧ殑鍖哄煙閰嶇疆鏌ヨ鍖婚櫌
+ searchHospitalsByDeptRegion('', deptId).then(response => {
+ const hospitals = response.data || []
+
+ if (type === 'out') {
+ this.hospitalOutResults = hospitals
+ console.log('鍔犺浇杞嚭鍖婚櫌锛堝尯鍩熼厤缃級锛氶儴闂�', deptId, '鏁伴噺:', this.hospitalOutResults.length)
+ } else if (type === 'in') {
+ // 杞叆鍖婚櫌鎸夊湴鍩熸帓搴�
+ this.hospitalInResults = this.sortHospitalsByRegion(hospitals)
+ console.log('鍔犺浇杞叆鍖婚櫌锛堝尯鍩熼厤缃級锛氶儴闂�', deptId, '鏁伴噺:', this.hospitalInResults.length)
+ }
+ }).catch(error => {
+ console.error('鍔犺浇鍖婚櫌澶辫触锛堝尯鍩熼厤缃級:', error)
+ // 澶辫触鍚庨檷绾т负鏅�氭悳绱�
+ this.loadDefaultHospitalsByRegion()
+ })
+ },
+
+ // 鎸夊湴鍩熸帓搴忓尰闄細鏈湴鍖哄煙浼樺厛锛�"瀹朵腑"濮嬬粓鍦ㄦ渶鍓嶉潰
+ sortHospitalsByRegion(hospitals) {
+ if (!hospitals || hospitals.length === 0) {
+ return hospitals
+ }
+
+ const region = this.selectedRegion
+ const homeHospital = [] // "瀹朵腑"
+ const localHospitals = [] // 鏈湴鍖婚櫌
+ const otherHospitals = [] // 鍏朵粬鍖婚櫌
+
+ hospitals.forEach(hospital => {
+ // "瀹朵腑"浼樺厛澶勭悊锛屾斁鍦ㄦ渶鍓嶉潰
+ if (hospital.hospName === '瀹朵腑') {
+ homeHospital.push(hospital)
+ return
+ }
+
+ // 鍒ゆ柇鍖婚櫌鏄惁鍦ㄦ湰鍦板尯鍩燂紙鐪併�佸競銆佸尯浠讳竴鍖呭惈鍦板煙鍏抽敭璇嶏級
+ const isLocal = region && (
+ (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 [...homeHospital, ...localHospitals, ...otherHospitals]
},
// 杞嚭鍖婚櫌杈撳叆妗嗚幏寰楃劍鐐�
onHospitalOutFocus() {
- // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鏄剧ず榛樿鐨�100鏉℃暟鎹�
+ // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鏄剧ず甯哥敤杞嚭鍖婚櫌
if (!this.hospitalOutSearchKeyword || this.hospitalOutSearchKeyword.trim() === '') {
- this.hospitalOutResults = [...this.defaultHospitals]
+ // 濡傛灉宸茬粡鍔犺浇杩囧父鐢ㄥ尰闄紝鐩存帴鏄剧ず
+ if (this.hospitalOutResults.length > 0) {
+ this.showHospitalOutResults = true
+ return
+ }
+
+ // 鍚﹀垯閲嶆柊鍔犺浇甯哥敤鍖婚櫌
+ if (this.selectedOrganizationServiceOrderClass) {
+ getFrequentOutHospitals(this.selectedOrganizationServiceOrderClass, this.selectedRegion).then(response => {
+ const hospitals = response.data || []
+ // 纭繚"瀹朵腑"鍦ㄦ渶鍓嶉潰
+ this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
+ // 濡傛灉娌℃湁甯哥敤鍖婚櫌锛岄檷绾т负鏅�氭悳绱�
+ if (this.hospitalOutResults.length === 0) {
+ searchHospitals('', this.selectedOrganizationId).then(res => {
+ const hospitals = res.data || []
+ this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
+ })
+ }
+ }).catch(error => {
+ console.error('鍔犺浇甯哥敤杞嚭鍖婚櫌澶辫触:', error)
+ searchHospitals('', this.selectedOrganizationId).then(res => {
+ const hospitals = res.data || []
+ this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
+ })
+ })
+ } else {
+ // 娌℃湁鏈嶅姟鍗曠紪鐮侊紝浣跨敤鏅�氭悳绱�
+ searchHospitals('', this.selectedOrganizationId).then(response => {
+ const hospitals = response.data || []
+ this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
+ }).catch(error => {
+ console.error('鍔犺浇杞嚭鍖婚櫌澶辫触:', error)
+ this.hospitalOutResults = []
+ })
+ }
}
this.showHospitalOutResults = true
},
@@ -818,27 +1063,37 @@
clearTimeout(this.searchTimer)
}
- // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず榛樿100鏉�
+ // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず褰撳墠鍖哄煙鐨勫尰闄�
if (!keyword || keyword.trim() === '') {
- this.hospitalOutResults = [...this.defaultHospitals]
+ searchHospitals('', this.selectedOrganizationId).then(response => {
+ const hospitals = response.data || []
+ // 纭繚"瀹朵腑"鍦ㄦ渶鍓嶉潰
+ this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
+ }).catch(error => {
+ console.error('鍔犺浇杞嚭鍖婚櫌澶辫触:', error)
+ this.hospitalOutResults = []
+ })
this.showHospitalOutResults = true
return
}
- // 鏈夊叧閿瘝鏃讹紝鍘绘湇鍔$鎼滅储
+ // 鏈夊叧閿瘝鏃讹紝鍘绘湇鍔$鎼滅储锛堜粎闄愬綋鍓嶅尯鍩燂級
this.searchTimer = setTimeout(() => {
this.searchHospitalOut(keyword)
}, 300)
},
- // 鎼滅储杞嚭鍖婚櫌
+ // 鎼滅储杞嚭鍖婚櫌锛堜粎闄愬綋鍓嶅尯鍩燂級
searchHospitalOut(keyword) {
- // 浼犲叆鍏抽敭璇嶅拰鍦板煙杩囨护
- searchHospitals(keyword, this.selectedRegion).then(response => {
- this.hospitalOutResults = response.data || []
+ // 浼犲叆鍏抽敭璇嶅拰閮ㄩ棬ID锛屽彧鎼滅储褰撳墠鍖哄煙鐨勫尰闄�
+ searchHospitals(keyword, this.selectedOrganizationId).then(response => {
+ const hospitals = response.data || []
+ // 纭繚"瀹朵腑"鍦ㄦ渶鍓嶉潰
+ this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
this.showHospitalOutResults = true
+ console.log('鎼滅储杞嚭鍖婚櫌:', keyword, '閮ㄩ棬ID:', this.selectedOrganizationId, '缁撴灉鏁�:', this.hospitalOutResults.length)
}).catch(error => {
- console.error('鎼滅储鍖婚櫌澶辫触:', error)
+ console.error('鎼滅储杞嚭鍖婚櫌澶辫触:', error)
this.hospitalOutResults = []
})
},
@@ -847,30 +1102,82 @@
selectHospitalOut(hospital) {
this.taskForm.hospitalOut.id = hospital.hospId // 淇濆瓨鍖婚櫌ID
this.taskForm.hospitalOut.name = hospital.hospName
- // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
- const fullAddress = this.buildFullAddress(hospital)
- this.taskForm.hospitalOut.address = fullAddress
+ // 濡傛灉閫夋嫨鐨勬槸"瀹朵腑"锛屾竻绌哄湴鍧�璁╃敤鎴锋墜鍔ㄨ緭鍏ワ紱鍚﹀垯鑷姩濉厖鍦板潃
+ if (hospital.hospName === '瀹朵腑') {
+ this.taskForm.hospitalOut.address = ''
+ // 绉戝鑷姩璁剧疆涓�"鍏跺畠"
+ this.taskForm.hospitalOut.department = '鍏跺畠'
+ this.taskForm.hospitalOut.departmentId = null
+ } else {
+ // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
+ const fullAddress = this.buildFullAddress(hospital)
+ this.taskForm.hospitalOut.address = fullAddress
+ // 娓呯┖绉戝锛岃鐢ㄦ埛閲嶆柊閫夋嫨
+ if (this.taskForm.hospitalOut.department === '鍏跺畠') {
+ this.taskForm.hospitalOut.department = ''
+ this.taskForm.hospitalOut.departmentId = null
+ }
+ }
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瀽鍜岃窛绂昏绠�
- // 鏆傛椂鐣欑┖锛岀敱鐢ㄦ埛鎵嬪姩杈撳叆璺濈
+ // 濡傛灉涓や釜閮戒笉鏄�"瀹朵腑",浣跨敤鍖婚櫌璺濈璁$畻
+ if (hospital.hospName !== '瀹朵腑' && this.taskForm.hospitalIn.name !== '瀹朵腑') {
+ this.calculateHospitalDistance()
+ } else {
+ // 鏈変竴涓槸"瀹朵腑",浣跨敤鍦板潃璁$畻
+ this.calculateDistanceByManualAddress()
+ }
}
},
// 杞叆鍖婚櫌杈撳叆妗嗚幏寰楃劍鐐�
onHospitalInFocus() {
- // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鏄剧ず榛樿鐨�100鏉℃暟鎹�
+ // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鏄剧ず甯哥敤杞叆鍖婚櫌
if (!this.hospitalInSearchKeyword || this.hospitalInSearchKeyword.trim() === '') {
- this.hospitalInResults = [...this.defaultHospitals]
+ // 濡傛灉宸茬粡鍔犺浇杩囧父鐢ㄥ尰闄紝鐩存帴鏄剧ず
+ if (this.hospitalInResults.length > 0) {
+ this.showHospitalInResults = true
+ return
+ }
+
+ // 鍚﹀垯閲嶆柊鍔犺浇甯哥敤鍖婚櫌
+ if (this.selectedOrganizationServiceOrderClass) {
+ getFrequentInHospitals(this.selectedOrganizationServiceOrderClass, '').then(response => {
+ const allHospitals = response.data || []
+ // 鎸夊湴鍩熸帓搴忥細鏈湴鍖哄煙浼樺厛
+ this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+ // 濡傛灉娌℃湁甯哥敤鍖婚櫌锛岄檷绾т负鏅�氭悳绱�
+ if (this.hospitalInResults.length === 0) {
+ searchHospitals('', null).then(res => {
+ const allHospitals = res.data || []
+ this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+ })
+ }
+ }).catch(error => {
+ console.error('鍔犺浇甯哥敤杞叆鍖婚櫌澶辫触:', error)
+ searchHospitals('', null).then(res => {
+ const allHospitals = res.data || []
+ this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+ })
+ })
+ } else {
+ // 娌℃湁鏈嶅姟鍗曠紪鐮侊紝浣跨敤鏅�氭悳绱�
+ searchHospitals('', null).then(response => {
+ const allHospitals = response.data || []
+ // 鎸夊湴鍩熸帓搴忥細鏈湴鍖哄煙浼樺厛
+ this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+ }).catch(error => {
+ console.error('鍔犺浇杞叆鍖婚櫌澶辫触:', error)
+ this.hospitalInResults = []
+ })
+ }
}
this.showHospitalInResults = true
},
@@ -885,27 +1192,37 @@
clearTimeout(this.searchTimer)
}
- // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず榛樿100鏉�
+ // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず鎵�鏈夊尰闄紙鏈湴鍖哄煙浼樺厛锛�
if (!keyword || keyword.trim() === '') {
- this.hospitalInResults = [...this.defaultHospitals]
+ searchHospitals('', null).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, this.selectedRegion).then(response => {
- this.hospitalInResults = response.data || []
+ // 浼犲叆鍏抽敭璇嶏紝涓嶄紶閮ㄩ棬ID锛堟悳绱㈡墍鏈夊尯鍩燂級
+ searchHospitals(keyword, null).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 = []
})
},
@@ -914,20 +1231,38 @@
selectHospitalIn(hospital) {
this.taskForm.hospitalIn.id = hospital.hospId // 淇濆瓨鍖婚櫌ID
this.taskForm.hospitalIn.name = hospital.hospName
- // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
- const fullAddress = this.buildFullAddress(hospital)
- this.taskForm.hospitalIn.address = fullAddress
+ // 濡傛灉閫夋嫨鐨勬槸"瀹朵腑"锛屾竻绌哄湴鍧�璁╃敤鎴锋墜鍔ㄨ緭鍏ワ紱鍚﹀垯鑷姩濉厖鍦板潃
+ if (hospital.hospName === '瀹朵腑') {
+ this.taskForm.hospitalIn.address = ''
+ // 绉戝鑷姩璁剧疆涓�"鍏跺畠"
+ this.taskForm.hospitalIn.department = '鍏跺畠'
+ this.taskForm.hospitalIn.departmentId = null
+ } else {
+ // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
+ const fullAddress = this.buildFullAddress(hospital)
+ this.taskForm.hospitalIn.address = fullAddress
+ // 娓呯┖绉戝锛岃鐢ㄦ埛閲嶆柊閫夋嫨
+ if (this.taskForm.hospitalIn.department === '鍏跺畠') {
+ this.taskForm.hospitalIn.department = ''
+ this.taskForm.hospitalIn.departmentId = null
+ }
+ }
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瀽鍜岃窛绂昏绠�
- // 鏆傛椂鐣欑┖锛岀敱鐢ㄦ埛鎵嬪姩杈撳叆璺濈
+ // 濡傛灉涓や釜閮戒笉鏄�"瀹朵腑",浣跨敤鍖婚櫌璺濈璁$畻
+ if (hospital.hospName !== '瀹朵腑' && this.taskForm.hospitalOut.name !== '瀹朵腑') {
+ this.calculateHospitalDistance()
+ } else {
+ // 鏈変竴涓槸"瀹朵腑",浣跨敤鍦板潃璁$畻
+ this.calculateDistanceByManualAddress()
+ }
}
},
@@ -953,24 +1288,14 @@
// 鍔犺浇褰撳墠鐢ㄦ埛鎵�鍦ㄥ垎鍏徃鐨勬墍鏈変汉鍛�
loadDeptStaff() {
- const deptId = this.currentUser.deptId
- if (!deptId) {
- console.error('鏃犳硶鑾峰彇褰撳墠鐢ㄦ埛鎵�鍦ㄩ儴闂�')
- this.$modal.showToast('鏃犳硶鑾峰彇鎵�鍦ㄩ儴闂ㄤ俊鎭�')
- return
- }
+ console.log('寮�濮嬪姞杞戒汉鍛樺垪琛�')
- // 鐩存帴鏌ヨ褰撳墠鐢ㄦ埛閮ㄩ棬涓嬬殑鎵�鏈夌敤鎴�
- // 鍚庣SQL浼氳嚜鍔ㄥ鐞嗭細濡傛灉浼犲叆鐨勬槸瀛愰儴闂紝浼氭煡鎵惧叾鎵�灞炵殑鍒嗗叕鍙稿強鍏舵墍鏈夊瓙閮ㄩ棬鐨勭敤鎴�
- const queryParams = {
- deptId: deptId,
- status: '0', // 鍙煡璇㈡甯哥姸鎬佺殑鐢ㄦ埛
- pageNum: 1,
- pageSize: 10000 // 璁剧疆瓒冲澶х殑椤甸潰澶у皬锛岃幏鍙栨墍鏈夌敤鎴�
- }
-
- 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,
@@ -981,6 +1306,8 @@
// 鏍规嵁宀椾綅鍚嶇О鎴栬鑹插悕绉板垽鏂被鍨�
type: this.getUserType(user)
}))
+
+ console.log('澶勭悊鍚庣殑浜哄憳鍒楄〃:', this.allStaffList, '鏁伴噺:', this.allStaffList.length)
// 鍒濆鍖栬繃婊ゅ垪琛�
this.filterStaffList()
@@ -1000,14 +1327,18 @@
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('鎶ゅ+') || deptName.includes('鎶ゅ+')) {
return 'nurse'
}
+ // 鍒ゆ柇鏄惁涓哄尰鐢�
+ if (postName.includes('鍖荤敓') || roleName.includes('鍖荤敓') || deptName.includes('鍖荤敓') ) {
+ return 'doctor'
+ }
+ if( deptName.includes("鍖绘姢")){
+ return 'doctor'
+ }
+
// 鍏朵粬绫诲瀷锛岄粯璁や负鍙告満
return 'driver'
},
@@ -1039,6 +1370,7 @@
// 杩囨护浜哄憳鍒楄〃
filterStaffList() {
+ console.log('寮�濮嬭繃婊や汉鍛樺垪琛紝鍘熷鏁伴噺:', this.allStaffList.length)
let list = [...this.allStaffList]
// 鎸夌被鍨嬭繃婊�
@@ -1050,6 +1382,8 @@
list = list.filter(staff => staff.type === 'nurse')
}
+ console.log('鎸夌被鍨嬭繃婊ゅ悗:', this.staffFilterType, '鏁伴噺:', list.length)
+
// 鎸夊叧閿瘝鎼滅储
if (this.staffSearchKeyword && this.staffSearchKeyword.trim() !== '') {
const keyword = this.staffSearchKeyword.trim().toLowerCase()
@@ -1059,7 +1393,10 @@
})
}
+ console.log('鎸夊叧閿瘝杩囨护鍚庯紝鏁伴噺:', list.length)
+
this.filteredStaffList = list
+ console.log('鏈�缁堣繃婊ょ粨鏋�:', this.filteredStaffList)
},
// 鍒囨崲浜哄憳閫変腑鐘舵��
@@ -1105,6 +1442,257 @@
addStaff() {
this.showStaffSelector()
+ },
+
+ // ==================== 鍦板潃杈撳叆鑱旀兂鐩稿叧鏂规硶 ====================
+
+ // 杞嚭鍦板潃杈撳叆鐩戝惉
+ onAddressOutInput(e) {
+ const query = e.detail.value
+ this.taskForm.hospitalOut.address = query
+
+ // 闃叉姈澶勭悊
+ if (this.addressSearchTimer) {
+ clearTimeout(this.addressSearchTimer)
+ }
+
+ // 濡傛灉杈撳叆涓虹┖锛岄殣钘忔彁绀哄垪琛�
+ if (!query || query.trim() === '') {
+ this.showAddressOutSuggestions = false
+ this.addressOutSuggestions = []
+ return
+ }
+
+ // 杈撳叆闀垮害澶т簬2鎵嶅紑濮嬫悳绱�
+ if (query.trim().length < 2) {
+ this.showAddressOutSuggestions = false
+ return
+ }
+
+ // 寤惰繜300ms鎼滅储
+ this.addressSearchTimer = setTimeout(() => {
+ this.searchAddressOut(query)
+ }, 300)
+ },
+
+ // 杞嚭鍦板潃杈撳叆妗嗚幏寰楃劍鐐�
+ onAddressOutFocus() {
+ // 濡傛灉鏈夊湴鍧�涓旀湁鎼滅储缁撴灉锛屾樉绀烘彁绀哄垪琛�
+ if (this.taskForm.hospitalOut.address && this.addressOutSuggestions.length > 0) {
+ this.showAddressOutSuggestions = true
+ }
+ },
+
+ // 鎼滅储杞嚭鍦板潃
+ searchAddressOut(query) {
+ // 鑾峰彇褰撳墠鍖哄煙锛堜紭鍏堜娇鐢ㄥ綊灞炴満鏋勭殑鍖哄煙锛�
+ const region = this.selectedRegion || '骞垮窞'
+
+ baiduPlaceSuggestion(query, region).then(response => {
+ if (response.code === 200 && response.data) {
+ this.addressOutSuggestions = response.data
+ this.showAddressOutSuggestions = true
+ } else {
+ this.addressOutSuggestions = []
+ this.showAddressOutSuggestions = false
+ }
+ }).catch(error => {
+ console.error('鎼滅储杞嚭鍦板潃澶辫触:', error)
+ this.addressOutSuggestions = []
+ this.showAddressOutSuggestions = false
+ })
+ },
+
+ // 閫夋嫨杞嚭鍦板潃
+ selectAddressOut(item) {
+ // 濉厖瀹屾暣鍦板潃
+ const fullAddress = item.district + item.address
+ this.taskForm.hospitalOut.address = fullAddress
+
+ // 淇濆瓨缁忕含搴︼紙濡傛灉鏈夛級
+ if (item.location) {
+ this.taskForm.hospitalOut.latitude = item.location.lat
+ this.taskForm.hospitalOut.longitude = item.location.lng
+ }
+
+ // 闅愯棌鎻愮ず鍒楄〃
+ this.showAddressOutSuggestions = false
+ this.addressOutSuggestions = []
+
+ // 濡傛灉杞叆鍦板潃涔熷凡濉啓,鑷姩璁$畻璺濈
+ if (this.taskForm.hospitalIn.address) {
+ this.calculateDistanceByManualAddress()
+ }
+ },
+
+ // 杞叆鍦板潃杈撳叆鐩戝惉
+ onAddressInInput(e) {
+ const query = e.detail.value
+ this.taskForm.hospitalIn.address = query
+
+ // 闃叉姈澶勭悊
+ if (this.addressSearchTimer) {
+ clearTimeout(this.addressSearchTimer)
+ }
+
+ // 濡傛灉杈撳叆涓虹┖锛岄殣钘忔彁绀哄垪琛�
+ if (!query || query.trim() === '') {
+ this.showAddressInSuggestions = false
+ this.addressInSuggestions = []
+ return
+ }
+
+ // 杈撳叆闀垮害澶т簬2鎵嶅紑濮嬫悳绱�
+ if (query.trim().length < 2) {
+ this.showAddressInSuggestions = false
+ return
+ }
+
+ // 寤惰繜300ms鎼滅储
+ this.addressSearchTimer = setTimeout(() => {
+ this.searchAddressIn(query)
+ }, 300)
+ },
+
+ // 杞叆鍦板潃杈撳叆妗嗚幏寰楃劍鐐�
+ onAddressInFocus() {
+ // 濡傛灉鏈夊湴鍧�涓旀湁鎼滅储缁撴灉锛屾樉绀烘彁绀哄垪琛�
+ if (this.taskForm.hospitalIn.address && this.addressInSuggestions.length > 0) {
+ this.showAddressInSuggestions = true
+ }
+ },
+
+ // 鎼滅储杞叆鍦板潃
+ searchAddressIn(query) {
+ // 鑾峰彇褰撳墠鍖哄煙锛堜紭鍏堜娇鐢ㄥ綊灞炴満鏋勭殑鍖哄煙锛�
+ const region = this.selectedRegion || '骞垮窞'
+
+ baiduPlaceSuggestion(query, region).then(response => {
+ if (response.code === 200 && response.data) {
+ this.addressInSuggestions = response.data
+ this.showAddressInSuggestions = true
+ } else {
+ this.addressInSuggestions = []
+ this.showAddressInSuggestions = false
+ }
+ }).catch(error => {
+ console.error('鎼滅储杞叆鍦板潃澶辫触:', error)
+ this.addressInSuggestions = []
+ this.showAddressInSuggestions = false
+ })
+ },
+
+ // 閫夋嫨杞叆鍦板潃
+ selectAddressIn(item) {
+ // 濉厖瀹屾暣鍦板潃
+ const fullAddress = item.district + item.address
+ this.taskForm.hospitalIn.address = fullAddress
+
+ // 淇濆瓨缁忕含搴︼紙濡傛灉鏈夛級
+ if (item.location) {
+ this.taskForm.hospitalIn.latitude = item.location.lat
+ this.taskForm.hospitalIn.longitude = item.location.lng
+ }
+
+ // 闅愯棌鎻愮ず鍒楄〃
+ this.showAddressInSuggestions = false
+ this.addressInSuggestions = []
+
+ // 濡傛灉杞嚭鍦板潃涔熷凡濉啓,鑷姩璁$畻璺濈
+ if (this.taskForm.hospitalOut.address) {
+ this.calculateDistanceByManualAddress()
+ }
+ },
+
+ // 鎵嬪姩杈撳叆鍦板潃鏃惰绠楄窛绂�
+ calculateDistanceByManualAddress() {
+ const fromAddress = this.taskForm.hospitalOut.address
+ const toAddress = this.taskForm.hospitalIn.address
+
+ if (!fromAddress || !toAddress) {
+ return
+ }
+
+ 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('璺濈璁$畻澶辫触,璇锋墜鍔ㄨ緭鍏�')
+ })
+ },
+
+ // 璺濈杈撳叆妗嗗け鐒︽椂瑙﹀彂鎴愪氦浠疯绠�
+ 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)
+ // 璁$畻澶辫触鏃朵笉鎻愮ず鐢ㄦ埛锛屽厑璁哥敤鎴锋墜鍔ㄨ緭鍏�
+ })
},
// ==================== 鐥呮儏閫夋嫨鐩稿叧鏂规硶 ====================
@@ -1206,9 +1794,28 @@
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.selectedOrganizationId) {
+ this.$modal.showToast('璇烽�夋嫨褰掑睘鏈烘瀯')
return false
}
@@ -1219,6 +1826,11 @@
if (!this.selectedDocumentType) {
this.$modal.showToast('璇烽�夋嫨鍗曟嵁绫诲瀷')
+ return false
+ }
+
+ if (!this.taskForm.transferTime) {
+ this.$modal.showToast('璇烽�夋嫨杞繍鏃堕棿')
return false
}
@@ -1254,6 +1866,16 @@
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
}
@@ -1349,11 +1971,18 @@
addTask(submitData).then(response => {
this.loading = false
this.$modal.showToast('浠诲姟鍒涘缓鎴愬姛')
+
+ // 寤惰繜璺宠浆锛岃鐢ㄦ埛鐪嬪埌鎴愬姛鎻愮ず
setTimeout(() => {
+ // 璺宠浆鍒颁换鍔″垪琛ㄥ苟瑙﹀彂鍒锋柊
uni.switchTab({
- url: '/pages/task/index'
+ url: '/pages/task/index',
+ success: () => {
+ // 浣跨敤浜嬩欢鎬荤嚎閫氱煡浠诲姟鍒楄〃椤甸潰鍒锋柊
+ uni.$emit('refreshTaskList')
+ }
})
- }, 1500)
+ }, 1000)
}).catch(error => {
this.loading = false
console.error('浠诲姟鍒涘缓澶辫触:', error)
@@ -1362,8 +1991,371 @@
}).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
},
// 鍚堝苟鍖婚櫌鍦板潃锛堢渷 + 甯� + 鍖� + 璇︾粏鍦板潃锛�
@@ -1382,6 +2374,53 @@
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('璺濈璁$畻澶辫触锛岃鎵嬪姩杈撳叆')
+ })
}
}
}
@@ -1411,9 +2450,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;
+ }
}
}
@@ -1480,9 +2534,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;
}
@@ -1797,6 +2902,97 @@
}
}
+// 鏅鸿兘璇嗗埆寮圭獥鏍峰紡
+.smart-parse-popup {
+ background-color: white;
+ border-radius: 20rpx 20rpx 0 0;
+ max-height: 80vh;
+ display: flex;
+ flex-direction: column;
+
+ .popup-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 30rpx;
+ border-bottom: 1rpx solid #f0f0f0;
+ flex-shrink: 0;
+
+ .popup-title {
+ font-size: 32rpx;
+ font-weight: bold;
+ color: #333;
+ }
+
+ .popup-close {
+ padding: 10rpx;
+ }
+ }
+
+ .parse-content {
+ flex: 1;
+ padding: 30rpx;
+ overflow-y: auto;
+
+ .parse-tip {
+ display: flex;
+ align-items: flex-start;
+ padding: 20rpx;
+ background-color: #f0f7ff;
+ border-radius: 10rpx;
+ margin-bottom: 20rpx;
+
+ text {
+ 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;
+ }
+ }
+
+ .popup-footer {
+ display: flex;
+ padding: 20rpx 30rpx;
+ border-top: 1rpx solid #f0f0f0;
+ gap: 20rpx;
+ flex-shrink: 0;
+
+ button {
+ flex: 1;
+ height: 80rpx;
+ border-radius: 10rpx;
+ font-size: 30rpx;
+ }
+
+ .cancel-btn {
+ background-color: #f5f5f5;
+ color: #666;
+ }
+
+ .confirm-btn {
+ background-color: #007AFF;
+ color: white;
+
+ &[disabled] {
+ background-color: #ccc;
+ color: #999;
+ }
+ }
+ }
+}
+
// 鐥呮儏閫夋嫨寮圭獥鏍峰紡
.disease-selector-popup {
background-color: white;
--
Gitblit v1.9.1