2023年11月10日 新增导出
This commit is contained in:
parent
36d43251d2
commit
61eb9891e6
|
@ -33,6 +33,9 @@
|
|||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:up-outlined" @click="handleBaobiao" style="margin-left: 8px">报表</a-button>
|
||||
|
||||
<a-button hidden type="primary" preIcon="ant-design:up-outlined" @click="onExportWord" style="margin-left: 8px">导出word</a-button>
|
||||
<a-button hidden type="primary" preIcon="ant-design:up-outlined" @click="onExportPdf" style="margin-left: 8px">导出pdf</a-button>
|
||||
<!--<a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
|
||||
{{ toggleSearchStatus ? '收起' : '展开' }}
|
||||
<Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
|
||||
|
@ -95,6 +98,8 @@
|
|||
import { columns } from './KcZhihuijiaoshiMonitorLog.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './KcZhihuijiaoshiMonitorLog.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import KcZhihuijiaoshiMonitorLogModal from './components/KcZhihuijiaoshiMonitorLogModal.vue'
|
||||
import KcZhihuijiaoshiMonitorStaticLogModal from './staticlist/KcZhihuijiaoshiMonitorStaticLogModal.vue'
|
||||
|
||||
|
@ -102,6 +107,7 @@
|
|||
const toggleSearchStatus = ref<boolean>(false);
|
||||
const registerModal = ref();
|
||||
const registerStaticModal = ref();
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
|
@ -237,8 +243,51 @@
|
|||
reload();
|
||||
}
|
||||
|
||||
async function onExportPdf(){
|
||||
await onExport('pdf');
|
||||
}
|
||||
async function onExportWord(){
|
||||
await onExport('doc');
|
||||
}
|
||||
async function onExport(dcType){
|
||||
//let dcType = 'pdf';
|
||||
// let dcType = 'doc';
|
||||
|
||||
let fileName = dcType == 'pdf'?'教学听课情况表.pdf':'教学听课情况表.docx';
|
||||
// let fileName = '教学听课情况表.docx';
|
||||
let paramsForm = queryParam.value;
|
||||
|
||||
paramsForm = { ...paramsForm }
|
||||
|
||||
let url = dcType == 'pdf'?'/jiaoshi/kcZhihuijiaoshiMonitorLog/exportPdf':'/jiaoshi/kcZhihuijiaoshiMonitorLog/exportWord'
|
||||
|
||||
const data = await defHttp.get({ url, params: paramsForm, responseType: 'blob' }, { isTransformResponse: false });
|
||||
// const data = await defHttp.get({ url: '/config/kcExportConfigTpkwcqkjzglx/exportWord', params: paramsForm, responseType: 'blob' }, { isTransformResponse: false });
|
||||
if (!data) {
|
||||
createMessage.warning('文件下载失败');
|
||||
return;
|
||||
}
|
||||
|
||||
let blobOptions = dcType == 'pdf'?{ type: 'application/pdf' }:{ type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' };
|
||||
// let blobOptions = { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' };
|
||||
|
||||
let navigator:any = window.navigator;
|
||||
let msSaveBlob = navigator.msSaveBlob;
|
||||
|
||||
if (typeof msSaveBlob !== 'undefined') {
|
||||
msSaveBlob(new Blob([data], blobOptions), fileName);
|
||||
} else {
|
||||
let url = window.URL.createObjectURL(new Blob([data], blobOptions));
|
||||
let link = document.createElement('a');
|
||||
link.style.display = 'none';
|
||||
link.href = url;
|
||||
link.setAttribute('download', fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link); //下载完成移除元素
|
||||
window.URL.revokeObjectURL(url); //释放掉blob对象
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue