WXL
2 天以前 3f49860639e6d5245f1e011fbe3b3aaff70dbb6c
src/views/ecg/doctor/components/RoutinePanel.vue
@@ -39,7 +39,6 @@
            placeholder="选择装机时间"
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="检查项目" prop="">
@@ -49,8 +48,8 @@
          <el-input v-model="formData.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="是否多耐" prop="tolerance">
         <el-tag type="info" v-if="formData.tolerance == 0">否</el-tag>
        <el-tag type="danger" v-else>是</el-tag>
          <el-tag type="info" v-if="formData.tolerance == 0">否</el-tag>
          <el-tag type="danger" v-else>是</el-tag>
        </el-form-item>
      </el-col>
    </el-row>
@@ -58,6 +57,10 @@
  <el-button @click="submitForm" type="primary" :disabled="formLoading">检查完成</el-button>
  <el-button @click="cancelInstall" :disabled="formLoading">放弃检查</el-button>
  <el-button @click="resetForm()">重 置</el-button>
  <el-button @click="yddownload()" :loading="yddownloadLoading"
    :disabled="yddownloadLoading">平板运动心电图知情同意书</el-button>
  <el-button @click="sgdownload()" :loading="sgdownloadLoading"
    :disabled="sgdownloadLoading">食管心脏电生理诊疗知情同意书</el-button>
  <el-button
    v-if="needAutoFeeConfirm(formData.checkType)"
    @click="feeConfirm"
@@ -151,7 +154,7 @@
import { isStringEmpty } from '@/utils/stringUtil'
import { curDayEnd, curDayStart } from '@/utils/dateUtil'
import { QueueVO } from '@/api/ecg/queue'
import { RoomBedVO } from '@/api/ecg/doctor'
import { RoomBedVO, DoctorApi } from '@/api/ecg/doctor'
import { Barcode } from '@/components/Barcode'
import { useCheckTypeStore } from '@/store/modules/checkType'
import { getCheckTypeName, needAutoFeeConfirm } from '../../../../utils/checkTypeFormatter'
@@ -163,6 +166,11 @@
  room: {
    type: Object as PropType<RoomBedVO>,
    required: true
  },
  setappointmentId: {
    type: [String, Number],
    required: false,
    default: null
  }
})
@@ -186,7 +194,8 @@
const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // 弹窗的是否展示
const yddownloadLoading = ref(false);
const sgdownloadLoading = ref(false);
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const formData = ref<Partial<DevRentVO>>({
@@ -259,7 +268,53 @@
  }
  formRef.value?.resetFields()
}
const yddownload = async () => {
  const response = await DoctorApi.yddownload(props.setappointmentId)
  console.log(response, 'xml1')
  console.log(response.fileContent, 'xml2')
  downloadWordFile(response.fileContent, response.fileName)
}
const sgdownload = async () => {
  const response = await DoctorApi.sgdownload(props.setappointmentId)
  downloadWordFile(response.fileContent, response.fileName)
}
const downloadWordFile = (data, filename = 'document') => {
  try {
    // 1. 确保文件名以.doc结尾
    if (!filename.endsWith('.doc')) {
      filename += '.doc'
    }
    // 2. 创建Blob对象,指定MIME类型为Word文档[9,10](@ref)
    // 对于Word 2003 XML格式,使用'application/msword'
    const blob = new Blob([data], { type: 'application/msword' })
    // 3. 为Blob对象创建一个临时的下载URL[8,10](@ref)
    const url = URL.createObjectURL(blob)
    // 4. 创建一个隐藏的不可见的<a>链接元素[10](@ref)
    const link = document.createElement('a')
    link.style.display = 'none' // 隐藏链接
    link.href = url
    link.download = filename // 设置下载的文件名
    // 5. 将链接添加到DOM中,模拟点击,然后移除它[10](@ref)
    document.body.appendChild(link)
    link.click()
    document.body.removeChild(link)
    // 6. 释放URL对象以释放内存[9,10](@ref)
    // 使用setTimeout确保下载触发后再释放
    setTimeout(() => {
      URL.revokeObjectURL(url)
    }, 100)
    console.log('文件下载已触发!')
  } catch (error) {
    console.error('下载文件时发生错误:', error)
    // 这里可以添加更友好的用户错误提示,例如使用alert或页面弹窗
  }
}
const getRentInfoByPatId = () => {
  const tempPatId = formData.value.patId
  resetForm()