| | |
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.OutputStream;
|
| | | import java.lang.reflect.Field;
|
| | | import java.lang.reflect.Method;
|
| | | import java.math.BigDecimal;
|
| | |
| | | * @return 结果
|
| | | * @throws IOException
|
| | | */
|
| | | public void exportExcel(HttpServletResponse response, List<T> list, String sheetName)throws IOException
|
| | | public void exportExcel(HttpServletResponse response, List<T> list, String sheetName)
|
| | | {
|
| | | exportExcel(response, list, sheetName, StringUtils.EMPTY);
|
| | | }
|
| | |
| | | * @return 结果
|
| | | * @throws IOException
|
| | | */
|
| | | public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title) throws IOException
|
| | | public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title)
|
| | | {
|
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| | | response.setCharacterEncoding("utf-8");
|
| | | this.init(list, sheetName, title, Type.EXPORT);
|
| | | exportExcel(response.getOutputStream());
|
| | | exportExcel(response);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param sheetName 工作表的名称
|
| | | * @return 结果
|
| | | */
|
| | | public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException
|
| | | public void importTemplateExcel(HttpServletResponse response, String sheetName)
|
| | | {
|
| | | importTemplateExcel(response, sheetName, StringUtils.EMPTY);
|
| | | }
|
| | |
| | | * @param title 标题
|
| | | * @return 结果
|
| | | */
|
| | | public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) throws IOException
|
| | | public void importTemplateExcel(HttpServletResponse response, String sheetName, String title)
|
| | | {
|
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| | | response.setCharacterEncoding("utf-8");
|
| | | this.init(null, sheetName, title, Type.IMPORT);
|
| | | exportExcel(response.getOutputStream());
|
| | | exportExcel(response);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | *
|
| | | * @return 结果
|
| | | */
|
| | | public void exportExcel(OutputStream out)
|
| | | public void exportExcel(HttpServletResponse response)
|
| | | {
|
| | | try
|
| | | {
|
| | | writeSheet();
|
| | | wb.write(out);
|
| | | wb.write(response.getOutputStream());
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | |
| | | finally
|
| | | {
|
| | | IOUtils.closeQuietly(wb);
|
| | | IOUtils.closeQuietly(out);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | @RequiresPermissions("${permissionPrefix}:export")
|
| | | @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, ${ClassName} ${className}) throws IOException
|
| | | public void export(HttpServletResponse response, ${ClassName} ${className})
|
| | | {
|
| | | List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
| | | ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
|
| | |
| | | handleExport() {
|
| | | this.download('${moduleName}/${businessName}/export', {
|
| | | ...this.queryParams
|
| | | }, `${moduleName}_${businessName}.xlsx`)
|
| | | }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
| | | }
|
| | | }
|
| | | };
|
| | |
| | | package com.ruoyi.job.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.quartz.SchedulerException;
|
| | |
| | | @RequiresPermissions("monitor:job:export")
|
| | | @Log(title = "定时任务", businessType = BusinessType.EXPORT)
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysJob sysJob) throws IOException
|
| | | public void export(HttpServletResponse response, SysJob sysJob)
|
| | | {
|
| | | List<SysJob> list = jobService.selectJobList(sysJob);
|
| | | ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
|
| | |
| | | package com.ruoyi.job.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | @RequiresPermissions("monitor:job:export")
|
| | | @Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysJobLog sysJobLog) throws IOException
|
| | | public void export(HttpServletResponse response, SysJobLog sysJobLog)
|
| | | {
|
| | | List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
| | | ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
|
| | |
| | | package com.ruoyi.system.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | @Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
| | | @RequiresPermissions("system:config:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysConfig config) throws IOException
|
| | | public void export(HttpServletResponse response, SysConfig config)
|
| | | {
|
| | | List<SysConfig> list = configService.selectConfigList(config);
|
| | | ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
| | |
| | | package com.ruoyi.system.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
| | | @Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
| | | @RequiresPermissions("system:dict:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysDictData dictData) throws IOException
|
| | | public void export(HttpServletResponse response, SysDictData dictData)
|
| | | {
|
| | | List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
| | | ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
| | |
| | | package com.ruoyi.system.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | @Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
| | | @RequiresPermissions("system:dict:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysDictType dictType) throws IOException
|
| | | public void export(HttpServletResponse response, SysDictType dictType)
|
| | | {
|
| | | List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
| | | ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
| | |
| | | package com.ruoyi.system.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | @Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
| | | @RequiresPermissions("system:logininfor:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysLogininfor logininfor) throws IOException
|
| | | public void export(HttpServletResponse response, SysLogininfor logininfor)
|
| | | {
|
| | | List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
| | | ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
| | |
| | | package com.ruoyi.system.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | @Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
| | | @RequiresPermissions("system:operlog:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysOperLog operLog) throws IOException
|
| | | public void export(HttpServletResponse response, SysOperLog operLog)
|
| | | {
|
| | | List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
| | | ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
| | |
| | | package com.ruoyi.system.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
| | | @RequiresPermissions("system:post:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysPost post) throws IOException
|
| | | public void export(HttpServletResponse response, SysPost post)
|
| | | {
|
| | | List<SysPost> list = postService.selectPostList(post);
|
| | | ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
| | |
| | | package com.ruoyi.system.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | @Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
| | | @RequiresPermissions("system:role:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysRole role) throws IOException
|
| | | public void export(HttpServletResponse response, SysRole role)
|
| | | {
|
| | | List<SysRole> list = roleService.selectRoleList(role);
|
| | | ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
| | |
| | | @Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
| | | @RequiresPermissions("system:user:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysUser user) throws IOException
|
| | | public void export(HttpServletResponse response, SysUser user)
|
| | | {
|
| | | List<SysUser> list = userService.selectUserList(user);
|
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
| | |
| | |
|
| | | let downloadLoadingInstance;
|
| | |
|
| | | axios.defaults.headers['Conntent-Type'] = 'application/json;charset=utf-8'
|
| | | axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
|
| | | // 创建axios实例
|
| | | const service = axios.create({
|
| | | // axios中请求配置有baseURL选项,表示请求URL公共部分
|
| | |
| | | return res.data
|
| | | }
|
| | | if (code === 401) {
|
| | | let doms = document.getElementsByClassName('el-message-box')[0]
|
| | | if(doms === undefined){
|
| | | MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
| | | confirmButtonText: '重新登录',
|
| | | cancelButtonText: '取消',
|
| | |
| | | location.href = '/index';
|
| | | })
|
| | | }).catch(() => {});
|
| | | }
|
| | | return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
|
| | | } else if (code === 500) {
|
| | | Message({
|
| | |
| | | * Copyright (c) 2019 ruoyi
|
| | | */
|
| | |
|
| | | const baseURL = process.env.VUE_APP_BASE_API
|
| | |
|
| | | // 日期格式化
|
| | | export function parseTime(time, pattern) {
|
| | | if (arguments.length === 0 || !time) {
|
| | |
| | | })
|
| | | })
|
| | | return actions.join('').substring(0, actions.join('').length - 1);
|
| | | }
|
| | |
|
| | | // 通用下载方法
|
| | | export function download(fileName) {
|
| | | window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
|
| | | }
|
| | |
|
| | | // 字符串格式化(%s )
|
| | |
| | | importTemplate() {
|
| | | this.download('system/user/importTemplate', {
|
| | | ...this.queryParams
|
| | | }, `user_${new Date().getTime()}.xlsx`)
|
| | | }, `user_template_${new Date().getTime()}.xlsx`)
|
| | | },
|
| | | // 文件上传中处理
|
| | | handleFileUploadProgress(event, file, fileList) {
|