Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

wangt 1 rok temu
rodzic
commit
37172bd30c
26 zmienionych plików z 251 dodań i 160 usunięć
  1. 4 1
      backend/src/main/java/com/jiayue/ssi/annotation/OperateLog.java
  2. 2 0
      backend/src/main/java/com/jiayue/ssi/aspectj/OperateLogAspect.java
  3. 20 0
      backend/src/main/java/com/jiayue/ssi/backenum/BusinessType.java
  4. 3 1
      backend/src/main/java/com/jiayue/ssi/config/MyAuthenticationProvider.java
  5. 2 1
      backend/src/main/java/com/jiayue/ssi/controller/ElectricFieldController.java
  6. 4 0
      backend/src/main/java/com/jiayue/ssi/controller/ForecastPowerShortTermController.java
  7. 3 2
      backend/src/main/java/com/jiayue/ssi/controller/IpBlacklistController.java
  8. 4 0
      backend/src/main/java/com/jiayue/ssi/controller/NwpController.java
  9. 4 0
      backend/src/main/java/com/jiayue/ssi/controller/ServerController.java
  10. 5 0
      backend/src/main/java/com/jiayue/ssi/controller/SysAlarmController.java
  11. 2 1
      backend/src/main/java/com/jiayue/ssi/controller/SysApproveController.java
  12. 4 2
      backend/src/main/java/com/jiayue/ssi/controller/SysLogininforController.java
  13. 6 3
      backend/src/main/java/com/jiayue/ssi/controller/SysMenuController.java
  14. 4 2
      backend/src/main/java/com/jiayue/ssi/controller/SysOperlogController.java
  15. 4 3
      backend/src/main/java/com/jiayue/ssi/controller/SysParameterController.java
  16. 2 1
      backend/src/main/java/com/jiayue/ssi/controller/SysPolicyController.java
  17. 6 3
      backend/src/main/java/com/jiayue/ssi/controller/SysRoleController.java
  18. 11 8
      backend/src/main/java/com/jiayue/ssi/controller/SysUserController.java
  19. 3 0
      backend/src/main/java/com/jiayue/ssi/controller/UserLoginController.java
  20. 11 0
      backend/src/main/java/com/jiayue/ssi/entity/SysOperLog.java
  21. 1 1
      backend/src/main/java/com/jiayue/ssi/filter/MailCodeFilter.java
  22. 2 1
      backend/src/main/java/com/jiayue/ssi/filter/VerifyCodeFilter.java
  23. 24 18
      backend/src/main/java/com/jiayue/ssi/filter/VerifySmFilter.java
  24. 14 8
      backend/src/test/java/com/jiayue/ssi/service/Sm2UiTest.java
  25. 50 53
      ui/src/App.vue
  26. 56 51
      ui/src/views/bizManager/electricField/index.vue

+ 4 - 1
backend/src/main/java/com/jiayue/ssi/annotation/OperateLog.java

@@ -26,7 +26,10 @@ public @interface OperateLog
      * 功能
      */
     public BusinessType businessType() default BusinessType.OTHER;
-
+    /**
+     * 操作描述
+     */
+    public String operdesc() default "";
     /**
      * 审计类型
      */

+ 2 - 0
backend/src/main/java/com/jiayue/ssi/aspectj/OperateLogAspect.java

@@ -141,6 +141,8 @@ public class OperateLogAspect {
         operLog.setBusinessType(log.businessType().ordinal());
         // 设置标题
         operLog.setTitle(log.title());
+        // 操作描述
+        operLog.setOperdesc(log.operdesc());
         // 审计类型
         operLog.setAuditType(log.auditType().ordinal());
         // 设置操作人类别

+ 20 - 0
backend/src/main/java/com/jiayue/ssi/backenum/BusinessType.java

@@ -8,9 +8,21 @@ package com.jiayue.ssi.backenum;
 public enum BusinessType
 {
     /**
+     * 查询
+     */
+    QUERY,
+    /**
+     * 解锁
+     */
+    UNLOCK,
+    /**
      * 其它
      */
     OTHER,
+    /**
+     * 初始/重置密码
+     */
+    RESETPWD,
 
     /**
      * 新增
@@ -21,6 +33,10 @@ public enum BusinessType
      * 修改
      */
     UPDATE,
+    /**
+     * 个人密码修改
+     */
+    PWDUPDATE,
 
     /**
      * 删除
@@ -31,6 +47,10 @@ public enum BusinessType
      * 授权
      */
     GRANT,
+    /**
+     * 获取角色信息
+     */
+    GETROLE,
 
     /**
      * 导出

+ 3 - 1
backend/src/main/java/com/jiayue/ssi/config/MyAuthenticationProvider.java

@@ -3,6 +3,7 @@ package com.jiayue.ssi.config;
 import cn.hutool.crypto.SmUtil;
 import com.jiayue.ssi.constant.SecretKeyConstants;
 import com.jiayue.ssi.util.SM2CryptUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
@@ -18,6 +19,7 @@ import javax.annotation.Resource;
 * @author xsl
 * @since 2023/03/13
 */
+@Slf4j
 public class MyAuthenticationProvider extends DaoAuthenticationProvider {
 
     @Resource
@@ -36,7 +38,7 @@ public class MyAuthenticationProvider extends DaoAuthenticationProvider {
             try {
                 decryptPassword= SmUtil.sm3(presentedPassword).toUpperCase();
             } catch (Exception e) {
-                e.printStackTrace();
+                log.error("用户密码解密错误,无法登录!");
             }
 //            if (!this.passwordEncoder.matches(decryptPassword, userDetails.getPassword())) {
 //                this.logger.debug("Authentication failed: password does not match stored value");

+ 2 - 1
backend/src/main/java/com/jiayue/ssi/controller/ElectricFieldController.java

@@ -37,6 +37,7 @@ public class ElectricFieldController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('biz:electric:getAll')")
+    @OperateLog(title = "场站管理", businessType = BusinessType.QUERY, auditType = AuditType.BIZ,operdesc = "查询场站信息")
     @PreventReplay
     public ResponseVO getAll() throws CustomException {
         try {
@@ -51,7 +52,7 @@ public class ElectricFieldController {
      * 保存场站
      */
     @PostMapping
-    @OperateLog(title = "场站信息", businessType = BusinessType.UPDATE, auditType = AuditType.BIZ)
+    @OperateLog(title = "场站信息", businessType = BusinessType.UPDATE, auditType = AuditType.BIZ,operdesc = "保存场站信息")
     @PreAuthorize("@ss.hasPermi('biz:electric:update')")
     @PreventReplay
     public ResponseVO update(@RequestBody ElectricField electricField) throws CustomException {

+ 4 - 0
backend/src/main/java/com/jiayue/ssi/controller/ForecastPowerShortTermController.java

@@ -3,7 +3,10 @@ package com.jiayue.ssi.controller;
 import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jiayue.ssi.annotation.OperateLog;
 import com.jiayue.ssi.annotation.PreventReplay;
+import com.jiayue.ssi.backenum.AuditType;
+import com.jiayue.ssi.backenum.BusinessType;
 import com.jiayue.ssi.constant.CustomException;
 import com.jiayue.ssi.entity.*;
 import com.jiayue.ssi.service.*;
@@ -39,6 +42,7 @@ public class ForecastPowerShortTermController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('biz:dq:getAll')")
+    @OperateLog(title = "短期预测", businessType = BusinessType.QUERY, auditType = AuditType.BIZ,operdesc = "查询短期预测数据")
     @PreventReplay
     public ResponseVO getAll(String currentPage, String pageSize, String startTime, String endTime) throws CustomException {
         try {

+ 3 - 2
backend/src/main/java/com/jiayue/ssi/controller/IpBlacklistController.java

@@ -42,6 +42,7 @@ public class IpBlacklistController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('system:ipblacklist:list')")
+    @OperateLog(title = "短期预测", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "查询黑名单列表")
     @PreventReplay
     public ResponseVO getAll(String currentPage, String pageSize, String ip) throws CustomException {
         try {
@@ -89,7 +90,7 @@ public class IpBlacklistController {
      * 新增ip
      */
     @PostMapping(value = "/addIp")
-    @OperateLog(title = "黑名单管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS)
+    @OperateLog(title = "黑名单管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS,operdesc = "新增黑名单")
     @PreAuthorize("@ss.hasPermi('system:ipblacklist:add')")
     @PreventReplay
     public ResponseVO addIp(@RequestBody SysBlacklist sysBlacklist) throws CustomException {
@@ -125,7 +126,7 @@ public class IpBlacklistController {
      * 删除用户信息
      */
     @PostMapping(value = "/delIp")
-    @OperateLog(title = "黑名单管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS)
+    @OperateLog(title = "黑名单管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS,operdesc = "删除黑名单")
     @PreAuthorize("@ss.hasPermi('system:ipblacklist:remove')")
     @PreventReplay
     public ResponseVO delIp(String id) throws CustomException {

+ 4 - 0
backend/src/main/java/com/jiayue/ssi/controller/NwpController.java

@@ -3,7 +3,10 @@ package com.jiayue.ssi.controller;
 import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jiayue.ssi.annotation.OperateLog;
 import com.jiayue.ssi.annotation.PreventReplay;
+import com.jiayue.ssi.backenum.AuditType;
+import com.jiayue.ssi.backenum.BusinessType;
 import com.jiayue.ssi.constant.CustomException;
 import com.jiayue.ssi.entity.Nwp;
 import com.jiayue.ssi.service.NwpService;
@@ -42,6 +45,7 @@ public class NwpController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('biz:nwp:getAll')")
+    @OperateLog(title = "NWP预测", businessType = BusinessType.QUERY, auditType = AuditType.BIZ,operdesc = "查询NWP预测数据")
     @PreventReplay
     public ResponseVO getAll(String currentPage, String pageSize, String startTime, String endTime) throws CustomException {
         try {

+ 4 - 0
backend/src/main/java/com/jiayue/ssi/controller/ServerController.java

@@ -1,6 +1,9 @@
 package com.jiayue.ssi.controller;
 
+import com.jiayue.ssi.annotation.OperateLog;
 import com.jiayue.ssi.annotation.PreventReplay;
+import com.jiayue.ssi.backenum.AuditType;
+import com.jiayue.ssi.backenum.BusinessType;
 import com.jiayue.ssi.constant.CustomException;
 import com.jiayue.ssi.entity.Server;
 import com.jiayue.ssi.util.ResponseVO;
@@ -22,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
 public class ServerController {
     @PreAuthorize("@ss.hasPermi('monitor:server:list')")
     @GetMapping()
+    @OperateLog(title = "服务监控", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取服务监控信息")
     @PreventReplay
     public ResponseVO getInfo() throws CustomException {
         try {

+ 5 - 0
backend/src/main/java/com/jiayue/ssi/controller/SysAlarmController.java

@@ -2,7 +2,10 @@ package com.jiayue.ssi.controller;
 
 import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.jiayue.ssi.annotation.OperateLog;
 import com.jiayue.ssi.annotation.PreventReplay;
+import com.jiayue.ssi.backenum.AuditType;
+import com.jiayue.ssi.backenum.BusinessType;
 import com.jiayue.ssi.constant.CustomException;
 import com.jiayue.ssi.entity.SysAlarm;
 import com.jiayue.ssi.service.SysAlarmService;
@@ -32,6 +35,7 @@ public class SysAlarmController {
      * @return
      */
     @GetMapping(value = "/getAll")
+    @OperateLog(title = "告警管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取告警信息列表")
     @PreventReplay
     public ResponseVO getAll() throws CustomException {
         try {
@@ -48,6 +52,7 @@ public class SysAlarmController {
      * 查收提交
      */
     @PostMapping(value = "/readDone")
+    @OperateLog(title = "告警管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS,operdesc = "查收告警信息")
     @PreventReplay
     public ResponseVO readDone(String id) throws CustomException {
         try {

+ 2 - 1
backend/src/main/java/com/jiayue/ssi/controller/SysApproveController.java

@@ -50,6 +50,7 @@ public class SysApproveController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('approveManager:approve:list')")
+    @OperateLog(title = "审核管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "查询审核列表")
     @PreventReplay
     public ResponseVO getAll(String currentPage, String pageSize, String approveStatus, String approveResult) throws CustomException {
         try {
@@ -235,7 +236,7 @@ public class SysApproveController {
      * 审批结果提交
      */
     @PostMapping(value = "/submitApprove")
-    @OperateLog(title = "审核管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS)
+    @OperateLog(title = "审核管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS,operdesc = "审核结果提交")
     @PreAuthorize("@ss.hasPermi('approveManager:approve:submitApprove')")
     @PreventReplay
     public ResponseVO submitApprove(@RequestBody SysApprove sysApprove) throws CustomException {

+ 4 - 2
backend/src/main/java/com/jiayue/ssi/controller/SysLogininforController.java

@@ -41,6 +41,7 @@ public class SysLogininforController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('auditManager:logininfor:list')")
+    @OperateLog(title = "登录日志", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "查询登录日志")
     @PreventReplay
     public ResponseVO getAll(String currentPage, String pageSize, String ipaddr, String userName,
                              String status, String startLoginTime, String endLoginTime, String sortOrder) throws CustomException {
@@ -125,7 +126,7 @@ public class SysLogininforController {
      * 删除登录信息
      */
     @PostMapping(value = "/delLoginInfo")
-    @OperateLog(title = "登录日志", businessType = BusinessType.DELETE, auditType = AuditType.SYS)
+    @OperateLog(title = "登录日志", businessType = BusinessType.DELETE, auditType = AuditType.SYS,operdesc = "删除登录日志")
     @PreAuthorize("@ss.hasPermi('auditManager:logininfor:remove')")
     public ResponseVO delLoginInfo(String infoId) throws CustomException {
         try {
@@ -149,7 +150,7 @@ public class SysLogininforController {
      * 清空登录信息
      */
     @PostMapping("/cleanLogininfor")
-    @OperateLog(title = "登录日志", businessType = BusinessType.CLEAN, auditType = AuditType.SYS)
+    @OperateLog(title = "登录日志", businessType = BusinessType.CLEAN, auditType = AuditType.SYS,operdesc = "清空登录日志")
     @PreAuthorize("@ss.hasPermi('auditManager:logininfor:remove')")
     public ResponseVO cleanLogininfor() throws CustomException {
         try {
@@ -172,6 +173,7 @@ public class SysLogininforController {
      */
     @GetMapping(value = "/logininforTotal")
     @PreAuthorize("@ss.hasPermi('auditManager:logininforTotal:list')")
+    @OperateLog(title = "登录日志", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "查询统计登录日志")
     @PreventReplay
     public ResponseVO logininforTotal(String startLoginTime, String endLoginTime) throws CustomException {
         try {

+ 6 - 3
backend/src/main/java/com/jiayue/ssi/controller/SysMenuController.java

@@ -45,6 +45,7 @@ public class SysMenuController {
      */
     @GetMapping("/list")
     @PreAuthorize("@ss.hasPermi('system:menu:list')")
+    @OperateLog(title = "菜单管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "查询菜单")
     @PreventReplay
     public ResponseVO list(SysMenu menu) throws CustomException {
         try {
@@ -64,7 +65,7 @@ public class SysMenuController {
      * 新增菜单
      */
     @PostMapping(value = "/addMenu")
-    @OperateLog(title = "菜单管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS)
+    @OperateLog(title = "菜单管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS,operdesc = "新增菜单")
     @PreAuthorize("@ss.hasPermi('system:menu:add')")
     @PreventReplay
     public ResponseVO addMenu(@RequestBody SysMenu menu) throws CustomException {
@@ -137,7 +138,7 @@ public class SysMenuController {
      * @return 执行结果
      */
     @PostMapping(value = "/updateMenu")
-    @OperateLog(title = "菜单管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS)
+    @OperateLog(title = "菜单管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS,operdesc = "修改菜单")
     @PreAuthorize("@ss.hasPermi('system:menu:edit')")
     @PreventReplay
     public ResponseVO updateMenu(@RequestBody SysMenu menu) throws CustomException {
@@ -211,6 +212,7 @@ public class SysMenuController {
      * 根据菜单编号获取详细信息
      */
     @GetMapping(value = "/{getDetailInfo}")
+    @OperateLog(title = "菜单管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取菜单详细信息")
     @PreventReplay
     public ResponseVO getDetailInfo(String menuId) throws CustomException {
         try {
@@ -237,7 +239,7 @@ public class SysMenuController {
      * 删除菜单信息
      */
     @PostMapping(value = "delMenu")
-    @OperateLog(title = "菜单管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS)
+    @OperateLog(title = "菜单管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS,operdesc = "删除菜单")
     @PreAuthorize("@ss.hasPermi('system:menu:remove')")
     @PreventReplay
     public ResponseVO delMenu(String menuId) throws CustomException {
@@ -285,6 +287,7 @@ public class SysMenuController {
      * 加载对应角色菜单列表树
      */
     @GetMapping(value = "/roleMenuTreeselect")
+    @OperateLog(title = "菜单管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取角色菜单列表")
     @PreventReplay
     public ResponseVO roleMenuTreeselect(String roleId) throws CustomException {
         try {

+ 4 - 2
backend/src/main/java/com/jiayue/ssi/controller/SysOperlogController.java

@@ -79,6 +79,7 @@ public class SysOperlogController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('auditManager:operlog:list')")
+    @OperateLog(title = "操作日志", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "查询操作日志")
     @PreventReplay
     public ResponseVO getAll(String currentPage, String pageSize, String title, String operName, String auditType,
                              String businessType, String status, String startOperTime, String endOperTime, String sortOrder) throws CustomException {
@@ -174,7 +175,7 @@ public class SysOperlogController {
      * 删除登录信息
      */
     @PostMapping(value = "/delOperlog")
-    @OperateLog(title = "操作日志", businessType = BusinessType.DELETE, auditType = AuditType.SYS)
+    @OperateLog(title = "操作日志", businessType = BusinessType.DELETE, auditType = AuditType.SYS,operdesc = "删除操作日志")
     @PreAuthorize("@ss.hasPermi('auditManager:operlog:remove')")
     public ResponseVO delOperlog(String operId) throws CustomException {
         try {
@@ -197,7 +198,7 @@ public class SysOperlogController {
      * 操作日志清空
      */
     @PostMapping("/cleanOperLog")
-    @OperateLog(title = "操作日志", businessType = BusinessType.CLEAN, auditType = AuditType.SYS)
+    @OperateLog(title = "操作日志", businessType = BusinessType.CLEAN, auditType = AuditType.SYS,operdesc = "清空操作日志")
     @PreAuthorize("@ss.hasPermi('auditManager:operlog:remove')")
     public ResponseVO cleanOperLog() throws CustomException {
         try {
@@ -220,6 +221,7 @@ public class SysOperlogController {
      */
     @GetMapping(value = "/sysOperlogTotal")
     @PreAuthorize("@ss.hasPermi('auditManager:sysOperlogTotal:list')")
+    @OperateLog(title = "操作日志", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "查询统计操作日志")
     @PreventReplay
     public ResponseVO sysOperlogTotal(String startLoginTime, String endLoginTime) throws CustomException {
         try {

+ 4 - 3
backend/src/main/java/com/jiayue/ssi/controller/SysParameterController.java

@@ -40,7 +40,7 @@ public class SysParameterController {
      * @return 执行结果
      */
     @PostMapping(value = "/addParameter")
-    @OperateLog(title = "参数管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS)
+    @OperateLog(title = "参数管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS,operdesc = "新增参数信息")
     @PreAuthorize("@ss.hasPermi('system:config:add')")
     @PreventReplay
     public ResponseVO addParameter(@RequestBody SysParameter sysParameter) throws CustomException {
@@ -92,7 +92,7 @@ public class SysParameterController {
      * @return 执行结果
      */
     @PostMapping(value = "/updateParameter")
-    @OperateLog(title = "参数管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS)
+    @OperateLog(title = "参数管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS,operdesc = "修改参数信息")
     @PreAuthorize("@ss.hasPermi('system:config:edit')")
     @PreventReplay
     public ResponseVO updateParameter(@RequestBody SysParameter sysParameter) throws CustomException {
@@ -148,7 +148,7 @@ public class SysParameterController {
      * 删除用户信息
      */
     @PostMapping(value = "/deleteParameter")
-    @OperateLog(title = "参数管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS)
+    @OperateLog(title = "参数管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS,operdesc = "删除参数信息")
     @PreAuthorize("@ss.hasPermi('system:config:remove')")
     @PreventReplay
     public ResponseVO deleteParameter(String id) throws CustomException {
@@ -179,6 +179,7 @@ public class SysParameterController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('system:config:list')")
+    @OperateLog(title = "参数管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "查询参数信息")
     @PreventReplay
     public ResponseVO getAll(String currentPage, String pageSize, String keywords) throws CustomException {
         try {

+ 2 - 1
backend/src/main/java/com/jiayue/ssi/controller/SysPolicyController.java

@@ -41,6 +41,7 @@ public class SysPolicyController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('system:policy:getAll')")
+    @OperateLog(title = "策略配置", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取策略配置信息")
     @PreventReplay
     public ResponseVO getAll() throws CustomException {
         try {
@@ -55,7 +56,7 @@ public class SysPolicyController {
      * 保存策略配置
      */
     @PostMapping
-    @OperateLog(title = "策略配置", businessType = BusinessType.UPDATE, auditType = AuditType.SYS)
+    @OperateLog(title = "策略配置", businessType = BusinessType.UPDATE, auditType = AuditType.SYS,operdesc = "保存策略配置信息")
     @PreAuthorize("@ss.hasPermi('system:policy:update')")
     @PreventReplay
     public ResponseVO update(@RequestBody SysPolicy sysPolicy) throws CustomException {

+ 6 - 3
backend/src/main/java/com/jiayue/ssi/controller/SysRoleController.java

@@ -45,6 +45,7 @@ public class SysRoleController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('system:role:list')")
+    @OperateLog(title = "角色管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "角色查询")
     @PreventReplay
     public ResponseVO getAll(String currentPage, String pageSize, String roleName, String status, String roleKey) throws CustomException {
         try {
@@ -116,7 +117,7 @@ public class SysRoleController {
      * @return 执行结果
      */
     @PostMapping(value = "/addRole")
-    @OperateLog(title = "角色管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS)
+    @OperateLog(title = "角色管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS,operdesc = "新增角色")
     @PreAuthorize("@ss.hasPermi('system:role:add')")
     @PreventReplay
     public ResponseVO addRole(@RequestBody SysRole role) throws CustomException {
@@ -169,7 +170,7 @@ public class SysRoleController {
      * @return 执行结果
      */
     @PostMapping(value = "/updateRole")
-    @OperateLog(title = "角色管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS)
+    @OperateLog(title = "角色管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS,operdesc = "修改角色")
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @PreventReplay
     public ResponseVO updateRole(@RequestBody SysRole role) throws CustomException {
@@ -231,6 +232,7 @@ public class SysRoleController {
      * 根据角色编号获取详细信息
      */
     @GetMapping(value = "getInfo")
+    @OperateLog(title = "角色管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取角色详细信息")
     @PreventReplay
     public ResponseVO getInfo(String roleId) throws CustomException {
         try {
@@ -257,7 +259,7 @@ public class SysRoleController {
      * 删除角色
      */
     @PostMapping(value = "/delRole")
-    @OperateLog(title = "角色管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS)
+    @OperateLog(title = "角色管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS,operdesc = "删除角色")
     @PreAuthorize("@ss.hasPermi('system:role:remove')")
     @PreventReplay
     public ResponseVO delRole(String roleId) throws CustomException {
@@ -295,6 +297,7 @@ public class SysRoleController {
      */
     @GetMapping(value = "/getRoleByType")
     @PreAuthorize("@ss.hasPermi('system:user:role')")
+    @OperateLog(title = "角色管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取分配角色列表")
     @PreventReplay
     public ResponseVO getRoleByType(String usertype) throws CustomException {
         try {

+ 11 - 8
backend/src/main/java/com/jiayue/ssi/controller/SysUserController.java

@@ -64,6 +64,7 @@ public class SysUserController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('system:user:list')")
+    @OperateLog(title = "用户管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "用户查询")
     @PreventReplay
     public ResponseVO getAll(String username, String phonenumber,
                              String status) throws CustomException {
@@ -132,7 +133,7 @@ public class SysUserController {
      * 新增用户
      */
     @PostMapping(value = "/addUser")
-    @OperateLog(title = "用户管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS)
+    @OperateLog(title = "用户管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS,operdesc = "新增用户")
     @PreAuthorize("@ss.hasPermi('system:user:add')")
     @PreventReplay
     public ResponseVO addUser(@RequestBody SysUser user) throws CustomException {
@@ -260,7 +261,7 @@ public class SysUserController {
      */
     @PostMapping(value = "/updateUser")
     @AgainVerify
-    @OperateLog(title = "用户管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS)
+    @OperateLog(title = "用户管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS,operdesc = "修改用户")
     @PreAuthorize("@ss.hasPermi('system:user:edit')")
     @PreventReplay
     public ResponseVO updateUser(@RequestBody SysUser user) throws CustomException {
@@ -377,7 +378,7 @@ public class SysUserController {
      * 初始密码发送邮箱
      */
     @PostMapping(value = "/resetPassword")
-    @OperateLog(title = "用户管理", businessType = BusinessType.OTHER, auditType = AuditType.SYS)
+    @OperateLog(title = "用户管理", businessType = BusinessType.RESETPWD, auditType = AuditType.SYS,operdesc = "初始/重置密码发送邮箱")
     @PreAuthorize("@ss.hasPermi('system:user:send')")
     @PreventReplay
     public ResponseVO resetPassword(String id) {
@@ -430,7 +431,7 @@ public class SysUserController {
      */
     @PostMapping(value = "/delUser")
     @AgainVerify
-    @OperateLog(title = "用户管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS)
+    @OperateLog(title = "用户管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS,operdesc = "删除用户")
     @PreAuthorize("@ss.hasPermi('system:user:remove')")
     @PreventReplay
     public ResponseVO delete(String id) throws CustomException {
@@ -473,7 +474,7 @@ public class SysUserController {
      * 修改密码
      */
     @PostMapping(value = "/updatePassword")
-    @OperateLog(title = "用户管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS)
+    @OperateLog(title = "用户管理", businessType = BusinessType.PWDUPDATE, auditType = AuditType.SYS,operdesc = "修改个人密码")
     @PreventReplay
     public ResponseVO updatePassword(String id, String oldPassword, String newPassword, String confirmPassword) throws CustomException {
         try {
@@ -557,7 +558,7 @@ public class SysUserController {
      * 解锁用户信息
      */
     @PostMapping(value = "/relockUser")
-    @OperateLog(title = "用户管理", businessType = BusinessType.OTHER, auditType = AuditType.SYS)
+    @OperateLog(title = "用户管理", businessType = BusinessType.UNLOCK, auditType = AuditType.SYS,operdesc = "用户账号解锁")
     @PreAuthorize("@ss.hasPermi('system:user:relock')")
     @PreventReplay
     public ResponseVO relockUser(String id) throws CustomException {
@@ -603,7 +604,7 @@ public class SysUserController {
      */
     @PostMapping("/authRole")
     @PreAuthorize("@ss.hasPermi('system:user:role')")
-    @OperateLog(title = "用户管理", businessType = BusinessType.GRANT, auditType = AuditType.SYS)
+    @OperateLog(title = "用户管理", businessType = BusinessType.GRANT, auditType = AuditType.SYS,operdesc = "用户授权角色")
     @PreventReplay
     public ResponseVO authRole(String userId, String roleId) throws CustomException {
         try {
@@ -667,6 +668,7 @@ public class SysUserController {
      * @return
      */
     @GetMapping("/getUserRole")
+    @OperateLog(title = "用户管理", businessType = BusinessType.GETROLE, auditType = AuditType.SYS,operdesc = "获取授权角色信息")
     @PreventReplay
     public ResponseVO getUserRole(Long userId) throws CustomException {
         try {
@@ -705,7 +707,7 @@ public class SysUserController {
      */
     @PostMapping(value = "/logOffUser")
     @AgainVerify
-    @OperateLog(title = "用户管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS)
+    @OperateLog(title = "用户管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS,operdesc = "注销用户账号")
     @PreAuthorize("@ss.hasPermi('system:user:logoff')")
     @PreventReplay
     public ResponseVO logOffUser(String id) throws CustomException {
@@ -767,6 +769,7 @@ public class SysUserController {
      */
     @GetMapping(value = "/getUserByHealthy")
     @PreAuthorize("@ss.hasPermi('monitor:onLine:list')")
+    @OperateLog(title = "在线用户管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "在线用户查询")
     @PreventReplay
     public ResponseVO getUserByHealthy(String currentPage, String pageSize, String onLineStatus) throws CustomException {
         try {

+ 3 - 0
backend/src/main/java/com/jiayue/ssi/controller/UserLoginController.java

@@ -1,6 +1,9 @@
 package com.jiayue.ssi.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.jiayue.ssi.annotation.OperateLog;
+import com.jiayue.ssi.backenum.AuditType;
+import com.jiayue.ssi.backenum.BusinessType;
 import com.jiayue.ssi.config.SendMailUtil;
 import com.jiayue.ssi.constant.CacheConstants;
 import com.jiayue.ssi.constant.CustomException;

+ 11 - 0
backend/src/main/java/com/jiayue/ssi/entity/SysOperLog.java

@@ -32,6 +32,17 @@ public class SysOperLog extends BaseEntity {
     @TableField(exist = false)
     private Integer[] businessTypes;
 
+    public String getOperdesc() {
+        return operdesc;
+    }
+
+    public void setOperdesc(String operdesc) {
+        this.operdesc = operdesc;
+    }
+
+    /** 操作描述 */
+    private String operdesc;
+
     /** 请求方法 */
     private String method;
 

+ 1 - 1
backend/src/main/java/com/jiayue/ssi/filter/MailCodeFilter.java

@@ -85,11 +85,11 @@ public class MailCodeFilter extends OncePerRequestFilter {
                     }
                 }
             }
-            filterChain.doFilter(request, response);
         } catch (Exception e) {
             e.printStackTrace();
             ResponseInfo.doResponse(response, "邮箱口令错误!", 401);
             return;
         }
+        filterChain.doFilter(request, response);
     }
 }

+ 2 - 1
backend/src/main/java/com/jiayue/ssi/filter/VerifyCodeFilter.java

@@ -73,10 +73,11 @@ public class VerifyCodeFilter extends OncePerRequestFilter {
                     return;
                 }
             }
-            filterChain.doFilter(request, response);
+
         } catch (Exception e) {
             ResponseInfo.doResponse(response, "验证码错误!", 401);
             return;
         }
+        filterChain.doFilter(request, response);
     }
 }

+ 24 - 18
backend/src/main/java/com/jiayue/ssi/filter/VerifySmFilter.java

@@ -7,7 +7,6 @@ import com.jiayue.ssi.constant.SecretKeyConstants;
 import com.jiayue.ssi.factory.LoginFactory;
 import com.jiayue.ssi.servlet.ParameterRequestWrapper;
 import com.jiayue.ssi.util.IPUtils;
-import com.jiayue.ssi.util.JwtTokenUtil;
 import com.jiayue.ssi.util.ResponseInfo;
 import com.jiayue.ssi.util.SM2CryptUtils;
 import lombok.RequiredArgsConstructor;
@@ -15,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.core.annotation.Order;
 import org.springframework.web.filter.OncePerRequestFilter;
+
 import javax.servlet.FilterChain;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -41,7 +41,7 @@ public class VerifySmFilter extends OncePerRequestFilter {
             ParameterRequestWrapper initWrapper = new ParameterRequestWrapper(request);
             // 不是登录操作
             if (!("POST".equalsIgnoreCase(request.getMethod())
-                && defaultFilterProcessUrl.equals(request.getServletPath())) && !("/getVerifyCode".equals(request.getServletPath()))
+                    && defaultFilterProcessUrl.equals(request.getServletPath())) && !("/getVerifyCode".equals(request.getServletPath()))
                     && !("/sysParameterController/getUseSendMail".equals(request.getServletPath())) && !("/getMailCode".equals(request.getServletPath()))) {
                 // 验证token
                 String tokenStr = request.getHeader("Authorization");
@@ -51,7 +51,7 @@ public class VerifySmFilter extends OncePerRequestFilter {
                     String tokenSign = request.getHeader("JySign");
                     // 验证签名
                     boolean verifySign =
-                        SM2CryptUtils.verifySign(SecretKeyConstants.CLIENT_PUBLIC_KEY, decryptTokenStr, tokenSign);
+                            SM2CryptUtils.verifySign(SecretKeyConstants.CLIENT_PUBLIC_KEY, decryptTokenStr, tokenSign);
                     if (!verifySign) {
                         // 验签失败
                         ResponseInfo.doResponse(response, "token验签失败,不能访问系统!", 401);
@@ -71,7 +71,7 @@ public class VerifySmFilter extends OncePerRequestFilter {
             }
             // 解密后的参数字符串
             String decryptStr = "";
-            if ("POST".equalsIgnoreCase(request.getMethod())||"PUT".equalsIgnoreCase(request.getMethod())||"DELETE".equalsIgnoreCase(request.getMethod())) {
+            if ("POST".equalsIgnoreCase(request.getMethod()) || "PUT".equalsIgnoreCase(request.getMethod()) || "DELETE".equalsIgnoreCase(request.getMethod())) {
                 byte[] bytes = null;
                 try {
                     bytes = initWrapper.getBodyContent(request).getBytes(StandardCharsets.UTF_8);
@@ -83,10 +83,9 @@ public class VerifySmFilter extends OncePerRequestFilter {
                 JSONObject jsonObject;
                 try {
                     jsonObject = JSONUtil.parseObj(json);
-                }
-                catch (Exception e){
+                } catch (Exception e) {
 //                    System.out.println("出错字符=====>"+json);
-                   throw e;
+                    throw e;
                 }
                 // 验证加密的参数文本
                 String data_sm2 = jsonObject.getStr("secretData");
@@ -95,7 +94,7 @@ public class VerifySmFilter extends OncePerRequestFilter {
                         decryptStr = SM2CryptUtils.decrypt(data_sm2, SecretKeyConstants.SERVER_PRIVATE_KEY);
                     } catch (Exception e) {
                         // 参数验签失败
-                        if (defaultFilterProcessUrl.equals(request.getServletPath())){
+                        if (defaultFilterProcessUrl.equals(request.getServletPath())) {
                             // 记录用户退出日志
                             LoginFactory.recordLogininfor("未知", Constants.LOGIN_FAIL, "参数解密失败");
                         }
@@ -107,9 +106,9 @@ public class VerifySmFilter extends OncePerRequestFilter {
                     try {
                         // 验证签名
                         boolean verifySign =
-                            SM2CryptUtils.verifySign(SecretKeyConstants.CLIENT_PUBLIC_KEY, decryptStr, paramSign);
+                                SM2CryptUtils.verifySign(SecretKeyConstants.CLIENT_PUBLIC_KEY, decryptStr, paramSign);
                         if (!verifySign) {
-                            if (defaultFilterProcessUrl.equals(request.getServletPath())){
+                            if (defaultFilterProcessUrl.equals(request.getServletPath())) {
                                 // 记录用户退出日志
                                 LoginFactory.recordLogininfor("未知", Constants.LOGIN_FAIL, "参数验签失败");
                             }
@@ -119,7 +118,7 @@ public class VerifySmFilter extends OncePerRequestFilter {
                         }
                     } catch (Exception e) {
                         // 验签失败
-                        if (defaultFilterProcessUrl.equals(request.getServletPath())){
+                        if (defaultFilterProcessUrl.equals(request.getServletPath())) {
                             // 记录用户退出日志
                             LoginFactory.recordLogininfor("未知", Constants.LOGIN_FAIL, "参数验签失败");
                         }
@@ -129,9 +128,8 @@ public class VerifySmFilter extends OncePerRequestFilter {
                     if (!"".equals(decryptStr)) {
                         try {
                             stringToMap = JSONUtil.parseObj(decryptStr);
-                        }
-                        catch (Exception e){
-                            if (defaultFilterProcessUrl.equals(request.getServletPath())){
+                        } catch (Exception e) {
+                            if (defaultFilterProcessUrl.equals(request.getServletPath())) {
                                 // 记录用户退出日志
                                 LoginFactory.recordLogininfor("未知", Constants.LOGIN_FAIL, "参数转换json失败");
                             }
@@ -147,13 +145,13 @@ public class VerifySmFilter extends OncePerRequestFilter {
                     Map<String, String> tempMap = new HashMap(16);
                     // 对加密串解密验签
                     try {
-                        String[] tempStr = get_sm2Str.replaceAll("&","&").split("&");
+                        String[] tempStr = get_sm2Str.replaceAll("&", "&").split("&");
                         for (int i = 0; i < tempStr.length; i++) {
                             String[] fieldStr = tempStr[i].split("=");
                             tempMap.put(fieldStr[0], fieldStr[1]);
                         }
                         decryptStr =
-                            SM2CryptUtils.decrypt(tempMap.get("secretData"), SecretKeyConstants.SERVER_PRIVATE_KEY);
+                                SM2CryptUtils.decrypt(tempMap.get("secretData"), SecretKeyConstants.SERVER_PRIVATE_KEY);
                     } catch (Exception e) {
                         // 参数验签失败
                         ResponseInfo.doResponse(response, "参数解密失败,不能访问系统!", 401);
@@ -164,7 +162,7 @@ public class VerifySmFilter extends OncePerRequestFilter {
                     // 验证签名
                     try {
                         boolean verifySign =
-                            SM2CryptUtils.verifySign(SecretKeyConstants.CLIENT_PUBLIC_KEY, decryptStr, paramSign);
+                                SM2CryptUtils.verifySign(SecretKeyConstants.CLIENT_PUBLIC_KEY, decryptStr, paramSign);
                         if (!verifySign) {
                             // 验签失败
                             ResponseInfo.doResponse(response, "参数验签失败,不能访问系统!", 401);
@@ -180,10 +178,18 @@ public class VerifySmFilter extends OncePerRequestFilter {
                     }
                 }
             }
+            //对参数里的字符进行合理化校验
+            String regex = "^[\\u4e00-\\u9fa5a-zA-Z0-9!@#$%^&*()_+|<>,.?/:;\\[\\]{}\\-\\s]*$";
+            for (String key : stringToMap.keySet()) {
+                if (!stringToMap.get(key).toString().matches(regex)) {
+                    ResponseInfo.doResponse(response, "参数验证失败,包含特殊字符 " + stringToMap.get(key), 405);
+                    return;
+                }
+            }
             ParameterRequestWrapper pr = new ParameterRequestWrapper(initWrapper, stringToMap, decryptStr);
             filterChain.doFilter(pr, response);
         } catch (Exception e) {
-            log.error(IPUtils.getIpAddr(request)+"访问系统失败",e);
+//            log.error(IPUtils.getIpAddr(request) + "访问系统失败", e);
             ResponseInfo.doResponse(response, "访问失败,联系管理员!", 401);
             return;
         }

+ 14 - 8
backend/src/test/java/com/jiayue/ssi/service/Sm2UiTest.java

@@ -1,5 +1,6 @@
 package com.jiayue.ssi.service;
 
+import cn.hutool.crypto.SmUtil;
 import com.jiayue.ssi.constant.SecretKeyConstants;
 import com.jiayue.ssi.util.SM2CryptUtils;
 
@@ -23,17 +24,22 @@ public class Sm2UiTest {
 
 
 
-        String jiami = SM2CryptUtils.encrypt("root","041967638ca43d4577d8dba166bff4437fde944270101f398a95b846ec2f8177d09f8abc5d62b6cd2c7216274d7abe0c8e04b0bb691207a32dd2e12d6bd2798672");
-        System.out.println("加密:"+jiami);
-        String jiemi = SM2CryptUtils.decrypt(jiami,"6155d63ee27cbeca07f3e40c4f8856f1be8119fcbda1aadc7e0e595e52bad7bd");
-        System.out.println("解密:"+jiemi);
+//        String jiami = SM2CryptUtils.encrypt("root","041967638ca43d4577d8dba166bff4437fde944270101f398a95b846ec2f8177d09f8abc5d62b6cd2c7216274d7abe0c8e04b0bb691207a32dd2e12d6bd2798672");
+//        System.out.println("加密:"+jiami);
+//        String jiemi = SM2CryptUtils.decrypt(jiami,"6155d63ee27cbeca07f3e40c4f8856f1be8119fcbda1aadc7e0e595e52bad7bd");
+//        System.out.println("解密:"+jiemi);
+//
+//
+//        String qianming = SM2CryptUtils.sign("6155d63ee27cbeca07f3e40c4f8856f1be8119fcbda1aadc7e0e595e52bad7bd",jiemi);
+//        System.out.println("签名:"+qianming);
+//
+//        boolean yanqian = SM2CryptUtils.verifySign("041967638ca43d4577d8dba166bff4437fde944270101f398a95b846ec2f8177d09f8abc5d62b6cd2c7216274d7abe0c8e04b0bb691207a32dd2e12d6bd2798672",jiemi,qianming);
+//        System.out.println("验签:"+yanqian);
 
 
-        String qianming = SM2CryptUtils.sign("6155d63ee27cbeca07f3e40c4f8856f1be8119fcbda1aadc7e0e595e52bad7bd",jiemi);
-        System.out.println("签名:"+qianming);
+        String a= SmUtil.sm3("Xsl147258").toUpperCase();
+        System.out.println(SM2CryptUtils.encrypt(a,SecretKeyConstants.SERVER_PUBLIC_KEY));
 
-        boolean yanqian = SM2CryptUtils.verifySign("041967638ca43d4577d8dba166bff4437fde944270101f398a95b846ec2f8177d09f8abc5d62b6cd2c7216274d7abe0c8e04b0bb691207a32dd2e12d6bd2798672",jiemi,qianming);
-        System.out.println("验签:"+yanqian);
 
     }
 }

+ 50 - 53
ui/src/App.vue

@@ -16,59 +16,56 @@ export default {
       return false;
     };
 
-    // window.addEventListener("beforeunload", e => {
-    //   this.beforeunloadHandler(e)
-    //   let userAgent = navigator.userAgent
-    //   let isOpera = userAgent.indexOf("Opera") > -1;
-    //   if (isOpera) { //判断是否Opera浏览器
-    //     return "Opera"
-    //   }
-    //   if (userAgent.indexOf("Firefox") > -1) {
-    //     this.unloadHandler();
-    //   }
-    //   if (userAgent.indexOf("MSIE") > -1) {
-    //     this.unloadHandler();
-    //   }
-    // });
-    // window.addEventListener("unload", async e => {
-    //   this.unloadHandler(e)
-    // });
+    window.addEventListener("beforeunload", e => {
+      this.beforeunloadHandler(e)
+      let userAgent = navigator.userAgent
+      let isOpera = userAgent.indexOf("Opera") > -1;
+      if (isOpera) { //判断是否Opera浏览器
+        return "Opera"
+      }
+      if (userAgent.indexOf("Firefox") > -1) {
+        this.unloadHandler();
+      }
+      if (userAgent.indexOf("MSIE") > -1) {
+        this.unloadHandler();
+      }
+    });
+    window.addEventListener("unload", async e => {
+      this.unloadHandler(e)
+    });
   },
-  // methods: {
-  //   beforeunloadHandler(e) {
-  //     this._beforeUnload_time = new Date().getTime();
-  //   },
-  //   unloadHandler(e) {
-  //     this._gap_time = new Date().getTime() - this._beforeUnload_time;
-  //
-  //     //判断是窗口关闭还是刷新
-  //     localStorage.setItem('time', this._gap_time)
-  //     console.log(this._gap_time, 333333)
-  //     if (this._gap_time <= 5) {
-  //       console.log(this._gap_time, 333333)
-  //       // // 发送设置同步 (退出登陆的api)
-  //       // this.$store.dispatch('LogOut').then(() => {
-  //       //   location.href = '/index';
-  //       // })
-  //
-  //
-  //       this.$axios.post(
-  //         '/logout', {}
-  //       ).then((res) => {
-  //         this.$message.success(res.data)
-  //         removeToken()
-  //         //注销返回自己的登录页
-  //         this.$router.push(`/login?redirect=${this.$route.fullPath}`)
-  //       })
-  //     } else {
-  //     }
-  //   },
-  // },
-  // destroyed() {
-  //   window.removeEventListener("beforeunload", e =>
-  //     this.beforeunloadHandler(e)
-  //   );
-  //   window.removeEventListener("unload", e => this.unloadHandler(e));
-  // }
+  methods: {
+    beforeunloadHandler(e) {
+      this._beforeUnload_time = new Date().getTime();
+    },
+    unloadHandler(e) {
+      this._gap_time = new Date().getTime() - this._beforeUnload_time;
+      //判断是窗口关闭还是刷新
+      localStorage.setItem('time', this._gap_time)
+      if (this._gap_time <= 5) {
+        // // 发送设置同步 (退出登陆的api)
+        // this.$store.dispatch('LogOut').then(() => {
+        //   location.href = '/index';
+        // })
+
+
+        this.$axios.post(
+          '/logout', {}
+        ).then((res) => {
+          this.$message.success(res.data)
+          removeToken()
+          //注销返回自己的登录页
+          this.$router.push(`/login?redirect=${this.$route.fullPath}`)
+        })
+      } else {
+      }
+    },
+  },
+  destroyed() {
+    window.removeEventListener("beforeunload", e =>
+      this.beforeunloadHandler(e)
+    );
+    window.removeEventListener("unload", e => this.unloadHandler(e));
+  }
 }
 </script>

+ 56 - 51
ui/src/views/bizManager/electricField/index.vue

@@ -7,50 +7,50 @@
       </div>
       <div>
         <el-card style="width: 80%;margin-left: 10%">
-          <div style="height: 30px" />
+          <div style="height: 30px"/>
           <el-form ref="form" v-loading="tableLoading" :model="form" :rules="rules">
-            <el-row style="gutter:30;text-align: left" class="row-bg el-row-two" justify="space-between">
+            <el-row class="row-bg el-row-two" justify="space-between" style="gutter:30;text-align: left">
               <el-col :span="12">
-                <el-form-item label="场站编号:" prop="stationCode" label-width="180px">
-                  <el-input v-model="form.stationCode" placeholder="必填项" maxlength="6" />
+                <el-form-item label="场站编号:" label-width="180px" prop="stationCode">
+                  <el-input v-model="form.stationCode" maxlength="6" placeholder="必填项"/>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item label="场站标识:" prop="sign" label-width="180px">
-                  <el-input v-model="form.sign" placeholder="必填项" maxlength="10" />
+                <el-form-item label="场站标识:" label-width="180px" prop="sign">
+                  <el-input v-model="form.sign" maxlength="10" placeholder="必填项"/>
                 </el-form-item>
               </el-col>
             </el-row>
-            <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
+            <el-row class="row-bg el-row-two" justify="space-between" style="gutter:30">
               <el-col :span="12">
-                <el-form-item label="场站名称:" prop="name" label-width="180px">
-                  <el-input v-model="form.name" placeholder="必填项" maxlength="50" />
+                <el-form-item label="场站名称:" label-width="180px" prop="name">
+                  <el-input v-model="form.name" maxlength="50" placeholder="必填项"/>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
                 <el-form-item
                   label="装机容量(MW):"
-                  prop="capacity"
                   label-width="180px"
+                  prop="capacity"
                   style="min-width: 110px"
                 >
-                  <el-input v-model="form.capacity" placeholder="必填项" maxlength="85" />
+                  <el-input v-model="form.capacity" maxlength="85" placeholder="必填项"/>
                 </el-form-item>
               </el-col>
             </el-row>
 
-            <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
+            <el-row class="row-bg el-row-two" justify="space-between" style="gutter:30">
               <el-col :span="12">
-                <el-form-item label="并网设备数:" prop="gridce" label-width="180px">
-                  <el-input v-model="form.gridce" placeholder="必填项" maxlength="10" />
+                <el-form-item label="并网设备数:" label-width="180px" prop="gridce">
+                  <el-input v-model="form.gridce" maxlength="10" placeholder="必填项"/>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
                 <el-form-item label="场站类型:" label-width="180px" prop="fieldType">
                   <el-select
                     v-model="form.fieldType"
-                    placeholder="请选择"
                     filterable
+                    placeholder="请选择"
                     style="width: 100%"
                   >
                     <el-option
@@ -63,15 +63,15 @@
                 </el-form-item>
               </el-col>
             </el-row>
-            <el-row style="gutter:30" class="row-bg" justify="space-between">
+            <el-row class="row-bg" justify="space-between" style="gutter:30">
               <el-col :span="12">
-                <el-form-item label="场站位置:" prop="location" label-width="180px">
-                  <el-input v-model="form.location" placeholder="必填项" maxlength="100" />
+                <el-form-item label="场站位置:" label-width="180px" prop="location">
+                  <el-input v-model="form.location" maxlength="100" placeholder="必填项"/>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item label="场站所属公司:" prop="company" label-width="180px">
-                  <el-input v-model="form.company" placeholder="必填项" maxlength="100" />
+                <el-form-item label="场站所属公司:" label-width="180px" prop="company">
+                  <el-input v-model="form.company" maxlength="100" placeholder="必填项"/>
                 </el-form-item>
               </el-col>
             </el-row>
@@ -80,15 +80,15 @@
             <span slot="footer" class="dialog-footer">
               <el-button
                 v-loading="tableLoading"
-                type="primary"
                 style="width: 15%"
+                type="primary"
                 @click="saveElectricField('form')"
               >保 存</el-button>
             </span>
           </div>
-          <div style="height: 30px" />
+          <div style="height: 30px"/>
         </el-card>
-        <div style="height: 20px" />
+        <div style="height: 20px"/>
       </div>
     </el-card>
   </div>
@@ -112,76 +112,82 @@ export default {
         {value: '0', label: '光伏'},
         {value: '1', label: '风电'}
       ],
-      form: { stationStatusEnum: {
-        code: 'E1',
-        message: '未运维'
-      }},
+      form: {
+        stationStatusEnum: {
+          code: 'E1',
+          message: '未运维'
+        }
+      },
       electricFieldStatrsEnumList: [],
-      intervals: [{ key: 0, value: 0, label: '不入库' },{ key: 60, value: 60, label: '一分钟' }, { key: 900, value: 900, label: '十五分钟' }],
+      intervals: [{key: 0, value: 0, label: '不入库'}, {key: 60, value: 60, label: '一分钟'}, {
+        key: 900,
+        value: 900,
+        label: '十五分钟'
+      }],
       // 表单验证规则
       rules: {
         stationCode: [
-          { required: true, message: '请填写场站编号' }
+          {required: true, message: '请填写场站编号'}
           // {message: '输入过长', max: 8}
         ],
         sign: [
-          { required: true, message: '请填写标识名称' }
+          {required: true, message: '请填写标识名称'}
           // {message: '输入过长', max: 15}
         ],
         name: [
-          { required: true, message: '请填写场站名称' }
+          {required: true, message: '请填写场站名称'}
           // {message: '输入过长', max: 50}
         ],
         capacity: [
-          { required: true, message: '请正确填写装机容量' },
-          { pattern: /^\d+(\.\d{0,2})?$/, message: '只能输入正数数字或带两位小数的数字' }
+          {required: true, message: '请正确填写装机容量'},
+          {pattern: /^\d+(\.\d{0,2})?$/, message: '只能输入正数数字或带两位小数的数字'}
           // {message: '输入过长', max: 10}
         ],
         gridce: [
-          { required: true, message: '请正确填写并网设备数' },
-          { pattern: /^[0-9]*[1-9][0-9]*$/, message: '只能输入正整数数字' }
+          {required: true, message: '请正确填写并网设备数'},
+          {pattern: /^[0-9]*[1-9][0-9]*$/, message: '只能输入正整数数字'}
           // {message: '输入过长', max: 5}
         ],
         longitude: [
-          { required: true, message: '请正确填写场站经度' },
+          {required: true, message: '请正确填写场站经度'},
           {pattern: /^\d+(\.\d{1,6})?$/, message: '只能输入正数数字或带小数点6位以内的数字'},
           {pattern: /^-?((0|1?[0-8]?[0-9]?)(([.][0-9]{1,10})?)|180(([.][0]{1,10})?))$/, message: '请输入正确的经度'}
           // {message: '输入过长', max: 10}
         ],
         latitude: [
-          { required: true, message: '请正确填写场站纬度' },
+          {required: true, message: '请正确填写场站纬度'},
           {pattern: /^\d+(\.\d{1,6})?$/, message: '只能输入正数数字或带小数点6位以内的数字'},
           {pattern: /^-?((0|[1-8]?[0-9]?)(([.][0-9]{1,10})?)|90(([.][0]{1,10})?))$/, message: '请输入正确的纬度'}
           // {message: '输入过长', max: 10}
         ],
         provinceEnum: [
-          { required: true, message: '请选择上报省调类型' }
+          {required: true, message: '请选择上报省调类型'}
         ],
         netSubstationName: [
-          { required: true, message: '请填写别名' }
+          {required: true, message: '请填写别名'}
           // {message: '输入过长', max: 50}
         ],
         electricFieldTypeEnum: [
-          { required: true, message: '请填写场站类型' }
+          {required: true, message: '请填写场站类型'}
         ],
         interval: [
-          { required: true, message: '请填写入库时间' }],
+          {required: true, message: '请填写入库时间'}],
         altitude: [
-          { required: true, message: '请填写场站海拔' },
-          { pattern: /^\d+(\.\d{2})?$/, message: '只能输入正数数字或带两位小数的数字' }
+          {required: true, message: '请填写场站海拔'},
+          {pattern: /^\d+(\.\d{2})?$/, message: '只能输入正数数字或带两位小数的数字'}
           // {message: '输入过长', max: 50}
         ],
         company: [
-          { required: true, message: '请填写场站所属公司' }
+          {required: true, message: '请填写场站所属公司'}
           // {message: '输入过长', max: 50}
         ],
         location: [
-          { required: true, message: '请填写场站位置' }
+          {required: true, message: '请填写场站位置'}
           // {message: '输入过长', max: 50}
         ],
         area: [
-          { required: true, message: '请填写场站面积' },
-          { pattern: /^\d+(\.\d{2})?$/, message: '只能输入正数数字或带两位小数的数字' }
+          {required: true, message: '请填写场站面积'},
+          {pattern: /^\d+(\.\d{2})?$/, message: '只能输入正数数字或带两位小数的数字'}
           // {message: '输入过长', max: 50}
         ]
       }
@@ -206,7 +212,7 @@ export default {
         sysTime: sysTime,
         lk: lk
       }
-      await this.$axios.get('/electricField/getAll',{params: searchParams}).then((res) => {
+      await this.$axios.get('/electricField/getAll', {params: searchParams}).then((res) => {
         this.form = res.data
         this.loading = false
       }).catch((error) => {
@@ -214,7 +220,7 @@ export default {
         // this.$message.error(error)
       })
     },
-    saveElectricField:debounce(function(formName){
+    saveElectricField: debounce(function (formName) {
       this.$refs[formName].validate(async (valid) => {
         if (valid) {
           let sysTime
@@ -238,12 +244,11 @@ export default {
             }
             this.tableLoading = false
           }).catch((error) => {
-            this.$message.error('场站信息保存出错' + error)
             this.tableLoading = false
           })
         }
       });
-    },1000)
+    }, 1000)
   }
 }
 </script>