diff --git a/pom.xml b/pom.xml index bc3e45cfe..c1d9a291c 100644 --- a/pom.xml +++ b/pom.xml @@ -21,10 +21,10 @@ 1.2.6 1.21 3.0.0 - 2.3.2 - 2.1.4 + 2.3.2 + 2.1.4 1.3.1 - 1.2.76 + 1.2.78 5.8.0 5.8.0 2.11.0 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java index 4588a7a53..f1afe51cf 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java @@ -47,7 +47,7 @@ public class TestController extends BaseController } @ApiOperation("获取用户详细") - @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) @GetMapping("/{userId}") public AjaxResult getUser(@PathVariable Integer userId) { @@ -63,10 +63,10 @@ public class TestController extends BaseController @ApiOperation("新增用户") @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer"), - @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String"), - @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String"), - @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String") + @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class), + @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class), + @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class) }) @PostMapping("/save") public AjaxResult save(UserEntity user) @@ -95,7 +95,7 @@ public class TestController extends BaseController } @ApiOperation("删除用户信息") - @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) @DeleteMapping("/{userId}") public AjaxResult delete(@PathVariable Integer userId) { diff --git a/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml b/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml index c7c36e375..4b8c49628 100644 --- a/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml +++ b/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml @@ -3,13 +3,18 @@ PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> - - - - - - - + + + + + + + + + + + + diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java index 50482c572..9fb64da1a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java @@ -5,6 +5,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.math.BigDecimal; +import com.ruoyi.common.utils.poi.ExcelHandlerAdapter; /** * 自定义导出Excel数据注解 @@ -108,7 +109,17 @@ public @interface Excel /** * 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右) */ - Align align() default Align.AUTO; + public Align align() default Align.AUTO; + + /** + * 自定义数据处理器 + */ + public Class> handler() default ExcelHandlerAdapter.class; + + /** + * 自定义数据处理器参数 + */ + public String[] args() default {}; public enum Align { diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java index 628eef1ef..408300525 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java @@ -19,5 +19,13 @@ import java.lang.annotation.Target; @Documented public @interface RepeatSubmit { + /** + * 间隔时间(ms),小于此时间视为重复提交 + */ + public int interval() default 5000; + /** + * 提示消息 + */ + public String message() default "不允许重复提交,请稍后再试"; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java index 04ae9b1db..8d8f5a6a3 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java @@ -211,6 +211,7 @@ public class FileUtils .append(percentEncodedFileName); response.setHeader("Content-disposition", contentDispositionValue.toString()); + response.setHeader("download-filename", percentEncodedFileName); } /** diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java index 3de26bb4b..415acbab2 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java @@ -387,7 +387,7 @@ public final class HTMLFilter { paramValue = processParamProtocol(paramValue); } - params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); + params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\""); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java new file mode 100644 index 000000000..c9ca2d5ed --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java @@ -0,0 +1,19 @@ +package com.ruoyi.common.utils.poi; + +/** + * Excel数据格式处理适配器 + * + * @author ruoyi + */ +public interface ExcelHandlerAdapter +{ + /** + * 格式化 + * + * @param value 单元格数据值 + * @param args excel注解args参数组 + * + * @return 处理后的值 + */ + Object format(Object value, String[] args); +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 54157f353..b9f9ac289 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -6,6 +6,7 @@ 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; import java.text.DecimalFormat; import java.util.ArrayList; @@ -46,6 +47,7 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.streaming.SXSSFWorkbook; @@ -124,6 +126,16 @@ public class ExcelUtil */ private List fields; + /** + * 当前行号 + */ + private int rownum; + + /** + * 标题 + */ + private String title; + /** * 最大高度 */ @@ -149,7 +161,7 @@ public class ExcelUtil this.clazz = clazz; } - public void init(List list, String sheetName, Type type) + public void init(List list, String sheetName, String title, Type type) { if (list == null) { @@ -158,8 +170,27 @@ public class ExcelUtil this.list = list; this.sheetName = sheetName; this.type = type; + this.title = title; createExcelField(); createWorkbook(); + createTitle(); + } + + /** + * 创建excel第一行标题 + */ + public void createTitle() + { + if (StringUtils.isNotEmpty(title)) + { + Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0); + titleRow.setHeightInPoints(30); + Cell titleCell = titleRow.createCell(0); + titleCell.setCellStyle(styles.get("title")); + titleCell.setCellValue(title); + sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(), + this.fields.size() - 1)); + } } /** @@ -170,17 +201,30 @@ public class ExcelUtil */ public List importExcel(InputStream is) throws Exception { - return importExcel(StringUtils.EMPTY, is); + return importExcel(is, 0); + } + + /** + * 对excel表单默认第一个索引名转换成list + * + * @param is 输入流 + * @param titleNum 标题占用行数 + * @return 转换后集合 + */ + public List importExcel(InputStream is, int titleNum) throws Exception + { + return importExcel(StringUtils.EMPTY, is, titleNum); } /** * 对excel表单指定表格索引名转换成list * * @param sheetName 表格索引名 + * @param titleNum 标题占用行数 * @param is 输入流 * @return 转换后集合 */ - public List importExcel(String sheetName, InputStream is) throws Exception + public List importExcel(String sheetName, InputStream is, int titleNum) throws Exception { this.type = Type.IMPORT; this.wb = WorkbookFactory.create(is); @@ -209,7 +253,7 @@ public class ExcelUtil // 定义一个map用于存放excel列的序号和field. Map cellMap = new HashMap(); // 获取表头 - Row heard = sheet.getRow(0); + Row heard = sheet.getRow(titleNum); for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) { Cell cell = heard.getCell(i); @@ -242,7 +286,7 @@ public class ExcelUtil } } } - for (int i = 1; i <= rows; i++) + for (int i = titleNum + 1; i <= rows; i++) { // 从第2行开始取数据,默认第一行是表头. Row row = sheet.getRow(i); @@ -333,6 +377,10 @@ public class ExcelUtil { val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); } + else if (!attr.handler().equals(ExcelHandlerAdapter.class)) + { + val = dataFormatHandlerAdapter(val, attr); + } else if (ColumnType.IMAGE == attr.cellType() && StringUtils.isNotEmpty(pictures)) { PictureData image = pictures.get(row.getRowNum() + "_" + entry.getKey()); @@ -340,8 +388,11 @@ public class ExcelUtil { val = ""; } - byte[] data = image.getData(); - val = FileUtils.writeImportBytes(data); + else + { + byte[] data = image.getData(); + val = FileUtils.writeImportBytes(data); + } } ReflectUtils.invokeSetter(entity, propertyName, val); } @@ -361,7 +412,20 @@ public class ExcelUtil */ public AjaxResult exportExcel(List list, String sheetName) { - this.init(list, sheetName, Type.EXPORT); + return exportExcel(list, sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public AjaxResult exportExcel(List list, String sheetName, String title) + { + this.init(list, sheetName, title, Type.EXPORT); return exportExcel(); } @@ -374,11 +438,26 @@ public class ExcelUtil * @return 结果 * @throws IOException */ - public void exportExcel(HttpServletResponse response, List list, String sheetName) throws IOException + public void exportExcel(HttpServletResponse response, List list, String sheetName)throws IOException + { + exportExcel(response, list, sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param response 返回数据 + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + * @throws IOException + */ + public void exportExcel(HttpServletResponse response, List list, String sheetName, String title) throws IOException { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - this.init(list, sheetName, Type.EXPORT); + this.init(list, sheetName, title, Type.EXPORT); exportExcel(response.getOutputStream()); } @@ -390,7 +469,19 @@ public class ExcelUtil */ public AjaxResult importTemplateExcel(String sheetName) { - this.init(null, sheetName, Type.IMPORT); + return importTemplateExcel(sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public AjaxResult importTemplateExcel(String sheetName, String title) + { + this.init(null, sheetName, title, Type.IMPORT); return exportExcel(); } @@ -401,10 +492,22 @@ public class ExcelUtil * @return 结果 */ public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException + { + importTemplateExcel(response, sheetName); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) throws IOException { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - this.init(null, sheetName, Type.IMPORT); + this.init(null, sheetName, title, Type.IMPORT); exportExcel(response.getOutputStream()); } @@ -465,13 +568,13 @@ public class ExcelUtil public void writeSheet() { // 取出一共有多少个sheet. - double sheetNo = Math.ceil(list.size() / sheetSize); - for (int index = 0; index <= sheetNo; index++) + int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize)); + for (int index = 0; index < sheetNo; index++) { createSheet(sheetNo, index); // 产生一行 - Row row = sheet.createRow(0); + Row row = sheet.createRow(rownum); int column = 0; // 写入各个字段的列头名称 for (Object[] os : fields) @@ -499,7 +602,7 @@ public class ExcelUtil int endNo = Math.min(startNo + sheetSize, list.size()); for (int i = startNo; i < endNo; i++) { - row = sheet.createRow(i + 1 - startNo); + row = sheet.createRow(i + 1 + rownum - startNo); // 得到导出对象. T vo = (T) list.get(i); int column = 0; @@ -527,6 +630,16 @@ public class ExcelUtil CellStyle style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); + Font titleFont = wb.createFont(); + titleFont.setFontName("Arial"); + titleFont.setFontHeightInPoints((short) 16); + titleFont.setBold(true); + style.setFont(titleFont); + styles.put("title", style); + + style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); style.setBorderRight(BorderStyle.THIN); style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBorderLeft(BorderStyle.THIN); @@ -726,6 +839,10 @@ public class ExcelUtil { cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString()); } + else if (!attr.handler().equals(ExcelHandlerAdapter.class)) + { + cell.setCellValue(dataFormatHandlerAdapter(value, attr)); + } else { // 设置列类型 @@ -898,6 +1015,28 @@ public class ExcelUtil return DictUtils.getDictValue(dictType, dictLabel, separator); } + /** + * 数据处理器 + * + * @param value 数据值 + * @param excel 数据注解 + * @return + */ + public String dataFormatHandlerAdapter(Object value, Excel excel) + { + try + { + Object instance = excel.handler().newInstance(); + Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class }); + value = formatMethod.invoke(instance, value, excel.args()); + } + catch (Exception e) + { + log.error("不能格式化数据 " + excel.handler(), e.getMessage()); + } + return Convert.toStr(value); + } + /** * 合计统计信息 */ @@ -1083,6 +1222,9 @@ public class ExcelUtil public void createWorkbook() { this.wb = new SXSSFWorkbook(500); + this.sheet = wb.createSheet(); + wb.setSheetName(0, sheetName); + this.styles = createStyles(wb); } /** @@ -1091,17 +1233,13 @@ public class ExcelUtil * @param sheetNo sheet数量 * @param index 序号 */ - public void createSheet(double sheetNo, int index) + public void createSheet(int sheetNo, int index) { - this.sheet = wb.createSheet(); - this.styles = createStyles(wb); // 设置工作表的名称. - if (sheetNo == 0) - { - wb.setSheetName(index, sheetName); - } - else + if (sheetNo > 1 && index > 0) { + this.sheet = wb.createSheet(); + this.createTitle(); wb.setSheetName(index, sheetName + index); } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index e4340d019..1074e05a3 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -1,12 +1,8 @@ package com.ruoyi.framework.aspectj; -import java.lang.reflect.Method; import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.Signature; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.core.domain.BaseEntity; @@ -55,27 +51,15 @@ public class DataScopeAspect */ public static final String DATA_SCOPE = "dataScope"; - // 配置织入点 - @Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)") - public void dataScopePointCut() - { - } - - @Before("dataScopePointCut()") - public void doBefore(JoinPoint point) throws Throwable + @Before("@annotation(controllerDataScope)") + public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable { clearDataScope(point); - handleDataScope(point); + handleDataScope(point, controllerDataScope); } - protected void handleDataScope(final JoinPoint joinPoint) + protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope) { - // 获得注解 - DataScope controllerDataScope = getAnnotationLog(joinPoint); - if (controllerDataScope == null) - { - return; - } // 获取当前的用户 LoginUser loginUser = SecurityUtils.getLoginUser(); if (StringUtils.isNotNull(loginUser)) @@ -150,22 +134,6 @@ public class DataScopeAspect } } - /** - * 是否存在注解,如果存在就获取 - */ - private DataScope getAnnotationLog(JoinPoint joinPoint) - { - Signature signature = joinPoint.getSignature(); - MethodSignature methodSignature = (MethodSignature) signature; - Method method = methodSignature.getMethod(); - - if (method != null) - { - return method.getAnnotation(DataScope.class); - } - return null; - } - /** * 拼接权限sql前先清空params.dataScope参数防止注入 */ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java index 97c249051..a2aaf2229 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java @@ -1,18 +1,13 @@ package com.ruoyi.framework.aspectj; -import java.lang.reflect.Method; import java.util.Collection; -import java.util.Iterator; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.Signature; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -43,21 +38,15 @@ public class LogAspect { private static final Logger log = LoggerFactory.getLogger(LogAspect.class); - // 配置织入点 - @Pointcut("@annotation(com.ruoyi.common.annotation.Log)") - public void logPointCut() - { - } - /** * 处理完请求后执行 * * @param joinPoint 切点 */ - @AfterReturning(pointcut = "logPointCut()", returning = "jsonResult") - public void doAfterReturning(JoinPoint joinPoint, Object jsonResult) + @AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult") + public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) { - handleLog(joinPoint, null, jsonResult); + handleLog(joinPoint, controllerLog, null, jsonResult); } /** @@ -66,22 +55,16 @@ public class LogAspect * @param joinPoint 切点 * @param e 异常 */ - @AfterThrowing(value = "logPointCut()", throwing = "e") - public void doAfterThrowing(JoinPoint joinPoint, Exception e) + @AfterThrowing(value = "@annotation(controllerLog)", throwing = "e") + public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) { - handleLog(joinPoint, e, null); + handleLog(joinPoint, controllerLog, e, null); } - protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult) + protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) { try { - // 获得注解 - Log controllerLog = getAnnotationLog(joinPoint); - if (controllerLog == null) - { - return; - } // 获取当前的用户 LoginUser loginUser = SecurityUtils.getLoginUser(); @@ -172,22 +155,6 @@ public class LogAspect } } - /** - * 是否存在注解,如果存在就获取 - */ - private Log getAnnotationLog(JoinPoint joinPoint) throws Exception - { - Signature signature = joinPoint.getSignature(); - MethodSignature methodSignature = (MethodSignature) signature; - Method method = methodSignature.getMethod(); - - if (method != null) - { - return method.getAnnotation(Log.class); - } - return null; - } - /** * 参数拼装 */ @@ -196,12 +163,18 @@ public class LogAspect String params = ""; if (paramsArray != null && paramsArray.length > 0) { - for (int i = 0; i < paramsArray.length; i++) + for (Object o : paramsArray) { - if (StringUtils.isNotNull(paramsArray[i]) && !isFilterObject(paramsArray[i])) + if (StringUtils.isNotNull(o) && !isFilterObject(o)) { - Object jsonObj = JSON.toJSON(paramsArray[i]); - params += jsonObj.toString() + " "; + try + { + Object jsonObj = JSON.toJSON(o); + params += jsonObj.toString() + " "; + } + catch (Exception e) + { + } } } } @@ -225,17 +198,17 @@ public class LogAspect else if (Collection.class.isAssignableFrom(clazz)) { Collection collection = (Collection) o; - for (Iterator iter = collection.iterator(); iter.hasNext();) + for (Object value : collection) { - return iter.next() instanceof MultipartFile; + return value instanceof MultipartFile; } } else if (Map.class.isAssignableFrom(clazz)) { Map map = (Map) o; - for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) + for (Object value : map.entrySet()) { - Map.Entry entry = (Map.Entry) iter.next(); + Map.Entry entry = (Map.Entry) value; return entry.getValue() instanceof MultipartFile; } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java index fd456b0d5..5020d000b 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java @@ -4,10 +4,8 @@ import java.lang.reflect.Method; import java.util.Collections; import java.util.List; import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.Signature; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,16 +47,9 @@ public class RateLimiterAspect this.limitScript = limitScript; } - // 配置织入点 - @Pointcut("@annotation(com.ruoyi.common.annotation.RateLimiter)") - public void rateLimiterPointCut() + @Before("@annotation(rateLimiter)") + public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable { - } - - @Before("rateLimiterPointCut()") - public void doBefore(JoinPoint point) throws Throwable - { - RateLimiter rateLimiter = getAnnotationRateLimiter(point); String key = rateLimiter.key(); int time = rateLimiter.time(); int count = rateLimiter.count(); @@ -84,33 +75,17 @@ public class RateLimiterAspect } } - /** - * 是否存在注解,如果存在就获取 - */ - private RateLimiter getAnnotationRateLimiter(JoinPoint joinPoint) - { - Signature signature = joinPoint.getSignature(); - MethodSignature methodSignature = (MethodSignature) signature; - Method method = methodSignature.getMethod(); - - if (method != null) - { - return method.getAnnotation(RateLimiter.class); - } - return null; - } - public String getCombineKey(RateLimiter rateLimiter, JoinPoint point) { StringBuffer stringBuffer = new StringBuffer(rateLimiter.key()); if (rateLimiter.limitType() == LimitType.IP) { - stringBuffer.append(IpUtils.getIpAddr(ServletUtils.getRequest())); + stringBuffer.append(IpUtils.getIpAddr(ServletUtils.getRequest())).append("-"); } MethodSignature signature = (MethodSignature) point.getSignature(); Method method = signature.getMethod(); Class> targetClass = method.getDeclaringClass(); - stringBuffer.append("-").append(targetClass.getName()).append("- ").append(method.getName()); + stringBuffer.append(targetClass.getName()).append("-").append(method.getName()); return stringBuffer.toString(); } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java index 322d6e344..fe1822f70 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java @@ -68,12 +68,12 @@ public class RedisConfig extends CachingConfigurerSupport "local time = tonumber(ARGV[2])\n" + "local current = redis.call('get', key);\n" + "if current and tonumber(current) > count then\n" + - " return current;\n" + + " return tonumber(current);\n" + "end\n" + "current = redis.call('incr', key)\n" + "if tonumber(current) == 1 then\n" + " redis.call('expire', key, time)\n" + "end\n" + - "return current;"; + "return tonumber(current);"; } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index bd3622901..58dd02ad0 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -107,8 +107,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter "/**/*.js", "/profile/**" ).permitAll() - .antMatchers("/common/download**").anonymous() - .antMatchers("/common/download/resource**").anonymous() .antMatchers("/swagger-ui.html").anonymous() .antMatchers("/swagger-resources/**").anonymous() .antMatchers("/webjars/**").anonymous() diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java index d310382f8..7b7f5a407 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java @@ -29,9 +29,9 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); if (annotation != null) { - if (this.isRepeatSubmit(request)) + if (this.isRepeatSubmit(request, annotation)) { - AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试"); + AjaxResult ajaxResult = AjaxResult.error(annotation.message()); ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult)); return false; } @@ -51,5 +51,5 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter * @return * @throws Exception */ - public abstract boolean isRepeatSubmit(HttpServletRequest request); + public abstract boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation); } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java index 3e82309e6..33c9c876b 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.annotation.RepeatSubmit; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.filter.RepeatedlyRequestWrapper; @@ -35,21 +36,9 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor @Autowired private RedisCache redisCache; - /** - * 间隔时间,单位:秒 默认10秒 - * - * 两次相同参数的请求,如果间隔时间大于该参数,系统不会认定为重复提交的数据 - */ - private int intervalTime = 10; - - public void setIntervalTime(int intervalTime) - { - this.intervalTime = intervalTime; - } - @SuppressWarnings("unchecked") @Override - public boolean isRepeatSubmit(HttpServletRequest request) + public boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation) { String nowParams = ""; if (request instanceof RepeatedlyRequestWrapper) @@ -87,7 +76,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor if (sessionMap.containsKey(url)) { Map preDataMap = (Map) sessionMap.get(url); - if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap)) + if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap, annotation.interval())) { return true; } @@ -95,7 +84,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor } Map cacheMap = new HashMap(); cacheMap.put(url, nowDataMap); - redisCache.setCacheObject(cacheRepeatKey, cacheMap, intervalTime, TimeUnit.SECONDS); + redisCache.setCacheObject(cacheRepeatKey, cacheMap, annotation.interval(), TimeUnit.MILLISECONDS); return false; } @@ -112,11 +101,11 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor /** * 判断两次间隔时间 */ - private boolean compareTime(Map nowMap, Map preMap) + private boolean compareTime(Map nowMap, Map preMap, int interval) { long time1 = (Long) nowMap.get(REPEAT_TIME); long time2 = (Long) preMap.get(REPEAT_TIME); - if ((time1 - time2) < (this.intervalTime * 1000)) + if ((time1 - time2) < interval) { return true; } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 07bb03cfd..2b5474327 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -87,7 +87,7 @@ public class SysLoginService } AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); LoginUser loginUser = (LoginUser) authentication.getPrincipal(); - recordLoginInfo(loginUser.getUser()); + recordLoginInfo(loginUser.getUserId()); // 生成token return tokenService.createToken(loginUser); } @@ -119,11 +119,15 @@ public class SysLoginService /** * 记录登录信息 + * + * @param userId 用户ID */ - public void recordLoginInfo(SysUser user) + public void recordLoginInfo(Long userId) { - user.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest())); - user.setLoginDate(DateUtils.getNowDate()); - userService.updateUserProfile(user); + SysUser sysUser = new SysUser(); + sysUser.setUserId(userId); + sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest())); + sysUser.setLoginDate(DateUtils.getNowDate()); + userService.updateUserProfile(sysUser); } } diff --git a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm index c2383c057..19802cee8 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -448,13 +448,13 @@ export default { #end if (this.form.${pkColumn.javaField} != null) { update${BusinessName}(this.form).then(response => { - this.msgSuccess("修改成功"); + this.#[[$modal]]#.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { add${BusinessName}(this.form).then(response => { - this.msgSuccess("新增成功"); + this.#[[$modal]]#.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -464,16 +464,12 @@ export default { }, /** 删除按钮操作 */ handleDelete(row) { - this.$confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return del${BusinessName}(row.${pkColumn.javaField}); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() { + return del${BusinessName}(row.${pkColumn.javaField}); + }).then(() => { + this.getList(); + this.#[[$modal]]#.msgSuccess("删除成功"); + }).catch(() => {}); } } }; diff --git a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm index 67d72b1cf..867225aba 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -503,13 +503,13 @@ export default { #end if (this.form.${pkColumn.javaField} != null) { update${BusinessName}(this.form).then(response => { - this.msgSuccess("修改成功"); + this.#[[$modal]]#.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { add${BusinessName}(this.form).then(response => { - this.msgSuccess("新增成功"); + this.#[[$modal]]#.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -520,16 +520,12 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids; - this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return del${BusinessName}(${pkColumn.javaField}s); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function() { + return del${BusinessName}(${pkColumn.javaField}s); + }).then(() => { + this.getList(); + this.#[[$modal]]#.msgSuccess("删除成功"); + }).catch(() => {}); }, #if($table.sub) /** ${subTable.functionName}序号 */ @@ -550,7 +546,7 @@ export default { /** ${subTable.functionName}删除按钮操作 */ handleDelete${subClassName}() { if (this.checked${subClassName}.length == 0) { - this.msgError("请先选择要删除的${subTable.functionName}数据"); + this.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据"); } else { const ${subclassName}List = this.${subclassName}List; const checked${subClassName} = this.checked${subClassName}; @@ -567,17 +563,13 @@ export default { /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm('是否确认导出所有${functionName}数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return export${BusinessName}(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.#[[$modal]]#.confirm('是否确认导出所有${functionName}数据项?').then(() => { + this.exportLoading = true; + return export${BusinessName}(queryParams); + }).then(response => { + this.#[[$download]]#.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); } } }; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java index f450caa42..af97f1492 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java @@ -169,6 +169,7 @@ public class SysMenuServiceImpl implements ISysMenuService children.setComponent(menu.getComponent()); children.setName(StringUtils.capitalize(menu.getPath())); children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); + children.setQuery(menu.getQuery()); childrenList.add(children); router.setChildren(childrenList); } diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 9048f5a4d..034e0642d 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -41,8 +41,8 @@ "clipboard": "2.0.6", "core-js": "3.8.1", "echarts": "4.9.0", - "element-ui": "2.15.5", - "file-saver": "2.0.4", + "element-ui": "2.15.6", + "file-saver": "2.0.5", "fuse.js": "6.4.3", "highlight.js": "9.18.5", "js-beautify": "1.13.0", @@ -71,8 +71,8 @@ "eslint-plugin-vue": "7.2.0", "lint-staged": "10.5.3", "runjs": "4.4.2", - "sass": "1.32.0", - "sass-loader": "10.1.0", + "sass": "1.32.13", + "sass-loader": "10.1.1", "script-ext-html-webpack-plugin": "2.1.5", "svg-sprite-loader": "5.1.1", "vue-template-compiler": "2.6.12" diff --git a/ruoyi-ui/src/layout/components/Settings/index.vue b/ruoyi-ui/src/layout/components/Settings/index.vue index 0a6becacb..4dff1d0c5 100644 --- a/ruoyi-ui/src/layout/components/Settings/index.vue +++ b/ruoyi-ui/src/layout/components/Settings/index.vue @@ -162,14 +162,8 @@ export default { this.sideTheme = val; }, saveSetting() { - const loading = this.$loading({ - lock: true, - fullscreen: false, - text: "正在保存到本地,请稍后...", - spinner: "el-icon-loading", - background: "rgba(0, 0, 0, 0.7)" - }); - localStorage.setItem( + this.$modal.loading("正在保存到本地,请稍后..."); + this.$cache.local.set( "layout-setting", `{ "topNav":${this.topNav}, @@ -181,17 +175,11 @@ export default { "theme":"${this.theme}" }` ); - setTimeout(loading.close(), 1000) + setTimeout(this.$modal.closeLoading(), 1000) }, resetSetting() { - this.$loading({ - lock: true, - fullscreen: false, - text: "正在清除设置缓存并刷新,请稍后...", - spinner: "el-icon-loading", - background: "rgba(0, 0, 0, 0.7)" - }); - localStorage.removeItem("layout-setting") + this.$modal.loading("正在清除设置缓存并刷新,请稍后..."); + this.$cache.local.remove("layout-setting") setTimeout("window.location.reload()", 1000) } } diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js index e055dd411..489600aa4 100644 --- a/ruoyi-ui/src/main.js +++ b/ruoyi-ui/src/main.js @@ -11,12 +11,14 @@ import App from './App' import store from './store' import router from './router' import directive from './directive' //directive +import plugins from './plugins' // plugins import './assets/icons' // icon import './permission' // permission control import { getDicts } from "@/api/system/dict/data"; import { getConfigKey } from "@/api/system/config"; -import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi"; +import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi"; +// 分页组件 import Pagination from "@/components/Pagination"; // 自定义表格工具组件 import RightToolbar from "@/components/RightToolbar" @@ -41,21 +43,8 @@ Vue.prototype.resetForm = resetForm Vue.prototype.addDateRange = addDateRange Vue.prototype.selectDictLabel = selectDictLabel Vue.prototype.selectDictLabels = selectDictLabels -Vue.prototype.download = download Vue.prototype.handleTree = handleTree -Vue.prototype.msgSuccess = function (msg) { - this.$message({ showClose: true, message: msg, type: "success" }); -} - -Vue.prototype.msgError = function (msg) { - this.$message({ showClose: true, message: msg, type: "error" }); -} - -Vue.prototype.msgInfo = function (msg) { - this.$message.info(msg); -} - // 全局组件挂载 Vue.component('DictTag', DictTag) Vue.component('Pagination', Pagination) @@ -65,6 +54,7 @@ Vue.component('FileUpload', FileUpload) Vue.component('ImageUpload', ImageUpload) Vue.use(directive) +Vue.use(plugins) Vue.use(VueMeta) DictData.install() diff --git a/ruoyi-ui/src/plugins/cache.js b/ruoyi-ui/src/plugins/cache.js new file mode 100644 index 000000000..6f71b8e5c --- /dev/null +++ b/ruoyi-ui/src/plugins/cache.js @@ -0,0 +1,77 @@ +const sessionCache = { + set (key, value) { + if (!sessionStorage) { + return + } + if (key != null && value != null) { + sessionStorage.setItem(key, value) + } + }, + get (key) { + if (!sessionStorage) { + return null + } + if (key == null) { + return null + } + return sessionStorage.getItem(key) + }, + setJSON (key, jsonValue) { + if (jsonValue != null) { + this.set(key, JSON.stringify(jsonValue)) + } + }, + getJSON (key) { + const value = this.get(key) + if (value != null) { + return JSON.parse(value) + } + }, + remove (key) { + sessionStorage.removeItem(key); + } +} +const localCache = { + set (key, value) { + if (!localStorage) { + return + } + if (key != null && value != null) { + localStorage.setItem(key, value) + } + }, + get (key) { + if (!localStorage) { + return null + } + if (key == null) { + return null + } + return localStorage.getItem(key) + }, + setJSON (key, jsonValue) { + if (jsonValue != null) { + this.set(key, JSON.stringify(jsonValue)) + } + }, + getJSON (key) { + const value = this.get(key) + if (value != null) { + return JSON.parse(value) + } + }, + remove (key) { + localStorage.removeItem(key); + } +} + +export default { + /** + * 会话级缓存 + */ + session: sessionCache, + /** + * 本地缓存 + */ + local: localCache +} diff --git a/ruoyi-ui/src/plugins/download.js b/ruoyi-ui/src/plugins/download.js new file mode 100644 index 000000000..cb10ab0e4 --- /dev/null +++ b/ruoyi-ui/src/plugins/download.js @@ -0,0 +1,48 @@ +import { saveAs } from 'file-saver' +import axios from 'axios' +import { getToken } from '@/utils/auth' + +const baseURL = process.env.VUE_APP_BASE_API + +export default { + name(name, isDelete = true) { + var url = baseURL + "/common/download?fileName=" + encodeURI(name) + "&delete=" + isDelete + axios({ + method: 'get', + url: url, + responseType: 'blob', + headers: { 'Authorization': 'Bearer ' + getToken() } + }).then(res => { + const blob = new Blob([res.data]) + this.saveAs(blob, decodeURI(res.headers['download-filename'])) + }) + }, + resource(resource) { + var url = baseURL + "/common/download/resource?resource=" + encodeURI(resource); + axios({ + method: 'get', + url: url, + responseType: 'blob', + headers: { 'Authorization': 'Bearer ' + getToken() } + }).then(res => { + const blob = new Blob([res.data]) + this.saveAs(blob, decodeURI(res.headers['download-filename'])) + }) + }, + zip(url, name) { + var url = baseURL + url + axios({ + method: 'get', + url: url, + responseType: 'blob', + headers: { 'Authorization': 'Bearer ' + getToken() } + }).then(res => { + const blob = new Blob([res.data], { type: 'application/zip' }) + this.saveAs(blob, name) + }) + }, + saveAs(text, name, opts) { + saveAs(text, name, opts); + } +} + diff --git a/ruoyi-ui/src/plugins/index.js b/ruoyi-ui/src/plugins/index.js new file mode 100644 index 000000000..a138e6d6f --- /dev/null +++ b/ruoyi-ui/src/plugins/index.js @@ -0,0 +1,14 @@ +import cache from './cache' +import modal from './modal' +import download from './download' + +export default { + install(Vue) { + // 缓存对象 + Vue.prototype.$cache = cache + // 模态框对象 + Vue.prototype.$modal = modal + // 下载文件 + Vue.prototype.$download = download + } +} diff --git a/ruoyi-ui/src/plugins/modal.js b/ruoyi-ui/src/plugins/modal.js new file mode 100644 index 000000000..7df61a890 --- /dev/null +++ b/ruoyi-ui/src/plugins/modal.js @@ -0,0 +1,75 @@ +import { Message, MessageBox, Notification, Loading } from 'element-ui' + +let loadingInstance; + +export default { + // 消息提示 + msg(content) { + Message.info(content) + }, + // 错误消息 + msgError(content) { + Message.error(content) + }, + // 成功消息 + msgSuccess(content) { + Message.success(content) + }, + // 警告消息 + msgWarning(content) { + Message.warning(content) + }, + // 弹出提示 + alert(content) { + MessageBox.alert(content, "系统提示") + }, + // 错误提示 + alertError(content) { + MessageBox.alert(content, "系统提示", { type: 'error' }) + }, + // 成功提示 + alertSuccess(content) { + MessageBox.alert(content, "系统提示", { type: 'success' }) + }, + // 警告提示 + alertWarning(content) { + MessageBox.alert(content, "系统提示", { type: 'warning' }) + }, + // 通知提示 + notify(content) { + Notification.info(content) + }, + // 错误通知 + notifyError(content) { + Notification.error(content); + }, + // 成功通知 + notifySuccess(content) { + Notification.success(content) + }, + // 警告通知 + notifyWarning(content) { + Notification.warning(content) + }, + // 确认窗体 + confirm(content) { + return MessageBox.confirm(content, "系统提示", { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: "warning", + }) + }, + // 打开遮罩层 + loading(content) { + loadingInstance = Loading.service({ + lock: true, + text: content, + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)", + }) + }, + // 关闭遮罩层 + closeLoading() { + loadingInstance.close(); + } +} diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 5669a4347..63bd379b7 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -3,8 +3,6 @@ * Copyright (c) 2019 ruoyi */ -const baseURL = process.env.VUE_APP_BASE_API - // 日期格式化 export function parseTime(time, pattern) { if (arguments.length === 0 || !time) { @@ -95,11 +93,6 @@ export function selectDictLabels(datas, value, separator) { 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 ) export function sprintf(str) { var args = arguments, flag = true, i = 1; diff --git a/ruoyi-ui/src/utils/zipdownload.js b/ruoyi-ui/src/utils/zipdownload.js deleted file mode 100644 index 8a1b81983..000000000 --- a/ruoyi-ui/src/utils/zipdownload.js +++ /dev/null @@ -1,42 +0,0 @@ -import axios from 'axios' -import { getToken } from '@/utils/auth' - -const mimeMap = { - xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - zip: 'application/zip' -} - -const baseUrl = process.env.VUE_APP_BASE_API -export function downLoadZip(str, filename) { - var url = baseUrl + str - axios({ - method: 'get', - url: url, - responseType: 'blob', - headers: { 'Authorization': 'Bearer ' + getToken() } - }).then(res => { - resolveBlob(res, mimeMap.zip) - }) -} -/** - * 解析blob响应内容并下载 - * @param {*} res blob响应内容 - * @param {String} mimeType MIME类型 - */ -export function resolveBlob(res, mimeType) { - const aLink = document.createElement('a') - var blob = new Blob([res.data], { type: mimeType }) - // //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名; - var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*') - var contentDisposition = decodeURI(res.headers['content-disposition']) - var result = patt.exec(contentDisposition) - var fileName = result[1] - fileName = fileName.replace(/\"/g, '') - aLink.style.display = 'none' - aLink.href = URL.createObjectURL(blob) - aLink.setAttribute('download', fileName) // 设置下载文件名称 - document.body.appendChild(aLink) - aLink.click() - URL.revokeObjectURL(aLink.href);//清除引用 - document.body.removeChild(aLink); -} diff --git a/ruoyi-ui/src/views/monitor/cache/index.vue b/ruoyi-ui/src/views/monitor/cache/index.vue index 98eed22ec..36957edd2 100644 --- a/ruoyi-ui/src/views/monitor/cache/index.vue +++ b/ruoyi-ui/src/views/monitor/cache/index.vue @@ -74,8 +74,6 @@ export default { name: "Server", data() { return { - // 加载层信息 - loading: [], // 统计命令信息 commandstats: null, // 使用内存 @@ -93,7 +91,7 @@ export default { getList() { getCache().then((response) => { this.cache = response.data; - this.loading.close(); + this.$modal.closeLoading(); this.commandstats = echarts.init(this.$refs.commandstats, "macarons"); this.commandstats.setOption({ @@ -141,12 +139,7 @@ export default { }, // 打开加载层 openLoading() { - this.loading = this.$loading({ - lock: true, - text: "拼命读取中", - spinner: "el-icon-loading", - background: "rgba(0, 0, 0, 0.7)", - }); + this.$modal.loading("正在加载缓存监控数据,请稍后!"); }, }, }; diff --git a/ruoyi-ui/src/views/monitor/job/index.vue b/ruoyi-ui/src/views/monitor/job/index.vue index fdabb16ea..06b939d85 100644 --- a/ruoyi-ui/src/views/monitor/job/index.vue +++ b/ruoyi-ui/src/views/monitor/job/index.vue @@ -240,7 +240,7 @@ - + @@ -425,29 +425,21 @@ export default { // 任务状态修改 handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用"; - this.$confirm('确认要"' + text + '""' + row.jobName + '"任务吗?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return changeJobStatus(row.jobId, row.status); - }).then(() => { - this.msgSuccess(text + "成功"); - }).catch(function() { - row.status = row.status === "0" ? "1" : "0"; - }); + this.$modal.confirm('确认要"' + text + '""' + row.jobName + '"任务吗?').then(function() { + return changeJobStatus(row.jobId, row.status); + }).then(() => { + this.$modal.msgSuccess(text + "成功"); + }).catch(function() { + row.status = row.status === "0" ? "1" : "0"; + }); }, /* 立即执行一次 */ handleRun(row) { - this.$confirm('确认要立即执行一次"' + row.jobName + '"任务吗?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return runJob(row.jobId, row.jobGroup); - }).then(() => { - this.msgSuccess("执行成功"); - }).catch(() => {}); + this.$modal.confirm('确认要立即执行一次"' + row.jobName + '"任务吗?').then(function() { + return runJob(row.jobId, row.jobGroup); + }).then(() => { + this.$modal.msgSuccess("执行成功"); + }).catch(() => {}); }, /** 任务详细信息 */ handleView(row) { @@ -492,13 +484,13 @@ export default { if (valid) { if (this.form.jobId != undefined) { updateJob(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addJob(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -509,31 +501,23 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const jobIds = row.jobId || this.ids; - this.$confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delJob(jobIds); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?').then(function() { + return delJob(jobIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm("是否确认导出所有定时任务数据项?", "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportJob(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有定时任务数据项?').then(() => { + this.exportLoading = true; + return exportJob(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/monitor/job/log.vue b/ruoyi-ui/src/views/monitor/job/log.vue index c7ccaa82c..44efe5f1e 100644 --- a/ruoyi-ui/src/views/monitor/job/log.vue +++ b/ruoyi-ui/src/views/monitor/job/log.vue @@ -275,44 +275,32 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const jobLogIds = this.ids; - this.$confirm('是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delJobLog(jobLogIds); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?').then(function() { + return delJobLog(jobLogIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); }, /** 清空按钮操作 */ handleClean() { - this.$confirm("是否确认清空所有调度日志数据项?", "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return cleanJobLog(); - }).then(() => { - this.getList(); - this.msgSuccess("清空成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认清空所有调度日志数据项?').then(function() { + return cleanJobLog(); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("清空成功"); + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm("是否确认导出所有调度日志数据项?", "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportJobLog(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有调度日志数据项?').then(() => { + this.exportLoading = true; + return exportJobLog(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/monitor/logininfor/index.vue b/ruoyi-ui/src/views/monitor/logininfor/index.vue index 06ace92f4..634141997 100644 --- a/ruoyi-ui/src/views/monitor/logininfor/index.vue +++ b/ruoyi-ui/src/views/monitor/logininfor/index.vue @@ -198,44 +198,32 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const infoIds = row.infoId || this.ids; - this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delLogininfor(infoIds); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?').then(function() { + return delLogininfor(infoIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); }, /** 清空按钮操作 */ handleClean() { - this.$confirm('是否确认清空所有登录日志数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return cleanLogininfor(); - }).then(() => { - this.getList(); - this.msgSuccess("清空成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认清空所有登录日志数据项?').then(function() { + return cleanLogininfor(); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("清空成功"); + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm('是否确认导出所有操作日志数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportLogininfor(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有操作日志数据项?').then(() => { + this.exportLoading = true; + return exportLogininfor(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/monitor/online/index.vue b/ruoyi-ui/src/views/monitor/online/index.vue index baec6e0b4..ab66827b8 100644 --- a/ruoyi-ui/src/views/monitor/online/index.vue +++ b/ruoyi-ui/src/views/monitor/online/index.vue @@ -111,16 +111,12 @@ export default { }, /** 强退按钮操作 */ handleForceLogout(row) { - this.$confirm('是否确认强退名称为"' + row.userName + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return forceLogout(row.tokenId); - }).then(() => { - this.getList(); - this.msgSuccess("强退成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认强退名称为"' + row.userName + '"的数据项?').then(function() { + return forceLogout(row.tokenId); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("强退成功"); + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/monitor/operlog/index.vue b/ruoyi-ui/src/views/monitor/operlog/index.vue index 7fb42de19..0aee4a6a5 100644 --- a/ruoyi-ui/src/views/monitor/operlog/index.vue +++ b/ruoyi-ui/src/views/monitor/operlog/index.vue @@ -285,44 +285,32 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const operIds = row.operId || this.ids; - this.$confirm('是否确认删除日志编号为"' + operIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delOperlog(operIds); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?').then(function() { + return delOperlog(operIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); }, /** 清空按钮操作 */ handleClean() { - this.$confirm('是否确认清空所有操作日志数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return cleanOperlog(); - }).then(() => { - this.getList(); - this.msgSuccess("清空成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认清空所有操作日志数据项?').then(function() { + return cleanOperlog(); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("清空成功"); + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm('是否确认导出所有操作日志数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportOperlog(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有操作日志数据项?').then(() => { + this.exportLoading = true; + return exportOperlog(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/monitor/server/index.vue b/ruoyi-ui/src/views/monitor/server/index.vue index 6a5060dc5..367001f4d 100644 --- a/ruoyi-ui/src/views/monitor/server/index.vue +++ b/ruoyi-ui/src/views/monitor/server/index.vue @@ -153,7 +153,7 @@ - + {{ sysFile.dirName }} {{ sysFile.sysTypeName }} {{ sysFile.typeName }} @@ -178,8 +178,6 @@ export default { name: "Server", data() { return { - // 加载层信息 - loading: [], // 服务器信息 server: [] }; @@ -193,17 +191,12 @@ export default { getList() { getServer().then(response => { this.server = response.data; - this.loading.close(); + this.$modal.closeLoading(); }); }, // 打开加载层 openLoading() { - this.loading = this.$loading({ - lock: true, - text: "拼命读取中", - spinner: "el-icon-loading", - background: "rgba(0, 0, 0, 0.7)" - }); + this.$modal.loading("正在加载服务监控数据,请稍后!"); } } }; diff --git a/ruoyi-ui/src/views/system/config/index.vue b/ruoyi-ui/src/views/system/config/index.vue index b86c8a0e0..efb69615b 100644 --- a/ruoyi-ui/src/views/system/config/index.vue +++ b/ruoyi-ui/src/views/system/config/index.vue @@ -308,13 +308,13 @@ export default { if (valid) { if (this.form.configId != undefined) { updateConfig(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addConfig(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -325,36 +325,28 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const configIds = row.configId || this.ids; - this.$confirm('是否确认删除参数编号为"' + configIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { + this.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function() { return delConfig(configIds); }).then(() => { this.getList(); - this.msgSuccess("删除成功"); + this.$modal.msgSuccess("删除成功"); }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm('是否确认导出所有参数数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportConfig(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有参数数据项?').then(() => { + this.exportLoading = true; + return exportConfig(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); }, /** 刷新缓存按钮操作 */ handleRefreshCache() { refreshCache().then(() => { - this.msgSuccess("刷新成功"); + this.$modal.msgSuccess("刷新成功"); }); } } diff --git a/ruoyi-ui/src/views/system/dept/index.vue b/ruoyi-ui/src/views/system/dept/index.vue index 591ba7521..f9c7741e5 100644 --- a/ruoyi-ui/src/views/system/dept/index.vue +++ b/ruoyi-ui/src/views/system/dept/index.vue @@ -305,13 +305,13 @@ export default { if (valid) { if (this.form.deptId != undefined) { updateDept(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addDept(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -321,16 +321,12 @@ export default { }, /** 删除按钮操作 */ handleDelete(row) { - this.$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delDept(row.deptId); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?').then(function() { + return delDept(row.deptId); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/dict/data.vue b/ruoyi-ui/src/views/system/dict/data.vue index 908ec9aab..36eb6afdb 100644 --- a/ruoyi-ui/src/views/system/dict/data.vue +++ b/ruoyi-ui/src/views/system/dict/data.vue @@ -354,13 +354,13 @@ export default { if (valid) { if (this.form.dictCode != undefined) { updateData(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addData(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -371,31 +371,23 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const dictCodes = row.dictCode || this.ids; - this.$confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delData(dictCodes); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?').then(function() { + return delData(dictCodes); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm('是否确认导出所有数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportData(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有数据项?').then(() => { + this.exportLoading = true; + return exportData(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/dict/index.vue b/ruoyi-ui/src/views/system/dict/index.vue index 3292731a3..37de40f3f 100644 --- a/ruoyi-ui/src/views/system/dict/index.vue +++ b/ruoyi-ui/src/views/system/dict/index.vue @@ -312,13 +312,13 @@ export default { if (valid) { if (this.form.dictId != undefined) { updateType(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addType(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -329,36 +329,28 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const dictIds = row.dictId || this.ids; - this.$confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delType(dictIds); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?').then(function() { + return delType(dictIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm('是否确认导出所有类型数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportType(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有类型数据项?').then(() => { + this.exportLoading = true; + return exportType(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); }, /** 刷新缓存按钮操作 */ handleRefreshCache() { refreshCache().then(() => { - this.msgSuccess("刷新成功"); + this.$modal.msgSuccess("刷新成功"); }); } } diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue index d7d4c0ff1..a89e1ee71 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -425,13 +425,13 @@ export default { if (valid) { if (this.form.menuId != undefined) { updateMenu(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addMenu(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -441,16 +441,12 @@ export default { }, /** 删除按钮操作 */ handleDelete(row) { - this.$confirm('是否确认删除名称为"' + row.menuName + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delMenu(row.menuId); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除名称为"' + row.menuName + '"的数据项?').then(function() { + return delMenu(row.menuId); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/notice/index.vue b/ruoyi-ui/src/views/system/notice/index.vue index 9d0924ffd..22b2ad5e7 100644 --- a/ruoyi-ui/src/views/system/notice/index.vue +++ b/ruoyi-ui/src/views/system/notice/index.vue @@ -285,13 +285,13 @@ export default { if (valid) { if (this.form.noticeId != undefined) { updateNotice(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addNotice(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -302,16 +302,12 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const noticeIds = row.noticeId || this.ids - this.$confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delNotice(noticeIds); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?').then(function() { + return delNotice(noticeIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/post/index.vue b/ruoyi-ui/src/views/system/post/index.vue index fc8675405..e2069687d 100644 --- a/ruoyi-ui/src/views/system/post/index.vue +++ b/ruoyi-ui/src/views/system/post/index.vue @@ -279,13 +279,13 @@ export default { if (valid) { if (this.form.postId != undefined) { updatePost(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addPost(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -296,31 +296,23 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const postIds = row.postId || this.ids; - this.$confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delPost(postIds); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?').then(function() { + return delPost(postIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm('是否确认导出所有岗位数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportPost(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有岗位数据项?').then(() => { + this.exportLoading = true; + return exportPost(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/role/authUser.vue b/ruoyi-ui/src/views/system/role/authUser.vue index 661c3690b..e18ea8b31 100644 --- a/ruoyi-ui/src/views/system/role/authUser.vue +++ b/ruoyi-ui/src/views/system/role/authUser.vue @@ -178,30 +178,22 @@ export default { /** 取消授权按钮操作 */ cancelAuthUser(row) { const roleId = this.queryParams.roleId; - this.$confirm('确认要取消该用户"' + row.userName + '"角色吗?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { + this.$modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?').then(function() { return authUserCancel({ userId: row.userId, roleId: roleId }); }).then(() => { this.getList(); - this.msgSuccess("取消授权成功"); + this.$modal.msgSuccess("取消授权成功"); }).catch(() => {}); }, /** 批量取消授权按钮操作 */ cancelAuthUserAll(row) { const roleId = this.queryParams.roleId; const userIds = this.userIds.join(","); - this.$confirm('是否取消选中用户授权数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - return authUserCancelAll({ roleId: roleId, userIds: userIds }); + this.$modal.confirm('是否取消选中用户授权数据项?').then(function() { + return authUserCancelAll({ roleId: roleId, userIds: userIds }); }).then(() => { this.getList(); - this.msgSuccess("取消授权成功"); + this.$modal.msgSuccess("取消授权成功"); }).catch(() => {}); } } diff --git a/ruoyi-ui/src/views/system/role/index.vue b/ruoyi-ui/src/views/system/role/index.vue index 97a2f8407..6e5855863 100644 --- a/ruoyi-ui/src/views/system/role/index.vue +++ b/ruoyi-ui/src/views/system/role/index.vue @@ -413,17 +413,13 @@ export default { // 角色状态修改 handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用"; - this.$confirm('确认要"' + text + '""' + row.roleName + '"角色吗?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return changeRoleStatus(row.roleId, row.status); - }).then(() => { - this.msgSuccess(text + "成功"); - }).catch(function() { - row.status = row.status === "0" ? "1" : "0"; - }); + this.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function() { + return changeRoleStatus(row.roleId, row.status); + }).then(() => { + this.$modal.msgSuccess(text + "成功"); + }).catch(function() { + row.status = row.status === "0" ? "1" : "0"; + }); }, // 取消按钮 cancel() { @@ -579,14 +575,14 @@ export default { if (this.form.roleId != undefined) { this.form.menuIds = this.getMenuAllCheckedKeys(); updateRole(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { this.form.menuIds = this.getMenuAllCheckedKeys(); addRole(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -599,7 +595,7 @@ export default { if (this.form.roleId != undefined) { this.form.deptIds = this.getDeptAllCheckedKeys(); dataScope(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.openDataScope = false; this.getList(); }); @@ -608,31 +604,23 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const roleIds = row.roleId || this.ids; - this.$confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delRole(roleIds); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function() { + return delRole(roleIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm('是否确认导出所有角色数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportRole(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有用户数据项?').then(() => { + this.exportLoading = true; + return exportRole(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/role/selectUser.vue b/ruoyi-ui/src/views/system/role/selectUser.vue index 3229462d6..a9e2ce0ff 100644 --- a/ruoyi-ui/src/views/system/role/selectUser.vue +++ b/ruoyi-ui/src/views/system/role/selectUser.vue @@ -124,7 +124,7 @@ export default { const roleId = this.queryParams.roleId; const userIds = this.userIds.join(","); authUserSelectAll({ roleId: roleId, userIds: userIds }).then(res => { - this.msgSuccess(res.msg); + this.$modal.msgSuccess(res.msg); if (res.code === 200) { this.visible = false; this.$emit("ok"); diff --git a/ruoyi-ui/src/views/system/user/authRole.vue b/ruoyi-ui/src/views/system/user/authRole.vue index e0cd7bceb..a4bcbe3f4 100644 --- a/ruoyi-ui/src/views/system/user/authRole.vue +++ b/ruoyi-ui/src/views/system/user/authRole.vue @@ -103,7 +103,7 @@ export default { const userId = this.form.userId; const roleIds = this.roleIds.join(","); updateAuthRole({ userId: userId, roleIds: roleIds }).then((response) => { - this.msgSuccess("授权成功"); + this.$modal.msgSuccess("授权成功"); this.close(); }); }, diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index 9dea91d1a..4f20b0872 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -503,17 +503,13 @@ export default { // 用户状态修改 handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用"; - this.$confirm('确认要"' + text + '""' + row.userName + '"用户吗?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return changeUserStatus(row.userId, row.status); - }).then(() => { - this.msgSuccess(text + "成功"); - }).catch(function() { - row.status = row.status === "0" ? "1" : "0"; - }); + this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function() { + return changeUserStatus(row.userId, row.status); + }).then(() => { + this.$modal.msgSuccess(text + "成功"); + }).catch(function() { + row.status = row.status === "0" ? "1" : "0"; + }); }, // 取消按钮 cancel() { @@ -606,7 +602,7 @@ export default { inputErrorMessage: "用户密码长度必须介于 5 和 20 之间", }).then(({ value }) => { resetUserPwd(row.userId, value).then(response => { - this.msgSuccess("修改成功,新密码是:" + value); + this.$modal.msgSuccess("修改成功,新密码是:" + value); }); }).catch(() => {}); }, @@ -621,13 +617,13 @@ export default { if (valid) { if (this.form.userId != undefined) { updateUser(this.form).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addUser(this.form).then(response => { - this.msgSuccess("新增成功"); + this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); @@ -638,31 +634,23 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const userIds = row.userId || this.ids; - this.$confirm('是否确认删除用户编号为"' + userIds + '"的数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { - return delUser(userIds); - }).then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function() { + return delUser(userIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; - this.$confirm('是否确认导出所有用户数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.exportLoading = true; - return exportUser(queryParams); - }).then(response => { - this.download(response.msg); - this.exportLoading = false; - }).catch(() => {}); + this.$modal.confirm('是否确认导出所有用户数据项?').then(() => { + this.exportLoading = true; + return exportUser(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => {}); }, /** 导入按钮操作 */ handleImport() { @@ -672,7 +660,7 @@ export default { /** 下载模板操作 */ importTemplate() { importTemplate().then(response => { - this.download(response.msg); + this.$download.name(response.msg); }); }, // 文件上传中处理 diff --git a/ruoyi-ui/src/views/system/user/profile/resetPwd.vue b/ruoyi-ui/src/views/system/user/profile/resetPwd.vue index a7d1c902e..e01926846 100644 --- a/ruoyi-ui/src/views/system/user/profile/resetPwd.vue +++ b/ruoyi-ui/src/views/system/user/profile/resetPwd.vue @@ -57,7 +57,7 @@ export default { if (valid) { updateUserPwd(this.user.oldPassword, this.user.newPassword).then( response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); } ); } diff --git a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue index 49c2cd545..402d9cc93 100644 --- a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue +++ b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue @@ -110,7 +110,7 @@ export default { // 上传预处理 beforeUpload(file) { if (file.type.indexOf("image/") == -1) { - this.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。"); + this.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。"); } else { const reader = new FileReader(); reader.readAsDataURL(file); @@ -128,7 +128,7 @@ export default { this.open = false; this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl; store.commit('SET_AVATAR', this.options.img); - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); this.visible = false; }); }); diff --git a/ruoyi-ui/src/views/system/user/profile/userInfo.vue b/ruoyi-ui/src/views/system/user/profile/userInfo.vue index 621a1a3a9..978cddf45 100644 --- a/ruoyi-ui/src/views/system/user/profile/userInfo.vue +++ b/ruoyi-ui/src/views/system/user/profile/userInfo.vue @@ -62,7 +62,7 @@ export default { this.$refs["form"].validate(valid => { if (valid) { updateUserProfile(this.user).then(response => { - this.msgSuccess("修改成功"); + this.$modal.msgSuccess("修改成功"); }); } }); diff --git a/ruoyi-ui/src/views/tool/build/index.vue b/ruoyi-ui/src/views/tool/build/index.vue index 0281d18df..e51140875 100644 --- a/ruoyi-ui/src/views/tool/build/index.vue +++ b/ruoyi-ui/src/views/tool/build/index.vue @@ -137,23 +137,13 @@