导入导出
This commit is contained in:
@@ -93,23 +93,30 @@
|
||||
日常巡检列表
|
||||
</span>
|
||||
<div class="header-actions">
|
||||
<el-button
|
||||
icon="FolderAdd"
|
||||
type="primary"
|
||||
<el-button
|
||||
icon="FolderAdd"
|
||||
type="primary"
|
||||
@click="formDialogRef.openDialog()">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Download"
|
||||
type="success"
|
||||
class="ml10"
|
||||
<el-button
|
||||
icon="Upload"
|
||||
type="success"
|
||||
class="ml10"
|
||||
@click="handleImport">
|
||||
导入
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Download"
|
||||
type="warning"
|
||||
class="ml10"
|
||||
@click="handleExport">
|
||||
导出
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="DataAnalysis"
|
||||
type="info"
|
||||
class="ml10"
|
||||
<el-button
|
||||
icon="DataAnalysis"
|
||||
type="info"
|
||||
class="ml10"
|
||||
@click="handleRank">
|
||||
学期统计
|
||||
</el-button>
|
||||
@@ -212,7 +219,15 @@
|
||||
|
||||
<!-- 编辑、新增 -->
|
||||
<FormDialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||
|
||||
|
||||
<!-- 导入对话框 -->
|
||||
<upload-excel
|
||||
ref="uploadExcelRef"
|
||||
:title="'导入日常巡检'"
|
||||
:url="'/stuwork/classcheckdaily/import'"
|
||||
:temp-url="templateUrl"
|
||||
@refreshDataList="getDataList" />
|
||||
|
||||
<!-- 学期统计对话框 -->
|
||||
<el-dialog
|
||||
title="学期统计"
|
||||
@@ -271,6 +286,7 @@
|
||||
import { ref, reactive, defineAsyncComponent, computed, onMounted } from 'vue'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObjs, exportData, getRank } from "/@/api/stuwork/classcheckdaily";
|
||||
import { makeExportClassCheckDailyTask } from "/@/api/stuwork/file";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { getDeptList } from '/@/api/basic/basicclass'
|
||||
import { getClassListByRole } from '/@/api/basic/basicclass'
|
||||
@@ -281,15 +297,19 @@ import { useTableColumnControl } from '/@/hooks/tableColumn'
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
const searchFormRef = ref()
|
||||
const columnControlRef = ref()
|
||||
const uploadExcelRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const deptList = ref<any[]>([])
|
||||
const classList = ref<any[]>([])
|
||||
const schoolYearList = ref<any[]>([])
|
||||
// 模板文件URL
|
||||
const templateUrl = ref('/stuwork/classcheckdaily/importTemplate')
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
@@ -402,22 +422,20 @@ const handleDelete = async (ids: string[]) => {
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
const res = await exportData(searchForm)
|
||||
const blob = new Blob([res.data])
|
||||
const elink = document.createElement('a')
|
||||
elink.download = '日常巡检.xlsx'
|
||||
elink.style.display = 'none'
|
||||
elink.href = URL.createObjectURL(blob)
|
||||
document.body.appendChild(elink)
|
||||
elink.click()
|
||||
URL.revokeObjectURL(elink.href)
|
||||
document.body.removeChild(elink)
|
||||
useMessage().success('导出成功')
|
||||
await makeExportClassCheckDailyTask(searchForm)
|
||||
useMessage().success('导出任务已创建,请在文件管理中下载')
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导出失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 导入
|
||||
const handleImport = () => {
|
||||
if (uploadExcelRef.value) {
|
||||
uploadExcelRef.value.show()
|
||||
}
|
||||
}
|
||||
|
||||
// 打开学期统计对话框
|
||||
const handleRank = () => {
|
||||
rankDialogVisible.value = true
|
||||
|
||||
Reference in New Issue
Block a user