| | |
| | | /> |
| | | |
| | | <view class="form-item"> |
| | | <OrganizationSelector |
| | | <OrganizationSelector |
| | | ref="organizationSelector" |
| | | v-model="selectedOrganizationId" |
| | | :required="true" |
| | | :auto-select-user-dept="false" |
| | |
| | | :required="false" |
| | | :auto-add-current-user="false" |
| | | :current-user-removable="true" |
| | | :branch-dept-ids="allOrganizationIds" |
| | | @change="onStaffChange" |
| | | /> |
| | | |
| | |
| | | |
| | | <view class="form-section-title">转出医院信息</view> |
| | | <HospitalSelector |
| | | label="区院名称" |
| | | label="医院名称" |
| | | address-label="转出地址" |
| | | :required="true" |
| | | :show-department="false" |
| | | v-model="taskForm.hospitalOut" |
| | | :dept-id="selectedOrganizationId" |
| | | @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" |
| | | :show-department="false" |
| | | v-model="taskForm.hospitalIn" |
| | | :dept-id="selectedOrganizationId" |
| | | @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">转运距离</view> |
| | |
| | | import uniDatetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue' |
| | | import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue' |
| | | import { getTask, updateTask } from "@/api/task" |
| | | import { baiduDistanceByAddress } from "@/api/map" |
| | | import { tiandituDistanceByAddress } from "@/api/map" |
| | | import { calculateTransferPrice } from "@/api/price" |
| | | import MapSelector from './components/map-selector.vue' |
| | | import VehicleSelector from './components/VehicleSelector.vue' |
| | |
| | | import DiseaseSelector from './components/DiseaseSelector.vue' |
| | | import DepartureSelector from './components/DepartureSelector.vue' |
| | | import StaffSelector from './components/StaffSelector.vue' |
| | | import DepartmentSelector from './components/DepartmentSelector.vue' |
| | | import distanceCalculator from '@/mixins/distanceCalculator.js' |
| | | |
| | | export default { |
| | |
| | | HospitalSelector, |
| | | DiseaseSelector, |
| | | DepartureSelector, |
| | | StaffSelector |
| | | StaffSelector, |
| | | DepartmentSelector |
| | | }, |
| | | mixins: [distanceCalculator], |
| | | data() { |
| | |
| | | taskDetail: null, |
| | | selectedVehicleId: null, |
| | | selectedOrganizationId: null, |
| | | allOrganizationIds: [], // 所有可选机构ID数组 |
| | | selectedRegion: '', |
| | | mapSelectorType: '', |
| | | // 扩展 addressCoordinates 支持多种键名 |
| | |
| | | }, 1500) |
| | | } |
| | | }, |
| | | |
| | | mounted() { |
| | | // 页面挂载后加载所有机构ID |
| | | this.loadAllOrganizationIds() |
| | | }, |
| | | methods: { |
| | | // 加载任务详情 |
| | | loadTaskDetail() { |
| | |
| | | const info = this.taskDetail.emergencyInfo |
| | | console.log('转运任务信息:', info) |
| | | |
| | | // 转运时间 |
| | | this.taskForm.transferTime = this.taskDetail.plannedStartTime || '' |
| | | // 转运时间(修复:1900年的日期显示为空) |
| | | const transferTime = this.taskDetail.plannedStartTime || '' |
| | | this.taskForm.transferTime = transferTime && transferTime.startsWith('1900') ? '' : transferTime |
| | | |
| | | // 患者信息 |
| | | this.taskForm.patient.contact = info.patientContact || '' |
| | |
| | | this.taskForm.hospitalOut.id = info.hospitalOutId || null |
| | | this.taskForm.hospitalOut.name = info.hospitalOutName || '' |
| | | this.taskForm.hospitalOut.department = info.hospitalOutDepartment || '' |
| | | this.taskForm.hospitalOut.departmentId = info.hospitalOutDepartmentId || null |
| | | this.taskForm.hospitalOut.bedNumber = info.hospitalOutBedNumber || '' |
| | | this.taskForm.hospitalOut.address = info.hospitalOutAddress || '' |
| | | console.log('转出医院科室ID:', info.hospitalOutDepartmentId) |
| | | |
| | | // 加载转出医院GPS坐标(不显示,但保存在数据中) |
| | | if (info.hospitalOutLongitude && info.hospitalOutLatitude) { |
| | |
| | | this.taskForm.hospitalIn.id = info.hospitalInId || null |
| | | this.taskForm.hospitalIn.name = info.hospitalInName || '' |
| | | this.taskForm.hospitalIn.department = info.hospitalInDepartment || '' |
| | | this.taskForm.hospitalIn.departmentId = info.hospitalInDepartmentId || null |
| | | this.taskForm.hospitalIn.bedNumber = info.hospitalInBedNumber || '' |
| | | this.taskForm.hospitalIn.address = info.hospitalInAddress || '' |
| | | console.log('转入医院科室ID:', info.hospitalInDepartmentId) |
| | | |
| | | // 加载转入医院GPS坐标(不显示,但保存在数据中) |
| | | if (info.hospitalInLongitude && info.hospitalInLatitude) { |
| | |
| | | } else { |
| | | console.warn('任务详情中没有emergencyInfo字段,尝试从主对象获取数据') |
| | | // 兼容处理:如果emergencyInfo不存在,尝试从主对象获取 |
| | | this.taskForm.transferTime = this.taskDetail.plannedStartTime || '' |
| | | const transferTime = this.taskDetail.plannedStartTime || '' |
| | | this.taskForm.transferTime = transferTime && transferTime.startsWith('1900') ? '' : transferTime |
| | | this.taskForm.transferDistance = this.taskDetail.estimatedDistance ? String(this.taskDetail.estimatedDistance) : '' |
| | | } |
| | | |
| | |
| | | console.log('设置目标地坐标:', this.taskDetail.destinationLongitude, this.taskDetail.destinationLatitude) |
| | | } |
| | | |
| | | // 设置执行人员(修复:确保 assignees 不为 null) |
| | | // 设置执行人员(修复:确保 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, |
| | | nickName: assignee.userName, |
| | | type: assignee.userType || 'driver', |
| | | phonenumber: '', |
| | | deptName: '' |
| | | })) |
| | | this.selectedStaff = this.taskDetail.assignees.map(assignee => { |
| | | console.log('处理执行人员:', assignee) |
| | | console.log(' - userName:', assignee.userName) |
| | | console.log(' - nickName:', assignee.nickName) |
| | | console.log(' - phonenumber:', assignee.phonenumber) |
| | | console.log(' - phone:', assignee.phone) |
| | | |
| | | return { |
| | | userId: assignee.userId, |
| | | nickName: assignee.userName || assignee.nickName || '', |
| | | type: assignee.userType || 'driver', |
| | | phonenumber: assignee.phonenumber || assignee.phone || '', |
| | | deptName: assignee.deptName || '' |
| | | } |
| | | }) |
| | | console.log('处理后的执行人员列表:', this.selectedStaff) |
| | | } else { |
| | | console.warn('任务没有分配执行人员或assignees为空') |
| | |
| | | // 车辆选择变化 |
| | | onVehicleChange(vehicle) { |
| | | console.log('选中车辆:', vehicle) |
| | | }, |
| | | |
| | | // 加载所有机构ID |
| | | loadAllOrganizationIds() { |
| | | // 通过 OrganizationSelector 组件获取所有机构 |
| | | const orgSelector = this.$refs.organizationSelector |
| | | if (orgSelector) { |
| | | orgSelector.reload().then(organizations => { |
| | | this.allOrganizationIds = organizations.map(org => org.deptId) |
| | | console.log('所有机构ID:', this.allOrganizationIds) |
| | | }) |
| | | } else { |
| | | // 如果组件还未挂载,稍后重试 |
| | | setTimeout(() => { |
| | | this.loadAllOrganizationIds() |
| | | }, 100) |
| | | } |
| | | }, |
| | | |
| | | // 归属机构选择变化 |
| | |
| | | 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) { |
| | | console.log('转出科室变化:', 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) { |
| | | console.log('转入科室变化:', 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 |
| | | } |
| | | }, |
| | | |
| | |
| | | return false |
| | | } |
| | | |
| | | // 验证联系电话格式 |
| | | if (this.taskForm.patient.phone && !/^1[3-9]\d{9}$/.test(this.taskForm.patient.phone)) { |
| | | this.$modal.showToast('请输入正确的手机号码') |
| | | return false |
| | | } |
| | | |
| | | if (!this.taskForm.hospitalOut.name) { |
| | | this.$modal.showToast('请输入转出医院名称') |
| | | return false |
| | |
| | | return false |
| | | } |
| | | |
| | | if (!this.taskForm.hospitalOut.department) { |
| | | this.$modal.showToast('请选择转出科室') |
| | | return false |
| | | } |
| | | |
| | | if (!this.taskForm.hospitalIn.name) { |
| | | this.$modal.showToast('请输入转入医院名称') |
| | | return false |
| | |
| | | |
| | | if (!this.taskForm.hospitalIn.address) { |
| | | this.$modal.showToast('请选择转入医院地址') |
| | | return false |
| | | } |
| | | |
| | | if (!this.taskForm.hospitalIn.department) { |
| | | this.$modal.showToast('请选择转入科室') |
| | | return false |
| | | } |
| | | |
| | | // 验证成交价必填 |
| | | if (!this.taskForm.price || this.taskForm.price.trim() === '') { |
| | | this.$modal.showToast('请输入成交价') |
| | | return false |
| | | } |
| | | |
| | | // 验证成交价格式(必须是数字) |
| | | if (isNaN(this.taskForm.price) || parseFloat(this.taskForm.price) < 0) { |
| | | this.$modal.showToast('请输入有效的成交价') |
| | | return false |
| | | } |
| | | |
| | | // 验证患者身份证格式(如果填写了) |
| | | if (this.taskForm.patient.idCard && this.taskForm.patient.idCard.trim() !== '') { |
| | | const idCard = this.taskForm.patient.idCard.trim() |
| | | // 简单验证18位身份证 |
| | | if (!/^\d{17}[\dXx]$/.test(idCard)) { |
| | | this.$modal.showToast('请输入正确的18位身份证号码') |
| | | return false |
| | | } |
| | | } |
| | | |
| | | // 验证病情至少选择一项或填写其他描述 |
| | | if ((!this.selectedDiseases || this.selectedDiseases.length === 0) && |
| | | (!this.taskForm.patient.otherCondition || this.taskForm.patient.otherCondition.trim() === '')) { |
| | | this.$modal.showToast('请选择病情或填写其他病情描述') |
| | | return false |
| | | } |
| | | |
| | | // 验证执行人员至少选择一个 |
| | | if (!this.selectedStaff || this.selectedStaff.length === 0) { |
| | | this.$modal.showToast('请至少选择一个执行人员') |
| | | return false |
| | | } |
| | | |
| | |
| | | this.loading = true |
| | | const submitData = this.buildSubmitData() |
| | | |
| | | console.log('提交数据 - 转出医院科室ID:', submitData.hospitalOut.departmentId) |
| | | console.log('提交数据 - 转入医院科室ID:', submitData.hospitalIn.departmentId) |
| | | |
| | | updateTask(submitData).then(response => { |
| | | this.loading = false |
| | | console.log('任务更新响应:', response) |
| | |
| | | |
| | | // 调用百度地图API计算距离 |
| | | const region = this.selectedRegion || '广州' |
| | | baiduDistanceByAddress(fromAddress, region, toAddress, region) |
| | | //baiduDistanceByAddress(fromAddress, region, toAddress, region) |
| | | tiandituDistanceByAddress(fromAddress,toAddress) |
| | | .then(response => { |
| | | uni.hideLoading() |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | | } |