| | |
| | | selectedVehicleId: null, |
| | | selectedOrganization: '', |
| | | mapSelectorType: '', |
| | | // 扩展 addressCoordinates 支持多种键名 |
| | | addressCoordinates: { |
| | | start: null, |
| | | end: null, |
| | | startAddress: null, |
| | | endAddress: null |
| | | }, |
| | | taskForm: { |
| | | serviceTime: '', |
| | | passenger: { |
| | |
| | | |
| | | // 设置地址坐标(使用mixin中的方法) |
| | | if (this.taskDetail.departureLongitude && this.taskDetail.departureLatitude) { |
| | | this.setStartLocation({ |
| | | const startLocation = { |
| | | lng: this.taskDetail.departureLongitude, |
| | | lat: this.taskDetail.departureLatitude |
| | | }) |
| | | } |
| | | this.setStartLocation(startLocation) |
| | | // 同时保存到 startAddress 键 |
| | | this.addressCoordinates.startAddress = startLocation |
| | | } |
| | | if (this.taskDetail.destinationLongitude && this.taskDetail.destinationLatitude) { |
| | | this.setEndLocation({ |
| | | const endLocation = { |
| | | lng: this.taskDetail.destinationLongitude, |
| | | lat: this.taskDetail.destinationLatitude |
| | | }) |
| | | } |
| | | this.setEndLocation(endLocation) |
| | | // 同时保存到 endAddress 键 |
| | | this.addressCoordinates.endAddress = endLocation |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载任务详情失败:', error) |
| | |
| | | |
| | | if (this.mapSelectorType === 'startAddress') { |
| | | this.taskForm.startAddress = formattedAddress |
| | | this.setLocationByAddress('start', address) |
| | | const location = this.setLocationByAddress('start', address) |
| | | // 同时保存到 startAddress 键 |
| | | this.addressCoordinates.startAddress = location |
| | | } else if (this.mapSelectorType === 'endAddress') { |
| | | this.taskForm.endAddress = formattedAddress |
| | | this.setLocationByAddress('end', address) |
| | | const location = this.setLocationByAddress('end', address) |
| | | // 同时保存到 endAddress 键 |
| | | this.addressCoordinates.endAddress = location |
| | | } |
| | | |
| | | // 监听mixin中的距离计算完成事件 |
| | |
| | | }, |
| | | |
| | | buildSubmitData() { |
| | | // 构建提交数据 - 使用与 TaskCreateVO 一致的结构 |
| | | const submitData = { |
| | | taskId: this.taskId, |
| | | taskType: 'WELFARE', |
| | | vehicleIds: this.selectedVehicleId ? [this.selectedVehicleId] : [], |
| | | plannedStartTime: this.taskForm.serviceTime, |
| | | welfareInfo: { |
| | | passengerContact: this.taskForm.passenger.contact, |
| | | passengerPhone: this.taskForm.passenger.phone, |
| | | pickupAddress: this.taskForm.startAddress, |
| | | destinationAddress: this.taskForm.endAddress, |
| | | serviceDistance: this.taskForm.distance ? parseFloat(this.taskForm.distance) : null, |
| | | servicePrice: this.taskForm.price ? parseFloat(this.taskForm.price) : null |
| | | |
| | | // 出发地地址和坐标 |
| | | departureAddress: this.taskForm.startAddress, |
| | | departureLongitude: this.addressCoordinates.startAddress ? this.addressCoordinates.startAddress.lng : null, |
| | | departureLatitude: this.addressCoordinates.startAddress ? this.addressCoordinates.startAddress.lat : null, |
| | | |
| | | // 目标地地址和坐标 |
| | | destinationAddress: this.taskForm.endAddress, |
| | | destinationLongitude: this.addressCoordinates.endAddress ? this.addressCoordinates.endAddress.lng : null, |
| | | destinationLatitude: this.addressCoordinates.endAddress ? this.addressCoordinates.endAddress.lat : null, |
| | | |
| | | // 距离和价格(主任务字段) |
| | | distance: this.taskForm.distance ? parseFloat(this.taskForm.distance) : null, |
| | | price: this.taskForm.price ? parseFloat(this.taskForm.price) : null, |
| | | |
| | | // 乘客信息(嵌套对象) |
| | | passenger: { |
| | | contact: this.taskForm.passenger.contact, |
| | | phone: this.taskForm.passenger.phone |
| | | } |
| | | } |
| | | |
| | | if (this.addressCoordinates.startAddress) { |
| | | submitData.departureLongitude = this.addressCoordinates.startAddress.lng |
| | | submitData.departureLatitude = this.addressCoordinates.startAddress.lat |
| | | } |
| | | |
| | | if (this.addressCoordinates.endAddress) { |
| | | submitData.destinationLongitude = this.addressCoordinates.endAddress.lng |
| | | submitData.destinationLatitude = this.addressCoordinates.endAddress.lat |
| | | } |
| | | |
| | | return submitData |