| | |
| | | taskId: null, |
| | | taskDetail: null, |
| | | mapSelectorType: '', |
| | | // 扩展 addressCoordinates 支持多种键名 |
| | | addressCoordinates: { |
| | | start: null, |
| | | end: null, |
| | | startLocation: null, |
| | | endLocation: null |
| | | }, |
| | | taskForm: { |
| | | taskDescription: '', |
| | | taskType: '', |
| | |
| | | |
| | | // 设置地址坐标(使用mixin中的方法) |
| | | if (this.taskDetail.departureLongitude && this.taskDetail.departureLatitude) { |
| | | this.setStartLocation({ |
| | | const startLocation = { |
| | | lng: this.taskDetail.departureLongitude, |
| | | lat: this.taskDetail.departureLatitude |
| | | }) |
| | | } |
| | | this.setStartLocation(startLocation) |
| | | // 同时保存到 startLocation 键 |
| | | this.addressCoordinates.startLocation = startLocation |
| | | } |
| | | if (this.taskDetail.destinationLongitude && this.taskDetail.destinationLatitude) { |
| | | this.setEndLocation({ |
| | | const endLocation = { |
| | | lng: this.taskDetail.destinationLongitude, |
| | | lat: this.taskDetail.destinationLatitude |
| | | }) |
| | | } |
| | | this.setEndLocation(endLocation) |
| | | // 同时保存到 endLocation 键 |
| | | this.addressCoordinates.endLocation = endLocation |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载任务详情失败:', error) |
| | |
| | | |
| | | if (this.mapSelectorType === 'startLocation') { |
| | | this.taskForm.startLocation = formattedAddress |
| | | this.setLocationByAddress('start', address) |
| | | const location = this.setLocationByAddress('start', address) |
| | | // 同时保存到 startLocation 键 |
| | | this.addressCoordinates.startLocation = location |
| | | } else if (this.mapSelectorType === 'endLocation') { |
| | | this.taskForm.endLocation = formattedAddress |
| | | this.setLocationByAddress('end', address) |
| | | const location = this.setLocationByAddress('end', address) |
| | | // 同时保存到 endLocation 键 |
| | | this.addressCoordinates.endLocation = location |
| | | } |
| | | |
| | | // 监听mixin中的距离计算完成事件 |
| | |
| | | }, |
| | | |
| | | buildSubmitData() { |
| | | // 构建提交数据 - 使用与 TaskCreateVO 一致的结构 |
| | | const submitData = { |
| | | taskId: this.taskId, |
| | | taskDescription: this.taskForm.taskDescription, |
| | |
| | | vehicleIds: this.taskForm.vehicleId ? [this.taskForm.vehicleId] : [], |
| | | plannedStartTime: this.taskForm.plannedStartTime, |
| | | plannedEndTime: this.taskForm.plannedEndTime, |
| | | |
| | | // 出发地地址和坐标 |
| | | departureAddress: this.taskForm.startLocation, |
| | | departureLongitude: this.addressCoordinates.startLocation ? this.addressCoordinates.startLocation.lng : null, |
| | | departureLatitude: this.addressCoordinates.startLocation ? this.addressCoordinates.startLocation.lat : null, |
| | | |
| | | // 目标地地址和坐标 |
| | | destinationAddress: this.taskForm.endLocation, |
| | | estimatedDistance: this.taskForm.distance ? parseFloat(this.taskForm.distance) : null, |
| | | destinationLongitude: this.addressCoordinates.endLocation ? this.addressCoordinates.endLocation.lng : null, |
| | | destinationLatitude: this.addressCoordinates.endLocation ? this.addressCoordinates.endLocation.lat : null, |
| | | |
| | | // 距离(主任务字段) |
| | | distance: this.taskForm.distance ? parseFloat(this.taskForm.distance) : null, |
| | | |
| | | remark: this.taskForm.remark |
| | | } |
| | | |
| | | if (this.addressCoordinates.startLocation) { |
| | | submitData.departureLongitude = this.addressCoordinates.startLocation.lng |
| | | submitData.departureLatitude = this.addressCoordinates.startLocation.lat |
| | | } |
| | | |
| | | if (this.addressCoordinates.endLocation) { |
| | | submitData.destinationLongitude = this.addressCoordinates.endLocation.lng |
| | | submitData.destinationLatitude = this.addressCoordinates.endLocation.lat |
| | | } |
| | | |
| | | return submitData |