导入导出

This commit is contained in:
yaojian
2026-03-06 11:49:01 +08:00
parent 9bbfc6e736
commit c70f302247
16 changed files with 1663 additions and 237 deletions

View File

@@ -82,12 +82,26 @@
班级卫生日常检查列表
</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="Upload"
type="success"
class="ml10"
@click="handleImport">
导入
</el-button>
<el-button
icon="Download"
type="warning"
class="ml10"
@click="handleExport">
导出
</el-button>
<right-toolbar
v-model:showSearch="showSearch"
class="ml10"
@@ -194,6 +208,14 @@
<!-- 编辑新增 -->
<FormDialog ref="formDialogRef" @refresh="getDataList(false)" />
<!-- 导入对话框 -->
<upload-excel
ref="uploadExcelRef"
:title="'导入日常行为'"
:url="'/stuwork/classhygienedaily/import'"
:temp-url="templateUrl"
@refreshDataList="getDataList" />
</div>
</template>
@@ -201,6 +223,7 @@
import { ref, reactive, defineAsyncComponent, computed, onMounted } from 'vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObjs } from "/@/api/stuwork/classhygienedaily";
import { downloadClassHygieneDailyTemplate, makeExportClassHygieneDailyTask } from "/@/api/stuwork/file";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { getDeptList } from '/@/api/basic/basicclass'
import { getClassListByRole } from '/@/api/basic/basicclass'
@@ -210,14 +233,18 @@ 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[]>([])
// 模板文件URL
const templateUrl = ref('/stuwork/classhygienedaily/importTemplate')
// 表格列配置
const tableColumns = [
@@ -292,6 +319,23 @@ const handleReset = () => {
getDataList()
}
// 导入
const handleImport = () => {
if (uploadExcelRef.value) {
uploadExcelRef.value.show()
}
}
// 导出
const handleExport = async () => {
try {
await makeExportClassHygieneDailyTask(searchForm)
useMessage().success('导出任务已创建,请在文件管理中下载')
} catch (err: any) {
useMessage().error(err.msg || '导出失败')
}
}
// 删除
const handleDelete = async (ids: string[]) => {
try {