| | |
| | | </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> |
| | | |
| | | <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 { addTask } from "@/api/task" |
| | | import { listAvailableVehicles, getUserBoundVehicle } from "@/api/vehicle" |
| | | import { calculateDistance, baiduDistanceByAddress } from "@/api/map" |
| | | import { searchHospitals } from "@/api/hospital" |
| | | 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 |
| | |
| | | }, |
| | | |
| | | 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 |
| | | }, |
| | |
| | | |
| | | // 转入医院输入框获得焦点 |
| | | 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 |
| | | }, |
| | |
| | | return false |
| | | } |
| | | |
| | | if (!this.selectedOrganizationId) { |
| | | this.$modal.showToast('请选择归属机构') |
| | | return false |
| | | } |
| | | |
| | | if (!this.selectedEmergencyTaskType) { |
| | | this.$modal.showToast('请选择任务类型') |
| | | return false |
| | |
| | | return false |
| | | } |
| | | |
| | | if (!this.taskForm.transferDistance) { |
| | | this.$modal.showToast('请输入转运公里数') |
| | | return false |
| | | } |
| | | |
| | | if (!this.taskForm.price) { |
| | | this.$modal.showToast('请输入成交价') |
| | | return false |
| | | } |
| | | |
| | | return true |
| | | }, |
| | | |