!56 feat(xispeak): 新增通过模板导入按钮
* feat(xispeak): 新增通过模板导入按钮 * feat(xispeak): 新增下载导入模板按钮
This commit is contained in:
@@ -43,6 +43,12 @@
|
||||
<j-upload-button type="primary" v-auth="'bg.xispeak:bg_xi_speak:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls"
|
||||
>导入</j-upload-button
|
||||
>
|
||||
<a-button type="primary" v-auth="'bg.xispeak:bg_xi_speak:exportXls'" preIcon="ant-design:download-outlined" @click="handleDownloadTemplate"
|
||||
>下载模板</a-button
|
||||
>
|
||||
<j-upload-button type="primary" v-auth="'bg.xispeak:bg_xi_speak:importExcel'" preIcon="ant-design:import-outlined" @click="handleImportByTemplate"
|
||||
>模板导入</j-upload-button
|
||||
>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
@@ -86,6 +92,7 @@
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { startProcessSchedules } from '/@/api/common/api';
|
||||
import { dateUtil } from '/@/utils/dateUtil';
|
||||
@@ -107,6 +114,8 @@
|
||||
batchDeleteBgXiSpeak,
|
||||
getExportUrl,
|
||||
getImportUrl,
|
||||
getExportXlsHeadersUrl,
|
||||
getImportExcelByEasyExcelUrl,
|
||||
getChildList,
|
||||
getChildListBatch,
|
||||
updateLaunchType,
|
||||
@@ -725,6 +734,40 @@
|
||||
feedbackViewModalRef.value.open(record);
|
||||
}
|
||||
|
||||
async function handleDownloadTemplate() {
|
||||
const data = await defHttp.get(
|
||||
{ url: getExportXlsHeadersUrl, params: {}, responseType: 'blob', timeout: 60000 },
|
||||
{ isTransformResponse: false },
|
||||
);
|
||||
if (!data) {
|
||||
createMessage.warning('文件下载失败');
|
||||
return;
|
||||
}
|
||||
const blob = new Blob([data]);
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = '习总书记重要讲话指示批示情况-导入模板.xls';
|
||||
link.click();
|
||||
URL.revokeObjectURL(link.href);
|
||||
}
|
||||
|
||||
async function handleImportByTemplate(data) {
|
||||
const isReturn = (fileInfo) => {
|
||||
try {
|
||||
if (fileInfo.code === 500 || fileInfo.code === 510) {
|
||||
createMessage.error(fileInfo.message || `${data.file.name} 导入失败`);
|
||||
} else {
|
||||
createMessage.success(fileInfo.message || `${data.file.name} 导入成功`);
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
} finally {
|
||||
reload();
|
||||
}
|
||||
};
|
||||
await defHttp.uploadFile({ url: getImportExcelByEasyExcelUrl }, { file: data.file }, { success: isReturn });
|
||||
}
|
||||
|
||||
function clearQueryParams() {
|
||||
Object.keys(queryParam.value).forEach((key) => {
|
||||
delete queryParam.value[key];
|
||||
|
||||
Reference in New Issue
Block a user