提交代码
This commit is contained in:
1 parent
714f0f97e8
commit
e60161f7b9
5 files changed
+407
-1
No files matched your search
@@ -120,6 +120,20 @@
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['dormViolation:dormViolation:export']">导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-dropdown class="mt-[1px]">
|
||||
<el-button>
|
||||
更多
|
||||
<el-icon class="el-icon--right"><ArrowDown /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item icon="Download" @click="importTemplate">下载模板</el-dropdown-item>
|
||||
<el-dropdown-item icon="Top" @click="handleImport">导入数据</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
@@ -551,6 +565,41 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 宿舍违纪导入对话框 -->
|
||||
<el-dialog v-model="upload.open" :title="upload.title" width="400px" append-to-body>
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
:limit="1"
|
||||
accept=".xlsx, .xls"
|
||||
:headers="upload.headers"
|
||||
:action="getImportUrl()"
|
||||
:disabled="upload.isUploading"
|
||||
:on-progress="handleFileUploadProgress"
|
||||
:on-success="handleFileSuccess"
|
||||
:on-error="handleFileError"
|
||||
:auto-upload="false"
|
||||
drag
|
||||
>
|
||||
<el-icon class="el-icon--upload">
|
||||
<UploadFilled />
|
||||
</el-icon>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<template #tip>
|
||||
<div class="text-center el-upload__tip">
|
||||
<div class="el-upload__tip" style="color: red">提示:不更新已经存在的违纪记录数据</div>
|
||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||
<el-button @click="upload.open = false">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -559,10 +608,11 @@ import { ref, reactive, toRefs, onMounted, getCurrentInstance, ComponentInternal
|
||||
import ElMessage from 'element-plus/es/components/message/index';
|
||||
import ElMessageBox from 'element-plus/es/components/message-box/index';
|
||||
import ElLoading from 'element-plus/es/components/loading/index';
|
||||
import { UploadFilled, Document, Loading, Download, Delete, InfoFilled } from '@element-plus/icons-vue';
|
||||
import { UploadFilled, Document, Loading, Download, Delete, InfoFilled, ArrowDown } from '@element-plus/icons-vue';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import ImagePreview from '@/components/ImagePreview/index.vue';
|
||||
import request from '@/utils/request';
|
||||
import { globalHeaders } from '@/utils/request';
|
||||
import {
|
||||
listDormViolation,
|
||||
getDormViolation,
|
||||
@@ -709,12 +759,29 @@ const attachmentList = ref<any[]>([]);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const dormViolationFormRef = ref<ElFormInstance>();
|
||||
const uploadRef = ref<any>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
// 导入参数
|
||||
const upload = reactive({
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 弹出层标题
|
||||
title: '',
|
||||
// 是否禁用上传
|
||||
isUploading: false,
|
||||
// 是否更新已经存在的数据
|
||||
updateSupport: false,
|
||||
// 设置上传的请求头部
|
||||
headers: globalHeaders(),
|
||||
// 上传的地址
|
||||
url: import.meta.env.VITE_APP_BASE_API + '/dormViolation/dormViolation/importData'
|
||||
});
|
||||
|
||||
const initFormData: DormViolationForm = {
|
||||
id: undefined,
|
||||
studentId: undefined,
|
||||
@@ -999,6 +1066,73 @@ const handleExport = () => {
|
||||
);
|
||||
};
|
||||
|
||||
/** 导入按钮操作 */
|
||||
const handleImport = () => {
|
||||
upload.title = '宿舍违纪导入';
|
||||
upload.open = true;
|
||||
};
|
||||
|
||||
/** 下载模板操作 */
|
||||
const importTemplate = () => {
|
||||
proxy?.download('dormViolation/dormViolation/importTemplate', {}, `宿舍违纪导入模板_${new Date().getTime()}.xlsx`);
|
||||
};
|
||||
|
||||
/** 文件上传中处理 */
|
||||
const handleFileUploadProgress = () => {
|
||||
upload.isUploading = true;
|
||||
};
|
||||
|
||||
/** 文件上传成功处理 */
|
||||
const handleFileSuccess = (response: any) => {
|
||||
upload.open = false;
|
||||
upload.isUploading = false;
|
||||
uploadRef.value?.clearFiles();
|
||||
|
||||
// 关闭所有loading消息
|
||||
ElMessage.closeAll();
|
||||
|
||||
ElMessageBox.alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + '</div>', '导入结果', {
|
||||
dangerouslyUseHTMLString: true
|
||||
});
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 文件上传失败处理 */
|
||||
const handleFileError = (error: any) => {
|
||||
upload.isUploading = false;
|
||||
uploadRef.value?.clearFiles();
|
||||
|
||||
// 关闭所有loading消息
|
||||
ElMessage.closeAll();
|
||||
|
||||
console.error('文件上传失败:', error);
|
||||
ElMessage.error('导入失败,请检查文件格式或网络连接');
|
||||
};
|
||||
|
||||
/** 获取导入URL */
|
||||
const getImportUrl = () => {
|
||||
const baseUrl = upload.url;
|
||||
const params = new URLSearchParams();
|
||||
params.append('updateSupport', 'false');
|
||||
return `${baseUrl}?${params.toString()}`;
|
||||
};
|
||||
|
||||
/** 提交上传文件 */
|
||||
const submitFileForm = () => {
|
||||
// 显示导入loading效果
|
||||
ElMessage({
|
||||
message: '正在导入数据,请耐心等待...',
|
||||
type: 'info',
|
||||
duration: 0
|
||||
});
|
||||
|
||||
// 设置上传中状态
|
||||
upload.isUploading = true;
|
||||
|
||||
// 提交文件上传
|
||||
uploadRef.value?.submit();
|
||||
};
|
||||
|
||||
/** 远程搜索学生 */
|
||||
const remoteSearchStudents = async (query: string) => {
|
||||
studentLoading.value = true;
|
||||
|
||||
Reference in new issue
Block a user