wlzboy
2025-12-26 5ceca957811a0da3741cf4957e6f1fcfca807be6
app/pagesTask/create-emergency.vue
@@ -266,7 +266,7 @@
import { mapState } from 'vuex'
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 { addTask } from "@/api/task"
import { addTask, checkTaskDuplicate } from "@/api/task"
import { listAvailableVehicles, getUserBoundVehicle } from "@/api/vehicle"
import { searchHospitals, searchHospitalsByDeptRegion } from "@/api/hospital"
import DepartureSelector from './components/DepartureSelector.vue'
@@ -567,11 +567,7 @@
      console.log('转出医院变化:', hospitalData)
      // 组件已经通过 v-model 更新了 taskForm.hospitalOut
      
      // 如果选择的是"家中",自动设置科室为"其它"
      if (hospitalData.name === '家中') {
        this.taskForm.hospitalOut.department = '其它'
        this.taskForm.hospitalOut.departmentId = null
      }
      // 科室的设置由 DepartmentSelector 组件自动处理(通过 isHome 属性)
      
      // 如果转入地址已填写,自动计算距离
      if (this.taskForm.hospitalIn.address) {
@@ -597,11 +593,7 @@
      console.log('转入医院变化:', hospitalData)
      // 组件已经通过 v-model 更新了 taskForm.hospitalIn
      
      // 如果选择的是"家中",自动设置科室为"其它"
      if (hospitalData.name === '家中') {
        this.taskForm.hospitalIn.department = '其它'
        this.taskForm.hospitalIn.departmentId = null
      }
      // 科室的设置由 DepartmentSelector 组件自动处理(通过 isHome 属性)
      
      // 如果转出地址已填写,自动计算距离
      if (this.taskForm.hospitalOut.address) {
@@ -813,6 +805,18 @@
        return false
      }
      
      // 如果转入医院是“家中”,必须填写地址
      if (this.taskForm.hospitalIn.name === '家中' && !this.taskForm.hospitalIn.address) {
        this.$modal.showToast('请输入转入地址(家中)')
        return false
      }
      // 如果转出医院是“家中”,必须填写地址
      if (this.taskForm.hospitalOut.name === '家中' && !this.taskForm.hospitalOut.address) {
        this.$modal.showToast('请输入转出地址(家中)')
        return false
      }
      if (!this.taskForm.transferDistance) {
        this.$modal.showToast('请输入转运公里数')
        return false
@@ -846,6 +850,10 @@
          conditionText = this.taskForm.patient.condition
        }
      }
      // 调试日志:检查转入医院地址
      console.log('构建提交数据 - 转入医院:', this.taskForm.hospitalIn.name)
      console.log('构建提交数据 - 转入医院地址:', this.taskForm.hospitalIn.address)
      
      const submitData = {
        taskType: 'EMERGENCY_TRANSFER',
@@ -908,7 +916,41 @@
      if (!this.validateForm()) {
        return
      }
      this.doSubmitTask();
    },
    checkTaskDp(){
   // 获取当前日期(格式YYYY-MM-DD)
      const today = new Date()
      const createDate = today.getFullYear() + '-' +
                        String(today.getMonth() + 1).padStart(2, '0') + '-' +
                        String(today.getDate()).padStart(2, '0')
      const phone = this.taskForm.patient.phone
      
      // 先检查是否重复
      uni.showLoading({
        title: '检查中...'
      })
      checkTaskDuplicate(phone, createDate).then(response => {
        uni.hideLoading()
        // 如果接口返回错误,说明存在重复
        if (response.code !== 200) {
          this.$modal.showToast(response.msg || '该联系电话在当天已有任务,不能重复提交')
          return
        }
        // 检查通过,继续提交
        this.doSubmitTask()
      }).catch(error => {
        uni.hideLoading()
        console.error('重复性检查失败:', error)
        this.$modal.showToast('检查失败,请重试')
      })
    },
    // 执行实际的提交操作
    doSubmitTask() {
      this.$modal.confirm('确定要保存任务吗?').then(() => {
        this.loading = true
        const submitData = this.buildSubmitData()