Merge remote-tracking branch 'origin/master'

This commit is contained in:
yjb 2021-10-08 09:50:16 +08:00
commit 254269b1ce
55 changed files with 795 additions and 734 deletions

View File

@ -24,7 +24,7 @@
<kaptcha.version>2.3.2</kaptcha.version> <kaptcha.version>2.3.2</kaptcha.version>
<mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version> <mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
<pagehelper.boot.version>1.3.1</pagehelper.boot.version> <pagehelper.boot.version>1.3.1</pagehelper.boot.version>
<fastjson.version>1.2.76</fastjson.version> <fastjson.version>1.2.78</fastjson.version>
<oshi.version>5.8.0</oshi.version> <oshi.version>5.8.0</oshi.version>
<jna.version>5.8.0</jna.version> <jna.version>5.8.0</jna.version>
<commons.io.version>2.11.0</commons.io.version> <commons.io.version>2.11.0</commons.io.version>

View File

@ -47,7 +47,7 @@ public class TestController extends BaseController
} }
@ApiOperation("获取用户详细") @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}") @GetMapping("/{userId}")
public AjaxResult getUser(@PathVariable Integer userId) public AjaxResult getUser(@PathVariable Integer userId)
{ {
@ -63,10 +63,10 @@ public class TestController extends BaseController
@ApiOperation("新增用户") @ApiOperation("新增用户")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer"), @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String"), @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String"), @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String") @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
}) })
@PostMapping("/save") @PostMapping("/save")
public AjaxResult save(UserEntity user) public AjaxResult save(UserEntity user)
@ -95,7 +95,7 @@ public class TestController extends BaseController
} }
@ApiOperation("删除用户信息") @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}") @DeleteMapping("/{userId}")
public AjaxResult delete(@PathVariable Integer userId) public AjaxResult delete(@PathVariable Integer userId)
{ {

View File

@ -3,13 +3,18 @@
PUBLIC "-//mybatis.org//DTD Config 3.0//EN" PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd"> "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration> <configuration>
<!-- 全局参数 -->
<settings> <settings>
<setting name="cacheEnabled" value="true" /> <!-- 全局映射器启用缓存 --> <!-- 使全局的映射器启用或禁用缓存 -->
<setting name="useGeneratedKeys" value="true" /> <!-- 允许 JDBC 支持自动生成主键 --> <setting name="cacheEnabled" value="true" />
<setting name="defaultExecutorType" value="REUSE" /> <!-- 配置默认的执行器 --> <!-- 允许JDBC 支持自动生成主键 -->
<setting name="logImpl" value="SLF4J" /> <!-- 指定 MyBatis 所用日志的具体实现 --> <setting name="useGeneratedKeys" value="true" />
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> 驼峰式命名 --> <!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 指定 MyBatis 所用日志的具体实现 -->
<setting name="logImpl" value="SLF4J" />
<!-- 使用驼峰命名法转换字段 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
</settings> </settings>
</configuration> </configuration>

View File

@ -5,6 +5,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.math.BigDecimal; import java.math.BigDecimal;
import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
/** /**
* 自定义导出Excel数据注解 * 自定义导出Excel数据注解
@ -108,7 +109,17 @@ public @interface Excel
/** /**
* 导出字段对齐方式0默认1靠左2居中3靠右 * 导出字段对齐方式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 public enum Align
{ {

View File

@ -19,5 +19,13 @@ import java.lang.annotation.Target;
@Documented @Documented
public @interface RepeatSubmit public @interface RepeatSubmit
{ {
/**
* 间隔时间(ms)小于此时间视为重复提交
*/
public int interval() default 5000;
/**
* 提示消息
*/
public String message() default "不允许重复提交,请稍后再试";
} }

View File

@ -211,6 +211,7 @@ public class FileUtils
.append(percentEncodedFileName); .append(percentEncodedFileName);
response.setHeader("Content-disposition", contentDispositionValue.toString()); response.setHeader("Content-disposition", contentDispositionValue.toString());
response.setHeader("download-filename", percentEncodedFileName);
} }
/** /**

View File

@ -387,7 +387,7 @@ public final class HTMLFilter
{ {
paramValue = processParamProtocol(paramValue); paramValue = processParamProtocol(paramValue);
} }
params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\"");
} }
} }

View File

@ -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);
}

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; 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.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory; 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.ss.util.CellRangeAddressList;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
@ -124,6 +126,16 @@ public class ExcelUtil<T>
*/ */
private List<Object[]> fields; private List<Object[]> fields;
/**
* 当前行号
*/
private int rownum;
/**
* 标题
*/
private String title;
/** /**
* 最大高度 * 最大高度
*/ */
@ -149,7 +161,7 @@ public class ExcelUtil<T>
this.clazz = clazz; this.clazz = clazz;
} }
public void init(List<T> list, String sheetName, Type type) public void init(List<T> list, String sheetName, String title, Type type)
{ {
if (list == null) if (list == null)
{ {
@ -158,8 +170,27 @@ public class ExcelUtil<T>
this.list = list; this.list = list;
this.sheetName = sheetName; this.sheetName = sheetName;
this.type = type; this.type = type;
this.title = title;
createExcelField(); createExcelField();
createWorkbook(); 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<T>
*/ */
public List<T> importExcel(InputStream is) throws Exception public List<T> importExcel(InputStream is) throws Exception
{ {
return importExcel(StringUtils.EMPTY, is); return importExcel(is, 0);
}
/**
* 对excel表单默认第一个索引名转换成list
*
* @param is 输入流
* @param titleNum 标题占用行数
* @return 转换后集合
*/
public List<T> importExcel(InputStream is, int titleNum) throws Exception
{
return importExcel(StringUtils.EMPTY, is, titleNum);
} }
/** /**
* 对excel表单指定表格索引名转换成list * 对excel表单指定表格索引名转换成list
* *
* @param sheetName 表格索引名 * @param sheetName 表格索引名
* @param titleNum 标题占用行数
* @param is 输入流 * @param is 输入流
* @return 转换后集合 * @return 转换后集合
*/ */
public List<T> importExcel(String sheetName, InputStream is) throws Exception public List<T> importExcel(String sheetName, InputStream is, int titleNum) throws Exception
{ {
this.type = Type.IMPORT; this.type = Type.IMPORT;
this.wb = WorkbookFactory.create(is); this.wb = WorkbookFactory.create(is);
@ -209,7 +253,7 @@ public class ExcelUtil<T>
// 定义一个map用于存放excel列的序号和field. // 定义一个map用于存放excel列的序号和field.
Map<String, Integer> cellMap = new HashMap<String, Integer>(); Map<String, Integer> cellMap = new HashMap<String, Integer>();
// 获取表头 // 获取表头
Row heard = sheet.getRow(0); Row heard = sheet.getRow(titleNum);
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++)
{ {
Cell cell = heard.getCell(i); Cell cell = heard.getCell(i);
@ -242,7 +286,7 @@ public class ExcelUtil<T>
} }
} }
} }
for (int i = 1; i <= rows; i++) for (int i = titleNum + 1; i <= rows; i++)
{ {
// 从第2行开始取数据,默认第一行是表头. // 从第2行开始取数据,默认第一行是表头.
Row row = sheet.getRow(i); Row row = sheet.getRow(i);
@ -333,6 +377,10 @@ public class ExcelUtil<T>
{ {
val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); 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)) else if (ColumnType.IMAGE == attr.cellType() && StringUtils.isNotEmpty(pictures))
{ {
PictureData image = pictures.get(row.getRowNum() + "_" + entry.getKey()); PictureData image = pictures.get(row.getRowNum() + "_" + entry.getKey());
@ -340,9 +388,12 @@ public class ExcelUtil<T>
{ {
val = ""; val = "";
} }
else
{
byte[] data = image.getData(); byte[] data = image.getData();
val = FileUtils.writeImportBytes(data); val = FileUtils.writeImportBytes(data);
} }
}
ReflectUtils.invokeSetter(entity, propertyName, val); ReflectUtils.invokeSetter(entity, propertyName, val);
} }
} }
@ -361,7 +412,20 @@ public class ExcelUtil<T>
*/ */
public AjaxResult exportExcel(List<T> list, String sheetName) public AjaxResult exportExcel(List<T> 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<T> list, String sheetName, String title)
{
this.init(list, sheetName, title, Type.EXPORT);
return exportExcel(); return exportExcel();
} }
@ -375,10 +439,25 @@ public class ExcelUtil<T>
* @throws IOException * @throws IOException
*/ */
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName)throws IOException public void exportExcel(HttpServletResponse response, List<T> 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<T> list, String sheetName, String title) throws IOException
{ {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
this.init(list, sheetName, Type.EXPORT); this.init(list, sheetName, title, Type.EXPORT);
exportExcel(response.getOutputStream()); exportExcel(response.getOutputStream());
} }
@ -390,7 +469,19 @@ public class ExcelUtil<T>
*/ */
public AjaxResult importTemplateExcel(String sheetName) 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(); return exportExcel();
} }
@ -401,10 +492,22 @@ public class ExcelUtil<T>
* @return 结果 * @return 结果
*/ */
public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException 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.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
this.init(null, sheetName, Type.IMPORT); this.init(null, sheetName, title, Type.IMPORT);
exportExcel(response.getOutputStream()); exportExcel(response.getOutputStream());
} }
@ -465,13 +568,13 @@ public class ExcelUtil<T>
public void writeSheet() public void writeSheet()
{ {
// 取出一共有多少个sheet. // 取出一共有多少个sheet.
double sheetNo = Math.ceil(list.size() / sheetSize); int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize));
for (int index = 0; index <= sheetNo; index++) for (int index = 0; index < sheetNo; index++)
{ {
createSheet(sheetNo, index); createSheet(sheetNo, index);
// 产生一行 // 产生一行
Row row = sheet.createRow(0); Row row = sheet.createRow(rownum);
int column = 0; int column = 0;
// 写入各个字段的列头名称 // 写入各个字段的列头名称
for (Object[] os : fields) for (Object[] os : fields)
@ -499,7 +602,7 @@ public class ExcelUtil<T>
int endNo = Math.min(startNo + sheetSize, list.size()); int endNo = Math.min(startNo + sheetSize, list.size());
for (int i = startNo; i < endNo; i++) 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); T vo = (T) list.get(i);
int column = 0; int column = 0;
@ -527,6 +630,16 @@ public class ExcelUtil<T>
CellStyle style = wb.createCellStyle(); CellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER); style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.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.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderLeft(BorderStyle.THIN); style.setBorderLeft(BorderStyle.THIN);
@ -726,6 +839,10 @@ public class ExcelUtil<T>
{ {
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString()); cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString());
} }
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
{
cell.setCellValue(dataFormatHandlerAdapter(value, attr));
}
else else
{ {
// 设置列类型 // 设置列类型
@ -898,6 +1015,28 @@ public class ExcelUtil<T>
return DictUtils.getDictValue(dictType, dictLabel, separator); 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<T>
public void createWorkbook() public void createWorkbook()
{ {
this.wb = new SXSSFWorkbook(500); this.wb = new SXSSFWorkbook(500);
this.sheet = wb.createSheet();
wb.setSheetName(0, sheetName);
this.styles = createStyles(wb);
} }
/** /**
@ -1091,17 +1233,13 @@ public class ExcelUtil<T>
* @param sheetNo sheet数量 * @param sheetNo sheet数量
* @param index 序号 * @param index 序号
*/ */
public void createSheet(double sheetNo, int index) public void createSheet(int sheetNo, int index)
{
// 设置工作表的名称.
if (sheetNo > 1 && index > 0)
{ {
this.sheet = wb.createSheet(); this.sheet = wb.createSheet();
this.styles = createStyles(wb); this.createTitle();
// 设置工作表的名称.
if (sheetNo == 0)
{
wb.setSheetName(index, sheetName);
}
else
{
wb.setSheetName(index, sheetName + index); wb.setSheetName(index, sheetName + index);
} }
} }

View File

@ -1,12 +1,8 @@
package com.ruoyi.framework.aspectj; package com.ruoyi.framework.aspectj;
import java.lang.reflect.Method;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
@ -55,27 +51,15 @@ public class DataScopeAspect
*/ */
public static final String DATA_SCOPE = "dataScope"; public static final String DATA_SCOPE = "dataScope";
// 配置织入点 @Before("@annotation(controllerDataScope)")
@Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)") public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable
public void dataScopePointCut()
{
}
@Before("dataScopePointCut()")
public void doBefore(JoinPoint point) throws Throwable
{ {
clearDataScope(point); 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(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNotNull(loginUser)) 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参数防止注入 * 拼接权限sql前先清空params.dataScope参数防止注入
*/ */

View File

@ -1,18 +1,13 @@
package com.ruoyi.framework.aspectj; package com.ruoyi.framework.aspectj;
import java.lang.reflect.Method;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -43,21 +38,15 @@ public class LogAspect
{ {
private static final Logger log = LoggerFactory.getLogger(LogAspect.class); private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
// 配置织入点
@Pointcut("@annotation(com.ruoyi.common.annotation.Log)")
public void logPointCut()
{
}
/** /**
* 处理完请求后执行 * 处理完请求后执行
* *
* @param joinPoint 切点 * @param joinPoint 切点
*/ */
@AfterReturning(pointcut = "logPointCut()", returning = "jsonResult") @AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
public void doAfterReturning(JoinPoint joinPoint, Object 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 joinPoint 切点
* @param e 异常 * @param e 异常
*/ */
@AfterThrowing(value = "logPointCut()", throwing = "e") @AfterThrowing(value = "@annotation(controllerLog)", throwing = "e")
public void doAfterThrowing(JoinPoint joinPoint, Exception 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 try
{ {
// 获得注解
Log controllerLog = getAnnotationLog(joinPoint);
if (controllerLog == null)
{
return;
}
// 获取当前的用户 // 获取当前的用户
LoginUser loginUser = SecurityUtils.getLoginUser(); 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,13 +163,19 @@ public class LogAspect
String params = ""; String params = "";
if (paramsArray != null && paramsArray.length > 0) 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]); try
{
Object jsonObj = JSON.toJSON(o);
params += jsonObj.toString() + " "; params += jsonObj.toString() + " ";
} }
catch (Exception e)
{
}
}
} }
} }
return params.trim(); return params.trim();
@ -225,17 +198,17 @@ public class LogAspect
else if (Collection.class.isAssignableFrom(clazz)) else if (Collection.class.isAssignableFrom(clazz))
{ {
Collection collection = (Collection) o; 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)) else if (Map.class.isAssignableFrom(clazz))
{ {
Map map = (Map) o; 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; return entry.getValue() instanceof MultipartFile;
} }
} }

View File

@ -4,10 +4,8 @@ import java.lang.reflect.Method;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -49,16 +47,9 @@ public class RateLimiterAspect
this.limitScript = limitScript; this.limitScript = limitScript;
} }
// 配置织入点 @Before("@annotation(rateLimiter)")
@Pointcut("@annotation(com.ruoyi.common.annotation.RateLimiter)") public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable
public void rateLimiterPointCut()
{ {
}
@Before("rateLimiterPointCut()")
public void doBefore(JoinPoint point) throws Throwable
{
RateLimiter rateLimiter = getAnnotationRateLimiter(point);
String key = rateLimiter.key(); String key = rateLimiter.key();
int time = rateLimiter.time(); int time = rateLimiter.time();
int count = rateLimiter.count(); 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) public String getCombineKey(RateLimiter rateLimiter, JoinPoint point)
{ {
StringBuffer stringBuffer = new StringBuffer(rateLimiter.key()); StringBuffer stringBuffer = new StringBuffer(rateLimiter.key());
if (rateLimiter.limitType() == LimitType.IP) if (rateLimiter.limitType() == LimitType.IP)
{ {
stringBuffer.append(IpUtils.getIpAddr(ServletUtils.getRequest())); stringBuffer.append(IpUtils.getIpAddr(ServletUtils.getRequest())).append("-");
} }
MethodSignature signature = (MethodSignature) point.getSignature(); MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod(); Method method = signature.getMethod();
Class<?> targetClass = method.getDeclaringClass(); Class<?> targetClass = method.getDeclaringClass();
stringBuffer.append("-").append(targetClass.getName()).append("- ").append(method.getName()); stringBuffer.append(targetClass.getName()).append("-").append(method.getName());
return stringBuffer.toString(); return stringBuffer.toString();
} }
} }

View File

@ -68,12 +68,12 @@ public class RedisConfig extends CachingConfigurerSupport
"local time = tonumber(ARGV[2])\n" + "local time = tonumber(ARGV[2])\n" +
"local current = redis.call('get', key);\n" + "local current = redis.call('get', key);\n" +
"if current and tonumber(current) > count then\n" + "if current and tonumber(current) > count then\n" +
" return current;\n" + " return tonumber(current);\n" +
"end\n" + "end\n" +
"current = redis.call('incr', key)\n" + "current = redis.call('incr', key)\n" +
"if tonumber(current) == 1 then\n" + "if tonumber(current) == 1 then\n" +
" redis.call('expire', key, time)\n" + " redis.call('expire', key, time)\n" +
"end\n" + "end\n" +
"return current;"; "return tonumber(current);";
} }
} }

View File

@ -107,8 +107,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
"/**/*.js", "/**/*.js",
"/profile/**" "/profile/**"
).permitAll() ).permitAll()
.antMatchers("/common/download**").anonymous()
.antMatchers("/common/download/resource**").anonymous()
.antMatchers("/swagger-ui.html").anonymous() .antMatchers("/swagger-ui.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous() .antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous() .antMatchers("/webjars/**").anonymous()

View File

@ -29,9 +29,9 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
if (annotation != null) 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)); ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult));
return false; return false;
} }
@ -51,5 +51,5 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter
* @return * @return
* @throws Exception * @throws Exception
*/ */
public abstract boolean isRepeatSubmit(HttpServletRequest request); public abstract boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation);
} }

View File

@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.filter.RepeatedlyRequestWrapper; import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
@ -35,21 +36,9 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
@Autowired @Autowired
private RedisCache redisCache; private RedisCache redisCache;
/**
* 间隔时间单位: 默认10秒
*
* 两次相同参数的请求如果间隔时间大于该参数系统不会认定为重复提交的数据
*/
private int intervalTime = 10;
public void setIntervalTime(int intervalTime)
{
this.intervalTime = intervalTime;
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public boolean isRepeatSubmit(HttpServletRequest request) public boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation)
{ {
String nowParams = ""; String nowParams = "";
if (request instanceof RepeatedlyRequestWrapper) if (request instanceof RepeatedlyRequestWrapper)
@ -87,7 +76,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
if (sessionMap.containsKey(url)) if (sessionMap.containsKey(url))
{ {
Map<String, Object> preDataMap = (Map<String, Object>) sessionMap.get(url); Map<String, Object> preDataMap = (Map<String, Object>) sessionMap.get(url);
if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap)) if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap, annotation.interval()))
{ {
return true; return true;
} }
@ -95,7 +84,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
} }
Map<String, Object> cacheMap = new HashMap<String, Object>(); Map<String, Object> cacheMap = new HashMap<String, Object>();
cacheMap.put(url, nowDataMap); cacheMap.put(url, nowDataMap);
redisCache.setCacheObject(cacheRepeatKey, cacheMap, intervalTime, TimeUnit.SECONDS); redisCache.setCacheObject(cacheRepeatKey, cacheMap, annotation.interval(), TimeUnit.MILLISECONDS);
return false; return false;
} }
@ -112,11 +101,11 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
/** /**
* 判断两次间隔时间 * 判断两次间隔时间
*/ */
private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap) private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap, int interval)
{ {
long time1 = (Long) nowMap.get(REPEAT_TIME); long time1 = (Long) nowMap.get(REPEAT_TIME);
long time2 = (Long) preMap.get(REPEAT_TIME); long time2 = (Long) preMap.get(REPEAT_TIME);
if ((time1 - time2) < (this.intervalTime * 1000)) if ((time1 - time2) < interval)
{ {
return true; return true;
} }

View File

@ -87,7 +87,7 @@ public class SysLoginService
} }
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal(); LoginUser loginUser = (LoginUser) authentication.getPrincipal();
recordLoginInfo(loginUser.getUser()); recordLoginInfo(loginUser.getUserId());
// 生成token // 生成token
return tokenService.createToken(loginUser); 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())); SysUser sysUser = new SysUser();
user.setLoginDate(DateUtils.getNowDate()); sysUser.setUserId(userId);
userService.updateUserProfile(user); sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
sysUser.setLoginDate(DateUtils.getNowDate());
userService.updateUserProfile(sysUser);
} }
} }

View File

@ -448,13 +448,13 @@ export default {
#end #end
if (this.form.${pkColumn.javaField} != null) { if (this.form.${pkColumn.javaField} != null) {
update${BusinessName}(this.form).then(response => { update${BusinessName}(this.form).then(response => {
this.msgSuccess("修改成功"); this.#[[$modal]]#.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
add${BusinessName}(this.form).then(response => { add${BusinessName}(this.form).then(response => {
this.msgSuccess("新增成功"); this.#[[$modal]]#.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -464,15 +464,11 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?', "警告", { this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return del${BusinessName}(row.${pkColumn.javaField}); return del${BusinessName}(row.${pkColumn.javaField});
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.#[[$modal]]#.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
} }
} }

View File

@ -503,13 +503,13 @@ export default {
#end #end
if (this.form.${pkColumn.javaField} != null) { if (this.form.${pkColumn.javaField} != null) {
update${BusinessName}(this.form).then(response => { update${BusinessName}(this.form).then(response => {
this.msgSuccess("修改成功"); this.#[[$modal]]#.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
add${BusinessName}(this.form).then(response => { add${BusinessName}(this.form).then(response => {
this.msgSuccess("新增成功"); this.#[[$modal]]#.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -520,15 +520,11 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids; const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids;
this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", { this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return del${BusinessName}(${pkColumn.javaField}s); return del${BusinessName}(${pkColumn.javaField}s);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.#[[$modal]]#.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
#if($table.sub) #if($table.sub)
@ -550,7 +546,7 @@ export default {
/** ${subTable.functionName}删除按钮操作 */ /** ${subTable.functionName}删除按钮操作 */
handleDelete${subClassName}() { handleDelete${subClassName}() {
if (this.checked${subClassName}.length == 0) { if (this.checked${subClassName}.length == 0) {
this.msgError("请先选择要删除的${subTable.functionName}数据"); this.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据");
} else { } else {
const ${subclassName}List = this.${subclassName}List; const ${subclassName}List = this.${subclassName}List;
const checked${subClassName} = this.checked${subClassName}; const checked${subClassName} = this.checked${subClassName};
@ -567,15 +563,11 @@ export default {
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有${functionName}数据项?', "警告", { this.#[[$modal]]#.confirm('是否确认导出所有${functionName}数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return export${BusinessName}(queryParams); return export${BusinessName}(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.#[[$download]]#.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
} }

View File

@ -169,6 +169,7 @@ public class SysMenuServiceImpl implements ISysMenuService
children.setComponent(menu.getComponent()); children.setComponent(menu.getComponent());
children.setName(StringUtils.capitalize(menu.getPath())); children.setName(StringUtils.capitalize(menu.getPath()));
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
children.setQuery(menu.getQuery());
childrenList.add(children); childrenList.add(children);
router.setChildren(childrenList); router.setChildren(childrenList);
} }

View File

@ -41,8 +41,8 @@
"clipboard": "2.0.6", "clipboard": "2.0.6",
"core-js": "3.8.1", "core-js": "3.8.1",
"echarts": "4.9.0", "echarts": "4.9.0",
"element-ui": "2.15.5", "element-ui": "2.15.6",
"file-saver": "2.0.4", "file-saver": "2.0.5",
"fuse.js": "6.4.3", "fuse.js": "6.4.3",
"highlight.js": "9.18.5", "highlight.js": "9.18.5",
"js-beautify": "1.13.0", "js-beautify": "1.13.0",
@ -71,8 +71,8 @@
"eslint-plugin-vue": "7.2.0", "eslint-plugin-vue": "7.2.0",
"lint-staged": "10.5.3", "lint-staged": "10.5.3",
"runjs": "4.4.2", "runjs": "4.4.2",
"sass": "1.32.0", "sass": "1.32.13",
"sass-loader": "10.1.0", "sass-loader": "10.1.1",
"script-ext-html-webpack-plugin": "2.1.5", "script-ext-html-webpack-plugin": "2.1.5",
"svg-sprite-loader": "5.1.1", "svg-sprite-loader": "5.1.1",
"vue-template-compiler": "2.6.12" "vue-template-compiler": "2.6.12"

View File

@ -162,14 +162,8 @@ export default {
this.sideTheme = val; this.sideTheme = val;
}, },
saveSetting() { saveSetting() {
const loading = this.$loading({ this.$modal.loading("正在保存到本地,请稍后...");
lock: true, this.$cache.local.set(
fullscreen: false,
text: "正在保存到本地,请稍后...",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)"
});
localStorage.setItem(
"layout-setting", "layout-setting",
`{ `{
"topNav":${this.topNav}, "topNav":${this.topNav},
@ -181,17 +175,11 @@ export default {
"theme":"${this.theme}" "theme":"${this.theme}"
}` }`
); );
setTimeout(loading.close(), 1000) setTimeout(this.$modal.closeLoading(), 1000)
}, },
resetSetting() { resetSetting() {
this.$loading({ this.$modal.loading("正在清除设置缓存并刷新,请稍后...");
lock: true, this.$cache.local.remove("layout-setting")
fullscreen: false,
text: "正在清除设置缓存并刷新,请稍后...",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)"
});
localStorage.removeItem("layout-setting")
setTimeout("window.location.reload()", 1000) setTimeout("window.location.reload()", 1000)
} }
} }

View File

@ -11,12 +11,14 @@ import App from './App'
import store from './store' import store from './store'
import router from './router' import router from './router'
import directive from './directive' //directive import directive from './directive' //directive
import plugins from './plugins' // plugins
import './assets/icons' // icon import './assets/icons' // icon
import './permission' // permission control import './permission' // permission control
import { getDicts } from "@/api/system/dict/data"; import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config"; 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 Pagination from "@/components/Pagination";
// 自定义表格工具组件 // 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar" import RightToolbar from "@/components/RightToolbar"
@ -41,21 +43,8 @@ Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree 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('DictTag', DictTag)
Vue.component('Pagination', Pagination) Vue.component('Pagination', Pagination)
@ -65,6 +54,7 @@ Vue.component('FileUpload', FileUpload)
Vue.component('ImageUpload', ImageUpload) Vue.component('ImageUpload', ImageUpload)
Vue.use(directive) Vue.use(directive)
Vue.use(plugins)
Vue.use(VueMeta) Vue.use(VueMeta)
DictData.install() DictData.install()

View File

@ -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
}

View File

@ -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);
}
}

View File

@ -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
}
}

View File

@ -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();
}
}

View File

@ -3,8 +3,6 @@
* Copyright (c) 2019 ruoyi * Copyright (c) 2019 ruoyi
*/ */
const baseURL = process.env.VUE_APP_BASE_API
// 日期格式化 // 日期格式化
export function parseTime(time, pattern) { export function parseTime(time, pattern) {
if (arguments.length === 0 || !time) { if (arguments.length === 0 || !time) {
@ -95,11 +93,6 @@ export function selectDictLabels(datas, value, separator) {
return actions.join('').substring(0, actions.join('').length - 1); 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 ) // 字符串格式化(%s )
export function sprintf(str) { export function sprintf(str) {
var args = arguments, flag = true, i = 1; var args = arguments, flag = true, i = 1;

View File

@ -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);
}

View File

@ -74,8 +74,6 @@ export default {
name: "Server", name: "Server",
data() { data() {
return { return {
//
loading: [],
// //
commandstats: null, commandstats: null,
// 使 // 使
@ -93,7 +91,7 @@ export default {
getList() { getList() {
getCache().then((response) => { getCache().then((response) => {
this.cache = response.data; this.cache = response.data;
this.loading.close(); this.$modal.closeLoading();
this.commandstats = echarts.init(this.$refs.commandstats, "macarons"); this.commandstats = echarts.init(this.$refs.commandstats, "macarons");
this.commandstats.setOption({ this.commandstats.setOption({
@ -141,12 +139,7 @@ export default {
}, },
// //
openLoading() { openLoading() {
this.loading = this.$loading({ this.$modal.loading("正在加载缓存监控数据,请稍后!");
lock: true,
text: "拼命读取中",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
});
}, },
}, },
}; };

View File

@ -240,7 +240,7 @@
</div> </div>
</el-dialog> </el-dialog>
<el-dialog title="Cron表达式生成器" :visible.sync="openCron" append-to-body class="scrollbar" destroy-on-close > <el-dialog title="Cron表达式生成器" :visible.sync="openCron" append-to-body destroy-on-close class="scrollbar">
<crontab @hide="openCron=false" @fill="crontabFill" :expression="expression"></crontab> <crontab @hide="openCron=false" @fill="crontabFill" :expression="expression"></crontab>
</el-dialog> </el-dialog>
@ -425,28 +425,20 @@ export default {
// //
handleStatusChange(row) { handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"; let text = row.status === "0" ? "启用" : "停用";
this.$confirm('确认要"' + text + '""' + row.jobName + '"任务吗?', "警告", { this.$modal.confirm('确认要"' + text + '""' + row.jobName + '"任务吗?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return changeJobStatus(row.jobId, row.status); return changeJobStatus(row.jobId, row.status);
}).then(() => { }).then(() => {
this.msgSuccess(text + "成功"); this.$modal.msgSuccess(text + "成功");
}).catch(function() { }).catch(function() {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0";
}); });
}, },
/* 立即执行一次 */ /* 立即执行一次 */
handleRun(row) { handleRun(row) {
this.$confirm('确认要立即执行一次"' + row.jobName + '"任务吗?', "警告", { this.$modal.confirm('确认要立即执行一次"' + row.jobName + '"任务吗?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return runJob(row.jobId, row.jobGroup); return runJob(row.jobId, row.jobGroup);
}).then(() => { }).then(() => {
this.msgSuccess("执行成功"); this.$modal.msgSuccess("执行成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 任务详细信息 */ /** 任务详细信息 */
@ -492,13 +484,13 @@ export default {
if (valid) { if (valid) {
if (this.form.jobId != undefined) { if (this.form.jobId != undefined) {
updateJob(this.form).then(response => { updateJob(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addJob(this.form).then(response => { addJob(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -509,29 +501,21 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const jobIds = row.jobId || this.ids; const jobIds = row.jobId || this.ids;
this.$confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delJob(jobIds); return delJob(jobIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm("是否确认导出所有定时任务数据项?", "警告", { this.$modal.confirm('是否确认导出所有定时任务数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportJob(queryParams); return exportJob(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
} }

View File

@ -275,42 +275,30 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const jobLogIds = this.ids; const jobLogIds = this.ids;
this.$confirm('是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delJobLog(jobLogIds); return delJobLog(jobLogIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 清空按钮操作 */ /** 清空按钮操作 */
handleClean() { handleClean() {
this.$confirm("是否确认清空所有调度日志数据项?", "警告", { this.$modal.confirm('是否确认清空所有调度日志数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return cleanJobLog(); return cleanJobLog();
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("清空成功"); this.$modal.msgSuccess("清空成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm("是否确认导出所有调度日志数据项?", "警告", { this.$modal.confirm('是否确认导出所有调度日志数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportJobLog(queryParams); return exportJobLog(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
} }

View File

@ -198,42 +198,30 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const infoIds = row.infoId || this.ids; const infoIds = row.infoId || this.ids;
this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delLogininfor(infoIds); return delLogininfor(infoIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 清空按钮操作 */ /** 清空按钮操作 */
handleClean() { handleClean() {
this.$confirm('是否确认清空所有登录日志数据项?', "警告", { this.$modal.confirm('是否确认清空所有登录日志数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return cleanLogininfor(); return cleanLogininfor();
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("清空成功"); this.$modal.msgSuccess("清空成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有操作日志数据项?', "警告", { this.$modal.confirm('是否确认导出所有操作日志数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportLogininfor(queryParams); return exportLogininfor(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
} }

View File

@ -111,15 +111,11 @@ export default {
}, },
/** 强退按钮操作 */ /** 强退按钮操作 */
handleForceLogout(row) { handleForceLogout(row) {
this.$confirm('是否确认强退名称为"' + row.userName + '"的数据项?', "警告", { this.$modal.confirm('是否确认强退名称为"' + row.userName + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return forceLogout(row.tokenId); return forceLogout(row.tokenId);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("强退成功"); this.$modal.msgSuccess("强退成功");
}).catch(() => {}); }).catch(() => {});
} }
} }

View File

@ -285,42 +285,30 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const operIds = row.operId || this.ids; const operIds = row.operId || this.ids;
this.$confirm('是否确认删除日志编号为"' + operIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delOperlog(operIds); return delOperlog(operIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 清空按钮操作 */ /** 清空按钮操作 */
handleClean() { handleClean() {
this.$confirm('是否确认清空所有操作日志数据项?', "警告", { this.$modal.confirm('是否确认清空所有操作日志数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return cleanOperlog(); return cleanOperlog();
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("清空成功"); this.$modal.msgSuccess("清空成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有操作日志数据项?', "警告", { this.$modal.confirm('是否确认导出所有操作日志数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportOperlog(queryParams); return exportOperlog(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
} }

View File

@ -153,7 +153,7 @@
</tr> </tr>
</thead> </thead>
<tbody v-if="server.sysFiles"> <tbody v-if="server.sysFiles">
<tr v-for="sysFile in server.sysFiles"> <tr v-for="(sysFile, index) in server.sysFiles" :key="index">
<td><div class="cell">{{ sysFile.dirName }}</div></td> <td><div class="cell">{{ sysFile.dirName }}</div></td>
<td><div class="cell">{{ sysFile.sysTypeName }}</div></td> <td><div class="cell">{{ sysFile.sysTypeName }}</div></td>
<td><div class="cell">{{ sysFile.typeName }}</div></td> <td><div class="cell">{{ sysFile.typeName }}</div></td>
@ -178,8 +178,6 @@ export default {
name: "Server", name: "Server",
data() { data() {
return { return {
//
loading: [],
// //
server: [] server: []
}; };
@ -193,17 +191,12 @@ export default {
getList() { getList() {
getServer().then(response => { getServer().then(response => {
this.server = response.data; this.server = response.data;
this.loading.close(); this.$modal.closeLoading();
}); });
}, },
// //
openLoading() { openLoading() {
this.loading = this.$loading({ this.$modal.loading("正在加载服务监控数据,请稍后!");
lock: true,
text: "拼命读取中",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)"
});
} }
} }
}; };

View File

@ -308,13 +308,13 @@ export default {
if (valid) { if (valid) {
if (this.form.configId != undefined) { if (this.form.configId != undefined) {
updateConfig(this.form).then(response => { updateConfig(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addConfig(this.form).then(response => { addConfig(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -325,36 +325,28 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const configIds = row.configId || this.ids; const configIds = row.configId || this.ids;
this.$confirm('是否确认删除参数编号为"' + configIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delConfig(configIds); return delConfig(configIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有参数数据项?', "警告", { this.$modal.confirm('是否确认导出所有参数数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportConfig(queryParams); return exportConfig(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
}, },
/** 刷新缓存按钮操作 */ /** 刷新缓存按钮操作 */
handleRefreshCache() { handleRefreshCache() {
refreshCache().then(() => { refreshCache().then(() => {
this.msgSuccess("刷新成功"); this.$modal.msgSuccess("刷新成功");
}); });
} }
} }

View File

@ -305,13 +305,13 @@ export default {
if (valid) { if (valid) {
if (this.form.deptId != undefined) { if (this.form.deptId != undefined) {
updateDept(this.form).then(response => { updateDept(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addDept(this.form).then(response => { addDept(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -321,15 +321,11 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delDept(row.deptId); return delDept(row.deptId);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
} }
} }

View File

@ -354,13 +354,13 @@ export default {
if (valid) { if (valid) {
if (this.form.dictCode != undefined) { if (this.form.dictCode != undefined) {
updateData(this.form).then(response => { updateData(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addData(this.form).then(response => { addData(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -371,29 +371,21 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const dictCodes = row.dictCode || this.ids; const dictCodes = row.dictCode || this.ids;
this.$confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delData(dictCodes); return delData(dictCodes);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有数据项?', "警告", { this.$modal.confirm('是否确认导出所有数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportData(queryParams); return exportData(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
} }

View File

@ -312,13 +312,13 @@ export default {
if (valid) { if (valid) {
if (this.form.dictId != undefined) { if (this.form.dictId != undefined) {
updateType(this.form).then(response => { updateType(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addType(this.form).then(response => { addType(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -329,36 +329,28 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const dictIds = row.dictId || this.ids; const dictIds = row.dictId || this.ids;
this.$confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delType(dictIds); return delType(dictIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有类型数据项?', "警告", { this.$modal.confirm('是否确认导出所有类型数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportType(queryParams); return exportType(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
}, },
/** 刷新缓存按钮操作 */ /** 刷新缓存按钮操作 */
handleRefreshCache() { handleRefreshCache() {
refreshCache().then(() => { refreshCache().then(() => {
this.msgSuccess("刷新成功"); this.$modal.msgSuccess("刷新成功");
}); });
} }
} }

View File

@ -425,13 +425,13 @@ export default {
if (valid) { if (valid) {
if (this.form.menuId != undefined) { if (this.form.menuId != undefined) {
updateMenu(this.form).then(response => { updateMenu(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addMenu(this.form).then(response => { addMenu(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -441,15 +441,11 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$confirm('是否确认删除名称为"' + row.menuName + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除名称为"' + row.menuName + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delMenu(row.menuId); return delMenu(row.menuId);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
} }
} }

View File

@ -285,13 +285,13 @@ export default {
if (valid) { if (valid) {
if (this.form.noticeId != undefined) { if (this.form.noticeId != undefined) {
updateNotice(this.form).then(response => { updateNotice(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addNotice(this.form).then(response => { addNotice(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -302,15 +302,11 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const noticeIds = row.noticeId || this.ids const noticeIds = row.noticeId || this.ids
this.$confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delNotice(noticeIds); return delNotice(noticeIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
} }
} }

View File

@ -279,13 +279,13 @@ export default {
if (valid) { if (valid) {
if (this.form.postId != undefined) { if (this.form.postId != undefined) {
updatePost(this.form).then(response => { updatePost(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addPost(this.form).then(response => { addPost(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -296,29 +296,21 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const postIds = row.postId || this.ids; const postIds = row.postId || this.ids;
this.$confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delPost(postIds); return delPost(postIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有岗位数据项?', "警告", { this.$modal.confirm('是否确认导出所有岗位数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportPost(queryParams); return exportPost(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
} }

View File

@ -178,30 +178,22 @@ export default {
/** 取消授权按钮操作 */ /** 取消授权按钮操作 */
cancelAuthUser(row) { cancelAuthUser(row) {
const roleId = this.queryParams.roleId; const roleId = this.queryParams.roleId;
this.$confirm('确认要取消该用户"' + row.userName + '"角色吗?', "警告", { this.$modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return authUserCancel({ userId: row.userId, roleId: roleId }); return authUserCancel({ userId: row.userId, roleId: roleId });
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("取消授权成功"); this.$modal.msgSuccess("取消授权成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 批量取消授权按钮操作 */ /** 批量取消授权按钮操作 */
cancelAuthUserAll(row) { cancelAuthUserAll(row) {
const roleId = this.queryParams.roleId; const roleId = this.queryParams.roleId;
const userIds = this.userIds.join(","); const userIds = this.userIds.join(",");
this.$confirm('是否取消选中用户授权数据项?', "警告", { this.$modal.confirm('是否取消选中用户授权数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
return authUserCancelAll({ roleId: roleId, userIds: userIds }); return authUserCancelAll({ roleId: roleId, userIds: userIds });
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("取消授权成功"); this.$modal.msgSuccess("取消授权成功");
}).catch(() => {}); }).catch(() => {});
} }
} }

View File

@ -413,14 +413,10 @@ export default {
// //
handleStatusChange(row) { handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"; let text = row.status === "0" ? "启用" : "停用";
this.$confirm('确认要"' + text + '""' + row.roleName + '"角色吗?', "警告", { this.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return changeRoleStatus(row.roleId, row.status); return changeRoleStatus(row.roleId, row.status);
}).then(() => { }).then(() => {
this.msgSuccess(text + "成功"); this.$modal.msgSuccess(text + "成功");
}).catch(function() { }).catch(function() {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0";
}); });
@ -579,14 +575,14 @@ export default {
if (this.form.roleId != undefined) { if (this.form.roleId != undefined) {
this.form.menuIds = this.getMenuAllCheckedKeys(); this.form.menuIds = this.getMenuAllCheckedKeys();
updateRole(this.form).then(response => { updateRole(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
this.form.menuIds = this.getMenuAllCheckedKeys(); this.form.menuIds = this.getMenuAllCheckedKeys();
addRole(this.form).then(response => { addRole(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -599,7 +595,7 @@ export default {
if (this.form.roleId != undefined) { if (this.form.roleId != undefined) {
this.form.deptIds = this.getDeptAllCheckedKeys(); this.form.deptIds = this.getDeptAllCheckedKeys();
dataScope(this.form).then(response => { dataScope(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.openDataScope = false; this.openDataScope = false;
this.getList(); this.getList();
}); });
@ -608,29 +604,21 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const roleIds = row.roleId || this.ids; const roleIds = row.roleId || this.ids;
this.$confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delRole(roleIds); return delRole(roleIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有角色数据项?', "警告", { this.$modal.confirm('是否确认导出所有用户数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportRole(queryParams); return exportRole(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
} }

View File

@ -124,7 +124,7 @@ export default {
const roleId = this.queryParams.roleId; const roleId = this.queryParams.roleId;
const userIds = this.userIds.join(","); const userIds = this.userIds.join(",");
authUserSelectAll({ roleId: roleId, userIds: userIds }).then(res => { authUserSelectAll({ roleId: roleId, userIds: userIds }).then(res => {
this.msgSuccess(res.msg); this.$modal.msgSuccess(res.msg);
if (res.code === 200) { if (res.code === 200) {
this.visible = false; this.visible = false;
this.$emit("ok"); this.$emit("ok");

View File

@ -103,7 +103,7 @@ export default {
const userId = this.form.userId; const userId = this.form.userId;
const roleIds = this.roleIds.join(","); const roleIds = this.roleIds.join(",");
updateAuthRole({ userId: userId, roleIds: roleIds }).then((response) => { updateAuthRole({ userId: userId, roleIds: roleIds }).then((response) => {
this.msgSuccess("授权成功"); this.$modal.msgSuccess("授权成功");
this.close(); this.close();
}); });
}, },

View File

@ -503,14 +503,10 @@ export default {
// //
handleStatusChange(row) { handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"; let text = row.status === "0" ? "启用" : "停用";
this.$confirm('确认要"' + text + '""' + row.userName + '"用户吗?', "警告", { this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return changeUserStatus(row.userId, row.status); return changeUserStatus(row.userId, row.status);
}).then(() => { }).then(() => {
this.msgSuccess(text + "成功"); this.$modal.msgSuccess(text + "成功");
}).catch(function() { }).catch(function() {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0";
}); });
@ -606,7 +602,7 @@ export default {
inputErrorMessage: "用户密码长度必须介于 5 和 20 之间", inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
}).then(({ value }) => { }).then(({ value }) => {
resetUserPwd(row.userId, value).then(response => { resetUserPwd(row.userId, value).then(response => {
this.msgSuccess("修改成功,新密码是:" + value); this.$modal.msgSuccess("修改成功,新密码是:" + value);
}); });
}).catch(() => {}); }).catch(() => {});
}, },
@ -621,13 +617,13 @@ export default {
if (valid) { if (valid) {
if (this.form.userId != undefined) { if (this.form.userId != undefined) {
updateUser(this.form).then(response => { updateUser(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addUser(this.form).then(response => { addUser(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -638,29 +634,21 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const userIds = row.userId || this.ids; const userIds = row.userId || this.ids;
this.$confirm('是否确认删除用户编号为"' + userIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delUser(userIds); return delUser(userIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有用户数据项?', "警告", { this.$modal.confirm('是否确认导出所有用户数据项?').then(() => {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportUser(queryParams); return exportUser(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
}, },
@ -672,7 +660,7 @@ export default {
/** 下载模板操作 */ /** 下载模板操作 */
importTemplate() { importTemplate() {
importTemplate().then(response => { importTemplate().then(response => {
this.download(response.msg); this.$download.name(response.msg);
}); });
}, },
// //

View File

@ -57,7 +57,7 @@ export default {
if (valid) { if (valid) {
updateUserPwd(this.user.oldPassword, this.user.newPassword).then( updateUserPwd(this.user.oldPassword, this.user.newPassword).then(
response => { response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
} }
); );
} }

View File

@ -110,7 +110,7 @@ export default {
// //
beforeUpload(file) { beforeUpload(file) {
if (file.type.indexOf("image/") == -1) { if (file.type.indexOf("image/") == -1) {
this.msgError("文件格式错误,请上传图片类型,如JPGPNG后缀的文件。"); this.$modal.msgError("文件格式错误,请上传图片类型,如JPGPNG后缀的文件。");
} else { } else {
const reader = new FileReader(); const reader = new FileReader();
reader.readAsDataURL(file); reader.readAsDataURL(file);
@ -128,7 +128,7 @@ export default {
this.open = false; this.open = false;
this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl; this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl;
store.commit('SET_AVATAR', this.options.img); store.commit('SET_AVATAR', this.options.img);
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.visible = false; this.visible = false;
}); });
}); });

View File

@ -62,7 +62,7 @@ export default {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
updateUserProfile(this.user).then(response => { updateUserProfile(this.user).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
}); });
} }
}); });

View File

@ -137,23 +137,13 @@
<script> <script>
import draggable from 'vuedraggable' import draggable from 'vuedraggable'
import { saveAs } from 'file-saver'
import beautifier from 'js-beautify' import beautifier from 'js-beautify'
import ClipboardJS from 'clipboard' import ClipboardJS from 'clipboard'
import render from '@/utils/generator/render' import render from '@/utils/generator/render'
import RightPanel from './RightPanel' import RightPanel from './RightPanel'
import { import { inputComponents, selectComponents, layoutComponents, formConf } from '@/utils/generator/config'
inputComponents, import { beautifierConf, titleCase } from '@/utils/index'
selectComponents, import { makeUpHtml, vueTemplate, vueScript, cssStyle } from '@/utils/generator/html'
layoutComponents,
formConf
} from '@/utils/generator/config'
import {
exportDefault, beautifierConf, isNumberStr, titleCase
} from '@/utils/index'
import {
makeUpHtml, vueTemplate, vueScript, cssStyle
} from '@/utils/generator/html'
import { makeUpJs } from '@/utils/generator/js' import { makeUpJs } from '@/utils/generator/js'
import { makeUpCss } from '@/utils/generator/css' import { makeUpCss } from '@/utils/generator/css'
import drawingDefalut from '@/utils/generator/drawingDefalut' import drawingDefalut from '@/utils/generator/drawingDefalut'
@ -161,7 +151,6 @@ import logo from '@/assets/logo/logo.png'
import CodeTypeDialog from './CodeTypeDialog' import CodeTypeDialog from './CodeTypeDialog'
import DraggableItem from './DraggableItem' import DraggableItem from './DraggableItem'
const emptyActiveData = { style: {}, autosize: {} }
let oldActiveId let oldActiveId
let tempActiveData let tempActiveData
@ -287,7 +276,7 @@ export default {
execDownload(data) { execDownload(data) {
const codeStr = this.generateCode() const codeStr = this.generateCode()
const blob = new Blob([codeStr], { type: 'text/plain;charset=utf-8' }) const blob = new Blob([codeStr], { type: 'text/plain;charset=utf-8' })
saveAs(blob, data.fileName) this.$download.saveAs(blob, data.fileName)
}, },
execCopy(data) { execCopy(data) {
document.getElementById('copyNode').click() document.getElementById('copyNode').click()

View File

@ -4,8 +4,8 @@
<el-tab-pane label="基本信息" name="basic"> <el-tab-pane label="基本信息" name="basic">
<basic-info-form ref="basicInfo" :info="info" /> <basic-info-form ref="basicInfo" :info="info" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="字段信息" name="cloum"> <el-tab-pane label="字段信息" name="columnInfo">
<el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight"> <el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight">
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" /> <el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" />
<el-table-column <el-table-column
label="字段列名" label="字段列名"
@ -141,13 +141,13 @@ export default {
data() { data() {
return { return {
// name // name
activeName: "cloum", activeName: "columnInfo",
// //
tableHeight: document.documentElement.scrollHeight - 245 + "px", tableHeight: document.documentElement.scrollHeight - 245 + "px",
// //
tables: [], tables: [],
// //
cloumns: [], columns: [],
// //
dictOptions: [], dictOptions: [],
// //
@ -161,7 +161,7 @@ export default {
if (tableId) { if (tableId) {
// //
getGenTable(tableId).then(res => { getGenTable(tableId).then(res => {
this.cloumns = res.data.rows; this.columns = res.data.rows;
this.info = res.data.info; this.info = res.data.info;
this.tables = res.data.tables; this.tables = res.data.tables;
}); });
@ -184,7 +184,7 @@ export default {
const validateResult = res.every(item => !!item); const validateResult = res.every(item => !!item);
if (validateResult) { if (validateResult) {
const genTable = Object.assign({}, basicForm.model, genForm.model); const genTable = Object.assign({}, basicForm.model, genForm.model);
genTable.columns = this.cloumns; genTable.columns = this.columns;
genTable.params = { genTable.params = {
treeCode: genTable.treeCode, treeCode: genTable.treeCode,
treeName: genTable.treeName, treeName: genTable.treeName,
@ -192,13 +192,13 @@ export default {
parentMenuId: genTable.parentMenuId parentMenuId: genTable.parentMenuId
}; };
updateGenTable(genTable).then(res => { updateGenTable(genTable).then(res => {
this.msgSuccess(res.msg); this.$modal.msgSuccess(res.msg);
if (res.code === 200) { if (res.code === 200) {
this.close(); this.close();
} }
}); });
} else { } else {
this.msgError("表单校验未通过,请重新检查提交内容"); this.$modal.msgError("表单校验未通过,请重新检查提交内容");
} }
}); });
}, },
@ -220,10 +220,10 @@ export default {
const sortable = Sortable.create(el, { const sortable = Sortable.create(el, {
handle: ".allowDrag", handle: ".allowDrag",
onEnd: evt => { onEnd: evt => {
const targetRow = this.cloumns.splice(evt.oldIndex, 1)[0]; const targetRow = this.columns.splice(evt.oldIndex, 1)[0];
this.cloumns.splice(evt.newIndex, 0, targetRow); this.columns.splice(evt.newIndex, 0, targetRow);
for (let index in this.cloumns) { for (let index in this.columns) {
this.cloumns[index].sort = parseInt(index) + 1; this.columns[index].sort = parseInt(index) + 1;
} }
} }
}); });

View File

@ -104,8 +104,13 @@ export default {
}, },
/** 导入按钮操作 */ /** 导入按钮操作 */
handleImportTable() { handleImportTable() {
importTable({ tables: this.tables.join(",") }).then(res => { const tableNames = this.tables.join(",");
this.msgSuccess(res.msg); if (tableNames == "") {
this.$modal.msgError("请选择要导入的表");
return;
}
importTable({ tables: tableNames }).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) { if (res.code === 200) {
this.visible = false; this.visible = false;
this.$emit("ok"); this.$emit("ok");

View File

@ -180,7 +180,6 @@
<script> <script>
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
import importTable from "./importTable"; import importTable from "./importTable";
import { downLoadZip } from "@/utils/zipdownload";
import hljs from "highlight.js/lib/highlight"; import hljs from "highlight.js/lib/highlight";
import "highlight.js/styles/github-gist.css"; import "highlight.js/styles/github-gist.css";
hljs.registerLanguage("java", require("highlight.js/lib/languages/java")); hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
@ -262,28 +261,24 @@ export default {
handleGenTable(row) { handleGenTable(row) {
const tableNames = row.tableName || this.tableNames; const tableNames = row.tableName || this.tableNames;
if (tableNames == "") { if (tableNames == "") {
this.msgError("请选择要生成的数据"); this.$modal.msgError("请选择要生成的数据");
return; return;
} }
if(row.genType === "1") { if(row.genType === "1") {
genCode(row.tableName).then(response => { genCode(row.tableName).then(response => {
this.msgSuccess("成功生成到自定义路径:" + row.genPath); this.$modal.msgSuccess("成功生成到自定义路径:" + row.genPath);
}); });
} else { } else {
downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi"); this.$download.zip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
} }
}, },
/** 同步数据库操作 */ /** 同步数据库操作 */
handleSynchDb(row) { handleSynchDb(row) {
const tableName = row.tableName; const tableName = row.tableName;
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?', "警告", { this.$modal.confirm('确认要强制同步"' + tableName + '"表结构吗?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return synchDb(tableName); return synchDb(tableName);
}).then(() => { }).then(() => {
this.msgSuccess("同步成功"); this.$modal.msgSuccess("同步成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 打开导入表弹窗 */ /** 打开导入表弹窗 */
@ -301,6 +296,7 @@ export default {
previewTable(row.tableId).then(response => { previewTable(row.tableId).then(response => {
this.preview.data = response.data; this.preview.data = response.data;
this.preview.open = true; this.preview.open = true;
this.preview.activeName = "domain.java";
}); });
}, },
/** 高亮显示 */ /** 高亮显示 */
@ -325,15 +321,11 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const tableIds = row.tableId || this.ids; const tableIds = row.tableId || this.ids;
this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", { this.$modal.confirm('是否确认删除表编号为"' + tableIds + '"的数据项?').then(function() {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delTable(tableIds); return delTable(tableIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
} }
} }