| | |
| | | </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 || '请选择归属机构' }} |
| | |
| | | |
| | | <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> |
| | |
| | | |
| | | <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" |
| | |
| | | </view> |
| | | |
| | | <view class="form-item"> |
| | | <view class="form-label">成交价</view> |
| | | <view class="form-label required">成交价</view> |
| | | <input |
| | | class="form-input" |
| | | type="digit" |
| | |
| | | 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, baiduDistanceByAddress } from "@/api/map" |
| | | import { searchHospitals } from "@/api/hospital" |
| | | import { calculateDistance, baiduDistanceByAddress, baiduPlaceSuggestion } from "@/api/map" |
| | | import { searchHospitals, getFrequentOutHospitals, getFrequentInHospitals } from "@/api/hospital" |
| | | import { listUser } from "@/api/system/user" |
| | | import { searchIcd10 } from "@/api/icd10" |
| | | |
| | | import { getDicts } from "@/api/dict" |
| | | import { getServiceOrdAreaTypes, getServiceOrderTypes, getHospitalDepartments } from "@/api/dictionary" |
| | | import { listBranchCompany } from "@/api/system/dept" |
| | | import { listBranchCompany, getDept } from "@/api/system/dept" |
| | | import MapSelector from '@/components/map-selector.vue' |
| | | |
| | | export default { |
| | |
| | | selectedVehicleId: null, |
| | | selectedOrganization: '', |
| | | selectedOrganizationId: null, // 归属机构ID(部门ID) |
| | | selectedOrganizationServiceOrderClass: '', // 归属机构的服务单编码 |
| | | selectedRegion: '', // 从归属机构中提取的地域信息(如:广州、深圳等) |
| | | selectedEmergencyTaskType: '', // 选中的任务类型文本 |
| | | selectedEmergencyTaskTypeId: null, // 选中的任务类型ID |
| | |
| | | showHospitalInResults: false, |
| | | searchTimer: null, |
| | | defaultHospitals: [], // 默认的100条医院数据 |
| | | // 地址搜索提示相关 |
| | | addressOutSuggestions: [], // 转出地址提示列表 |
| | | showAddressOutSuggestions: false, |
| | | addressInSuggestions: [], // 转入地址提示列表 |
| | | showAddressInSuggestions: false, |
| | | addressSearchTimer: null, // 地址搜索防抖定时器 |
| | | // 人员选择相关 |
| | | selectedStaff: [], // 已选择的人员列表 |
| | | allStaffList: [], // 所有人员列表 |
| | |
| | | }, |
| | | |
| | | 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 = [] |
| | | }) |
| | | }, |
| | |
| | | const selected = this.organizationOptions[index] |
| | | this.selectedOrganization = selected.deptName |
| | | this.selectedOrganizationId = selected.deptId // 保存部门ID |
| | | // 从归属机构中提取地域关键词(去除"分公司"后缀) |
| | | // 例如:"广州分公司" -> "广州" |
| | | this.selectedOrganizationServiceOrderClass = selected.serviceOrderClass || '' // 保存服务单编码 |
| | | // 从归属机构中提取地域关键词(去除“分公司”后缀) |
| | | // 例如:“广州分公司” -> “广州” |
| | | this.selectedRegion = selected.deptName.replace(/分公司$/g, '').trim() |
| | | // 重新加载医院列表(带地域过滤) |
| | | this.loadDefaultHospitals() |
| | |
| | | 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) |
| | | console.log('默认选中归属机构:', this.selectedOrganization, '部门ID:', this.selectedOrganizationId, '服务单编码:', this.selectedOrganizationServiceOrderClass, '地域:', this.selectedRegion) |
| | | // 加载医院列表(带地域过滤) |
| | | this.loadDefaultHospitals() |
| | | } |
| | |
| | | this.taskForm.hospitalIn.departmentId = selected.id // 保存科室ID |
| | | }, |
| | | |
| | | // 加载默认医院列表(前100条) |
| | | // 加载默认医院列表(常用医院) |
| | | loadDefaultHospitals() { |
| | | // 检查是否有服务单编码 |
| | | if (!this.selectedOrganizationServiceOrderClass) { |
| | | console.warn('未找到服务单编码,无法加载常用医院') |
| | | // 如果没有服务单编码,降级为普通搜索(按地域过滤) |
| | | this.loadDefaultHospitalsByRegion() |
| | | return |
| | | } |
| | | |
| | | // 转出医院:加载当前分公司的常用转出医院 |
| | | getFrequentOutHospitals(this.selectedOrganizationServiceOrderClass, this.selectedRegion).then(response => { |
| | | this.hospitalOutResults = response.data || [] |
| | | console.log('加载常用转出医院:', this.selectedOrganizationServiceOrderClass, '地域:', this.selectedRegion, '数量:', this.hospitalOutResults.length) |
| | | |
| | | // 如果没有常用医院,降级为普通搜索 |
| | | if (this.hospitalOutResults.length === 0) { |
| | | console.log('未找到常用转出医院,降级为地域搜索') |
| | | searchHospitals('', this.selectedRegion).then(res => { |
| | | this.hospitalOutResults = res.data || [] |
| | | }) |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载常用转出医院失败:', error) |
| | | // 失败后降级为普通搜索 |
| | | searchHospitals('', this.selectedRegion).then(res => { |
| | | this.hospitalOutResults = res.data || [] |
| | | }) |
| | | }) |
| | | |
| | | // 转入医院:加载当前分公司的常用转入医院(本地区域优先) |
| | | getFrequentInHospitals(this.selectedOrganizationServiceOrderClass, '').then(response => { |
| | | const allHospitals = response.data || [] |
| | | // 将医院按地域排序:本地区域优先 |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | console.log('加载常用转入医院:', this.selectedOrganizationServiceOrderClass, '数量:', this.hospitalInResults.length) |
| | | |
| | | // 如果没有常用医院,降级为普通搜索 |
| | | if (this.hospitalInResults.length === 0) { |
| | | console.log('未找到常用转入医院,降级为全部医院') |
| | | searchHospitals('', '').then(res => { |
| | | const allHospitals = res.data || [] |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | }) |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载常用转入医院失败:', error) |
| | | // 失败后降级为普通搜索 |
| | | searchHospitals('', '').then(res => { |
| | | const allHospitals = res.data || [] |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | // 降级加载医院(按地域过滤) |
| | | loadDefaultHospitalsByRegion() { |
| | | // 转出医院:只加载当前区域的医院(带地域过滤) |
| | | searchHospitals('', this.selectedRegion).then(response => { |
| | | this.hospitalOutResults = response.data || [] |
| | |
| | | }) |
| | | |
| | | // 转入医院:加载所有医院(不带地域过滤,后续会按地域排序) |
| | | searchHospitals('', this.selectedRegion).then(response => { |
| | | searchHospitals('', '').then(response => { |
| | | const allHospitals = response.data || [] |
| | | // 将医院按地域排序:本地区域优先 |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | |
| | | |
| | | // 转出医院输入框获得焦点 |
| | | onHospitalOutFocus() { |
| | | // 如果没有搜索关键词,只显示当前区域的医院 |
| | | // 如果没有搜索关键词,显示常用转出医院 |
| | | if (!this.hospitalOutSearchKeyword || this.hospitalOutSearchKeyword.trim() === '') { |
| | | searchHospitals('', this.selectedRegion).then(response => { |
| | | this.hospitalOutResults = response.data || [] |
| | | }).catch(error => { |
| | | console.error('加载转出医院失败:', error) |
| | | this.hospitalOutResults = [] |
| | | }) |
| | | // 如果已经加载过常用医院,直接显示 |
| | | if (this.hospitalOutResults.length > 0) { |
| | | this.showHospitalOutResults = true |
| | | return |
| | | } |
| | | |
| | | // 否则重新加载常用医院 |
| | | if (this.selectedOrganizationServiceOrderClass) { |
| | | getFrequentOutHospitals(this.selectedOrganizationServiceOrderClass, this.selectedRegion).then(response => { |
| | | this.hospitalOutResults = response.data || [] |
| | | // 如果没有常用医院,降级为普通搜索 |
| | | if (this.hospitalOutResults.length === 0) { |
| | | searchHospitals('', this.selectedRegion).then(res => { |
| | | this.hospitalOutResults = res.data || [] |
| | | }) |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载常用转出医院失败:', error) |
| | | searchHospitals('', this.selectedRegion).then(res => { |
| | | this.hospitalOutResults = res.data || [] |
| | | }) |
| | | }) |
| | | } else { |
| | | // 没有服务单编码,使用普通搜索 |
| | | searchHospitals('', this.selectedRegion).then(response => { |
| | | this.hospitalOutResults = response.data || [] |
| | | }).catch(error => { |
| | | console.error('加载转出医院失败:', error) |
| | | this.hospitalOutResults = [] |
| | | }) |
| | | } |
| | | } |
| | | this.showHospitalOutResults = true |
| | | }, |
| | |
| | | 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 = '' |
| | | } else { |
| | | // 合并省市区 + 详细地址 |
| | | const fullAddress = this.buildFullAddress(hospital) |
| | | this.taskForm.hospitalOut.address = fullAddress |
| | | } |
| | | this.hospitalOutSearchKeyword = hospital.hospName |
| | | this.showHospitalOutResults = false |
| | | this.hospitalOutResults = [] |
| | |
| | | // 保存转出医院的城市信息 |
| | | this.taskForm.hospitalOut.city = hospital.hopsCity || '' |
| | | |
| | | // 如果两个医院都已选择,自动计算距离 |
| | | // 如果转入地址已填写,自动计算距离 |
| | | if (this.taskForm.hospitalIn.address) { |
| | | this.calculateHospitalDistance() |
| | | // 如果两个都不是"家中",使用医院距离计算 |
| | | if (hospital.hospName !== '家中' && this.taskForm.hospitalIn.name !== '家中') { |
| | | this.calculateHospitalDistance() |
| | | } else { |
| | | // 有一个是"家中",使用地址计算 |
| | | this.calculateDistanceByManualAddress() |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 转入医院输入框获得焦点 |
| | | onHospitalInFocus() { |
| | | // 如果没有搜索关键词,显示所有医院(本地区域优先) |
| | | // 如果没有搜索关键词,显示常用转入医院 |
| | | if (!this.hospitalInSearchKeyword || this.hospitalInSearchKeyword.trim() === '') { |
| | | searchHospitals('', '').then(response => { |
| | | const allHospitals = response.data || [] |
| | | // 按地域排序:本地区域优先 |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | }).catch(error => { |
| | | console.error('加载转入医院失败:', error) |
| | | this.hospitalInResults = [] |
| | | }) |
| | | // 如果已经加载过常用医院,直接显示 |
| | | 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('', '').then(res => { |
| | | const allHospitals = res.data || [] |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | }) |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载常用转入医院失败:', error) |
| | | searchHospitals('', '').then(res => { |
| | | const allHospitals = res.data || [] |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | }) |
| | | }) |
| | | } else { |
| | | // 没有服务单编码,使用普通搜索 |
| | | searchHospitals('', '').then(response => { |
| | | const allHospitals = response.data || [] |
| | | // 按地域排序:本地区域优先 |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | }).catch(error => { |
| | | console.error('加载转入医院失败:', error) |
| | | this.hospitalInResults = [] |
| | | }) |
| | | } |
| | | } |
| | | this.showHospitalInResults = true |
| | | }, |
| | |
| | | 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 = '' |
| | | } else { |
| | | // 合并省市区 + 详细地址 |
| | | const fullAddress = this.buildFullAddress(hospital) |
| | | this.taskForm.hospitalIn.address = fullAddress |
| | | } |
| | | this.hospitalInSearchKeyword = hospital.hospName |
| | | this.showHospitalInResults = false |
| | | this.hospitalInResults = [] |
| | |
| | | // 保存转入医院的城市信息 |
| | | this.taskForm.hospitalIn.city = hospital.hopsCity || '' |
| | | |
| | | // 如果两个医院都已选择,自动计算距离 |
| | | // 如果转出地址已填写,自动计算距离 |
| | | if (this.taskForm.hospitalOut.address) { |
| | | this.calculateHospitalDistance() |
| | | // 如果两个都不是"家中",使用医院距离计算 |
| | | if (hospital.hospName !== '家中' && this.taskForm.hospitalOut.name !== '家中') { |
| | | this.calculateHospitalDistance() |
| | | } else { |
| | | // 有一个是"家中",使用地址计算 |
| | | this.calculateDistanceByManualAddress() |
| | | } |
| | | } |
| | | }, |
| | | |
| | |
| | | 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}公里`) |
| | | } else { |
| | | console.error('距离计算失败:', response.msg) |
| | | this.$modal.showToast('距离计算失败,请手动输入') |
| | | } |
| | | }) |
| | | .catch(error => { |
| | | uni.hideLoading() |
| | | console.error('距离计算失败:', error) |
| | | this.$modal.showToast('距离计算失败,请手动输入') |
| | | }) |
| | | }, |
| | | |
| | | // ==================== 病情选择相关方法 ==================== |
| | | |
| | | // 显示病情选择弹窗 |
| | |
| | | return false |
| | | } |
| | | |
| | | if (!this.selectedOrganizationId) { |
| | | this.$modal.showToast('请选择归属机构') |
| | | return false |
| | | } |
| | | |
| | | if (!this.selectedEmergencyTaskType) { |
| | | 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 |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | .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; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | .form-input { |
| | | height: 70rpx; |
| | | padding: 0 20rpx; |