| | |
| | | /> |
| | | |
| | | <view class="form-item"> |
| | | <view class="form-label required">任务类型</view> |
| | | <picker mode="selector" :range="emergencyTaskTypeOptions" range-key="text" @change="onEmergencyTaskTypeChange"> |
| | | <view class="form-input picker-input"> |
| | | {{ selectedEmergencyTaskType || '请选择任务类型' }} |
| | | <uni-icons type="arrowright" size="16" color="#999"></uni-icons> |
| | | </view> |
| | | </picker> |
| | | </view> |
| | | |
| | | <view class="form-item"> |
| | | <view class="form-label required">单据类型</view> |
| | | <picker mode="selector" :range="documentTypeOptions" range-key="text" @change="onDocumentTypeChange"> |
| | | <view class="form-input picker-input"> |
| | | {{ selectedDocumentType || '请选择单据类型' }} |
| | | <uni-icons type="arrowright" size="16" color="#999"></uni-icons> |
| | | </view> |
| | | </picker> |
| | | </view> |
| | | |
| | | <view class="form-item"> |
| | | <view class="form-label required">转运时间</view> |
| | | <uni-datetime-picker |
| | | v-model="taskForm.transferTime" |
| | |
| | | import { getTask, updateTask } from "@/api/task" |
| | | import { tiandituDistanceByAddress } from "@/api/map" |
| | | import { calculateTransferPrice } from "@/api/price" |
| | | import { getServiceOrdAreaTypes, getServiceOrderTypes } from "@/api/dictionary" |
| | | import MapSelector from './components/map-selector.vue' |
| | | import VehicleSelector from './components/VehicleSelector.vue' |
| | | import OrganizationSelector from './components/OrganizationSelector.vue' |
| | |
| | | departureLatitude: null, |
| | | selectedDiseases: [], // 已选择的病情列表(确保初始化为空数组) |
| | | selectedStaff: [], // 已选择的人员列表(确保初始化为空数组) |
| | | // 任务类型和单据类型相关 |
| | | selectedEmergencyTaskType: '', // 选中的任务类型文本 |
| | | selectedEmergencyTaskTypeId: null, // 选中的任务类型ID |
| | | selectedDocumentType: '', // 选中的单据类型文本 |
| | | selectedDocumentTypeId: null, // 选中的单据类型ID |
| | | pendingTaskTypeId: null, // 等待设置的任务类型ID |
| | | pendingDocumentTypeId: null, // 等待设置的单据类型ID |
| | | emergencyTaskTypes: [], // 任务类型列表(从 SQL Server 动态加载) |
| | | emergencyTaskTypeOptions: [], // 任务类型选项(用于picker显示) |
| | | documentTypes: [], // 单据类型列表 |
| | | documentTypeOptions: [], // 单据类型选项(用于picker显示) |
| | | taskForm: { |
| | | transferTime: '', |
| | | patient: { |
| | |
| | | if (options.id) { |
| | | this.taskId = options.id |
| | | this.loadTaskDetail() |
| | | // 加载任务类型数据 |
| | | this.loadEmergencyTaskTypes() |
| | | // 加载单据类型数据 |
| | | this.loadDocumentTypes() |
| | | } else { |
| | | this.$modal.showToast('任务ID不能为空') |
| | | setTimeout(() => { |
| | |
| | | // 转运距离和价格 |
| | | this.taskForm.transferDistance = info.transferDistance ? String(info.transferDistance) : '' |
| | | this.taskForm.price = info.transferPrice ? String(info.transferPrice) : '' |
| | | |
| | | // 任务类型和单据类型 |
| | | if (info.taskTypeId) { |
| | | // 直接设置任务类型,如果选项还未加载完成,则在加载完成后再次设置 |
| | | const taskType = this.emergencyTaskTypeOptions.find(option => option.id == info.taskTypeId) |
| | | if (taskType) { |
| | | this.selectedEmergencyTaskType = taskType.text |
| | | this.selectedEmergencyTaskTypeId = taskType.id |
| | | } else { |
| | | // 如果选项还未加载完成,标记需要设置的ID |
| | | this.pendingTaskTypeId = info.taskTypeId |
| | | } |
| | | } |
| | | |
| | | if (info.documentTypeId) { |
| | | // 直接设置单据类型,如果选项还未加载完成,则在加载完成后再次设置 |
| | | const docType = this.documentTypeOptions.find(option => option.id == info.documentTypeId) |
| | | if (docType) { |
| | | this.selectedDocumentType = docType.text |
| | | this.selectedDocumentTypeId = docType.id |
| | | } else { |
| | | // 如果选项还未加载完成,标记需要设置的ID |
| | | this.pendingDocumentTypeId = info.documentTypeId |
| | | } |
| | | } |
| | | } else { |
| | | console.warn('任务详情中没有emergencyInfo字段,尝试从主对象获取数据') |
| | | // 兼容处理:如果emergencyInfo不存在,尝试从主对象获取 |
| | |
| | | // 车辆选择变化 |
| | | onVehicleChange(vehicle) { |
| | | console.log('选中车辆:', vehicle) |
| | | }, |
| | | |
| | | // 加载任务类型数据(从 SQL Server) |
| | | loadEmergencyTaskTypes() { |
| | | getServiceOrderTypes().then(response => { |
| | | const list = response.data || [] |
| | | this.emergencyTaskTypes = list |
| | | this.emergencyTaskTypeOptions = list.map(item => ({ |
| | | id: item.vID, |
| | | text: item.vtext |
| | | })) |
| | | |
| | | // 如果任务详情已加载,设置当前选中的任务类型 |
| | | if (this.taskDetail && this.taskDetail.emergencyInfo && this.taskDetail.emergencyInfo.taskTypeId) { |
| | | const currentType = this.emergencyTaskTypeOptions.find(option => option.id == this.taskDetail.emergencyInfo.taskTypeId) |
| | | if (currentType) { |
| | | this.selectedEmergencyTaskType = currentType.text |
| | | this.selectedEmergencyTaskTypeId = currentType.id |
| | | } |
| | | } |
| | | |
| | | // 检查是否有待设置的任务类型ID |
| | | if (this.pendingTaskTypeId) { |
| | | const pendingType = this.emergencyTaskTypeOptions.find(option => option.id == this.pendingTaskTypeId) |
| | | if (pendingType) { |
| | | this.selectedEmergencyTaskType = pendingType.text |
| | | this.selectedEmergencyTaskTypeId = pendingType.id |
| | | this.pendingTaskTypeId = null |
| | | } |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载任务类型失败:', error) |
| | | this.emergencyTaskTypes = [] |
| | | this.emergencyTaskTypeOptions = [] |
| | | }) |
| | | }, |
| | | |
| | | // 任务类型选择 |
| | | onEmergencyTaskTypeChange(e) { |
| | | const index = e.detail.value |
| | | const selected = this.emergencyTaskTypeOptions[index] |
| | | this.selectedEmergencyTaskType = selected.text |
| | | this.selectedEmergencyTaskTypeId = selected.id |
| | | }, |
| | | |
| | | // 加载单据类型数据 |
| | | loadDocumentTypes() { |
| | | getServiceOrdAreaTypes().then(response => { |
| | | const list = response.data || [] |
| | | this.documentTypes = list |
| | | this.documentTypeOptions = list.map(item => ({ |
| | | id: item.vID, |
| | | text: item.vtext |
| | | })) |
| | | |
| | | // 如果任务详情已加载,设置当前选中的单据类型 |
| | | if (this.taskDetail && this.taskDetail.emergencyInfo && this.taskDetail.emergencyInfo.documentTypeId) { |
| | | const currentType = this.documentTypeOptions.find(option => option.id == this.taskDetail.emergencyInfo.documentTypeId) |
| | | if (currentType) { |
| | | this.selectedDocumentType = currentType.text |
| | | this.selectedDocumentTypeId = currentType.id |
| | | } |
| | | } |
| | | |
| | | // 检查是否有待设置的单据类型ID |
| | | if (this.pendingDocumentTypeId) { |
| | | const pendingType = this.documentTypeOptions.find(option => option.id == this.pendingDocumentTypeId) |
| | | if (pendingType) { |
| | | this.selectedDocumentType = pendingType.text |
| | | this.selectedDocumentTypeId = pendingType.id |
| | | this.pendingDocumentTypeId = null |
| | | } |
| | | } |
| | | }).catch(error => { |
| | | console.error('加载单据类型失败:', error) |
| | | this.documentTypes = [] |
| | | this.documentTypeOptions = [] |
| | | }) |
| | | }, |
| | | |
| | | // 单据类型选择 |
| | | onDocumentTypeChange(e) { |
| | | const index = e.detail.value |
| | | const selected = this.documentTypeOptions[index] |
| | | this.selectedDocumentType = selected.text |
| | | this.selectedDocumentTypeId = selected.id |
| | | }, |
| | | |
| | | // 加载所有机构ID |
| | |
| | | return false |
| | | } |
| | | |
| | | if (!this.selectedEmergencyTaskType) { |
| | | this.$modal.showToast('请选择任务类型') |
| | | return false |
| | | } |
| | | |
| | | if (!this.selectedDocumentType) { |
| | | this.$modal.showToast('请选择单据类型') |
| | | return false |
| | | } |
| | | |
| | | if (!this.taskForm.patient.contact) { |
| | | this.$modal.showToast('请输入联系人') |
| | | return false |
| | |
| | | deptId: this.selectedOrganizationId, |
| | | vehicleIds: this.selectedVehicleId ? [this.selectedVehicleId] : [], |
| | | plannedStartTime: this.taskForm.transferTime, |
| | | // 任务类型和单据类型 |
| | | taskTypeId: this.selectedEmergencyTaskTypeId, |
| | | documentTypeId: this.selectedDocumentTypeId, |
| | | |
| | | // 出发地地址和坐标(使用转出医院地址) |
| | | departureAddress: this.departureAddress || this.taskForm.hospitalOut.address, |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </style> |