导入导出
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
<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="Download" type="warning" class="ml10" @click="handleExport"> 导出 </el-button>
|
||||
<right-toolbar v-model:showSearch="showSearch" class="ml10" @queryTable="getDataList">
|
||||
<TableColumnControl
|
||||
ref="columnControlRef"
|
||||
@@ -108,47 +107,35 @@
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<el-dialog title="导入获奖活动信息" v-model="importDialogVisible" :width="500" :close-on-click-modal="false" draggable>
|
||||
<div style="margin-bottom: 15px">
|
||||
<el-button icon="Download" type="success" @click="handleDownloadTemplate"> 下载模板 </el-button>
|
||||
</div>
|
||||
<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>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">只能上传 xlsx/xls 文件</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="importDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleImportSubmit" :disabled="!importFile || importLoading">确 认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<upload-excel
|
||||
ref="uploadExcelRef"
|
||||
:title="'导入活动获奖'"
|
||||
:url="'/stuwork/file/importActivityAwards'"
|
||||
:temp-url="'/stuwork/file/exportActivityAwardsTemplate'"
|
||||
@refreshDataList="getDataList"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="ActivityAwards">
|
||||
import { reactive, ref } from 'vue';
|
||||
import { reactive, ref, defineAsyncComponent } from 'vue';
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { fetchList, delObj } from '/@/api/stuwork/activityawards';
|
||||
import { exportActivityAwardsTemplate, importActivityAwards, downloadBlobFile } from '/@/api/stuwork/file';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { parseTime } from '/@/utils/formatTime';
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue';
|
||||
import { UploadFilled, List, Trophy, CreditCard, Avatar, Medal, Calendar, EditPen, Setting, Menu, Document } from '@element-plus/icons-vue';
|
||||
import { List, Trophy, CreditCard, Avatar, Medal, Calendar, EditPen, Setting, Menu, Document } from '@element-plus/icons-vue';
|
||||
import { useTableColumnControl } from '/@/hooks/tableColumn';
|
||||
import FormDialog from './form.vue';
|
||||
|
||||
// 引入组件
|
||||
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref();
|
||||
const uploadRef = ref();
|
||||
const uploadExcelRef = ref();
|
||||
const columnControlRef = ref();
|
||||
const showSearch = ref(false);
|
||||
const importDialogVisible = ref(false);
|
||||
const importFile = ref<File | null>(null);
|
||||
const importLoading = ref(false);
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
@@ -205,51 +192,12 @@ const handleDelete = async (row: any) => {
|
||||
|
||||
// 导入
|
||||
const handleImport = () => {
|
||||
importDialogVisible.value = true;
|
||||
importFile.value = null;
|
||||
uploadRef.value?.clearFiles();
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
await downloadBlobFile(exportActivityAwardsTemplate(), '活动获奖导入模板.xlsx');
|
||||
};
|
||||
|
||||
// 下载模板
|
||||
const handleDownloadTemplate = async () => {
|
||||
await downloadBlobFile(exportActivityAwardsTemplate(), '活动获奖导入模板.xlsx');
|
||||
};
|
||||
|
||||
// 文件变化
|
||||
const handleFileChange = (file: any) => {
|
||||
importFile.value = file.raw;
|
||||
};
|
||||
|
||||
// 提交导入
|
||||
const handleImportSubmit = async () => {
|
||||
if (!importFile.value) {
|
||||
useMessage().warning('请选择要导入的文件');
|
||||
return;
|
||||
}
|
||||
|
||||
importLoading.value = true;
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', importFile.value);
|
||||
await importActivityAwards(formData);
|
||||
useMessage().success('导入成功');
|
||||
importDialogVisible.value = false;
|
||||
importFile.value = null;
|
||||
uploadRef.value?.clearFiles();
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导入失败');
|
||||
} finally {
|
||||
importLoading.value = false;
|
||||
if (uploadExcelRef.value) {
|
||||
uploadExcelRef.value.show();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '/@/assets/styles/modern-page.scss';
|
||||
</style>
|
||||
</style>
|
||||
@@ -48,7 +48,6 @@
|
||||
</span>
|
||||
<div class="header-actions">
|
||||
<el-button icon="Upload" type="primary" @click="handleImport"> 导入 </el-button>
|
||||
<el-button icon="Download" type="warning" class="ml10" @click="handleExport"> 导出 </el-button>
|
||||
<right-toolbar v-model:showSearch="showSearch" class="ml10" @queryTable="getDataList" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -162,43 +161,61 @@
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导入对话框 -->
|
||||
<upload-excel
|
||||
ref="uploadExcelRef"
|
||||
:title="'导入宿舍月卫生'"
|
||||
:url="'/stuwork/file/importDormHygieneMonthly'"
|
||||
:temp-url="templateUrl"
|
||||
@refreshDataList="getDataList"
|
||||
/>
|
||||
<el-dialog v-model="importDialogVisible" title="导入宿舍月卫生" width="500px" :close-on-click-modal="false">
|
||||
<el-form :model="importForm" ref="importFormRef" label-width="80px" style="margin-bottom: 15px">
|
||||
<el-form-item label="楼号" prop="buildingNo">
|
||||
<el-select v-model="importForm.buildingNo" placeholder="请选择楼号" filterable style="width: 100%">
|
||||
<el-option v-for="item in buildingList" :key="item.buildingNo" :label="item.buildingNo" :value="item.buildingNo" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="月份" prop="month">
|
||||
<el-date-picker v-model="importForm.month" type="month" placeholder="选择月份" format="YYYY-MM" value-format="YYYY-MM" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="Download" type="success" @click="handleDownloadTemplate"> 下载模板 </el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-upload ref="importUploadRef" :auto-upload="false" :on-change="handleImportFileChange" :limit="1" accept=".xlsx,.xls" drag>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip text-center">只能上传 xlsx/xls 文件,请先选择楼号和月份后下载模板</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<el-button @click="importDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleImportSubmit" :disabled="!importFile || importLoading">确认导入</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="DormHygieneMonthly">
|
||||
import { reactive, ref, onMounted, defineAsyncComponent } from 'vue';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { fetchList, addObj, editObj, delObj, triggerEvaluation } from '/@/api/stuwork/dormhygienemonthly';
|
||||
import { exportDormHygieneMonthlyTemplate, downloadBlobFile } from '/@/api/stuwork/file';
|
||||
import { exportDormHygieneMonthlyTemplate, importDormHygieneMonthly, downloadBlobFile } from '/@/api/stuwork/file';
|
||||
import { getBuildingList } from '/@/api/stuwork/dormbuilding';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { Search, Document, Plus, Edit, Delete, Promotion } from '@element-plus/icons-vue';
|
||||
|
||||
// 引入组件
|
||||
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
|
||||
|
||||
// 定义变量内容
|
||||
const searchFormRef = ref();
|
||||
const formRef = ref();
|
||||
const evalFormRef = ref();
|
||||
const uploadExcelRef = ref();
|
||||
const importFormRef = ref();
|
||||
const importUploadRef = ref();
|
||||
const showSearch = ref(true);
|
||||
const loading = ref(false);
|
||||
const submitLoading = ref(false);
|
||||
const evalLoading = ref(false);
|
||||
const importLoading = ref(false);
|
||||
const dataList = ref<any[]>([]);
|
||||
const buildingList = ref<any[]>([]);
|
||||
const dialogVisible = ref(false);
|
||||
const evalDialogVisible = ref(false);
|
||||
const dialogTitle = ref('新增宿舍月卫生');
|
||||
// 模板文件URL
|
||||
const templateUrl = ref('/stuwork/file/exportDormHygieneMonthlyTemplate');
|
||||
const evalDialogVisible = ref(false);
|
||||
const importDialogVisible = ref(false);
|
||||
const importFile = ref<File | null>(null);
|
||||
|
||||
// 分页
|
||||
const page = reactive({
|
||||
@@ -229,6 +246,12 @@ const evalForm = reactive({
|
||||
month: '',
|
||||
});
|
||||
|
||||
// 导入表单
|
||||
const importForm = reactive({
|
||||
buildingNo: '',
|
||||
month: '',
|
||||
});
|
||||
|
||||
// 表单校验规则
|
||||
const rules = {
|
||||
month: [{ required: true, message: '请选择月份', trigger: 'change' }],
|
||||
@@ -344,14 +367,55 @@ const handleEvaluation = () => {
|
||||
|
||||
// 导入
|
||||
const handleImport = () => {
|
||||
if (uploadExcelRef.value) {
|
||||
uploadExcelRef.value.show();
|
||||
importForm.buildingNo = '';
|
||||
importForm.month = '';
|
||||
importFile.value = null;
|
||||
importDialogVisible.value = true;
|
||||
};
|
||||
|
||||
// 下载模板
|
||||
const handleDownloadTemplate = async () => {
|
||||
if (!importForm.buildingNo) {
|
||||
useMessage().warning('请先选择楼号');
|
||||
return;
|
||||
}
|
||||
if (!importForm.month) {
|
||||
useMessage().warning('请先选择月份');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await downloadBlobFile(exportDormHygieneMonthlyTemplate(importForm), `宿舍月卫生导入模板_${importForm.month}.xlsx`);
|
||||
} catch (err: any) {
|
||||
useMessage().error(err?.msg || '下载模板失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
await downloadBlobFile(exportDormHygieneMonthlyTemplate(searchForm), '宿舍月卫生.xlsx');
|
||||
// 导入文件变化
|
||||
const handleImportFileChange = (file: any) => {
|
||||
importFile.value = file.raw;
|
||||
};
|
||||
|
||||
// 提交导入
|
||||
const handleImportSubmit = async () => {
|
||||
if (!importFile.value) {
|
||||
useMessage().warning('请先选择要上传的文件');
|
||||
return;
|
||||
}
|
||||
|
||||
importLoading.value = true;
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', importFile.value);
|
||||
await importDormHygieneMonthly(formData);
|
||||
useMessage().success('导入成功');
|
||||
importDialogVisible.value = false;
|
||||
importFile.value = null;
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导入失败');
|
||||
} finally {
|
||||
importLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 提交评比
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
<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="Download" type="warning" class="ml10" @click="handleExport"> 导出 </el-button>
|
||||
<right-toolbar v-model:showSearch="showSearch" class="ml10" @queryTable="getDataList">
|
||||
<TableColumnControl
|
||||
ref="columnControlRef"
|
||||
@@ -150,33 +149,21 @@
|
||||
<!-- 新增/编辑表单弹窗 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<el-dialog title="导入文明班级" v-model="importDialogVisible" :width="500" :close-on-click-modal="false" draggable>
|
||||
<div style="margin-bottom: 15px">
|
||||
<el-button icon="Download" type="success" @click="handleDownloadTemplate"> 下载模板 </el-button>
|
||||
</div>
|
||||
<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>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">只能上传 xlsx/xls 文件</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="importDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleImportSubmit" :disabled="!importFile || importLoading">确 认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 导入对话框 -->
|
||||
<upload-excel
|
||||
ref="uploadExcelRef"
|
||||
:title="'导入文明班级'"
|
||||
:url="'/stuwork/file/importRewardClass'"
|
||||
:temp-url="'/stuwork/file/exportRewardClassTemplate'"
|
||||
@refreshDataList="getDataList"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="RewardClass">
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { reactive, ref, onMounted, defineAsyncComponent } from 'vue';
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { fetchList, delObj } from '/@/api/stuwork/rewardclass';
|
||||
import { exportRewardClassTemplate, importRewardClass, downloadBlobFile } from '/@/api/stuwork/file';
|
||||
import { getDeptList } from '/@/api/basic/basicclass';
|
||||
import { getClassListByRole } from '/@/api/basic/basicclass';
|
||||
import { queryAllSchoolYear } from '/@/api/basic/basicyear';
|
||||
@@ -184,7 +171,6 @@ import { getDicts } from '/@/api/admin/dict';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue';
|
||||
import {
|
||||
UploadFilled,
|
||||
List,
|
||||
Calendar,
|
||||
Clock,
|
||||
@@ -201,9 +187,12 @@ import {
|
||||
import { useTableColumnControl } from '/@/hooks/tableColumn';
|
||||
import FormDialog from './form.vue';
|
||||
|
||||
// 引入组件
|
||||
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref();
|
||||
const uploadRef = ref();
|
||||
const uploadExcelRef = ref();
|
||||
const searchFormRef = ref();
|
||||
const columnControlRef = ref();
|
||||
const showSearch = ref(true);
|
||||
@@ -211,9 +200,6 @@ const schoolYearList = ref<any[]>([]);
|
||||
const schoolTermList = ref<any[]>([]);
|
||||
const deptList = ref<any[]>([]);
|
||||
const classList = ref<any[]>([]);
|
||||
const importDialogVisible = ref(false);
|
||||
const importFile = ref<File | null>(null);
|
||||
const importLoading = ref(false);
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
@@ -280,47 +266,8 @@ const handleReset = () => {
|
||||
|
||||
// 导入
|
||||
const handleImport = () => {
|
||||
importDialogVisible.value = true;
|
||||
importFile.value = null;
|
||||
uploadRef.value?.clearFiles();
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
await downloadBlobFile(exportRewardClassTemplate(), '文明班级导入模板.xlsx');
|
||||
};
|
||||
|
||||
// 下载模板
|
||||
const handleDownloadTemplate = async () => {
|
||||
await downloadBlobFile(exportRewardClassTemplate(), '文明班级导入模板.xlsx');
|
||||
};
|
||||
|
||||
// 文件变化
|
||||
const handleFileChange = (file: any) => {
|
||||
importFile.value = file.raw;
|
||||
};
|
||||
|
||||
// 提交导入
|
||||
const handleImportSubmit = async () => {
|
||||
if (!importFile.value) {
|
||||
useMessage().warning('请选择要导入的文件');
|
||||
return;
|
||||
}
|
||||
|
||||
importLoading.value = true;
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', importFile.value);
|
||||
await importRewardClass(formData);
|
||||
useMessage().success('导入成功');
|
||||
importDialogVisible.value = false;
|
||||
importFile.value = null;
|
||||
uploadRef.value?.clearFiles();
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导入失败');
|
||||
} finally {
|
||||
importLoading.value = false;
|
||||
if (uploadExcelRef.value) {
|
||||
uploadExcelRef.value.show();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -414,4 +361,4 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '/@/assets/styles/modern-page.scss';
|
||||
</style>
|
||||
</style>
|
||||
@@ -46,7 +46,6 @@
|
||||
<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="Download" type="warning" class="ml10" @click="handleExport"> 导出 </el-button>
|
||||
<right-toolbar v-model:showSearch="showSearch" class="ml10" @queryTable="getDataList">
|
||||
<TableColumnControl
|
||||
ref="columnControlRef"
|
||||
@@ -137,53 +136,41 @@
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
|
||||
<!-- 导入对话框 -->
|
||||
<el-dialog title="导入数据" v-model="importDialogVisible" :width="500" :close-on-click-modal="false" draggable>
|
||||
<div style="margin-bottom: 15px">
|
||||
<el-button icon="Download" type="success" @click="handleDownloadTemplate"> 下载模板 </el-button>
|
||||
</div>
|
||||
<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>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">只能上传 xlsx/xls 文件</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="importDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleImportSubmit" :disabled="!importFile || importLoading">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<upload-excel
|
||||
ref="uploadExcelRef"
|
||||
:title="'导入文明宿舍'"
|
||||
:url="'/stuwork/file/importRewardDorm'"
|
||||
:temp-url="'/stuwork/file/exportRewardDormTemplate'"
|
||||
@refreshDataList="getDataList"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="RewardDorm">
|
||||
import { reactive, ref, onMounted, computed } from 'vue';
|
||||
import { reactive, ref, onMounted, computed, defineAsyncComponent } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { fetchList, delObj } from '/@/api/stuwork/rewarddorm';
|
||||
import { exportRewardDormTemplate, importRewardDorm, downloadBlobFile } from '/@/api/stuwork/file';
|
||||
import { queryAllSchoolYear } from '/@/api/basic/basicyear';
|
||||
import { getDicts } from '/@/api/admin/dict';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue';
|
||||
import { UploadFilled, List, Calendar, Clock, House, Trophy, EditPen, Setting, Menu, Search, Document } from '@element-plus/icons-vue';
|
||||
import { List, Calendar, Clock, House, Trophy, EditPen, Setting, Menu, Search, Document } from '@element-plus/icons-vue';
|
||||
import { useTableColumnControl } from '/@/hooks/tableColumn';
|
||||
import FormDialog from './form.vue';
|
||||
|
||||
// 引入组件
|
||||
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
|
||||
|
||||
// 定义变量
|
||||
const route = useRoute();
|
||||
const formDialogRef = ref();
|
||||
const uploadRef = ref();
|
||||
const uploadExcelRef = ref();
|
||||
const searchFormRef = ref();
|
||||
const columnControlRef = ref();
|
||||
const showSearch = ref(true);
|
||||
const schoolYearList = ref<any[]>([]);
|
||||
const schoolTermList = ref<any[]>([]);
|
||||
const importDialogVisible = ref(false);
|
||||
const importFile = ref<File | null>(null);
|
||||
const importLoading = ref(false);
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
@@ -243,47 +230,8 @@ const handleReset = () => {
|
||||
|
||||
// 导入
|
||||
const handleImport = () => {
|
||||
importDialogVisible.value = true;
|
||||
importFile.value = null;
|
||||
uploadRef.value?.clearFiles();
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
await downloadBlobFile(exportRewardDormTemplate(), '文明宿舍导入模板.xlsx');
|
||||
};
|
||||
|
||||
// 下载模板
|
||||
const handleDownloadTemplate = async () => {
|
||||
await downloadBlobFile(exportRewardDormTemplate(), '文明宿舍导入模板.xlsx');
|
||||
};
|
||||
|
||||
// 文件变化
|
||||
const handleFileChange = (file: any) => {
|
||||
importFile.value = file.raw;
|
||||
};
|
||||
|
||||
// 提交导入
|
||||
const handleImportSubmit = async () => {
|
||||
if (!importFile.value) {
|
||||
useMessage().warning('请先选择要上传的文件');
|
||||
return;
|
||||
}
|
||||
|
||||
importLoading.value = true;
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', importFile.value);
|
||||
await importRewardDorm(formData);
|
||||
useMessage().success('导入成功');
|
||||
importDialogVisible.value = false;
|
||||
importFile.value = null;
|
||||
uploadRef.value?.clearFiles();
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导入失败');
|
||||
} finally {
|
||||
importLoading.value = false;
|
||||
if (uploadExcelRef.value) {
|
||||
uploadExcelRef.value.show();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -347,4 +295,4 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '/@/assets/styles/modern-page.scss';
|
||||
</style>
|
||||
</style>
|
||||
@@ -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);
|
||||
|
||||
@@ -52,8 +52,6 @@
|
||||
<el-button type="primary" plain icon="Search" @click="getDataList">查询</el-button>
|
||||
<el-button icon="Refresh" @click="handleReset">重置</el-button>
|
||||
<el-button type="warning" icon="Bell" @click="handleSendWarning" :loading="warningLoading">发送预警</el-button>
|
||||
<el-button type="success" icon="Download" @click="handleDownloadTemplate">导入模板</el-button>
|
||||
<el-button type="primary" icon="Upload" @click="handleImport">导入考核</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
@@ -153,50 +151,16 @@
|
||||
<el-empty description="暂无考核记录" :image-size="80" />
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导入操行考核弹窗 -->
|
||||
<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>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">
|
||||
只能上传 xlsx/xls 文件,请先下载导入模板
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="importDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleImportSubmit" :disabled="!importFile || importLoading">确认导入</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="StuConductTerm">
|
||||
import { reactive, ref, onMounted, computed } from 'vue'
|
||||
import { getStuConductTerm, queryDataByStuNo, sendConductWarning } from "/@/api/stuwork/stuconduct";
|
||||
import { exportConductAssessmentTemplate, importConductAssessment, downloadBlobFile } from "/@/api/stuwork/file";
|
||||
import { getClassListByRole } from "/@/api/basic/basicclass";
|
||||
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
|
||||
import { getDicts } from "/@/api/admin/dict";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { UploadFilled } from '@element-plus/icons-vue'
|
||||
|
||||
// 表格样式 - 在组件内部定义,不从外部导入
|
||||
const tableStyle = {
|
||||
@@ -206,7 +170,6 @@ const tableStyle = {
|
||||
|
||||
// 定义变量内容
|
||||
const searchFormRef = ref()
|
||||
const uploadRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const loading = ref(false)
|
||||
const warningLoading = ref(false)
|
||||
@@ -218,9 +181,6 @@ const viewDialogVisible = ref(false)
|
||||
const viewLoading = ref(false)
|
||||
const viewRow = ref<any>(null)
|
||||
const viewDetailList = ref<any[]>([])
|
||||
const importDialogVisible = ref(false)
|
||||
const importFile = ref<File | null>(null)
|
||||
const importLoading = ref(false)
|
||||
|
||||
// 查询表单
|
||||
const queryForm = reactive({
|
||||
@@ -430,51 +390,6 @@ const handleSendWarning = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 下载导入模板
|
||||
const handleDownloadTemplate = async () => {
|
||||
try {
|
||||
await downloadBlobFile(exportConductAssessmentTemplate(), `操行考核导入模板_${Date.now()}.xlsx`)
|
||||
} catch (err: any) {
|
||||
useMessage().error(err?.msg || '下载模板失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 打开导入弹窗
|
||||
const handleImport = () => {
|
||||
importDialogVisible.value = true
|
||||
importFile.value = null
|
||||
uploadRef.value?.clearFiles()
|
||||
}
|
||||
|
||||
// 文件选择变化
|
||||
const handleFileChange = (file: any) => {
|
||||
importFile.value = file.raw
|
||||
}
|
||||
|
||||
// 提交导入
|
||||
const handleImportSubmit = async () => {
|
||||
if (!importFile.value) {
|
||||
useMessage().warning('请先选择要上传的文件')
|
||||
return
|
||||
}
|
||||
|
||||
importLoading.value = true
|
||||
try {
|
||||
const formData = new FormData()
|
||||
formData.append('file', importFile.value)
|
||||
await importConductAssessment(formData)
|
||||
useMessage().success('导入成功')
|
||||
importDialogVisible.value = false
|
||||
importFile.value = null
|
||||
uploadRef.value?.clearFiles()
|
||||
getDataList()
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导入失败')
|
||||
} finally {
|
||||
importLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 获取学年列表
|
||||
const getSchoolYearList = async () => {
|
||||
try {
|
||||
@@ -562,4 +477,4 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user