| | |
| | | import { addTask } from "@/api/task" |
| | | import { listAvailableVehicles, getUserBoundVehicle } from "@/api/vehicle" |
| | | import { calculateDistance, baiduDistanceByAddress, baiduPlaceSuggestion } from "@/api/map" |
| | | import { searchHospitals, getFrequentOutHospitals, getFrequentInHospitals } from "@/api/hospital" |
| | | import { searchHospitals, getFrequentOutHospitals, getFrequentInHospitals, searchHospitalsByDeptRegion } from "@/api/hospital" |
| | | import { listUser } from "@/api/system/user" |
| | | import { searchIcd10 } from "@/api/icd10" |
| | | |
| | |
| | | this.selectedOrganizationServiceOrderClass = selected.serviceOrderClass || '' // 保存服务单编码 |
| | | // 从归属机构中提取地域关键词(去除“分公司”后缀) |
| | | // 例如:“广州分公司” -> “广州” |
| | | this.selectedRegion = selected.deptName.replace(/分公司$/g, '').trim() |
| | | //如果出现广州总公司,也要去除“总公司”后缀 |
| | | this.selectedRegion = this.replaceRegion(selected.deptName); |
| | | // 重新加载医院列表(带地域过滤) |
| | | this.loadDefaultHospitals() |
| | | }, |
| | | |
| | | replaceRegion(region){ |
| | | return region.replace(/(分公司|总公司|总部)$/g, '').trim(); |
| | | }, |
| | | // 加载分公司数据(parent_id=100的部门) |
| | | loadBranchCompanies() { |
| | | listBranchCompany().then(response => { |
| | |
| | | this.selectedOrganizationId = this.organizationOptions[index].deptId // 保存部门ID |
| | | this.selectedOrganizationServiceOrderClass = this.organizationOptions[index].serviceOrderClass || '' // 保存服务单编码 |
| | | // 提取地域关键词 |
| | | this.selectedRegion = this.selectedOrganization.replace(/分公司$/g, '').trim() |
| | | this.selectedRegion =this.replaceRegion(this.selectedOrganization); |
| | | console.log('默认选中归属机构:', this.selectedOrganization, '部门ID:', this.selectedOrganizationId, '服务单编码:', this.selectedOrganizationServiceOrderClass, '地域:', this.selectedRegion) |
| | | // 加载医院列表(带地域过滤) |
| | | this.loadDefaultHospitals() |
| | |
| | | |
| | | // 加载默认医院列表(常用医院) |
| | | loadDefaultHospitals() { |
| | | // 检查是否有服务单编码 |
| | | if (!this.selectedOrganizationServiceOrderClass) { |
| | | console.warn('未找到服务单编码,无法加载常用医院') |
| | | // 如果没有服务单编码,降级为普通搜索(按地域过滤) |
| | | this.loadDefaultHospitalsByRegion() |
| | | // 检查是否有归属机构ID |
| | | if (!this.selectedOrganizationId) { |
| | | console.warn('未选择归属机构,无法加载医院列表') |
| | | 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 || [] |
| | | }) |
| | | }) |
| | | // 转出医院:根据归属机构的区域配置加载 |
| | | this.loadHospitalsByDeptRegion('out') |
| | | |
| | | // 转入医院:加载当前分公司的常用转入医院(本地区域优先) |
| | | 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) |
| | | }) |
| | | }) |
| | | // 转入医院:根据归属机构的区域配置加载 |
| | | this.loadHospitalsByDeptRegion('in') |
| | | }, |
| | | |
| | | // 降级加载医院(按地域过滤) |
| | |
| | | }).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() |
| | | }) |
| | | }, |
| | | |
| | |
| | | this.hospitalOutResults = this.sortHospitalsByRegion(hospitals) |
| | | // 如果没有常用医院,降级为普通搜索 |
| | | if (this.hospitalOutResults.length === 0) { |
| | | searchHospitals('', this.selectedRegion).then(res => { |
| | | searchHospitals('', this.selectedOrganizationId).then(res => { |
| | | const hospitals = res.data || [] |
| | | this.hospitalOutResults = this.sortHospitalsByRegion(hospitals) |
| | | }) |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载常用转出医院失败:', error) |
| | | searchHospitals('', this.selectedRegion).then(res => { |
| | | searchHospitals('', this.selectedOrganizationId).then(res => { |
| | | const hospitals = res.data || [] |
| | | this.hospitalOutResults = this.sortHospitalsByRegion(hospitals) |
| | | }) |
| | | }) |
| | | } else { |
| | | // 没有服务单编码,使用普通搜索 |
| | | searchHospitals('', this.selectedRegion).then(response => { |
| | | searchHospitals('', this.selectedOrganizationId).then(response => { |
| | | const hospitals = response.data || [] |
| | | this.hospitalOutResults = this.sortHospitalsByRegion(hospitals) |
| | | }).catch(error => { |
| | |
| | | |
| | | // 如果关键词为空,显示当前区域的医院 |
| | | if (!keyword || keyword.trim() === '') { |
| | | searchHospitals('', this.selectedRegion).then(response => { |
| | | searchHospitals('', this.selectedOrganizationId).then(response => { |
| | | const hospitals = response.data || [] |
| | | // 确保"家中"在最前面 |
| | | this.hospitalOutResults = this.sortHospitalsByRegion(hospitals) |
| | |
| | | |
| | | // 搜索转出医院(仅限当前区域) |
| | | searchHospitalOut(keyword) { |
| | | // 传入关键词和地域过滤,只搜索当前区域的医院 |
| | | searchHospitals(keyword, this.selectedRegion).then(response => { |
| | | // 传入关键词和部门ID,只搜索当前区域的医院 |
| | | searchHospitals(keyword, this.selectedOrganizationId).then(response => { |
| | | const hospitals = response.data || [] |
| | | // 确保"家中"在最前面 |
| | | this.hospitalOutResults = this.sortHospitalsByRegion(hospitals) |
| | | this.showHospitalOutResults = true |
| | | console.log('搜索转出医院:', keyword, '区域:', this.selectedRegion, '结果数:', this.hospitalOutResults.length) |
| | | console.log('搜索转出医院:', keyword, '部门ID:', this.selectedOrganizationId, '结果数:', this.hospitalOutResults.length) |
| | | }).catch(error => { |
| | | console.error('搜索转出医院失败:', error) |
| | | this.hospitalOutResults = [] |
| | |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | // 如果没有常用医院,降级为普通搜索 |
| | | if (this.hospitalInResults.length === 0) { |
| | | searchHospitals('', '').then(res => { |
| | | searchHospitals('', null).then(res => { |
| | | const allHospitals = res.data || [] |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | }) |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载常用转入医院失败:', error) |
| | | searchHospitals('', '').then(res => { |
| | | searchHospitals('', null).then(res => { |
| | | const allHospitals = res.data || [] |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | | }) |
| | | }) |
| | | } else { |
| | | // 没有服务单编码,使用普通搜索 |
| | | searchHospitals('', '').then(response => { |
| | | searchHospitals('', null).then(response => { |
| | | const allHospitals = response.data || [] |
| | | // 按地域排序:本地区域优先 |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | |
| | | |
| | | // 如果关键词为空,显示所有医院(本地区域优先) |
| | | if (!keyword || keyword.trim() === '') { |
| | | searchHospitals('', '').then(response => { |
| | | searchHospitals('', null).then(response => { |
| | | const allHospitals = response.data || [] |
| | | // 按地域排序:"家中"最前,本地区域优先 |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | |
| | | |
| | | // 搜索转入医院(不限区域,但本地区域优先) |
| | | searchHospitalIn(keyword) { |
| | | // 传入关键词,不传地域过滤(搜索所有区域) |
| | | searchHospitals(keyword, '').then(response => { |
| | | // 传入关键词,不传部门ID(搜索所有区域) |
| | | searchHospitals(keyword, null).then(response => { |
| | | const allHospitals = response.data || [] |
| | | // 按地域排序:"家中"最前,本地区域优先 |
| | | this.hospitalInResults = this.sortHospitalsByRegion(allHospitals) |
| | |
| | | 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) |