| | |
| | | /> |
| | | </view> |
| | | |
| | | <DepartureSelector |
| | | :address.sync="departureAddress" |
| | | :longitude.sync="departureLongitude" |
| | | :latitude.sync="departureLatitude" |
| | | :region="selectedRegion" |
| | | :required="false" |
| | | @address-selected="onDepartureAddressSelected" |
| | | @location-success="onDepartureLocationSuccess" |
| | | /> |
| | | |
| | | <view class="form-item"> |
| | | <view class="form-label required">转运时间</view> |
| | | <uni-datetime-picker |
| | |
| | | import OrganizationSelector from './components/OrganizationSelector.vue' |
| | | import HospitalSelector from './components/HospitalSelector.vue' |
| | | import DiseaseSelector from './components/DiseaseSelector.vue' |
| | | import DepartureSelector from './components/DepartureSelector.vue' |
| | | import distanceCalculator from '@/mixins/distanceCalculator.js' |
| | | |
| | | export default { |
| | |
| | | VehicleSelector, |
| | | OrganizationSelector, |
| | | HospitalSelector, |
| | | DiseaseSelector |
| | | DiseaseSelector, |
| | | DepartureSelector |
| | | }, |
| | | mixins: [distanceCalculator], |
| | | data() { |
| | |
| | | selectedOrganizationId: null, |
| | | selectedRegion: '', |
| | | mapSelectorType: '', |
| | | // 扩展 addressCoordinates 支持多种键名 |
| | | addressCoordinates: { |
| | | start: null, |
| | | end: null, |
| | | hospitalOutAddress: null, |
| | | hospitalInAddress: null |
| | | }, |
| | | // 出发地信息 |
| | | departureAddress: '', |
| | | departureLongitude: null, |
| | | departureLatitude: null, |
| | | selectedDiseases: [], // 已选择的病情列表 |
| | | selectedStaff: [], // 已选择的人员列表 |
| | | selectedDiseases: [], // 已选择的病情列表(确保初始化为空数组) |
| | | selectedStaff: [], // 已选择的人员列表(确保初始化为空数组) |
| | | allStaffList: [], // 所有人员列表 |
| | | filteredStaffList: [], // 过滤后的人员列表 |
| | | staffSearchKeyword: '', // 人员搜索关键词 |
| | |
| | | this.taskForm.patient.idCard = info.patientIdCard || '' |
| | | this.taskForm.patient.condition = info.patientCondition || '' |
| | | |
| | | // 解析病情信息 |
| | | this.parseDiseaseInfo(info.patientCondition, info.diseaseIds) |
| | | // 解析病情信息(修复:使用与创建界面一致的逻辑) |
| | | this.parseDiseaseInfo(info.patientCondition, info.diseases) |
| | | |
| | | // 转出医院信息 |
| | | this.taskForm.hospitalOut.id = info.hospitalOutId || null |
| | |
| | | console.log('设置目标地坐标:', this.taskDetail.destinationLongitude, this.taskDetail.destinationLatitude) |
| | | } |
| | | |
| | | // 设置执行人员 |
| | | if (this.taskDetail.assignees && this.taskDetail.assignees.length > 0) { |
| | | // 设置执行人员(修复:确保 assignees 不为 null) |
| | | if (this.taskDetail.assignees && Array.isArray(this.taskDetail.assignees) && this.taskDetail.assignees.length > 0) { |
| | | console.log('原始执行人员数据:', this.taskDetail.assignees) |
| | | this.selectedStaff = this.taskDetail.assignees.map(assignee => ({ |
| | | userId: assignee.userId, |
| | |
| | | } else { |
| | | console.warn('任务没有分配执行人员或assignees为空') |
| | | console.log('taskDetail.assignees:', this.taskDetail.assignees) |
| | | // 确保 selectedStaff 初始化为空数组 |
| | | this.selectedStaff = [] |
| | | } |
| | | |
| | | console.log('表单数据填充完成:', this.taskForm) |
| | |
| | | |
| | | // 归属机构选择变化 |
| | | onOrganizationChange(orgData) { |
| | | // orgData 包含:deptId, deptName, serviceOrderClass, region |
| | | // orgData 包含:deptId, deptName, serviceOrderClass, region, departureAddress, departureLongitude, departureLatitude |
| | | this.selectedOrganizationId = orgData.deptId |
| | | console.log('选中归属机构:', orgData.deptName, '部门ID:', orgData.deptId) |
| | | this.selectedRegion = orgData.region |
| | | |
| | | // 自动填充出发地信息(机构的地址和坐标) |
| | | if (orgData.departureAddress) { |
| | | this.departureAddress = orgData.departureAddress |
| | | this.departureLongitude = orgData.departureLongitude || null |
| | | this.departureLatitude = orgData.departureLatitude || null |
| | | console.log('自动填充机构出发地:', this.departureAddress, '坐标:', this.departureLongitude, this.departureLatitude) |
| | | } |
| | | |
| | | console.log('选中归属机构:', orgData.deptName, '部门ID:', orgData.deptId, '地域:', orgData.region) |
| | | }, |
| | | |
| | | // 出发地地址选择(从地图建议中选择) |
| | | onDepartureAddressSelected(data) { |
| | | // data 包含: address, longitude, latitude, location |
| | | console.log('出发地地址选择:', data) |
| | | // 组件已经通过 .sync 更新了 departureAddress, departureLongitude, departureLatitude |
| | | }, |
| | | |
| | | // 出发地GPS定位成功 |
| | | onDepartureLocationSuccess(data) { |
| | | // data 包含: address, longitude, latitude |
| | | console.log('出发地GPS定位成功:', data) |
| | | // 组件已经通过 .sync 更新了 departureAddress, departureLongitude, departureLatitude |
| | | }, |
| | | |
| | | // 转出医院变化 |
| | |
| | | this.selectedStaff.splice(index, 1) |
| | | }, |
| | | |
| | | // 解析病情信息(从字符串解析出ICD-10疾病列表) |
| | | parseDiseaseInfo(conditionText, diseaseIds) { |
| | | // 解析病情信息(从字符串解析出ICD-10疾病列表)- 修复:与创建界面保持一致 |
| | | parseDiseaseInfo(conditionText, diseases) { |
| | | console.log('========== 开始解析病情信息 ==========') |
| | | console.log('conditionText:', conditionText) |
| | | console.log('diseases数组:', diseases) |
| | | |
| | | if (!conditionText) { |
| | | console.log('病情文本为空,清空选中病情') |
| | | this.selectedDiseases = [] |
| | | this.taskForm.patient.otherCondition = '' |
| | | return |
| | | } |
| | | |
| | | // 解析diseaseIds(逗号分隔的字符串转为数组) |
| | | const diseaseIdArray = diseaseIds ? diseaseIds.split(',').map(id => parseInt(id.trim())).filter(id => !isNaN(id)) : [] |
| | | |
| | | // 如果包含"其他:"分隔符,拆分病情和其他描述 |
| | | if (conditionText.includes('\n其他:')) { |
| | | const parts = conditionText.split('\n其他:') |
| | | const diseasePart = parts[0] |
| | | this.taskForm.patient.otherCondition = parts[1] || '' |
| | | console.log('病情部分:', diseasePart) |
| | | console.log('其他描述:', this.taskForm.patient.otherCondition) |
| | | |
| | | // 解析病情部分 |
| | | this.parseDiseaseList(diseasePart, diseaseIdArray) |
| | | this.parseDiseaseList(diseasePart, diseases) |
| | | } else { |
| | | // 没有"其他"部分,全部作为其他描述 |
| | | this.taskForm.patient.otherCondition = conditionText |
| | | this.selectedDiseases = [] |
| | | // 没有"其他"部分,尝试解析是否有疾病列表 |
| | | const hasDiseasesFormat = /([^(]+)\(([^)]+)\)/.test(conditionText) |
| | | console.log('是否包含疾病格式:', hasDiseasesFormat) |
| | | |
| | | if (hasDiseasesFormat) { |
| | | // 有疾病格式,解析疾病列表 |
| | | this.parseDiseaseList(conditionText, diseases) |
| | | this.taskForm.patient.otherCondition = '' |
| | | } else { |
| | | // 没有疾病格式,全部作为其他描述 |
| | | console.log('无疾病格式,作为其他描述') |
| | | this.taskForm.patient.otherCondition = conditionText |
| | | this.selectedDiseases = [] |
| | | } |
| | | } |
| | | |
| | | console.log('解析完成,selectedDiseases:', JSON.stringify(this.selectedDiseases)) |
| | | console.log('解析完成,otherCondition:', this.taskForm.patient.otherCondition) |
| | | console.log('========================================\n') |
| | | }, |
| | | |
| | | // 解析病情列表(格式:疾病名(编码)、疾病名(编码)) |
| | | parseDiseaseList(diseasePart, diseaseIdArray) { |
| | | parseDiseaseList(diseasePart, diseasesData) { |
| | | console.log('--- parseDiseaseList 开始 ---') |
| | | console.log('diseasePart:', diseasePart) |
| | | console.log('diseasesData:', diseasesData) |
| | | |
| | | if (!diseasePart) { |
| | | console.log('病情部分为空') |
| | | this.selectedDiseases = [] |
| | | return |
| | | } |
| | | |
| | | // 如果后端已经返回了diseases数组,直接使用 |
| | | if (diseasesData && Array.isArray(diseasesData) && diseasesData.length > 0) { |
| | | console.log('使用后端返回的diseases数组,数量:', diseasesData.length) |
| | | this.selectedDiseases = diseasesData.map(d => ({ |
| | | id: d.icdId || null, |
| | | icdCode: d.icdCode || '', |
| | | icdName: d.icdName || '' |
| | | })) |
| | | console.log('解析后的selectedDiseases:', JSON.stringify(this.selectedDiseases)) |
| | | return |
| | | } |
| | | |
| | | // 否则,从字符串解析 |
| | | console.log('从字符串解析病情') |
| | | // 匹配格式:疾病名(编码) |
| | | const regex = /([^(]+)\(([^)]+)\)/g |
| | | const diseases = [] |
| | | let match |
| | | let index = 0 |
| | | |
| | | while ((match = regex.exec(diseasePart)) !== null) { |
| | | const icdName = match[1].replace(/[、,\s]+$/, '').replace(/^[、,\s]+/, '').trim() |
| | | const icdCode = match[2].trim() |
| | | |
| | | console.log('匹配到病情 - 名称:', icdName, '编码:', icdCode) |
| | | |
| | | // 只添加病情名称不为空的项 |
| | | if (icdName) { |
| | | diseases.push({ |
| | | icdName: icdName, |
| | | id: null, // 从字符串解析时,没有ID |
| | | icdCode: icdCode, |
| | | id: diseaseIdArray && index < diseaseIdArray.length ? diseaseIdArray[index] : null |
| | | icdName: icdName |
| | | }) |
| | | index++ |
| | | } |
| | | } |
| | | |
| | | console.log('从字符串解析完成,数量:', diseases.length) |
| | | this.selectedDiseases = diseases |
| | | console.log('--- parseDiseaseList 结束 ---\n') |
| | | }, |
| | | |
| | | // 选择转出医院地址 |
| | |
| | | }, |
| | | |
| | | buildSubmitData() { |
| | | // 确保 selectedDiseases 和 selectedStaff 不为 null(修复:防止迭代 null 导致错误) |
| | | if (!this.selectedDiseases) { |
| | | this.selectedDiseases = [] |
| | | } |
| | | if (!this.selectedStaff) { |
| | | this.selectedStaff = [] |
| | | } |
| | | |
| | | // 合并病情信息:选中的ICD-10疾病 + 其他描述 |
| | | let conditionText = '' |
| | | if (this.selectedDiseases.length > 0) { |
| | |
| | | } |
| | | } |
| | | |
| | | // 构建提交数据 - 使用与 TaskCreateVO 一致的结构 |
| | | const submitData = { |
| | | taskId: this.taskId, |
| | | taskType: 'EMERGENCY_TRANSFER', |
| | | deptId: this.selectedOrganizationId, |
| | | vehicleIds: this.selectedVehicleId ? [this.selectedVehicleId] : [], |
| | | plannedStartTime: this.taskForm.transferTime, |
| | | // 出发地使用 departureAddress(如果有),否则使用转出医院地址 |
| | | |
| | | // 出发地地址和坐标(使用转出医院地址) |
| | | departureAddress: this.departureAddress || this.taskForm.hospitalOut.address, |
| | | // 目标地使用转入医院地址 |
| | | departureLongitude: this.departureLongitude || (this.addressCoordinates.hospitalOutAddress ? this.addressCoordinates.hospitalOutAddress.lng : null), |
| | | departureLatitude: this.departureLatitude || (this.addressCoordinates.hospitalOutAddress ? this.addressCoordinates.hospitalOutAddress.lat : null), |
| | | |
| | | // 目标地地址和坐标(使用转入医院地址) |
| | | destinationAddress: this.taskForm.hospitalIn.address, |
| | | destinationLongitude: this.addressCoordinates.hospitalInAddress ? this.addressCoordinates.hospitalInAddress.lng : null, |
| | | destinationLatitude: this.addressCoordinates.hospitalInAddress ? this.addressCoordinates.hospitalInAddress.lat : null, |
| | | |
| | | // 转运距离和价格(主任务字段) |
| | | distance: this.taskForm.transferDistance ? parseFloat(this.taskForm.transferDistance) : null, |
| | | price: this.taskForm.price ? parseFloat(this.taskForm.price) : null, |
| | | |
| | | // 病情ID列表(用于同步调度单的OrdICD_ID参数) |
| | | diseaseIds: this.selectedDiseases.map(d => d.id).filter(id => id !== null), |
| | | // 执行人员列表 |
| | | assignees: this.selectedStaff.map(staff => ({ |
| | | |
| | | // 执行人员列表(确保不为 null) |
| | | assignees: (this.selectedStaff && Array.isArray(this.selectedStaff)) ? this.selectedStaff.map(staff => ({ |
| | | userId: staff.userId, |
| | | userName: staff.nickName, |
| | | userType: staff.type |
| | | })), |
| | | emergencyInfo: { |
| | | patientContact: this.taskForm.patient.contact, |
| | | patientPhone: this.taskForm.patient.phone, |
| | | patientName: this.taskForm.patient.name, |
| | | patientGender: this.taskForm.patient.gender, |
| | | patientIdCard: this.taskForm.patient.idCard, |
| | | patientCondition: conditionText, // 使用合并后的病情信息 |
| | | hospitalOutName: this.taskForm.hospitalOut.name, |
| | | hospitalOutDepartment: this.taskForm.hospitalOut.department, |
| | | hospitalOutBedNumber: this.taskForm.hospitalOut.bedNumber, |
| | | hospitalOutAddress: this.taskForm.hospitalOut.address, |
| | | // 转出医院GPS坐标(保存到扩展表) |
| | | hospitalOutLongitude: this.addressCoordinates.hospitalOutAddress ? this.addressCoordinates.hospitalOutAddress.lng : null, |
| | | hospitalOutLatitude: this.addressCoordinates.hospitalOutAddress ? this.addressCoordinates.hospitalOutAddress.lat : null, |
| | | hospitalInName: this.taskForm.hospitalIn.name, |
| | | hospitalInDepartment: this.taskForm.hospitalIn.department, |
| | | hospitalInBedNumber: this.taskForm.hospitalIn.bedNumber, |
| | | hospitalInAddress: this.taskForm.hospitalIn.address, |
| | | // 转入医院GPS坐标(保存到扩展表) |
| | | hospitalInLongitude: this.addressCoordinates.hospitalInAddress ? this.addressCoordinates.hospitalInAddress.lng : null, |
| | | hospitalInLatitude: this.addressCoordinates.hospitalInAddress ? this.addressCoordinates.hospitalInAddress.lat : null, |
| | | transferDistance: this.taskForm.transferDistance ? parseFloat(this.taskForm.transferDistance) : null, |
| | | transferPrice: this.taskForm.price ? parseFloat(this.taskForm.price) : null, |
| | | })) : [], |
| | | |
| | | // 患者信息(嵌套对象) |
| | | patient: { |
| | | contact: this.taskForm.patient.contact, |
| | | phone: this.taskForm.patient.phone, |
| | | name: this.taskForm.patient.name, |
| | | gender: this.taskForm.patient.gender, |
| | | idCard: this.taskForm.patient.idCard, |
| | | condition: conditionText, // 使用合并后的病情信息 |
| | | // 病情详细信息(过滤掉空的病情名称) |
| | | diseases: this.selectedDiseases |
| | | .filter(d => d.icdName && d.icdName.trim()) |
| | |
| | | icdCode: d.icdCode, |
| | | icdName: d.icdName |
| | | })) |
| | | }, |
| | | |
| | | // 转出医院信息(嵌套对象) |
| | | hospitalOut: { |
| | | id: this.taskForm.hospitalOut.id, |
| | | name: this.taskForm.hospitalOut.name, |
| | | address: this.taskForm.hospitalOut.address, |
| | | longitude: this.addressCoordinates.hospitalOutAddress ? this.addressCoordinates.hospitalOutAddress.lng : null, |
| | | latitude: this.addressCoordinates.hospitalOutAddress ? this.addressCoordinates.hospitalOutAddress.lat : null, |
| | | department: this.taskForm.hospitalOut.department, |
| | | departmentId: this.taskForm.hospitalOut.departmentId, |
| | | bedNumber: this.taskForm.hospitalOut.bedNumber |
| | | }, |
| | | |
| | | // 转入医院信息(嵌套对象) |
| | | hospitalIn: { |
| | | id: this.taskForm.hospitalIn.id, |
| | | name: this.taskForm.hospitalIn.name, |
| | | address: this.taskForm.hospitalIn.address, |
| | | longitude: this.addressCoordinates.hospitalInAddress ? this.addressCoordinates.hospitalInAddress.lng : null, |
| | | latitude: this.addressCoordinates.hospitalInAddress ? this.addressCoordinates.hospitalInAddress.lat : null, |
| | | department: this.taskForm.hospitalIn.department, |
| | | departmentId: this.taskForm.hospitalIn.departmentId, |
| | | bedNumber: this.taskForm.hospitalIn.bedNumber |
| | | } |
| | | } |
| | | |
| | | // 出发地GPS坐标 |
| | | if (this.departureLongitude && this.departureLatitude) { |
| | | submitData.departureLongitude = this.departureLongitude |
| | | submitData.departureLatitude = this.departureLatitude |
| | | } |
| | | |
| | | // 目标地GPS坐标由后端自动获取 |
| | | |
| | | return submitData |
| | | }, |