导入导出
This commit is contained in:
@@ -64,7 +64,9 @@
|
||||
</span>
|
||||
<div class="header-actions">
|
||||
<el-button icon="Plus" type="primary" @click="formDialogRef.openDialog()"> 新增 </el-button>
|
||||
<el-button icon="Upload" type="success" class="ml10" @click="handleImport"> 导入 </el-button>
|
||||
<el-button icon="Upload" type="success" class="ml10" @click="handleImport"> 导入行为记录 </el-button>
|
||||
<el-button icon="Download" type="primary" plain class="ml10" @click="handleDownloadConductTemplate"> 导入考核模板 </el-button>
|
||||
<el-button icon="Upload" type="warning" class="ml10" @click="handleConductImport"> 导入考核 </el-button>
|
||||
<right-toolbar v-model:showSearch="showSearch" class="ml10" @queryTable="getDataList">
|
||||
<TableColumnControl
|
||||
ref="columnControlRef"
|
||||
@@ -167,7 +169,7 @@
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
|
||||
<!-- 导入对话框 -->
|
||||
<el-dialog title="导入数据" v-model="importDialogVisible" :width="500" :close-on-click-modal="false" draggable>
|
||||
<el-dialog title="导入行为记录" v-model="importDialogVisible" :width="500" :close-on-click-modal="false" draggable>
|
||||
<el-upload ref="uploadRef" :auto-upload="false" :on-change="handleFileChange" :limit="1" accept=".xlsx,.xls" drag>
|
||||
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
@@ -182,6 +184,26 @@
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导入操行考核弹窗 -->
|
||||
<el-dialog title="导入操行考核数据" v-model="conductImportDialogVisible" :width="500" :close-on-click-modal="false" draggable>
|
||||
<div style="margin-bottom: 15px">
|
||||
<el-button icon="Download" type="success" @click="handleDownloadConductTemplate"> 下载模板 </el-button>
|
||||
</div>
|
||||
<el-upload :auto-upload="false" :on-change="handleConductFileChange" :limit="1" accept=".xlsx,.xls" drag>
|
||||
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">只能上传 xlsx/xls 文件,请先下载导入模板</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="conductImportDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleConductImportSubmit" :disabled="!conductImportFile || conductImportLoading">确认导入</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -190,6 +212,7 @@ import { reactive, ref, onMounted, computed, nextTick } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { fetchList, delObj, importExcel } from '/@/api/stuwork/stuconduct';
|
||||
import { exportConductAssessmentTemplate, importConductAssessment, downloadBlobFile } from '/@/api/stuwork/file';
|
||||
import { getDeptList } from '/@/api/basic/basicclass';
|
||||
import { queryAllSchoolYear } from '/@/api/basic/basicyear';
|
||||
import { getClassListByRole } from '/@/api/basic/basicclass';
|
||||
@@ -230,6 +253,9 @@ const typeList = ref<any[]>([]);
|
||||
const importDialogVisible = ref(false);
|
||||
const importFile = ref<File | null>(null);
|
||||
const importLoading = ref(false);
|
||||
const conductImportDialogVisible = ref(false);
|
||||
const conductImportFile = ref<File | null>(null);
|
||||
const conductImportLoading = ref(false);
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
@@ -365,6 +391,49 @@ const handleImportSubmit = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 下载操行考核导入模板
|
||||
const handleDownloadConductTemplate = async () => {
|
||||
try {
|
||||
await downloadBlobFile(exportConductAssessmentTemplate(), `操行考核导入模板_${Date.now()}.xlsx`);
|
||||
} catch (err: any) {
|
||||
useMessage().error(err?.msg || '下载模板失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 打开操行考核导入弹窗
|
||||
const handleConductImport = () => {
|
||||
conductImportDialogVisible.value = true;
|
||||
conductImportFile.value = null;
|
||||
};
|
||||
|
||||
// 操行考核文件变化
|
||||
const handleConductFileChange = (file: any) => {
|
||||
conductImportFile.value = file.raw;
|
||||
};
|
||||
|
||||
// 提交操行考核导入
|
||||
const handleConductImportSubmit = async () => {
|
||||
if (!conductImportFile.value) {
|
||||
useMessage().warning('请先选择要上传的文件');
|
||||
return;
|
||||
}
|
||||
|
||||
conductImportLoading.value = true;
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', conductImportFile.value);
|
||||
await importConductAssessment(formData);
|
||||
useMessage().success('导入成功');
|
||||
conductImportDialogVisible.value = false;
|
||||
conductImportFile.value = null;
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导入失败');
|
||||
} finally {
|
||||
conductImportLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 编辑
|
||||
const handleEdit = (row: any) => {
|
||||
formDialogRef.value?.openDialog('edit', row);
|
||||
|
||||
Reference in New Issue
Block a user