增加导出按钮
This commit is contained in:
parent
869d6eb1b4
commit
6af69269a2
@ -86,6 +86,11 @@ v-loading.fullscreen.lock="fullscreenLoading"
|
||||
@change="uploadFile"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleExport">
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出Excel
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
@ -197,12 +202,16 @@ import template from "@/views/summary/print/template";
|
||||
import barcode from "@/views/summary/print/barcode";
|
||||
import IDCardReader from '@/components/IDCardReader.vue';
|
||||
import sdk from '@/components/IDCardReader/sdk';
|
||||
import download from '@/utils/download' // 添加下载工具导入
|
||||
import { ElMessageBox } from 'element-plus' // 添加 ElMessageBox 导入
|
||||
|
||||
defineOptions({ name: 'Department' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const importLoading = ref(false) // 导入Excel的加载状态
|
||||
const fullscreenLoading = ref(false) // 全屏加载状态
|
||||
const exportLoading = ref(false) // 导出Excel的加载状态
|
||||
const list = ref<PatientVO[]>([]) // 用于展示的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
@ -701,4 +710,38 @@ const handleDateChange = (val: [string, string] | null) => {
|
||||
queryParams.printTimeRange = undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 使用 ElMessageBox 实现确认对话框
|
||||
await ElMessageBox.confirm(
|
||||
`是否导出当前<span style="color: #f56c6c; font-weight: bold; font-size: 18px;">${total.value}</span>条患者数据?`,
|
||||
'导出确认',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
dangerouslyUseHTMLString: true // 允许使用 HTML 标签
|
||||
}
|
||||
)
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await PatientApi.exportPatient({
|
||||
...queryParams,
|
||||
pName: queryParams.pname?.trim() || undefined,
|
||||
isprint: queryParams.isprint || undefined,
|
||||
printTimeRange: queryParams.printTimeRange
|
||||
})
|
||||
download.excel(data, '患者信息.xls')
|
||||
} catch (error: any) {
|
||||
// 只有当错误不是用户取消操作时才显示错误提示
|
||||
if (error !== 'cancel') {
|
||||
console.error('导出失败:', error)
|
||||
message.error(`导出失败: ${error.message || '未知错误'}`)
|
||||
}
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user