| | |
| | | type="digit" |
| | | placeholder="请输入转运公里数" |
| | | v-model="taskForm.transferDistance" |
| | | @blur="onDistanceChange" |
| | | /> |
| | | </view> |
| | | |
| | |
| | | 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 { getDicts } from "@/api/dict" |
| | | import { getServiceOrdAreaTypes, getServiceOrderTypes, getHospitalDepartments } from "@/api/dictionary" |
| | |
| | | |
| | | console.log('距离计算成功:', distanceInKm, 'km') |
| | | this.$modal.showToast(`距离: ${distanceInKm}公里`) |
| | | |
| | | // 距离计算成功后,自动计算成交价 |
| | | this.calculatePrice() |
| | | } else { |
| | | console.error('距离计算失败:', response.msg) |
| | | this.$modal.showToast('距离计算失败,请手动输入') |
| | |
| | | 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) |
| | | // 计算失败时不提示用户,允许用户手动输入 |
| | | }) |
| | | }, |
| | | |
| | | // ==================== 病情选择相关方法 ==================== |
| | |
| | | |
| | | console.log('距离计算成功:', distanceInKm, 'km') |
| | | // this.$modal.showToast(`距离计算成功: ${distanceInKm}公里`) |
| | | |
| | | // 距离计算成功后,自动计算成交价 |
| | | this.calculatePrice() |
| | | } else { |
| | | console.error('距离计算失败:', response.msg) |
| | | this.$modal.showToast('距离计算失败,请手动输入') |