!75 feat(excel): BgPartymatter/BgTakepulse 前端适配 Excel 导入导出
* feat(excel): BgPartymatter/BgTakepulse 前端适配 Excel 导入导出
This commit is contained in:
@@ -45,7 +45,9 @@
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="actionAuth.add" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||
<a-button type="primary" v-auth="actionAuth.exportXls" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||
<!-- <j-upload-button type="primary" v-auth="actionAuth.importExcel" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>-->
|
||||
<a-button type="primary" v-auth="actionAuth.exportXls" preIcon="ant-design:download-outlined" @click="handleDownloadTemplate">下载模板</a-button>
|
||||
<j-upload-button type="primary" v-auth="actionAuth.importExcel" preIcon="ant-design:check-outlined" @click="handleCheckExcel">模板校验</j-upload-button>
|
||||
<j-upload-button type="primary" v-auth="actionAuth.importExcel" preIcon="ant-design:import-outlined" @click="handleImportByTemplate">模板导入</j-upload-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
@@ -141,7 +143,10 @@
|
||||
import FlowScheduleStartModalForBG from '/src/components/semri/process/FlowScheduleStartModalForBG.vue';
|
||||
import SUploadFile from '/@/components/semri/fileComponent/SUploadFile.vue';
|
||||
import { columns, superQuerySchema, bgPartymatterFeedbackColumns } from './BgPartymatter.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, bgPartymatterFeedbackList, saveOrUpdate } from './BgPartymatter.api';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getImportExcelByEasyExcelUrl, getCheckExcelByEasyExcelUrl, getExportXlsHeadersUrl, bgPartymatterFeedbackList, saveOrUpdate } from './BgPartymatter.api';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { showImportValidationErrors } from '/@/utils/helper/importError';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -600,6 +605,7 @@
|
||||
});
|
||||
}
|
||||
/* ----------------------以下为原生查询需要添加的-------------------------- */
|
||||
const { createMessage } = useMessage();
|
||||
const toggleSearchStatus = ref<boolean>(false);
|
||||
const labelCol = reactive({
|
||||
xs:24,
|
||||
@@ -612,6 +618,60 @@
|
||||
sm: 20,
|
||||
});
|
||||
|
||||
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 handleCheckExcel(data) {
|
||||
const isReturn = (fileInfo) => {
|
||||
try {
|
||||
if (fileInfo.code === 500 || fileInfo.code === 510) {
|
||||
if (fileInfo.result && Array.isArray(fileInfo.result) && fileInfo.result.length > 0) {
|
||||
showImportValidationErrors(fileInfo.message || `${data.file.name} 校验失败`, fileInfo.result);
|
||||
} else {
|
||||
createMessage.error(fileInfo.message || `${data.file.name} 校验失败`);
|
||||
}
|
||||
} else {
|
||||
createMessage.success(fileInfo.message || `${data.file.name} 校验通过`);
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
};
|
||||
await defHttp.uploadFile({ url: getCheckExcelByEasyExcelUrl }, { file: data.file }, { success: isReturn });
|
||||
}
|
||||
|
||||
async function handleImportByTemplate(data) {
|
||||
const isReturn = (fileInfo) => {
|
||||
try {
|
||||
if (fileInfo.code === 500 || fileInfo.code === 510) {
|
||||
if (fileInfo.result && Array.isArray(fileInfo.result) && fileInfo.result.length > 0) {
|
||||
showImportValidationErrors(fileInfo.message || `${data.file.name} 导入失败`, fileInfo.result);
|
||||
} else {
|
||||
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 });
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user