| | |
| | | label="医院名称" |
| | | address-label="转出地址" |
| | | :required="true" |
| | | :department-required="true" |
| | | :show-department="false" |
| | | v-model="taskForm.hospitalOut" |
| | | :dept-id="selectedOrganizationId" |
| | | :region="selectedRegion" |
| | | :department-options="departmentOptions" |
| | | @change="onHospitalOutChange" |
| | | @address-selected="onHospitalOutAddressSelected" |
| | | /> |
| | | <DepartmentSelector |
| | | label="转出科室" |
| | | :required="true" |
| | | v-model="taskForm.hospitalOut.department" |
| | | :department-id="taskForm.hospitalOut.departmentId" |
| | | :is-home="taskForm.hospitalOut.name === '家中'" |
| | | @change="onHospitalOutDepartmentChange" |
| | | /> |
| | | |
| | | <view class="form-item"> |
| | | <view class="form-label">床号</view> |
| | | <input |
| | | class="form-input" |
| | | placeholder="请输入床号" |
| | | v-model="taskForm.hospitalOut.bedNumber" |
| | | /> |
| | | </view> |
| | | |
| | | <view class="form-section-title">转入医院信息</view> |
| | | <HospitalSelector |
| | | label="医院名称" |
| | | address-label="转入地址" |
| | | :required="true" |
| | | :department-required="true" |
| | | :show-department="false" |
| | | v-model="taskForm.hospitalIn" |
| | | :dept-id="selectedOrganizationId" |
| | | :region="selectedRegion" |
| | | :department-options="departmentOptions" |
| | | @change="onHospitalInChange" |
| | | @address-selected="onHospitalInAddressSelected" |
| | | /> |
| | | <DepartmentSelector |
| | | label="转入科室" |
| | | :required="true" |
| | | v-model="taskForm.hospitalIn.department" |
| | | :department-id="taskForm.hospitalIn.departmentId" |
| | | :is-home="taskForm.hospitalIn.name === '家中'" |
| | | @change="onHospitalInDepartmentChange" |
| | | /> |
| | | |
| | | <view class="form-item"> |
| | | <view class="form-label">床号</view> |
| | | <input |
| | | class="form-input" |
| | | placeholder="请输入床号" |
| | | v-model="taskForm.hospitalIn.bedNumber" |
| | | /> |
| | | </view> |
| | | |
| | | <view class="form-item"> |
| | | <view class="form-label required">转运公里数</view> |
| | |
| | | import { checkVehicleActiveTasks } from "@/api/task" |
| | | |
| | | import { getDicts } from "@/api/dict" |
| | | import { getServiceOrdAreaTypes, getServiceOrderTypes, getHospitalDepartments } from "@/api/dictionary" |
| | | import { getServiceOrdAreaTypes, getServiceOrderTypes } from "@/api/dictionary" |
| | | import { listBranchCompany, getDept } from "@/api/system/dept" |
| | | import MapSelector from './components/map-selector.vue' |
| | | import OrganizationSelector from './components/OrganizationSelector.vue' |
| | | import HospitalSelector from './components/HospitalSelector.vue' |
| | | import DiseaseSelector from './components/DiseaseSelector.vue' |
| | | import StaffSelector from './components/StaffSelector.vue' |
| | | import DepartmentSelector from './components/DepartmentSelector.vue' |
| | | |
| | | export default { |
| | | components: { |
| | |
| | | HospitalSelector, |
| | | DiseaseSelector, |
| | | DepartureSelector, |
| | | StaffSelector |
| | | StaffSelector, |
| | | DepartmentSelector |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | emergencyTaskTypeOptions: [], // 任务类型选项(用于picker显示) |
| | | documentTypes: [], // 单据类型列表 |
| | | documentTypeOptions: [], // 单据类型选项(用于picker显示) |
| | | departmentOptions: [], // 科室字典数据 |
| | | loading: false, |
| | | // 智能识别相关 |
| | | rawText: '', |
| | |
| | | this.getAvailableVehicles().then(() => { |
| | | this.getUserBoundVehicleInfo() |
| | | }) |
| | | // 加载科室字典数据 |
| | | this.loadDepartments() |
| | | // 加载任务类型数据 |
| | | this.loadEmergencyTaskTypes() |
| | | // 加载单据类型数据 |
| | |
| | | } |
| | | }, |
| | | |
| | | // 加载科室数据(从 SQL Server 动态加载) |
| | | loadDepartments() { |
| | | getHospitalDepartments().then(response => { |
| | | const list = response.data || []; |
| | | this.departmentOptions = list.map(item => ({ |
| | | id: item.vID, |
| | | text: item.vtext, |
| | | dictValue: item.vtext // 为了保持兼容性,保留dictValue字段 |
| | | })); |
| | | // console.log('科室数据加载成功:', this.departmentOptions); |
| | | }).catch(error => { |
| | | console.error('加载科室数据失败:', error) |
| | | this.departmentOptions = [] |
| | | }) |
| | | }, |
| | | |
| | | // 加载任务类型数据(从 SQL Server) |
| | | loadEmergencyTaskTypes() { |
| | | getServiceOrderTypes().then(response => { |
| | |
| | | console.log('转出医院变化:', hospitalData) |
| | | // 组件已经通过 v-model 更新了 taskForm.hospitalOut |
| | | |
| | | // 如果选择的是"家中",自动设置科室为"其它" |
| | | if (hospitalData.name === '家中') { |
| | | this.taskForm.hospitalOut.department = '其它' |
| | | this.taskForm.hospitalOut.departmentId = null |
| | | } |
| | | |
| | | // 如果转入地址已填写,自动计算距离 |
| | | if (this.taskForm.hospitalIn.address) { |
| | | // 如果两个都不是"家中",使用医院距离计算 |
| | |
| | | console.log('转入医院变化:', hospitalData) |
| | | // 组件已经通过 v-model 更新了 taskForm.hospitalIn |
| | | |
| | | // 如果选择的是"家中",自动设置科室为"其它" |
| | | if (hospitalData.name === '家中') { |
| | | this.taskForm.hospitalIn.department = '其它' |
| | | this.taskForm.hospitalIn.departmentId = null |
| | | } |
| | | |
| | | // 如果转出地址已填写,自动计算距离 |
| | | if (this.taskForm.hospitalOut.address) { |
| | | // 如果两个都不是"家中",使用医院距离计算 |
| | |
| | | onHospitalInAddressSelected(data) { |
| | | if (this.taskForm.hospitalOut.address) { |
| | | this.calculateDistanceByManualAddress() |
| | | } |
| | | }, |
| | | |
| | | // 转出科室变化 |
| | | onHospitalOutDepartmentChange(data) { |
| | | if (data && typeof data === 'object') { |
| | | this.taskForm.hospitalOut.department = data.department |
| | | this.taskForm.hospitalOut.departmentId = data.departmentId |
| | | } else { |
| | | this.taskForm.hospitalOut.department = data |
| | | this.taskForm.hospitalOut.departmentId = null |
| | | } |
| | | }, |
| | | |
| | | // 转入科室变化 |
| | | onHospitalInDepartmentChange(data) { |
| | | if (data && typeof data === 'object') { |
| | | this.taskForm.hospitalIn.department = data.department |
| | | this.taskForm.hospitalIn.departmentId = data.departmentId |
| | | } else { |
| | | this.taskForm.hospitalIn.department = data |
| | | this.taskForm.hospitalIn.departmentId = null |
| | | } |
| | | }, |
| | | |
| | |
| | | if (result.phone) this.taskForm.patient.phone = result.phone |
| | | if (result.price) this.taskForm.price = result.price |
| | | |
| | | // 应用科室信息(匹配 departmentOptions 中的数据) |
| | | // 应用科室信息(通过 DepartmentSelector 组件处理) |
| | | if (result.departmentOut) { |
| | | const deptOut = this.matchDepartment(result.departmentOut) |
| | | if (deptOut) { |
| | | this.taskForm.hospitalOut.department = deptOut.text |
| | | this.taskForm.hospitalOut.departmentId = deptOut.id |
| | | } |
| | | this.taskForm.hospitalOut.department = result.departmentOut |
| | | // 科室ID会在 DepartmentSelector 组件中自动匹配 |
| | | } |
| | | if (result.departmentIn) { |
| | | const deptIn = this.matchDepartment(result.departmentIn) |
| | | if (deptIn) { |
| | | this.taskForm.hospitalIn.department = deptIn.text |
| | | this.taskForm.hospitalIn.departmentId = deptIn.id |
| | | } |
| | | this.taskForm.hospitalIn.department = result.departmentIn |
| | | // 科室ID会在 DepartmentSelector 组件中自动匹配 |
| | | } |
| | | |
| | | // 处理医院名称 → 精确匹配医院并补全地址与ID(不限制分公司区域) |
| | |
| | | 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) { |
| | | // 常见科室关键词(作为兜底方案) |
| | |
| | | '检验科', '病理科', '药剂科', '营养科' |
| | | ] |
| | | |
| | | // 优先尝试从 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('|') |
| | | |