mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-04-27 01:37:53 +08:00
Compare commits
26 Commits
39c1dafced
...
v3.6.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63a556bd3a | ||
|
|
d94b7d1a5f | ||
|
|
385fc50c19 | ||
|
|
50fc2989ee | ||
|
|
80483dd17c | ||
|
|
ab77b8cb8d | ||
|
|
14e8885fba | ||
|
|
c29f5e2c04 | ||
|
|
b33ea72445 | ||
|
|
543d169827 | ||
|
|
9ddcb875a1 | ||
|
|
aa5530f51b | ||
|
|
0017cc8862 | ||
|
|
88c2e4979a | ||
|
|
b43048a589 | ||
|
|
0025941824 | ||
|
|
784fe5c399 | ||
|
|
af2d446a5f | ||
|
|
1f8dd5feb5 | ||
|
|
d3b5e93952 | ||
|
|
8d84783daf | ||
|
|
0bf6679753 | ||
|
|
e1e8b541db | ||
|
|
d30a6450c9 | ||
|
|
571a25d486 | ||
|
|
b0ff5a01a1 |
12
README.md
12
README.md
@@ -1,11 +1,11 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-b99b286755aef70355a7084753f89cdb7c9.png">
|
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-b99b286755aef70355a7084753f89cdb7c9.png">
|
||||||
</p>
|
</p>
|
||||||
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.6.7</h1>
|
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.6.8</h1>
|
||||||
<h4 align="center">基于 Vue/Element UI 和 Spring Boot/Spring Cloud & Alibaba 前后端分离的分布式微服务架构</h4>
|
<h4 align="center">基于 Vue/Element UI 和 Spring Boot/Spring Cloud & Alibaba 前后端分离的分布式微服务架构</h4>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://gitee.com/y_project/RuoYi-Cloud/stargazers"><img src="https://gitee.com/y_project/RuoYi-Cloud/badge/star.svg?theme=dark"></a>
|
<a href="https://gitee.com/y_project/RuoYi-Cloud/stargazers"><img src="https://gitee.com/y_project/RuoYi-Cloud/badge/star.svg?theme=dark"></a>
|
||||||
<a href="https://gitee.com/y_project/RuoYi-Cloud"><img src="https://img.shields.io/badge/RuoYi-v3.6.7-brightgreen.svg"></a>
|
<a href="https://gitee.com/y_project/RuoYi-Cloud"><img src="https://img.shields.io/badge/RuoYi-v3.6.8-brightgreen.svg"></a>
|
||||||
<a href="https://gitee.com/y_project/RuoYi-Cloud/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
|
<a href="https://gitee.com/y_project/RuoYi-Cloud/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -24,10 +24,10 @@
|
|||||||
RuoYi-Cloud 后端项目提供 Spring Boot 2.x / 3.x / 4.x 多版本分支的并行维护。
|
RuoYi-Cloud 后端项目提供 Spring Boot 2.x / 3.x / 4.x 多版本分支的并行维护。
|
||||||
|
|
||||||
| 名称 | 说明 | 地址 |
|
| 名称 | 说明 | 地址 |
|
||||||
| :---------------- | :------------------------ | :-------------------------------------------------------- |
|
| :---------------- | :----------------------------------- | :-------------------------------------------------------- |
|
||||||
| master 默认分支 | Spring Boot 4.x (JDK 17+) | https://gitee.com/y_project/RuoYi-Cloud |
|
| master 默认分支 | Spring Boot 4.x (JDK 17+、Nacos 3.x) | https://gitee.com/y_project/RuoYi-Cloud |
|
||||||
| springboot3 分支 | Spring Boot 3.x (JDK 17+) | https://gitee.com/y_project/RuoYi-Cloud/tree/springboot3 |
|
| springboot3 分支 | Spring Boot 3.x (JDK 17+、Nacos 3.x) | https://gitee.com/y_project/RuoYi-Cloud/tree/springboot3 |
|
||||||
| springboot2 分支 | Spring Boot 2.x (JDK 8+) | https://gitee.com/y_project/RuoYi-Cloud/tree/springboot2 |
|
| springboot2 分支 | Spring Boot 2.x (JDK 8+、 Nacos 2.x) | https://gitee.com/y_project/RuoYi-Cloud/tree/springboot2 |
|
||||||
|
|
||||||
RuoYi-Cloud 前端项目提供 Vue 2.x / 3.x / JavaScript TypeScript 版本均可混用搭配
|
RuoYi-Cloud 前端项目提供 Vue 2.x / 3.x / JavaScript TypeScript 版本均可混用搭配
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ usage() {
|
|||||||
|
|
||||||
# copy sql
|
# copy sql
|
||||||
echo "begin copy sql "
|
echo "begin copy sql "
|
||||||
cp ../sql/ry_20250523.sql ./mysql/db
|
cp ../sql/ry_20260321.sql ./mysql/db
|
||||||
cp ../sql/ry_config_20260311.sql ./mysql/db
|
cp ../sql/ry_config_20260311.sql ./mysql/db
|
||||||
|
|
||||||
# copy html
|
# copy html
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ version : '3.8'
|
|||||||
services:
|
services:
|
||||||
ruoyi-nacos:
|
ruoyi-nacos:
|
||||||
container_name: ruoyi-nacos
|
container_name: ruoyi-nacos
|
||||||
image: nacos/nacos-server
|
image: nacos/nacos-server:v3.0.2
|
||||||
build:
|
build:
|
||||||
context: ./nacos
|
context: ./nacos
|
||||||
environment:
|
environment:
|
||||||
- MODE=standalone
|
- MODE=standalone
|
||||||
|
- NACOS_AUTH_TOKEN=your_auth_token
|
||||||
|
- NACOS_AUTH_IDENTITY_KEY=your_identity_key
|
||||||
|
- NACOS_AUTH_IDENTITY_VALUE=your_identity_value
|
||||||
volumes:
|
volumes:
|
||||||
- ./nacos/logs/:/home/nacos/logs
|
- ./nacos/logs/:/home/nacos/logs
|
||||||
- ./nacos/conf/application.properties:/home/nacos/conf/application.properties
|
- ./nacos/conf/application.properties:/home/nacos/conf/application.properties
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ nacos.core.auth.system.type=nacos
|
|||||||
nacos.core.auth.enabled=false
|
nacos.core.auth.enabled=false
|
||||||
nacos.core.auth.default.token.expire.seconds=18000
|
nacos.core.auth.default.token.expire.seconds=18000
|
||||||
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
|
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
|
||||||
|
nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
|
||||||
nacos.core.auth.caching.enabled=true
|
nacos.core.auth.caching.enabled=true
|
||||||
nacos.core.auth.enable.userAgentAuthWhite=false
|
nacos.core.auth.enable.userAgentAuthWhite=false
|
||||||
nacos.core.auth.server.identity.key=serverIdentity
|
nacos.core.auth.server.identity.key=serverIdentity
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 基础镜像
|
# 基础镜像
|
||||||
FROM nacos/nacos-server
|
FROM nacos/nacos-server:v3.0.2
|
||||||
# author
|
# author
|
||||||
MAINTAINER ruoyi
|
MAINTAINER ruoyi
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 基础镜像
|
# 基础镜像
|
||||||
FROM openjdk:8-jre
|
FROM openjdk:17
|
||||||
# author
|
# author
|
||||||
MAINTAINER ruoyi
|
MAINTAINER ruoyi
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 基础镜像
|
# 基础镜像
|
||||||
FROM openjdk:8-jre
|
FROM openjdk:17
|
||||||
# author
|
# author
|
||||||
MAINTAINER ruoyi
|
MAINTAINER ruoyi
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 基础镜像
|
# 基础镜像
|
||||||
FROM openjdk:8-jre
|
FROM openjdk:17
|
||||||
# author
|
# author
|
||||||
MAINTAINER ruoyi
|
MAINTAINER ruoyi
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 基础镜像
|
# 基础镜像
|
||||||
FROM openjdk:8-jre
|
FROM openjdk:17
|
||||||
# author
|
# author
|
||||||
MAINTAINER ruoyi
|
MAINTAINER ruoyi
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 基础镜像
|
# 基础镜像
|
||||||
FROM openjdk:8-jre
|
FROM openjdk:17
|
||||||
# author
|
# author
|
||||||
MAINTAINER ruoyi
|
MAINTAINER ruoyi
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 基础镜像
|
# 基础镜像
|
||||||
FROM openjdk:8-jre
|
FROM openjdk:17
|
||||||
# author
|
# author
|
||||||
MAINTAINER ruoyi
|
MAINTAINER ruoyi
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 基础镜像
|
# 基础镜像
|
||||||
FROM openjdk:8-jre
|
FROM openjdk:17
|
||||||
# author
|
# author
|
||||||
MAINTAINER ruoyi
|
MAINTAINER ruoyi
|
||||||
|
|
||||||
|
|||||||
4
pom.xml
4
pom.xml
@@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
|
|
||||||
<name>ruoyi</name>
|
<name>ruoyi</name>
|
||||||
<url>http://www.ruoyi.vip</url>
|
<url>http://www.ruoyi.vip</url>
|
||||||
<description>若依微服务系统</description>
|
<description>若依微服务系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi.version>3.6.7</ruoyi.version>
|
<ruoyi.version>3.6.8</ruoyi.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-api</artifactId>
|
<artifactId>ruoyi-api</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.auth.form.LoginBody;
|
import com.ruoyi.auth.form.LoginBody;
|
||||||
import com.ruoyi.auth.form.RegisterBody;
|
import com.ruoyi.auth.form.RegisterBody;
|
||||||
|
import com.ruoyi.auth.form.UnLockBody;
|
||||||
import com.ruoyi.auth.service.SysLoginService;
|
import com.ruoyi.auth.service.SysLoginService;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.JwtUtils;
|
import com.ruoyi.common.core.utils.JwtUtils;
|
||||||
@@ -75,4 +76,14 @@ public class TokenController
|
|||||||
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解锁屏幕
|
||||||
|
*/
|
||||||
|
@PostMapping("/unlockscreen")
|
||||||
|
public R<?> unlockScreen(@RequestBody UnLockBody unLockBody)
|
||||||
|
{
|
||||||
|
sysLoginService.unlock(unLockBody.getPassword());
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
24
ruoyi-auth/src/main/java/com/ruoyi/auth/form/UnLockBody.java
Normal file
24
ruoyi-auth/src/main/java/com/ruoyi/auth/form/UnLockBody.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package com.ruoyi.auth.form;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统解锁对象
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class UnLockBody
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 用户密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public String getPassword()
|
||||||
|
{
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password)
|
||||||
|
{
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,11 +113,40 @@ public class SysLoginService
|
|||||||
remoteUserService.recordUserLogin(sysUser, SecurityConstants.INNER);
|
remoteUserService.recordUserLogin(sysUser, SecurityConstants.INNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出
|
||||||
|
*/
|
||||||
public void logout(String loginName)
|
public void logout(String loginName)
|
||||||
{
|
{
|
||||||
recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解锁
|
||||||
|
*/
|
||||||
|
public void unlock(String password)
|
||||||
|
{
|
||||||
|
String username = SecurityUtils.getUsername();
|
||||||
|
// 或密码为空 错误
|
||||||
|
if (StringUtils.isEmpty(password))
|
||||||
|
{
|
||||||
|
throw new ServiceException("密码不能为空");
|
||||||
|
}
|
||||||
|
// 查询用户信息
|
||||||
|
R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||||
|
|
||||||
|
if (R.FAIL == userResult.getCode())
|
||||||
|
{
|
||||||
|
throw new ServiceException(userResult.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
SysUser user = userResult.getData().getSysUser();
|
||||||
|
if (!SecurityUtils.matchesPassword(password, user.getPassword()))
|
||||||
|
{
|
||||||
|
throw new ServiceException("密码错误,请重新输入");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册
|
* 注册
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
@@ -104,12 +105,12 @@ public class GenController extends BaseController
|
|||||||
@RequiresPermissions("tool:gen:import")
|
@RequiresPermissions("tool:gen:import")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/importTable")
|
@PostMapping("/importTable")
|
||||||
public AjaxResult importTableSave(String tables)
|
public AjaxResult importTableSave(@RequestParam("tables") String tables, @RequestParam("tplWebType") String tplWebType)
|
||||||
{
|
{
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
String[] tableNames = Convert.toStrArray(tables);
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
||||||
genTableService.importGenTable(tableList);
|
genTableService.importGenTable(tableList, tplWebType);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class GenTable extends BaseEntity
|
|||||||
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
||||||
private String tplCategory;
|
private String tplCategory;
|
||||||
|
|
||||||
/** 前端类型(element-ui模版 element-plus模版) */
|
/** 前端类型(element-ui模版 element-plus模版 element-plus-typescript模版) */
|
||||||
private String tplWebType;
|
private String tplWebType;
|
||||||
|
|
||||||
/** 生成包路径 */
|
/** 生成包路径 */
|
||||||
@@ -267,6 +267,7 @@ public class GenTable extends BaseEntity
|
|||||||
{
|
{
|
||||||
this.subTable = subTable;
|
this.subTable = subTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GenTableColumn> getColumns()
|
public List<GenTableColumn> getColumns()
|
||||||
{
|
{
|
||||||
return columns;
|
return columns;
|
||||||
@@ -346,6 +347,7 @@ public class GenTable extends BaseEntity
|
|||||||
{
|
{
|
||||||
return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
|
return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTree()
|
public boolean isTree()
|
||||||
{
|
{
|
||||||
return isTree(this.tplCategory);
|
return isTree(this.tplCategory);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -157,7 +159,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void importGenTable(List<GenTable> tableList)
|
public void importGenTable(List<GenTable> tableList, String tplWebType)
|
||||||
{
|
{
|
||||||
String operName = SecurityUtils.getUsername();
|
String operName = SecurityUtils.getUsername();
|
||||||
try
|
try
|
||||||
@@ -165,6 +167,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
for (GenTable table : tableList)
|
for (GenTable table : tableList)
|
||||||
{
|
{
|
||||||
String tableName = table.getTableName();
|
String tableName = table.getTableName();
|
||||||
|
table.setTplWebType(tplWebType);
|
||||||
GenUtils.initTable(table, operName);
|
GenUtils.initTable(table, operName);
|
||||||
int row = genTableMapper.insertGenTable(table);
|
int row = genTableMapper.insertGenTable(table);
|
||||||
if (row > 0)
|
if (row > 0)
|
||||||
@@ -227,11 +230,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
@Override
|
@Override
|
||||||
public byte[] downloadCode(String tableName)
|
public byte[] downloadCode(String tableName)
|
||||||
{
|
{
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
return downloadCode(new String[] { tableName });
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
|
||||||
generatorCode(tableName, zip);
|
|
||||||
IOUtils.closeQuietly(zip);
|
|
||||||
return outputStream.toByteArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -342,9 +341,14 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
{
|
{
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||||
|
Map<String, StringBuffer> typeFiles = new HashMap<>();
|
||||||
for (String tableName : tableNames)
|
for (String tableName : tableNames)
|
||||||
{
|
{
|
||||||
generatorCode(tableName, zip);
|
generatorCode(tableName, zip, typeFiles);
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, StringBuffer> entry : typeFiles.entrySet())
|
||||||
|
{
|
||||||
|
writeToZip(zip, entry.getKey(), entry.getValue().toString());
|
||||||
}
|
}
|
||||||
IOUtils.closeQuietly(zip);
|
IOUtils.closeQuietly(zip);
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
@@ -353,7 +357,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
/**
|
/**
|
||||||
* 查询表信息并生成代码
|
* 查询表信息并生成代码
|
||||||
*/
|
*/
|
||||||
private void generatorCode(String tableName, ZipOutputStream zip)
|
private void generatorCode(String tableName, ZipOutputStream zip, Map<String, StringBuffer> typeFiles)
|
||||||
{
|
{
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
@@ -374,19 +378,46 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
||||||
tpl.merge(context, sw);
|
tpl.merge(context, sw);
|
||||||
|
String fileName = VelocityUtils.getFileName(template, table);
|
||||||
|
// index-bak.ts 模版,追加内容
|
||||||
|
if (fileName.contains("index-bak.ts"))
|
||||||
|
{
|
||||||
|
if (!typeFiles.containsKey(fileName))
|
||||||
|
{
|
||||||
|
typeFiles.put(fileName, new StringBuffer(sw.toString()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Arrays.stream(sw.toString().split("\n")).filter(line -> line.startsWith("export * from")).forEach(line -> typeFiles.get(fileName).append("\n").append(line));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 其他文件正常添加
|
||||||
|
writeToZip(zip, fileName, sw.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将字符串内容写入ZIP输出流
|
||||||
|
*
|
||||||
|
* @param zip ZIP输出流
|
||||||
|
* @param fileName ZIP条目名称(即文件名)
|
||||||
|
* @param content 要写入的内容
|
||||||
|
*/
|
||||||
|
private void writeToZip(ZipOutputStream zip, String fileName, String content)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 添加到zip
|
zip.putNextEntry(new ZipEntry(fileName));
|
||||||
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
IOUtils.write(content, zip, Constants.UTF8);
|
||||||
IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
|
||||||
IOUtils.closeQuietly(sw);
|
|
||||||
zip.flush();
|
zip.flush();
|
||||||
zip.closeEntry();
|
zip.closeEntry();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
log.error("渲染模板失败,表名:" + table.getTableName(), e);
|
log.error("写入ZIP文件失败,文件名: " + fileName, e);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,9 @@ public interface IGenTableService
|
|||||||
* 导入表结构
|
* 导入表结构
|
||||||
*
|
*
|
||||||
* @param tableList 导入表列表
|
* @param tableList 导入表列表
|
||||||
|
* @param tplWebType 前端类型
|
||||||
*/
|
*/
|
||||||
public void importGenTable(List<GenTable> tableList);
|
public void importGenTable(List<GenTable> tableList, String tplWebType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预览代码
|
* 预览代码
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ public class VelocityUtils
|
|||||||
/** 默认上级菜单,系统工具 */
|
/** 默认上级菜单,系统工具 */
|
||||||
private static final String DEFAULT_PARENT_MENU_ID = "3";
|
private static final String DEFAULT_PARENT_MENU_ID = "3";
|
||||||
|
|
||||||
|
/** Vue3 Element Plus 模版 */
|
||||||
|
private static final String ELEMENT_PLUS = "element-plus";
|
||||||
|
|
||||||
|
/** Vue3 Element Plus TypeScript 模版 */
|
||||||
|
private static final String ELEMENT_PLUS_TYPESSRIPT = "element-plus-typescript";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置模板变量信息
|
* 设置模板变量信息
|
||||||
*
|
*
|
||||||
@@ -130,10 +136,16 @@ public class VelocityUtils
|
|||||||
public static List<String> getTemplateList(String tplCategory, String tplWebType)
|
public static List<String> getTemplateList(String tplCategory, String tplWebType)
|
||||||
{
|
{
|
||||||
String useWebType = "vm/vue";
|
String useWebType = "vm/vue";
|
||||||
if ("element-plus".equals(tplWebType))
|
String apiTemplate = "vm/js/api.js.vm";
|
||||||
|
if (StringUtils.equals(ELEMENT_PLUS, tplWebType))
|
||||||
{
|
{
|
||||||
useWebType = "vm/vue/v3";
|
useWebType = "vm/vue/v3";
|
||||||
}
|
}
|
||||||
|
else if (StringUtils.equals(ELEMENT_PLUS_TYPESSRIPT, tplWebType))
|
||||||
|
{
|
||||||
|
useWebType = "vm/vue/v3ts";
|
||||||
|
apiTemplate = "vm/ts/api.ts.vm";
|
||||||
|
}
|
||||||
List<String> templates = new ArrayList<String>();
|
List<String> templates = new ArrayList<String>();
|
||||||
templates.add("vm/java/domain.java.vm");
|
templates.add("vm/java/domain.java.vm");
|
||||||
templates.add("vm/java/mapper.java.vm");
|
templates.add("vm/java/mapper.java.vm");
|
||||||
@@ -142,7 +154,12 @@ public class VelocityUtils
|
|||||||
templates.add("vm/java/controller.java.vm");
|
templates.add("vm/java/controller.java.vm");
|
||||||
templates.add("vm/xml/mapper.xml.vm");
|
templates.add("vm/xml/mapper.xml.vm");
|
||||||
templates.add("vm/sql/sql.vm");
|
templates.add("vm/sql/sql.vm");
|
||||||
templates.add("vm/js/api.js.vm");
|
templates.add(apiTemplate);
|
||||||
|
if (StringUtils.equals(ELEMENT_PLUS_TYPESSRIPT, tplWebType))
|
||||||
|
{
|
||||||
|
templates.add("vm/ts/type.ts.vm");
|
||||||
|
templates.add("vm/ts/index.ts.vm");
|
||||||
|
}
|
||||||
if (GenConstants.TPL_CRUD.equals(tplCategory))
|
if (GenConstants.TPL_CRUD.equals(tplCategory))
|
||||||
{
|
{
|
||||||
templates.add(useWebType + "/index.vue.vm");
|
templates.add(useWebType + "/index.vue.vm");
|
||||||
@@ -215,6 +232,18 @@ public class VelocityUtils
|
|||||||
{
|
{
|
||||||
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
||||||
}
|
}
|
||||||
|
else if (template.contains("api.ts.vm"))
|
||||||
|
{
|
||||||
|
fileName = StringUtils.format("{}/api/{}/{}.ts", vuePath, moduleName, businessName);
|
||||||
|
}
|
||||||
|
else if (template.contains("type.ts.vm"))
|
||||||
|
{
|
||||||
|
fileName = StringUtils.format("{}/types/api/{}/{}.ts", vuePath, moduleName, businessName);
|
||||||
|
}
|
||||||
|
else if (template.contains("index.ts.vm"))
|
||||||
|
{
|
||||||
|
fileName = StringUtils.format("{}/types/api/index-bak.ts", vuePath);
|
||||||
|
}
|
||||||
else if (template.contains("index.vue.vm"))
|
else if (template.contains("index.vue.vm"))
|
||||||
{
|
{
|
||||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package ${packageName}.controller;
|
package ${packageName}.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|||||||
51
ruoyi-modules/ruoyi-gen/src/main/resources/vm/ts/api.ts.vm
Normal file
51
ruoyi-modules/ruoyi-gen/src/main/resources/vm/ts/api.ts.vm
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
import type { AjaxResult, TableDataInfo, ${BusinessName}QueryParams, ${ClassName} } from '@/types'
|
||||||
|
|
||||||
|
// 查询${functionName}列表
|
||||||
|
#if($table.tree)
|
||||||
|
export function list${BusinessName}(query?: ${BusinessName}QueryParams): Promise<AjaxResult<${ClassName}[]>> {
|
||||||
|
#else
|
||||||
|
export function list${BusinessName}(query: ${BusinessName}QueryParams): Promise<TableDataInfo<${ClassName}[]>> {
|
||||||
|
#end
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询${functionName}详细
|
||||||
|
export function get${BusinessName}(${pkColumn.javaField}: number): Promise<AjaxResult<${ClassName}>> {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增${functionName}
|
||||||
|
export function add${BusinessName}(data: ${ClassName}): Promise<AjaxResult> {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改${functionName}
|
||||||
|
export function update${BusinessName}(data: ${ClassName}): Promise<AjaxResult> {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除${functionName}
|
||||||
|
export function del${BusinessName}(${pkColumn.javaField}: number | number[]): Promise<AjaxResult> {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* API 类型统一导出
|
||||||
|
*/
|
||||||
|
....
|
||||||
|
|
||||||
|
// 防止覆盖,需手动追加下面代码到index.ts文件中,追加好后此文件可删除
|
||||||
|
|
||||||
|
// ${moduleName} 模块
|
||||||
|
export * from "./${moduleName}/${businessName}";
|
||||||
51
ruoyi-modules/ruoyi-gen/src/main/resources/vm/ts/type.ts.vm
Normal file
51
ruoyi-modules/ruoyi-gen/src/main/resources/vm/ts/type.ts.vm
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import type { PageDomain, BaseEntity } from "../common";
|
||||||
|
|
||||||
|
/** ${functionName}配置分页查询参数 */
|
||||||
|
export interface ${BusinessName}QueryParams extends PageDomain {
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
#set($type = "string")
|
||||||
|
#if($column.javaType == "Long" || $column.javaType == "Integer")
|
||||||
|
#set($type = "number")
|
||||||
|
#elseif($column.javaType == "Boolean")
|
||||||
|
#set($type = "boolean")
|
||||||
|
#end
|
||||||
|
/** ${column.columnComment} */
|
||||||
|
${column.javaField}?: ${type};
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ${functionName}配置信息 */
|
||||||
|
export interface ${ClassName} extends BaseEntity {
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($type = "string")
|
||||||
|
#if($column.javaType == "Long" || $column.javaType == "Integer")
|
||||||
|
#set($type = "number")
|
||||||
|
#elseif($column.javaType == "Boolean")
|
||||||
|
#set($type = "boolean")
|
||||||
|
#end
|
||||||
|
/** ${column.columnComment} */
|
||||||
|
${column.javaField}?: ${type};
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
/** $table.subTable.functionName信息 */
|
||||||
|
${subclassName}List?: ${subClassName}[];
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
#if($table.sub)
|
||||||
|
|
||||||
|
/** ${subTable.functionName}配置信息 */
|
||||||
|
export interface ${subClassName} extends BaseEntity {
|
||||||
|
#foreach ($column in $subTable.columns)
|
||||||
|
#set($type = "string")
|
||||||
|
#if($column.javaType == "Long" || $column.javaType == "Integer")
|
||||||
|
#set($type = "number")
|
||||||
|
#elseif($column.javaType == "Boolean")
|
||||||
|
#set($type = "boolean")
|
||||||
|
#end
|
||||||
|
/** ${column.columnComment} */
|
||||||
|
${column.javaField}?: ${type};
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
#end
|
||||||
@@ -0,0 +1,476 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
#set($dictType=$column.dictType)
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.htmlType == "input")
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
placeholder="请输入${comment}"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="选择${comment}">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
<el-form-item label="${comment}" style="width: 308px">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="daterange${AttrName}"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="Plus"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['${permissionPrefix}:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
icon="Sort"
|
||||||
|
@click="toggleExpandAll"
|
||||||
|
>展开/折叠</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
v-if="refreshTable"
|
||||||
|
v-loading="loading"
|
||||||
|
:data="${businessName}List"
|
||||||
|
row-key="${treeCode}"
|
||||||
|
:default-expand-all="isExpandAll"
|
||||||
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
|
>
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($javaField=$column.javaField)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.pk)
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "imageUpload")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && "" != $column.dictType)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||||
|
<template #default="scope">
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
|
||||||
|
#else
|
||||||
|
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
|
||||||
|
#end
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && "" != $javaField)
|
||||||
|
#if(${foreach.index} == 1)
|
||||||
|
<el-table-column label="${comment}" prop="${javaField}" />
|
||||||
|
#else
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${permissionPrefix}:edit']">修改</el-button>
|
||||||
|
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${permissionPrefix}:add']">新增</el-button>
|
||||||
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${permissionPrefix}:remove']">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<!-- 添加或修改${functionName}对话框 -->
|
||||||
|
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($field=$column.javaField)
|
||||||
|
#if($column.insert && !$column.pk)
|
||||||
|
#if(($column.usableColumn) || (!$column.superColumn))
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#set($dictType=$column.dictType)
|
||||||
|
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
|
||||||
|
<el-form-item label="${comment}" prop="${treeParentCode}">
|
||||||
|
<el-tree-select
|
||||||
|
v-model="form.${treeParentCode}"
|
||||||
|
:data="${businessName}Options"
|
||||||
|
:props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }"
|
||||||
|
value-key="${treeCode}"
|
||||||
|
placeholder="请选择${comment}"
|
||||||
|
check-strictly
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "input")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "imageUpload")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<image-upload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "fileUpload")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<file-upload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "editor")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<editor v-model="form.${field}" :min-height="192"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||||
|
:value="parseInt(dict.value)"
|
||||||
|
#else
|
||||||
|
:value="dict.value"
|
||||||
|
#end
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-checkbox-group v-model="form.${field}">
|
||||||
|
<el-checkbox
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value">
|
||||||
|
{{dict.label}}
|
||||||
|
</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-checkbox-group v-model="form.${field}">
|
||||||
|
<el-checkbox>请选择字典生成</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-radio-group v-model="form.${field}">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||||
|
:label="parseInt(dict.value)"
|
||||||
|
#else
|
||||||
|
:label="dict.value"
|
||||||
|
#end
|
||||||
|
>{{dict.label}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "radio" && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-radio-group v-model="form.${field}">
|
||||||
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="form.${field}"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="选择${comment}">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "textarea")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="${BusinessName}">
|
||||||
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"
|
||||||
|
import type { ${ClassName}, ${BusinessName}QueryParams } from "@/types/api/${moduleName}/${businessName}"
|
||||||
|
import type { TreeSelect } from '@/types/api/common'
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
#if(${dicts} != '')
|
||||||
|
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||||||
|
const { ${dictsNoSymbol} } = proxy.useDict(${dicts})
|
||||||
|
#end
|
||||||
|
|
||||||
|
const ${businessName}List = ref<any[]>([])
|
||||||
|
const ${businessName}Options = ref<TreeSelect[]>([])
|
||||||
|
const open = ref<boolean>(false)
|
||||||
|
const loading = ref<boolean>(true)
|
||||||
|
const showSearch = ref<boolean>(true)
|
||||||
|
const title = ref<string>("")
|
||||||
|
const isExpandAll = ref<boolean>(true)
|
||||||
|
const refreshTable = ref<boolean>(true)
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
const daterange${AttrName} = ref([])
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
form: {} as ${ClassName},
|
||||||
|
queryParams: {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
} as ${BusinessName}QueryParams,
|
||||||
|
rules: {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.required)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
$column.javaField: [
|
||||||
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
|
||||||
|
]#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data)
|
||||||
|
|
||||||
|
/** 查询${functionName}列表 */
|
||||||
|
function getList() {
|
||||||
|
loading.value = true
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
queryParams.value.params = {}
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
if (null != daterange${AttrName}.value && '' != daterange${AttrName}.value) {
|
||||||
|
queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0]
|
||||||
|
queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1]
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
list${BusinessName}(queryParams.value).then(response => {
|
||||||
|
${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}")
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询${functionName}下拉树结构 */
|
||||||
|
function getTreeselect() {
|
||||||
|
list${BusinessName}().then(response => {
|
||||||
|
${businessName}Options.value = []
|
||||||
|
const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] }
|
||||||
|
data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}")
|
||||||
|
${businessName}Options.value.push(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
function cancel() {
|
||||||
|
open.value = false
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表单重置
|
||||||
|
function reset() {
|
||||||
|
form.value = {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
|
#else
|
||||||
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
proxy.resetForm("${businessName}Ref")
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
daterange${AttrName}.value = []
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
proxy.resetForm("queryRef")
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
function handleAdd(row: ${ClassName}) {
|
||||||
|
reset()
|
||||||
|
getTreeselect()
|
||||||
|
if (row != null && row.${treeCode}) {
|
||||||
|
form.value.${treeParentCode} = row.${treeCode}
|
||||||
|
} else {
|
||||||
|
form.value.${treeParentCode} = 0
|
||||||
|
}
|
||||||
|
open.value = true
|
||||||
|
title.value = "添加${functionName}"
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 展开/折叠操作 */
|
||||||
|
function toggleExpandAll() {
|
||||||
|
refreshTable.value = false
|
||||||
|
isExpandAll.value = !isExpandAll.value
|
||||||
|
nextTick(() => {
|
||||||
|
refreshTable.value = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
async function handleUpdate(row: ${ClassName}) {
|
||||||
|
reset()
|
||||||
|
await getTreeselect()
|
||||||
|
if (row != null) {
|
||||||
|
form.value.${treeParentCode} = row.${treeParentCode}
|
||||||
|
}
|
||||||
|
get${BusinessName}(row.${pkColumn.javaField}!).then(response => {
|
||||||
|
form.value = response.data
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
form.value.$column.javaField = form.value.${column.javaField}.split(",")
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
open.value = true
|
||||||
|
title.value = "修改${functionName}"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
proxy.#[[$]]#refs["${businessName}Ref"].validate((valid: boolean) => {
|
||||||
|
if (valid) {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
form.value.$column.javaField = form.value.${column.javaField}.join(",")
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
if (form.value.${pkColumn.javaField} != null) {
|
||||||
|
update${BusinessName}(form.value).then(() => {
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("修改成功")
|
||||||
|
open.value = false
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
add${BusinessName}(form.value).then(() => {
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("新增成功")
|
||||||
|
open.value = false
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
function handleDelete(row: ${ClassName}) {
|
||||||
|
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() {
|
||||||
|
return del${BusinessName}(row.${pkColumn.javaField}!)
|
||||||
|
}).then(() => {
|
||||||
|
getList()
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("删除成功")
|
||||||
|
}).catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
getList()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,594 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
#set($dictType=$column.dictType)
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.htmlType == "input")
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
placeholder="请输入${comment}"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="请选择${comment}">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
<el-form-item label="${comment}" style="width: 308px">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="daterange${AttrName}"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="Plus"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['${permissionPrefix}:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="Edit"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['${permissionPrefix}:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="Delete"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['${permissionPrefix}:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="Download"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['${permissionPrefix}:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($javaField=$column.javaField)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.pk)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "imageUpload")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && "" != $column.dictType)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||||
|
<template #default="scope">
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
|
||||||
|
#else
|
||||||
|
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
|
||||||
|
#end
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && "" != $javaField)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${permissionPrefix}:edit']">修改</el-button>
|
||||||
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${permissionPrefix}:remove']">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNum"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改${functionName}对话框 -->
|
||||||
|
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($field=$column.javaField)
|
||||||
|
#if($column.insert && !$column.pk)
|
||||||
|
#if(($column.usableColumn) || (!$column.superColumn))
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#set($dictType=$column.dictType)
|
||||||
|
#if($column.htmlType == "input")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "imageUpload")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<image-upload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "fileUpload")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<file-upload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "editor")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<editor v-model="form.${field}" :min-height="192"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||||
|
:value="parseInt(dict.value)"
|
||||||
|
#else
|
||||||
|
:value="dict.value"
|
||||||
|
#end
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-checkbox-group v-model="form.${field}">
|
||||||
|
<el-checkbox
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value">
|
||||||
|
{{dict.label}}
|
||||||
|
</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-checkbox-group v-model="form.${field}">
|
||||||
|
<el-checkbox>请选择字典生成</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-radio-group v-model="form.${field}">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||||
|
:label="parseInt(dict.value)"
|
||||||
|
#else
|
||||||
|
:label="dict.value"
|
||||||
|
#end
|
||||||
|
>{{dict.label}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "radio" && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-radio-group v-model="form.${field}">
|
||||||
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="form.${field}"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="请选择${comment}">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "textarea")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
<el-divider content-position="center">${subTable.functionName}信息</el-divider>
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" icon="Plus" @click="handleAdd${subClassName}">添加</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" icon="Delete" @click="handleDelete${subClassName}">删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-table :data="${subclassName}List" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
|
||||||
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
|
<el-table-column label="序号" width="60">
|
||||||
|
<template #default="{ $index }">
|
||||||
|
{{ $index + 1 }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#foreach($column in $subTable.columns)
|
||||||
|
#set($javaField=$column.javaField)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.pk || $javaField == ${subTableFkclassName})
|
||||||
|
#elseif($column.list && $column.htmlType == "input")
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="240">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="scope.row.$javaField"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="请选择$comment">
|
||||||
|
</el-date-picker>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in $column.dictType"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
</el-table>
|
||||||
|
#end
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="Config">
|
||||||
|
#if($table.sub)
|
||||||
|
import type { ${ClassName}, ${subClassName}, ${BusinessName}QueryParams } from "@/types/api/${moduleName}/${businessName}"
|
||||||
|
#else
|
||||||
|
import type { ${ClassName}, ${BusinessName}QueryParams } from "@/types/api/${moduleName}/${businessName}"
|
||||||
|
#end
|
||||||
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
#if(${dicts} != '')
|
||||||
|
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||||||
|
const { ${dictsNoSymbol} } = proxy.useDict(${dicts})
|
||||||
|
#end
|
||||||
|
|
||||||
|
const ${businessName}List = ref<${ClassName}[]>([])
|
||||||
|
#if($table.sub)
|
||||||
|
const ${subclassName}List = ref([])
|
||||||
|
#end
|
||||||
|
const open = ref<boolean>(false)
|
||||||
|
const loading = ref<boolean>(true)
|
||||||
|
const showSearch = ref<boolean>(true)
|
||||||
|
const ids = ref<number[]>([])
|
||||||
|
#if($table.sub)
|
||||||
|
const checked${subClassName} = ref([])
|
||||||
|
#end
|
||||||
|
const single = ref<boolean>(true)
|
||||||
|
const multiple = ref<boolean>(true)
|
||||||
|
const total = ref<number>(0)
|
||||||
|
const title = ref<string>("")
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
const daterange${AttrName} = ref<string[]>([])
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
form: {} as ${ClassName},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
} as ${BusinessName}QueryParams,
|
||||||
|
rules: {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.required)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
$column.javaField: [
|
||||||
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
|
||||||
|
]#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data)
|
||||||
|
|
||||||
|
/** 查询${functionName}列表 */
|
||||||
|
function getList() {
|
||||||
|
loading.value = true
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
queryParams.value.params = {}
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
if (null != daterange${AttrName}.value && '' != daterange${AttrName}.value) {
|
||||||
|
queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0]
|
||||||
|
queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1]
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
list${BusinessName}(queryParams.value).then(response => {
|
||||||
|
${businessName}List.value = response.rows
|
||||||
|
total.value = response.total
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
function cancel() {
|
||||||
|
open.value = false
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表单重置
|
||||||
|
function reset() {
|
||||||
|
form.value = {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
|
#else
|
||||||
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
#if($table.sub)
|
||||||
|
${subclassName}List.value = []
|
||||||
|
#end
|
||||||
|
proxy.resetForm("${businessName}Ref")
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
queryParams.value.pageNum = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
daterange${AttrName}.value = []
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
proxy.resetForm("queryRef")
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多选框选中数据
|
||||||
|
function handleSelectionChange(selection: ${ClassName}[]) {
|
||||||
|
ids.value = selection.map(item => item.${pkColumn.javaField})
|
||||||
|
single.value = selection.length != 1
|
||||||
|
multiple.value = !selection.length
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
function handleAdd() {
|
||||||
|
reset()
|
||||||
|
open.value = true
|
||||||
|
title.value = "添加${functionName}"
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
function handleUpdate(row: ${ClassName}) {
|
||||||
|
reset()
|
||||||
|
const _${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value[0]
|
||||||
|
get${BusinessName}(_${pkColumn.javaField}).then(response => {
|
||||||
|
form.value = response.data
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
form.value.$column.javaField = form.value.${column.javaField}.split(",")
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
${subclassName}List.value = response.data?.${subclassName}List ?? []
|
||||||
|
#end
|
||||||
|
open.value = true
|
||||||
|
title.value = "修改${functionName}"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
proxy.#[[$]]#refs["${businessName}Ref"].validate((valid: boolean) => {
|
||||||
|
if (valid) {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
form.value.$column.javaField = form.value.${column.javaField}.join(",")
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
form.value.${subclassName}List = ${subclassName}List.value
|
||||||
|
#end
|
||||||
|
if (form.value.${pkColumn.javaField} != null) {
|
||||||
|
update${BusinessName}(form.value).then(() => {
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("修改成功")
|
||||||
|
open.value = false
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
add${BusinessName}(form.value).then(() => {
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("新增成功")
|
||||||
|
open.value = false
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
function handleDelete(row: ${ClassName}) {
|
||||||
|
const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value
|
||||||
|
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').then(function() {
|
||||||
|
return del${BusinessName}(_${pkColumn.javaField}s)
|
||||||
|
}).then(() => {
|
||||||
|
getList()
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("删除成功")
|
||||||
|
}).catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
#if($table.sub)
|
||||||
|
/** ${subTable.functionName}添加按钮操作 */
|
||||||
|
function handleAdd${subClassName}() {
|
||||||
|
let obj: ${subClassName} = {}
|
||||||
|
#foreach($column in $subTable.columns)
|
||||||
|
#if($column.pk || $column.javaField == ${subTableFkclassName})
|
||||||
|
#elseif($column.list && "" != $javaField)
|
||||||
|
obj.$column.javaField = undefined
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
${subclassName}List.value.push(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ${subTable.functionName}删除按钮操作 */
|
||||||
|
function handleDelete${subClassName}() {
|
||||||
|
if (checked${subClassName}.value.length == 0) {
|
||||||
|
proxy.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据")
|
||||||
|
} else {
|
||||||
|
const ${subclassName}s = ${subclassName}List.value
|
||||||
|
const checked${subClassName}s = checked${subClassName}.value
|
||||||
|
${subclassName}List.value = ${subclassName}s.filter(function(item: any) {
|
||||||
|
return checked${subClassName}s.indexOf(item.index) == -1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 复选框选中数据 */
|
||||||
|
function handle${subClassName}SelectionChange(selection: any[]) {
|
||||||
|
checked${subClassName}.value = selection.map(item => item.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
function handleExport() {
|
||||||
|
proxy.download('${moduleName}/${businessName}/export', {
|
||||||
|
...queryParams.value
|
||||||
|
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
||||||
|
}
|
||||||
|
|
||||||
|
getList()
|
||||||
|
</script>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.ruoyi.job.domain;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
@@ -44,10 +45,12 @@ public class SysJobLog extends BaseEntity
|
|||||||
private String exceptionInfo;
|
private String exceptionInfo;
|
||||||
|
|
||||||
/** 开始时间 */
|
/** 开始时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
|
|
||||||
/** 停止时间 */
|
/** 结束时间 */
|
||||||
private Date stopTime;
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
public Long getJobLogId()
|
public Long getJobLogId()
|
||||||
{
|
{
|
||||||
@@ -129,14 +132,14 @@ public class SysJobLog extends BaseEntity
|
|||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getStopTime()
|
public Date getEndTime()
|
||||||
{
|
{
|
||||||
return stopTime;
|
return endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStopTime(Date stopTime)
|
public void setEndTime(Date endTime)
|
||||||
{
|
{
|
||||||
this.stopTime = stopTime;
|
this.endTime = endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -149,7 +152,7 @@ public class SysJobLog extends BaseEntity
|
|||||||
.append("status", getStatus())
|
.append("status", getStatus())
|
||||||
.append("exceptionInfo", getExceptionInfo())
|
.append("exceptionInfo", getExceptionInfo())
|
||||||
.append("startTime", getStartTime())
|
.append("startTime", getStartTime())
|
||||||
.append("stopTime", getStopTime())
|
.append("stopTime", getEndTime())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ public abstract class AbstractQuartzJob implements Job
|
|||||||
sysJobLog.setJobGroup(sysJob.getJobGroup());
|
sysJobLog.setJobGroup(sysJob.getJobGroup());
|
||||||
sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
|
sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
|
||||||
sysJobLog.setStartTime(startTime);
|
sysJobLog.setStartTime(startTime);
|
||||||
sysJobLog.setStopTime(new Date());
|
sysJobLog.setEndTime(new Date());
|
||||||
long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime();
|
long runMs = sysJobLog.getEndTime().getTime() - sysJobLog.getStartTime().getTime();
|
||||||
sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
|
sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
|
||||||
if (e != null)
|
if (e != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,11 +12,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="jobMessage" column="job_message" />
|
<result property="jobMessage" column="job_message" />
|
||||||
<result property="status" column="status" />
|
<result property="status" column="status" />
|
||||||
<result property="exceptionInfo" column="exception_info" />
|
<result property="exceptionInfo" column="exception_info" />
|
||||||
|
<result property="startTime" column="start_time" />
|
||||||
|
<result property="endTime" column="end_time" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectJobLogVo">
|
<sql id="selectJobLogVo">
|
||||||
select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time
|
select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, start_time, end_time, create_time
|
||||||
from sys_job_log
|
from sys_job_log
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@@ -78,6 +80,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="jobMessage != null and jobMessage != ''">job_message,</if>
|
<if test="jobMessage != null and jobMessage != ''">job_message,</if>
|
||||||
<if test="status != null and status != ''">status,</if>
|
<if test="status != null and status != ''">status,</if>
|
||||||
<if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if>
|
<if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if>
|
||||||
|
<if test="startTime != null">start_time,</if>
|
||||||
|
<if test="endTime != null">end_time,</if>
|
||||||
create_time
|
create_time
|
||||||
)values(
|
)values(
|
||||||
<if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if>
|
<if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if>
|
||||||
@@ -87,6 +91,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
|
<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
|
<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
|
||||||
|
<if test="startTime != null">#{startTime},</if>
|
||||||
|
<if test="endTime != null">#{endTime},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectJobVo">
|
<sql id="selectJobVo">
|
||||||
select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark
|
select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, update_by, update_time, remark
|
||||||
from sys_job
|
from sys_job
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.6.7</version>
|
<version>3.6.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -111,6 +112,20 @@ public class SysDeptController extends BaseController
|
|||||||
return toAjax(deptService.updateDept(dept));
|
return toAjax(deptService.updateDept(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存部门排序
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:dept:edit")
|
||||||
|
@Log(title = "保存部门排序", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/updateSort")
|
||||||
|
public AjaxResult updateSort(@RequestBody Map<String, String> params)
|
||||||
|
{
|
||||||
|
String[] deptIds = params.get("deptIds").split(",");
|
||||||
|
String[] orderNums = params.get("orderNums").split(",");
|
||||||
|
deptService.updateDeptSort(deptIds, orderNums);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除部门
|
* 删除部门
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
@@ -133,6 +134,20 @@ public class SysMenuController extends BaseController
|
|||||||
return toAjax(menuService.updateMenu(menu));
|
return toAjax(menuService.updateMenu(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存菜单排序
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:menu:edit")
|
||||||
|
@Log(title = "保存菜单排序", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/updateSort")
|
||||||
|
public AjaxResult updateSort(@RequestBody Map<String, String> params)
|
||||||
|
{
|
||||||
|
String[] menuIds = params.get("menuIds").split(",");
|
||||||
|
String[] orderNums = params.get("orderNums").split(",");
|
||||||
|
menuService.updateMenuSort(menuIds, orderNums);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单
|
* 删除菜单
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
@@ -19,6 +21,7 @@ import com.ruoyi.common.log.enums.BusinessType;
|
|||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
|
import com.ruoyi.system.service.ISysNoticeReadService;
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
import com.ruoyi.system.service.ISysNoticeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,6 +36,9 @@ public class SysNoticeController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ISysNoticeService noticeService;
|
private ISysNoticeService noticeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysNoticeReadService noticeReadService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取通知公告列表
|
* 获取通知公告列表
|
||||||
*/
|
*/
|
||||||
@@ -79,6 +85,46 @@ public class SysNoticeController extends BaseController
|
|||||||
return toAjax(noticeService.updateNotice(notice));
|
return toAjax(noticeService.updateNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页顶部公告列表(返回全部正常公告,带当前用户已读标记,最多5条)
|
||||||
|
*/
|
||||||
|
@GetMapping("/listTop")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult listTop()
|
||||||
|
{
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
List<SysNotice> list = noticeReadService.selectNoticeListWithReadStatus(userId, 5);
|
||||||
|
long unreadCount = list.stream().filter(n -> !n.getIsRead()).count();
|
||||||
|
AjaxResult result = AjaxResult.success(list);
|
||||||
|
result.put("unreadCount", unreadCount);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标记公告已读
|
||||||
|
*/
|
||||||
|
@PostMapping("/markRead")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult markRead(Long noticeId)
|
||||||
|
{
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
noticeReadService.markRead(noticeId, userId);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量标记已读
|
||||||
|
*/
|
||||||
|
@PostMapping("/markReadAll")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult markReadAll(String ids)
|
||||||
|
{
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
Long[] noticeIds = Convert.toLongArray(ids);
|
||||||
|
noticeReadService.markReadBatch(userId, noticeIds);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除通知公告
|
* 删除通知公告
|
||||||
*/
|
*/
|
||||||
@@ -87,6 +133,7 @@ public class SysNoticeController extends BaseController
|
|||||||
@DeleteMapping("/{noticeIds}")
|
@DeleteMapping("/{noticeIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
||||||
{
|
{
|
||||||
|
noticeReadService.deleteByNoticeIds(noticeIds);
|
||||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import jakarta.validation.constraints.NotBlank;
|
|||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
import com.ruoyi.common.core.xss.Xss;
|
import com.ruoyi.common.core.xss.Xss;
|
||||||
|
|
||||||
@@ -31,6 +32,10 @@ public class SysNotice extends BaseEntity
|
|||||||
/** 公告状态(0正常 1关闭) */
|
/** 公告状态(0正常 1关闭) */
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
/** 是否已读 */
|
||||||
|
@JsonProperty("isRead")
|
||||||
|
private boolean isRead;
|
||||||
|
|
||||||
public Long getNoticeId()
|
public Long getNoticeId()
|
||||||
{
|
{
|
||||||
return noticeId;
|
return noticeId;
|
||||||
@@ -84,6 +89,16 @@ public class SysNotice extends BaseEntity
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIsRead()
|
||||||
|
{
|
||||||
|
return isRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsRead(boolean isRead)
|
||||||
|
{
|
||||||
|
this.isRead = isRead;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告已读记录表 sys_notice_read
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class SysNoticeRead
|
||||||
|
{
|
||||||
|
/** 主键 */
|
||||||
|
private Long readId;
|
||||||
|
|
||||||
|
/** 公告ID */
|
||||||
|
private Long noticeId;
|
||||||
|
|
||||||
|
/** 用户ID */
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** 阅读时间 */
|
||||||
|
private Date readTime;
|
||||||
|
|
||||||
|
public Long getReadId()
|
||||||
|
{
|
||||||
|
return readId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReadId(Long readId)
|
||||||
|
{
|
||||||
|
this.readId = readId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getNoticeId()
|
||||||
|
{
|
||||||
|
return noticeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNoticeId(Long noticeId)
|
||||||
|
{
|
||||||
|
this.noticeId = noticeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUserId()
|
||||||
|
{
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Long userId)
|
||||||
|
{
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getReadTime()
|
||||||
|
{
|
||||||
|
return readTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReadTime(Date readTime)
|
||||||
|
{
|
||||||
|
this.readTime = readTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("readId", getReadId())
|
||||||
|
.append("noticeId", getNoticeId())
|
||||||
|
.append("userId", getUserId())
|
||||||
|
.append("readTime", getReadTime())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -108,6 +108,13 @@ public interface SysDeptMapper
|
|||||||
*/
|
*/
|
||||||
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
|
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存部门排序
|
||||||
|
*
|
||||||
|
* @param dept 部门信息
|
||||||
|
*/
|
||||||
|
public void updateDeptSort(SysDept dept);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除部门管理信息
|
* 删除部门管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -106,6 +106,13 @@ public interface SysMenuMapper
|
|||||||
*/
|
*/
|
||||||
public int updateMenu(SysMenu menu);
|
public int updateMenu(SysMenu menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存菜单排序
|
||||||
|
*
|
||||||
|
* @param menu 菜单信息
|
||||||
|
*/
|
||||||
|
public void updateMenuSort(SysMenu menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单管理信息
|
* 删除菜单管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import com.ruoyi.system.domain.SysNoticeRead;
|
||||||
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告已读记录 数据层
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public interface SysNoticeReadMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 新增已读记录(忽略重复)
|
||||||
|
*
|
||||||
|
* @param noticeRead 已读记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertNoticeRead(SysNoticeRead noticeRead);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询某用户未读公告数量
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 未读数量
|
||||||
|
*/
|
||||||
|
public int selectUnreadCount(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询某用户是否已读某公告
|
||||||
|
*
|
||||||
|
* @param noticeId 公告ID
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 已读记录数(0未读 1已读)
|
||||||
|
*/
|
||||||
|
public int selectIsRead(@Param("noticeId") Long noticeId, @Param("userId") Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量标记已读
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param noticeIds 公告ID数组
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertNoticeReadBatch(@Param("userId") Long userId, @Param("noticeIds") Long[] noticeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询带已读状态的公告列表(SQL层限制条数,一次查询完成)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param limit 最多返回条数
|
||||||
|
* @return 带 isRead 标记的公告列表
|
||||||
|
*/
|
||||||
|
public List<SysNotice> selectNoticeListWithReadStatus(@Param("userId") Long userId, @Param("limit") int limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告删除时清理对应已读记录
|
||||||
|
*
|
||||||
|
* @param noticeIds 公告ID数组
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteByNoticeIds(@Param("noticeIds") Long[] noticeIds);
|
||||||
|
}
|
||||||
@@ -114,6 +114,14 @@ public interface ISysDeptService
|
|||||||
*/
|
*/
|
||||||
public int updateDept(SysDept dept);
|
public int updateDept(SysDept dept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存部门排序
|
||||||
|
*
|
||||||
|
* @param deptIds 部门ID数组
|
||||||
|
* @param orderNums 排序数组
|
||||||
|
*/
|
||||||
|
public void updateDeptSort(String[] deptIds, String[] orderNums);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除部门管理信息
|
* 删除部门管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -126,6 +126,14 @@ public interface ISysMenuService
|
|||||||
*/
|
*/
|
||||||
public int updateMenu(SysMenu menu);
|
public int updateMenu(SysMenu menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存菜单排序
|
||||||
|
*
|
||||||
|
* @param menuIds 菜单ID
|
||||||
|
* @param orderNums 排序ID
|
||||||
|
*/
|
||||||
|
public void updateMenuSort(String[] menuIds, String[] orderNums);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单管理信息
|
* 删除菜单管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告已读记录 服务层
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public interface ISysNoticeReadService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 标记已读(幂等,重复调用不报错)
|
||||||
|
*
|
||||||
|
* @param noticeId 公告ID
|
||||||
|
* @param userId 用户ID
|
||||||
|
*/
|
||||||
|
public void markRead(Long noticeId, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询某用户未读公告数量
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 未读数量
|
||||||
|
*/
|
||||||
|
public int selectUnreadCount(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询公告列表并标记当前用户已读状态(用于首页展示)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param limit 最多返回条数
|
||||||
|
* @return 带 isRead 标记的公告列表
|
||||||
|
*/
|
||||||
|
public List<SysNotice> selectNoticeListWithReadStatus(Long userId, int limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量标记已读
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param noticeIds 公告ID数组
|
||||||
|
*/
|
||||||
|
public void markReadBatch(Long userId, Long[] noticeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除公告时清理对应已读记录
|
||||||
|
*
|
||||||
|
* @param noticeIds 公告ID数组
|
||||||
|
*/
|
||||||
|
public void deleteByNoticeIds(Long[] noticeIds);
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
@@ -280,6 +281,32 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存部门排序
|
||||||
|
*
|
||||||
|
* @param deptIds 部门ID数组
|
||||||
|
* @param orderNums 排序数组
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void updateDeptSort(String[] deptIds, String[] orderNums)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = 0; i < deptIds.length; i++)
|
||||||
|
{
|
||||||
|
SysDept dept = new SysDept();
|
||||||
|
dept.setDeptId(Convert.toLong(deptIds[i]));
|
||||||
|
dept.setOrderNum(Convert.toInt(orderNums[i]));
|
||||||
|
deptMapper.updateDeptSort(dept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new ServiceException("保存排序异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除部门管理信息
|
* 删除部门管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.domain.SysRole;
|
import com.ruoyi.system.api.domain.SysRole;
|
||||||
@@ -321,6 +324,32 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||||||
return menuMapper.updateMenu(menu);
|
return menuMapper.updateMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存菜单排序
|
||||||
|
*
|
||||||
|
* @param menuIds 菜单ID
|
||||||
|
* @param orderNums 排序ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void updateMenuSort(String[] menuIds, String[] orderNums)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = 0; i < menuIds.length; i++)
|
||||||
|
{
|
||||||
|
SysMenu menu = new SysMenu();
|
||||||
|
menu.setMenuId(Convert.toLong(menuIds[i]));
|
||||||
|
menu.setOrderNum(Convert.toInt(orderNums[i]));
|
||||||
|
menuMapper.updateMenuSort(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new ServiceException("保存排序异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单管理信息
|
* 删除菜单管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ruoyi.system.domain.SysNoticeRead;
|
||||||
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
|
import com.ruoyi.system.mapper.SysNoticeReadMapper;
|
||||||
|
import com.ruoyi.system.service.ISysNoticeReadService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告已读记录 服务层实现
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysNoticeReadServiceImpl implements ISysNoticeReadService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private SysNoticeReadMapper noticeReadMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标记已读
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void markRead(Long noticeId, Long userId)
|
||||||
|
{
|
||||||
|
SysNoticeRead record = new SysNoticeRead();
|
||||||
|
record.setNoticeId(noticeId);
|
||||||
|
record.setUserId(userId);
|
||||||
|
noticeReadMapper.insertNoticeRead(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询某用户未读公告数量
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int selectUnreadCount(Long userId)
|
||||||
|
{
|
||||||
|
return noticeReadMapper.selectUnreadCount(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询公告列表并标记当前用户已读状态
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysNotice> selectNoticeListWithReadStatus(Long userId, int limit)
|
||||||
|
{
|
||||||
|
return noticeReadMapper.selectNoticeListWithReadStatus(userId, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量标记已读
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void markReadBatch(Long userId, Long[] noticeIds)
|
||||||
|
{
|
||||||
|
if (noticeIds == null || noticeIds.length == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
noticeReadMapper.insertNoticeReadBatch(userId, noticeIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除公告时清理对应已读记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteByNoticeIds(Long[] noticeIds)
|
||||||
|
{
|
||||||
|
noticeReadMapper.deleteByNoticeIds(noticeIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -150,6 +150,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="updateDeptSort" parameterType="SysDept">
|
||||||
|
update sys_dept set order_num = #{orderNum} where dept_id = #{deptId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<delete id="deleteDeptById" parameterType="Long">
|
<delete id="deleteDeptById" parameterType="Long">
|
||||||
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|||||||
@@ -204,6 +204,10 @@
|
|||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateMenuSort" parameterType="SysMenu">
|
||||||
|
update sys_menu set order_num = #{orderNum} where menu_id = #{menuId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<delete id="deleteMenuById" parameterType="Long">
|
<delete id="deleteMenuById" parameterType="Long">
|
||||||
delete from sys_menu where menu_id = #{menuId}
|
delete from sys_menu where menu_id = #{menuId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
AND create_by like concat('%', #{createBy}, '%')
|
AND create_by like concat('%', #{createBy}, '%')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by notice_id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertNotice" parameterType="SysNotice">
|
<insert id="insertNotice" parameterType="SysNotice">
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.system.mapper.SysNoticeReadMapper">
|
||||||
|
|
||||||
|
<resultMap type="SysNoticeRead" id="SysNoticeReadResult">
|
||||||
|
<id property="readId" column="read_id" />
|
||||||
|
<result property="noticeId" column="notice_id" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="readTime" column="read_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 新增已读记录 -->
|
||||||
|
<insert id="insertNoticeRead" parameterType="SysNoticeRead">
|
||||||
|
insert ignore into sys_notice_read (notice_id, user_id, read_time)
|
||||||
|
values (#{noticeId}, #{userId}, sysdate())
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 查询未读数量:正常状态公告 减去 当前用户已读数 -->
|
||||||
|
<select id="selectUnreadCount" resultType="int">
|
||||||
|
select count(*) from sys_notice n
|
||||||
|
where n.status = '0' and not exists (select 1 from sys_notice_read r where r.notice_id = n.notice_id and r.user_id = #{userId})
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询是否已读 -->
|
||||||
|
<select id="selectIsRead" resultType="int">
|
||||||
|
select count(*) from sys_notice_read where notice_id = #{noticeId} and user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询带已读状态的公告列表(直接在SQL中限制条数) -->
|
||||||
|
<select id="selectNoticeListWithReadStatus" resultType="SysNotice">
|
||||||
|
select
|
||||||
|
n.notice_id as noticeId,
|
||||||
|
n.notice_title as noticeTitle,
|
||||||
|
n.notice_type as noticeType,
|
||||||
|
n.status,
|
||||||
|
n.create_by as createBy,
|
||||||
|
n.create_time as createTime,
|
||||||
|
case when r.notice_id is not null then true else false end as isRead
|
||||||
|
from sys_notice n
|
||||||
|
left join sys_notice_read r
|
||||||
|
on r.notice_id = n.notice_id and r.user_id = #{userId}
|
||||||
|
where n.status = '0'
|
||||||
|
order by n.notice_id desc
|
||||||
|
limit #{limit}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 批量标记已读 -->
|
||||||
|
<insert id="insertNoticeReadBatch">
|
||||||
|
insert ignore into sys_notice_read (notice_id, user_id, read_time)
|
||||||
|
values
|
||||||
|
<foreach collection="noticeIds" item="noticeId" separator=",">
|
||||||
|
(#{noticeId}, #{userId}, sysdate())
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 删除公告时清理已读记录 -->
|
||||||
|
<delete id="deleteByNoticeIds">
|
||||||
|
delete from sys_notice_read where notice_id in
|
||||||
|
<foreach collection="noticeIds" item="noticeId" open="(" separator="," close=")">
|
||||||
|
#{noticeId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ruoyi",
|
"name": "ruoyi",
|
||||||
"version": "3.6.7",
|
"version": "3.6.8",
|
||||||
"description": "若依管理系统",
|
"description": "若依管理系统",
|
||||||
"author": "若依",
|
"author": "若依",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@riophae/vue-treeselect": "0.4.0",
|
"@riophae/vue-treeselect": "0.4.0",
|
||||||
"axios": "0.28.1",
|
"axios": "0.30.3",
|
||||||
"clipboard": "2.0.8",
|
"clipboard": "2.0.8",
|
||||||
"core-js": "3.37.1",
|
"core-js": "3.37.1",
|
||||||
"echarts": "5.4.0",
|
"echarts": "5.4.0",
|
||||||
|
|||||||
@@ -25,6 +25,15 @@ export function register(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解锁屏幕
|
||||||
|
export function unlockScreen(password) {
|
||||||
|
return request({
|
||||||
|
url: '/auth/unlockscreen',
|
||||||
|
method: 'post',
|
||||||
|
data: { password }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 刷新方法
|
// 刷新方法
|
||||||
export function refreshToken() {
|
export function refreshToken() {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -43,6 +43,15 @@ export function updateDept(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 保存部门排序
|
||||||
|
export function updateDeptSort(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/dept/updateSort',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 删除部门
|
// 删除部门
|
||||||
export function delDept(deptId) {
|
export function delDept(deptId) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -51,6 +51,15 @@ export function updateMenu(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 保存菜单排序
|
||||||
|
export function updateMenuSort(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/menu/updateSort',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 删除菜单
|
// 删除菜单
|
||||||
export function delMenu(menuId) {
|
export function delMenu(menuId) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -42,3 +42,29 @@ export function delNotice(noticeId) {
|
|||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 首页顶部公告列表(带已读状态)
|
||||||
|
export function listNoticeTop() {
|
||||||
|
return request({
|
||||||
|
url: '/system/notice/listTop',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 标记公告已读
|
||||||
|
export function markNoticeRead(noticeId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/notice/markRead',
|
||||||
|
method: 'post',
|
||||||
|
params: { noticeId }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量标记已读
|
||||||
|
export function markNoticeReadAll(ids) {
|
||||||
|
return request({
|
||||||
|
url: '/system/notice/markReadAll',
|
||||||
|
method: 'post',
|
||||||
|
params: { ids }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
1
ruoyi-ui/src/assets/icons/svg/bell.svg
Normal file
1
ruoyi-ui/src/assets/icons/svg/bell.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1773923748724" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5930" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M512 212l48.8 12c101.6 24.8 176 117.6 176 220.8v254.4l18.4 18.4 24.8 25.6h-536l24.8-25.6 18.4-18.4V444.8c0-103.2 73.6-196.8 176-220.8l48.8-12M512 64c-36.8 0-64 30.4-64 68v30.4C320.8 192 223.2 307.2 223.2 444.8v228.8L136 763.2v44.8h752v-44.8l-87.2-89.6V444.8c0-137.6-97.6-252.8-224.8-283.2v-28.8c0-32-17.6-60.8-48-67.2-5.6-1.6-11.2-1.6-16-1.6z m88 808H424c0 49.6 38.4 88 88 88s88-38.4 88-88z" p-id="5931"></path></svg>
|
||||||
|
After Width: | Height: | Size: 750 B |
@@ -82,3 +82,11 @@
|
|||||||
.el-range-separator {
|
.el-range-separator {
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.el-menu--collapse
|
||||||
|
> div
|
||||||
|
> .el-submenu
|
||||||
|
> .el-submenu__title
|
||||||
|
.el-submenu__icon-arrow {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ $--button-font-weight: 400;
|
|||||||
$--border-color-light: #dfe4ed;
|
$--border-color-light: #dfe4ed;
|
||||||
$--border-color-lighter: #e6ebf5;
|
$--border-color-lighter: #e6ebf5;
|
||||||
|
|
||||||
$--table-border:1px solid#dfe6ec;
|
$--table-border: 1px solid #dfe6ec;
|
||||||
|
|
||||||
/* icon font path, required */
|
/* icon font path, required */
|
||||||
$--font-path: '~element-ui/lib/theme-chalk/fonts';
|
$--font-path: '~element-ui/lib/theme-chalk/fonts';
|
||||||
|
|||||||
@@ -81,6 +81,10 @@
|
|||||||
margin-top: 6vh !important;
|
margin-top: 6vh !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.el-dialog__body {
|
||||||
|
padding: 8px 20px !important;
|
||||||
|
}
|
||||||
|
|
||||||
.el-dialog__wrapper.scrollbar .el-dialog .el-dialog__body {
|
.el-dialog__wrapper.scrollbar .el-dialog .el-dialog__body {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
@@ -228,6 +232,120 @@
|
|||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 详细卡片样式 */
|
||||||
|
.detail-wrap { padding: 0 4px; }
|
||||||
|
|
||||||
|
.detail-card {
|
||||||
|
border: 1px solid #ebeef5;
|
||||||
|
border-radius: 6px;
|
||||||
|
margin-bottom: 14px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-card-title {
|
||||||
|
background: #f7f9fb;
|
||||||
|
padding: 8px 16px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
border-bottom: 1px solid #ebeef5;
|
||||||
|
}
|
||||||
|
.detail-card-title i { margin-right: 5px; color: #409EFF; }
|
||||||
|
|
||||||
|
.detail-row { padding: 0 8px; }
|
||||||
|
|
||||||
|
.detail-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
padding: 10px 8px;
|
||||||
|
font-size: 13px;
|
||||||
|
border-bottom: 1px solid #f5f7fa;
|
||||||
|
}
|
||||||
|
.detail-item:last-child { border-bottom: none; }
|
||||||
|
|
||||||
|
.detail-label {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 72px;
|
||||||
|
color: #909399;
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
.detail-value { color: #303133; flex: 1; word-break: break-all; }
|
||||||
|
.detail-location { color: #999; font-size: 12px; }
|
||||||
|
|
||||||
|
.method-tag {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 1px 7px;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-right: 6px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
.mono { font-family: Consolas, 'SFMono-Regular', monospace; font-size: 12px; }
|
||||||
|
.code-body { padding: 14px; }
|
||||||
|
.code-wrap {
|
||||||
|
background: #f7f9fb;
|
||||||
|
border: 1px solid #e8ecf0;
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
max-height: 260px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.code-action {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
right: 8px;
|
||||||
|
z-index: 10;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.code-action .el-button {
|
||||||
|
height: 24px;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.9);
|
||||||
|
border: 1px solid #dcdcdc;
|
||||||
|
}
|
||||||
|
.code-action .el-button:hover {
|
||||||
|
background: #ffffff;
|
||||||
|
border-color: #409EFF;
|
||||||
|
}
|
||||||
|
.code-pre {
|
||||||
|
margin: 0;
|
||||||
|
padding: 12px 14px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.6;
|
||||||
|
font-family: Consolas, 'SFMono-Regular', monospace;
|
||||||
|
color: #444;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
overflow: auto;
|
||||||
|
max-height: 240px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* error */
|
||||||
|
.error-title { color: #c0392b !important; }
|
||||||
|
.error-title i { color: #c0392b !important; }
|
||||||
|
.error-body { padding: 12px 16px; }
|
||||||
|
.error-msg {
|
||||||
|
background: #fff8f8;
|
||||||
|
border-left: 3px solid #e74c3c;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
color: #c0392b;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.7;
|
||||||
|
word-break: break-all;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* http method */
|
||||||
|
.method-GET { background: #e8f5e9; color: #27ae60; }
|
||||||
|
.method-POST { background: #e3f2fd; color: #1565c0; }
|
||||||
|
.method-PUT { background: #fff3e0; color: #e65100; }
|
||||||
|
.method-DELETE { background: #ffebee; color: #c62828; }
|
||||||
|
|
||||||
/* text color */
|
/* text color */
|
||||||
.text-navy {
|
.text-navy {
|
||||||
color: #1ab394;
|
color: #1ab394;
|
||||||
|
|||||||
@@ -74,6 +74,8 @@
|
|||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
text-overflow: ellipsis !important;
|
text-overflow: ellipsis !important;
|
||||||
white-space: nowrap !important;
|
white-space: nowrap !important;
|
||||||
|
height: 44px !important;
|
||||||
|
line-height: 44px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
// menu hover
|
// menu hover
|
||||||
@@ -105,6 +107,96 @@
|
|||||||
background-color: $base-sub-menu-hover !important;
|
background-color: $base-sub-menu-hover !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// theme-dark 深色主题
|
||||||
|
&.theme-dark {
|
||||||
|
box-shadow: 2px 0 8px rgba(0, 0, 0, 0.4);
|
||||||
|
border-right: none;
|
||||||
|
|
||||||
|
.el-menu-item.is-active {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background-color: var(--current-color-dark-bg, rgba(64, 158, 255, 0.2));
|
||||||
|
border-right: 3px solid var(--current-color, #409eff);
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-submenu.is-active > .el-submenu__title {
|
||||||
|
color: var(--current-color, #409eff) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu-item:not(.is-active),
|
||||||
|
.submenu-title-noDropdown,
|
||||||
|
.el-submenu__title {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background-color: transparent;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 1;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover::before {
|
||||||
|
background-color: var(--current-color-dark-bg, rgba(64, 158, 255, 0.2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// theme-light 浅色主题
|
||||||
|
&.theme-light {
|
||||||
|
border-right: 1px solid #e8eaf0;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.el-menu-item,
|
||||||
|
.el-submenu__title {
|
||||||
|
color: rgba(0, 0, 0, 0.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu-item.is-active {
|
||||||
|
color: var(--current-color, #409eff) !important;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background-color: var(--current-color-light, #ecf5ff);
|
||||||
|
border-right: 3px solid var(--current-color, #409eff);
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-submenu.is-active > .el-submenu__title {
|
||||||
|
color: var(--current-color, #409eff) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu-item:not(.is-active):hover,
|
||||||
|
.submenu-title-noDropdown:hover,
|
||||||
|
.el-submenu__title:hover {
|
||||||
|
background-color: #f5f7fa !important;
|
||||||
|
color: rgba(0, 0, 0, 0.85) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nest-menu .el-submenu > .el-submenu__title,
|
||||||
|
.el-submenu .el-menu-item {
|
||||||
|
background-color: #fafafa !important;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: #f0f5ff !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.hideSidebar {
|
.hideSidebar {
|
||||||
|
|||||||
@@ -9,32 +9,17 @@ $yellow:#FEC171;
|
|||||||
$panGreen: #30B08F;
|
$panGreen: #30B08F;
|
||||||
|
|
||||||
// 默认菜单主题风格
|
// 默认菜单主题风格
|
||||||
$base-menu-color:#bfcbd9;
|
$base-menu-color: #bfcbd9;
|
||||||
$base-menu-color-active:#f4f4f5;
|
$base-menu-color-active: #ffffff;
|
||||||
$base-menu-background:#304156;
|
$base-menu-background: #1a1f2e;
|
||||||
$base-logo-title-color: #ffffff;
|
$base-logo-title-color: #ffffff;
|
||||||
|
|
||||||
$base-menu-light-color:rgba(0,0,0,.70);
|
$base-menu-light-color:rgba(0,0,0,.70);
|
||||||
$base-menu-light-background:#ffffff;
|
$base-menu-light-background:#ffffff;
|
||||||
$base-logo-light-title-color: #001529;
|
$base-logo-light-title-color: #001529;
|
||||||
|
|
||||||
$base-sub-menu-background:#1f2d3d;
|
$base-sub-menu-background: #141824;
|
||||||
$base-sub-menu-hover:#001528;
|
$base-sub-menu-hover: rgba(255,255,255,.06);
|
||||||
|
|
||||||
// 自定义暗色菜单风格
|
|
||||||
/**
|
|
||||||
$base-menu-color:hsla(0,0%,100%,.65);
|
|
||||||
$base-menu-color-active:#fff;
|
|
||||||
$base-menu-background:#001529;
|
|
||||||
$base-logo-title-color: #ffffff;
|
|
||||||
|
|
||||||
$base-menu-light-color:rgba(0,0,0,.70);
|
|
||||||
$base-menu-light-background:#ffffff;
|
|
||||||
$base-logo-light-title-color: #001529;
|
|
||||||
|
|
||||||
$base-sub-menu-background:#000c17;
|
|
||||||
$base-sub-menu-hover:#001528;
|
|
||||||
*/
|
|
||||||
|
|
||||||
$base-sidebar-width: 200px;
|
$base-sidebar-width: 200px;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
:visible.sync="show"
|
:visible.sync="show"
|
||||||
width="600px"
|
width="600px"
|
||||||
@close="close"
|
@close="close"
|
||||||
|
@opened="onDialogOpened"
|
||||||
:show-close="false"
|
:show-close="false"
|
||||||
append-to-body
|
append-to-body
|
||||||
>
|
>
|
||||||
@@ -21,24 +22,54 @@
|
|||||||
@keydown.down.native="navigateResult('down')"
|
@keydown.down.native="navigateResult('down')"
|
||||||
>
|
>
|
||||||
</el-input>
|
</el-input>
|
||||||
|
|
||||||
|
<div class="result-count" v-if="search && options.length > 0">
|
||||||
|
找到 <strong>{{ options.length }}</strong> 个结果
|
||||||
|
</div>
|
||||||
|
|
||||||
<el-scrollbar wrap-class="right-scrollbar-wrapper">
|
<el-scrollbar wrap-class="right-scrollbar-wrapper">
|
||||||
<div class="result-wrap">
|
<div class="result-wrap">
|
||||||
<div class="search-item" v-for="(item, index) in options" :key="item.path" :style="activeStyle(index)" @mouseenter="activeIndex = index" @mouseleave="activeIndex = -1">
|
<template v-if="options.length > 0">
|
||||||
|
<div
|
||||||
|
class="search-item"
|
||||||
|
v-for="(item, index) in options"
|
||||||
|
:key="item.path"
|
||||||
|
:class="{ 'is-active': index === activeIndex }"
|
||||||
|
:style="activeStyle(index)"
|
||||||
|
@mouseenter="activeIndex = index"
|
||||||
|
@mouseleave="activeIndex = -1"
|
||||||
|
>
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<svg-icon class="menu-icon" :icon-class="item.icon" />
|
<svg-icon class="menu-icon" :icon-class="item.icon" />
|
||||||
</div>
|
</div>
|
||||||
<div class="search-info" @click="change(item)">
|
<div class="search-info" @click="change(item)">
|
||||||
<div class="menu-title">
|
<div class="menu-title" v-html="highlightText(item.title.join(' / '))"></div>
|
||||||
{{ item.title.join(" / ") }}
|
<div class="menu-path" v-html="highlightText(item.path)"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-path">
|
<svg-icon icon-class="enter" v-show="index === activeIndex" />
|
||||||
{{ item.path }}
|
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="empty-state" v-else-if="search && options.length === 0">
|
||||||
|
<i class="el-icon-search empty-icon"></i>
|
||||||
|
<p class="empty-text">未找到 "<strong>{{ search }}</strong>" 相关菜单</p>
|
||||||
|
<p class="empty-tip">试试其他关键词或路径</p>
|
||||||
</div>
|
</div>
|
||||||
<svg-icon icon-class="enter" v-show="index === activeIndex"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
|
|
||||||
|
<div class="search-footer">
|
||||||
|
<span class="shortcut-item">
|
||||||
|
<kbd>↑</kbd><kbd>↓</kbd> 切换
|
||||||
|
</span>
|
||||||
|
<span class="shortcut-item">
|
||||||
|
<kbd>↵</kbd> 选择
|
||||||
|
</span>
|
||||||
|
<span class="shortcut-item">
|
||||||
|
<kbd>Esc</kbd> 关闭
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -83,33 +114,37 @@ export default {
|
|||||||
click() {
|
click() {
|
||||||
this.show = !this.show
|
this.show = !this.show
|
||||||
if (this.show) {
|
if (this.show) {
|
||||||
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.focus()
|
|
||||||
this.options = this.searchPool
|
this.options = this.searchPool
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onDialogOpened() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.headerSearchSelectRef && this.$refs.headerSearchSelectRef.focus()
|
||||||
|
})
|
||||||
|
},
|
||||||
close() {
|
close() {
|
||||||
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.blur()
|
this.$refs.headerSearchSelectRef && this.$refs.headerSearchSelectRef.blur()
|
||||||
this.search = ''
|
this.search = ''
|
||||||
this.options = []
|
this.options = this.searchPool
|
||||||
this.show = false
|
this.show = false
|
||||||
this.activeIndex = -1
|
this.activeIndex = -1
|
||||||
},
|
},
|
||||||
change(val) {
|
change(val) {
|
||||||
const path = val.path
|
const p = val.path
|
||||||
const query = val.query
|
const query = val.query
|
||||||
if(isHttp(val.path)) {
|
if (isHttp(val.path)) {
|
||||||
// http(s):// 路径新窗口打开
|
// http(s):// 路径新窗口打开
|
||||||
const pindex = path.indexOf("http")
|
const pindex = p.indexOf('http')
|
||||||
window.open(path.substr(pindex, path.length), "_blank")
|
window.open(p.substr(pindex, p.length), '_blank')
|
||||||
} else {
|
} else {
|
||||||
if (query) {
|
if (query) {
|
||||||
this.$router.push({ path: path, query: JSON.parse(query) })
|
this.$router.push({ path: p, query: JSON.parse(query) })
|
||||||
} else {
|
} else {
|
||||||
this.$router.push(path)
|
this.$router.push(p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.search = ''
|
this.search = ''
|
||||||
this.options = []
|
this.options = this.searchPool
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.show = false
|
this.show = false
|
||||||
})
|
})
|
||||||
@@ -117,7 +152,7 @@ export default {
|
|||||||
initFuse(list) {
|
initFuse(list) {
|
||||||
this.fuse = new Fuse(list, {
|
this.fuse = new Fuse(list, {
|
||||||
shouldSort: true,
|
shouldSort: true,
|
||||||
threshold: 0.4,
|
threshold: 0.2,
|
||||||
minMatchCharLength: 1,
|
minMatchCharLength: 1,
|
||||||
keys: [{
|
keys: [{
|
||||||
name: 'title',
|
name: 'title',
|
||||||
@@ -128,37 +163,25 @@ export default {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// Filter out the routes that can be displayed in the sidebar
|
|
||||||
// And generate the internationalized title
|
|
||||||
generateRoutes(routes, basePath = '/', prefixTitle = []) {
|
generateRoutes(routes, basePath = '/', prefixTitle = []) {
|
||||||
let res = []
|
let res = []
|
||||||
|
|
||||||
for (const router of routes) {
|
for (const router of routes) {
|
||||||
// skip hidden router
|
|
||||||
if (router.hidden) { continue }
|
if (router.hidden) { continue }
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
path: !isHttp(router.path) ? path.resolve(basePath, router.path) : router.path,
|
path: !isHttp(router.path) ? path.resolve(basePath, router.path) : router.path,
|
||||||
title: [...prefixTitle],
|
title: [...prefixTitle],
|
||||||
icon: ''
|
icon: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
if (router.meta && router.meta.title) {
|
if (router.meta && router.meta.title) {
|
||||||
data.title = [...data.title, router.meta.title]
|
data.title = [...data.title, router.meta.title]
|
||||||
data.icon = router.meta.icon
|
data.icon = router.meta.icon
|
||||||
|
|
||||||
if (router.redirect !== 'noRedirect') {
|
if (router.redirect !== 'noRedirect') {
|
||||||
// only push the routes with title
|
|
||||||
// special case: need to exclude parent router without redirect
|
|
||||||
res.push(data)
|
res.push(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (router.query) {
|
if (router.query) {
|
||||||
data.query = router.query
|
data.query = router.query
|
||||||
}
|
}
|
||||||
|
|
||||||
// recursive child routes
|
|
||||||
if (router.children) {
|
if (router.children) {
|
||||||
const tempRoutes = this.generateRoutes(router.children, data.path, data.title)
|
const tempRoutes = this.generateRoutes(router.children, data.path, data.title)
|
||||||
if (tempRoutes.length >= 1) {
|
if (tempRoutes.length >= 1) {
|
||||||
@@ -171,7 +194,18 @@ export default {
|
|||||||
querySearch(query) {
|
querySearch(query) {
|
||||||
this.activeIndex = -1
|
this.activeIndex = -1
|
||||||
if (query !== '') {
|
if (query !== '') {
|
||||||
this.options = this.fuse.search(query).map((item) => item.item) ?? this.searchPool
|
const q = query.toLowerCase()
|
||||||
|
const pathMatches = this.searchPool.filter(item =>
|
||||||
|
item.path.toLowerCase().includes(q)
|
||||||
|
)
|
||||||
|
const fuseMatches = this.fuse.search(query).map(item => item.item)
|
||||||
|
const merged = [...pathMatches]
|
||||||
|
fuseMatches.forEach(item => {
|
||||||
|
if (!merged.find(m => m.path === item.path)) {
|
||||||
|
merged.push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.options = merged
|
||||||
} else {
|
} else {
|
||||||
this.options = this.searchPool
|
this.options = this.searchPool
|
||||||
}
|
}
|
||||||
@@ -179,14 +213,14 @@ export default {
|
|||||||
activeStyle(index) {
|
activeStyle(index) {
|
||||||
if (index !== this.activeIndex) return {}
|
if (index !== this.activeIndex) return {}
|
||||||
return {
|
return {
|
||||||
"background-color": this.theme,
|
'background-color': this.theme,
|
||||||
"color": "#fff"
|
'color': '#fff'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
navigateResult(direction) {
|
navigateResult(direction) {
|
||||||
if (direction === "up") {
|
if (direction === 'up') {
|
||||||
this.activeIndex = this.activeIndex <= 0 ? this.options.length - 1 : this.activeIndex - 1
|
this.activeIndex = this.activeIndex <= 0 ? this.options.length - 1 : this.activeIndex - 1
|
||||||
} else if (direction === "down") {
|
} else if (direction === 'down') {
|
||||||
this.activeIndex = this.activeIndex >= this.options.length - 1 ? 0 : this.activeIndex + 1
|
this.activeIndex = this.activeIndex >= this.options.length - 1 ? 0 : this.activeIndex + 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -194,6 +228,16 @@ export default {
|
|||||||
if (this.options.length > 0 && this.activeIndex >= 0) {
|
if (this.options.length > 0 && this.activeIndex >= 0) {
|
||||||
this.change(this.options[this.activeIndex])
|
this.change(this.options[this.activeIndex])
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
highlightText(text) {
|
||||||
|
if (!text) return ''
|
||||||
|
if (!this.search) return text
|
||||||
|
const keyword = this.escapeRegExp(this.search)
|
||||||
|
const reg = new RegExp(`(${keyword})`, 'gi')
|
||||||
|
return text.replace(reg, '<span class="highlight">$1</span>')
|
||||||
|
},
|
||||||
|
escapeRegExp(str) {
|
||||||
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,7 +246,17 @@ export default {
|
|||||||
<style lang='scss' scoped>
|
<style lang='scss' scoped>
|
||||||
::v-deep {
|
::v-deep {
|
||||||
.el-dialog__header {
|
.el-dialog__header {
|
||||||
padding: 0 !important;
|
padding: 6px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight {
|
||||||
|
color: red;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-active .highlight {
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,19 +268,33 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.result-count {
|
||||||
|
padding: 6px 16px 0;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #aaa;
|
||||||
|
|
||||||
|
strong {
|
||||||
|
color: red;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.result-wrap {
|
.result-wrap {
|
||||||
height: 280px;
|
height: 280px;
|
||||||
margin: 6px 0;
|
margin: 4px 0;
|
||||||
|
|
||||||
.search-item {
|
.search-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background 0.15s;
|
||||||
|
|
||||||
.left {
|
.left {
|
||||||
width: 60px;
|
width: 60px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
.menu-icon {
|
.menu-icon {
|
||||||
width: 18px;
|
width: 18px;
|
||||||
@@ -242,11 +310,16 @@ export default {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
.menu-title,
|
.menu-title,
|
||||||
.menu-path {
|
.menu-path {
|
||||||
height: 20px;
|
height: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-path {
|
.menu-path {
|
||||||
color: #ccc;
|
color: #ccc;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
@@ -257,6 +330,68 @@ export default {
|
|||||||
.search-item:hover {
|
.search-item:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
.empty-icon {
|
||||||
|
font-size: 42px;
|
||||||
|
color: #e0e0e0;
|
||||||
|
margin-bottom: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-text {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #999;
|
||||||
|
margin: 0 0 6px;
|
||||||
|
|
||||||
|
strong {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-tip {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #bbb;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 28px;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-top: 1px solid #f0f0f0;
|
||||||
|
color: #999;
|
||||||
|
font-size: 12px;
|
||||||
|
|
||||||
|
.shortcut-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
kbd {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
padding: 0 5px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #f7f7f7;
|
||||||
|
color: #555;
|
||||||
|
font-size: 11px;
|
||||||
|
font-family: inherit;
|
||||||
|
line-height: 1;
|
||||||
|
box-shadow: 0 1px 0 #ccc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,34 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
// 搜索
|
// 搜索
|
||||||
toggleSearch() {
|
toggleSearch() {
|
||||||
this.$emit("update:showSearch", !this.showSearch)
|
let el = this.$el
|
||||||
|
let formEl = null
|
||||||
|
while ((el = el.parentElement) && el !== document.body) {
|
||||||
|
if ((formEl = el.querySelector('.el-form'))) break
|
||||||
|
}
|
||||||
|
if (!formEl) return this.$emit('update:showSearch', !this.showSearch)
|
||||||
|
this._animateSearch(formEl, this.showSearch)
|
||||||
|
},
|
||||||
|
// 搜索栏动画
|
||||||
|
_animateSearch(el, isHide) {
|
||||||
|
const DURATION = 260
|
||||||
|
const TRANSITION = 'max-height 0.25s ease, opacity 0.2s ease'
|
||||||
|
const clear = () => Object.assign(el.style, { transition: '', maxHeight: '', opacity: '', overflow: '' })
|
||||||
|
Object.assign(el.style, { overflow: 'hidden', transition: '' })
|
||||||
|
if (isHide) {
|
||||||
|
Object.assign(el.style, { maxHeight: el.scrollHeight + 'px', opacity: '1', transition: TRANSITION })
|
||||||
|
requestAnimationFrame(() => Object.assign(el.style, { maxHeight: '0', opacity: '0' }))
|
||||||
|
setTimeout(() => { this.$emit('update:showSearch', false); clear() }, DURATION)
|
||||||
|
} else {
|
||||||
|
this.$emit('update:showSearch', true)
|
||||||
|
this.$nextTick(() => {
|
||||||
|
Object.assign(el.style, { maxHeight: '0', opacity: '0' })
|
||||||
|
requestAnimationFrame(() => requestAnimationFrame(() => {
|
||||||
|
Object.assign(el.style, { transition: TRANSITION, maxHeight: el.scrollHeight + 'px', opacity: '1' })
|
||||||
|
}))
|
||||||
|
setTimeout(clear, DURATION)
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 刷新
|
// 刷新
|
||||||
refresh() {
|
refresh() {
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ export default {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
&:fullscreen,
|
||||||
|
&:-webkit-full-screen,
|
||||||
|
&:-moz-full-screen,
|
||||||
|
&:-ms-fullscreen {
|
||||||
|
background: #fff;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.fixed-header + .app-main {
|
.fixed-header + .app-main {
|
||||||
|
|||||||
229
ruoyi-ui/src/layout/components/HeaderNotice/index.vue
Normal file
229
ruoyi-ui/src/layout/components/HeaderNotice/index.vue
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-popover ref="noticePopover" placement="bottom-end" width="320" trigger="manual" :value="noticeVisible" popper-class="notice-popover">
|
||||||
|
<div class="notice-header">
|
||||||
|
<span class="notice-title">通知公告</span>
|
||||||
|
<span class="notice-mark-all" @click="markAllRead">全部已读</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="noticeLoading" class="notice-loading"><i class="el-icon-loading"></i> 加载中...</div>
|
||||||
|
<div v-else-if="noticeList.length === 0" class="notice-empty"><i class="el-icon-inbox"></i><br>暂无公告</div>
|
||||||
|
<div v-else>
|
||||||
|
<div v-for="item in noticeList" :key="item.noticeId" class="notice-item" :class="{ 'is-read': item.isRead }" @click="previewNotice(item)">
|
||||||
|
<el-tag size="mini" :type="item.noticeType === '1' ? 'warning' : 'success'" class="notice-tag">
|
||||||
|
{{ item.noticeType === '1' ? '通知' : '公告' }}
|
||||||
|
</el-tag>
|
||||||
|
<span class="notice-item-title">{{ item.noticeTitle }}</span>
|
||||||
|
<span class="notice-item-date">{{ item.createTime }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-popover>
|
||||||
|
|
||||||
|
<div v-popover:noticePopover class="right-menu-item hover-effect notice-trigger" @mouseenter="onNoticeEnter" @mouseleave="onNoticeLeave">
|
||||||
|
<svg-icon icon-class="bell" />
|
||||||
|
<span v-if="unreadCount > 0" class="notice-badge">{{ unreadCount }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-dialog :title="previewTitle" :visible.sync="previewVisible" width="680px" append-to-body custom-class="notice-preview-dialog">
|
||||||
|
<div class="notice-preview-meta">
|
||||||
|
<el-tag size="small" :type="previewNoticeType === '1' ? 'warning' : 'success'">
|
||||||
|
{{ previewNoticeType === '1' ? '通知' : '公告' }}
|
||||||
|
</el-tag>
|
||||||
|
<span class="notice-preview-info"><i class="el-icon-user"></i> {{ previewCreateBy }}</span>
|
||||||
|
<span class="notice-preview-info"><i class="el-icon-time"></i> {{ previewCreateTime }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="notice-preview-divider"></div>
|
||||||
|
<div class="notice-preview-content" v-html="previewContent"></div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listNoticeTop, markNoticeRead, markNoticeReadAll, getNotice } from '@/api/system/notice'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'HeaderNotice',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
noticeList: [], // 通知列表
|
||||||
|
unreadCount: 0, // 未读数量
|
||||||
|
noticeLoading: false, // 加载状态
|
||||||
|
noticeVisible: false, // 弹出层显示状态
|
||||||
|
noticeLeaveTimer: null, // 鼠标离开计时器
|
||||||
|
previewVisible: false, // 预览弹窗显示状态
|
||||||
|
previewTitle: '', // 预览弹窗标题
|
||||||
|
previewContent: '', // 预览弹窗内容
|
||||||
|
previewNoticeType: '', // 预览弹窗类型
|
||||||
|
previewCreateBy: '', // 预览弹窗创建人
|
||||||
|
previewCreateTime: '' // 预览弹窗创建时间
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.loadNoticeTop()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 鼠标移入铃铛区域
|
||||||
|
onNoticeEnter() {
|
||||||
|
clearTimeout(this.noticeLeaveTimer)
|
||||||
|
this.noticeVisible = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const popper = this.$refs.noticePopover.$refs.popper
|
||||||
|
if (popper && !popper._noticeBound) {
|
||||||
|
popper._noticeBound = true
|
||||||
|
popper.addEventListener('mouseenter', () => clearTimeout(this.noticeLeaveTimer))
|
||||||
|
popper.addEventListener('mouseleave', () => {
|
||||||
|
this.noticeLeaveTimer = setTimeout(() => { this.noticeVisible = false }, 100)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 鼠标离开铃铛区域
|
||||||
|
onNoticeLeave() {
|
||||||
|
this.noticeLeaveTimer = setTimeout(() => { this.noticeVisible = false }, 150)
|
||||||
|
},
|
||||||
|
// 加载顶部公告列表
|
||||||
|
loadNoticeTop() {
|
||||||
|
this.noticeLoading = true
|
||||||
|
listNoticeTop().then(res => {
|
||||||
|
this.noticeList = res.data || []
|
||||||
|
this.unreadCount = res.unreadCount !== undefined ? res.unreadCount : this.noticeList.filter(n => !n.isRead).length
|
||||||
|
}).finally(() => {
|
||||||
|
this.noticeLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 预览公告详情
|
||||||
|
previewNotice(item) {
|
||||||
|
if (!item.isRead) {
|
||||||
|
markNoticeRead(item.noticeId).catch(() => {})
|
||||||
|
item.isRead = true
|
||||||
|
const idx = this.noticeList.indexOf(item)
|
||||||
|
if (idx !== -1) this.$set(this.noticeList, idx, { ...item, isRead: true })
|
||||||
|
this.unreadCount = Math.max(0, this.unreadCount - 1)
|
||||||
|
}
|
||||||
|
getNotice(item.noticeId).then(res => {
|
||||||
|
const notice = res.data
|
||||||
|
this.previewTitle = notice.noticeTitle
|
||||||
|
this.previewContent = notice.noticeContent
|
||||||
|
this.previewNoticeType = notice.noticeType
|
||||||
|
this.previewCreateBy = notice.createBy
|
||||||
|
this.previewCreateTime = notice.createTime
|
||||||
|
this.previewVisible = true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 全部已读
|
||||||
|
markAllRead() {
|
||||||
|
const ids = this.noticeList.map(n => n.noticeId).join(',')
|
||||||
|
if (!ids) return
|
||||||
|
markNoticeReadAll(ids).catch(() => {})
|
||||||
|
this.noticeList = this.noticeList.map(n => ({ ...n, isRead: true }))
|
||||||
|
this.unreadCount = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.notice-trigger {
|
||||||
|
position: relative;
|
||||||
|
transform: translateX(-6px);
|
||||||
|
.svg-icon { width: 1.2em; height: 1.2em; vertical-align: -0.2em; }
|
||||||
|
.notice-badge {
|
||||||
|
position: absolute;
|
||||||
|
top: 7px;
|
||||||
|
right: -3px;
|
||||||
|
background: #f56c6c;
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 10px;
|
||||||
|
height: 16px;
|
||||||
|
line-height: 16px;
|
||||||
|
padding: 0 4px;
|
||||||
|
min-width: 16px;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.notice-popover {
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
.notice-popover .notice-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 10px 14px;
|
||||||
|
background: #f7f9fb;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.notice-popover .notice-mark-all {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #409EFF;
|
||||||
|
font-weight: normal;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.notice-popover .notice-mark-all:hover { color: #2b7cc1; }
|
||||||
|
.notice-popover .notice-loading,
|
||||||
|
.notice-popover .notice-empty {
|
||||||
|
padding: 24px;
|
||||||
|
text-align: center;
|
||||||
|
color: #bbb;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.8;
|
||||||
|
}
|
||||||
|
.notice-popover .notice-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
border-bottom: 1px solid #f5f5f5;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.15s;
|
||||||
|
}
|
||||||
|
.notice-popover .notice-item:last-child { border-bottom: none; }
|
||||||
|
.notice-popover .notice-item:hover { background: #f7f9fb; }
|
||||||
|
.notice-popover .notice-item.is-read .notice-tag,
|
||||||
|
.notice-popover .notice-item.is-read .notice-item-title,
|
||||||
|
.notice-popover .notice-item.is-read .notice-item-date { opacity: 0.45; filter: grayscale(1); color: #999; }
|
||||||
|
.notice-popover .notice-tag { flex-shrink: 0; }
|
||||||
|
.notice-popover .notice-item-title {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #333;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.notice-popover .notice-item-date {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 11px;
|
||||||
|
color: #bbb;
|
||||||
|
}
|
||||||
|
::v-deep .notice-preview-dialog {
|
||||||
|
.el-dialog__body { padding: 0 20px 20px; }
|
||||||
|
.notice-preview-meta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
padding: 12px 0;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #888;
|
||||||
|
.notice-preview-info { display: flex; align-items: center; gap: 4px; }
|
||||||
|
}
|
||||||
|
.notice-preview-divider {
|
||||||
|
height: 1px;
|
||||||
|
background: linear-gradient(to right, transparent, #e2e8f0, transparent);
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
.notice-preview-content {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.85;
|
||||||
|
color: #2d3748;
|
||||||
|
word-break: break-word;
|
||||||
|
img { max-width: 100%; border-radius: 4px; }
|
||||||
|
p { margin: 0 0 1em; }
|
||||||
|
a { color: #409EFF; text-decoration: underline; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -26,6 +26,10 @@
|
|||||||
<size-select id="size-select" class="right-menu-item hover-effect" />
|
<size-select id="size-select" class="right-menu-item hover-effect" />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
|
<el-tooltip content="消息通知" effect="dark" placement="bottom">
|
||||||
|
<header-notice id="header-notice" class="right-menu-item hover-effect" />
|
||||||
|
</el-tooltip>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="hover">
|
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="hover">
|
||||||
@@ -40,6 +44,9 @@
|
|||||||
<el-dropdown-item @click.native="setLayout" v-if="setting">
|
<el-dropdown-item @click.native="setLayout" v-if="setting">
|
||||||
<span>布局设置</span>
|
<span>布局设置</span>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item @click.native="lockScreen">
|
||||||
|
<span>锁定屏幕</span>
|
||||||
|
</el-dropdown-item>
|
||||||
<el-dropdown-item divided @click.native="logout">
|
<el-dropdown-item divided @click.native="logout">
|
||||||
<span>退出登录</span>
|
<span>退出登录</span>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
@@ -61,9 +68,9 @@ import SizeSelect from '@/components/SizeSelect'
|
|||||||
import Search from '@/components/HeaderSearch'
|
import Search from '@/components/HeaderSearch'
|
||||||
import RuoYiGit from '@/components/RuoYi/Git'
|
import RuoYiGit from '@/components/RuoYi/Git'
|
||||||
import RuoYiDoc from '@/components/RuoYi/Doc'
|
import RuoYiDoc from '@/components/RuoYi/Doc'
|
||||||
|
import HeaderNotice from './HeaderNotice'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
emits: ['setLayout'],
|
|
||||||
components: {
|
components: {
|
||||||
Breadcrumb,
|
Breadcrumb,
|
||||||
Logo,
|
Logo,
|
||||||
@@ -74,7 +81,8 @@ export default {
|
|||||||
SizeSelect,
|
SizeSelect,
|
||||||
Search,
|
Search,
|
||||||
RuoYiGit,
|
RuoYiGit,
|
||||||
RuoYiDoc
|
RuoYiDoc,
|
||||||
|
HeaderNotice
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
@@ -106,6 +114,12 @@ export default {
|
|||||||
setLayout(event) {
|
setLayout(event) {
|
||||||
this.$emit('setLayout')
|
this.$emit('setLayout')
|
||||||
},
|
},
|
||||||
|
lockScreen() {
|
||||||
|
const currentPath = this.$route.fullPath
|
||||||
|
this.$store.dispatch('lock/lockScreen', currentPath).then(() => {
|
||||||
|
this.$router.push('/lock')
|
||||||
|
})
|
||||||
|
},
|
||||||
logout() {
|
logout() {
|
||||||
this.$confirm('确定注销并退出系统吗?', '提示', {
|
this.$confirm('确定注销并退出系统吗?', '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
@@ -173,11 +187,6 @@ export default {
|
|||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.errLog-container {
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right-menu {
|
.right-menu {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
line-height: 50px;
|
line-height: 50px;
|
||||||
|
|||||||
@@ -65,6 +65,11 @@
|
|||||||
<el-switch v-model="tagsView" class="drawer-switch" />
|
<el-switch v-model="tagsView" class="drawer-switch" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="drawer-item">
|
||||||
|
<span>持久化标签页</span>
|
||||||
|
<el-switch v-model="tagsViewPersist" :disabled="!tagsView" class="drawer-switch" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="drawer-item">
|
<div class="drawer-item">
|
||||||
<span>显示页签图标</span>
|
<span>显示页签图标</span>
|
||||||
<el-switch v-model="tagsIcon" :disabled="!tagsView" class="drawer-switch" />
|
<el-switch v-model="tagsIcon" :disabled="!tagsView" class="drawer-switch" />
|
||||||
@@ -125,6 +130,17 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
tagsViewPersist: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.settings.tagsViewPersist
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.$store.dispatch('settings/changeSetting', {
|
||||||
|
key: 'tagsViewPersist',
|
||||||
|
value: val
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
tagsView: {
|
tagsView: {
|
||||||
get() {
|
get() {
|
||||||
return this.$store.state.settings.tagsView
|
return this.$store.state.settings.tagsView
|
||||||
@@ -231,12 +247,16 @@ export default {
|
|||||||
},
|
},
|
||||||
saveSetting() {
|
saveSetting() {
|
||||||
this.$modal.loading("正在保存到本地,请稍候...")
|
this.$modal.loading("正在保存到本地,请稍候...")
|
||||||
|
if (!this.tagsViewPersist) {
|
||||||
|
this.$cache.local.remove('tags-view-visited')
|
||||||
|
}
|
||||||
this.$cache.local.set(
|
this.$cache.local.set(
|
||||||
"layout-setting",
|
"layout-setting",
|
||||||
`{
|
`{
|
||||||
"navType":${this.navType},
|
"navType":${this.navType},
|
||||||
"tagsView":${this.tagsView},
|
"tagsView":${this.tagsView},
|
||||||
"tagsIcon":${this.tagsIcon},
|
"tagsIcon":${this.tagsIcon},
|
||||||
|
"tagsViewPersist":${this.tagsViewPersist},
|
||||||
"fixedHeader":${this.fixedHeader},
|
"fixedHeader":${this.fixedHeader},
|
||||||
"sidebarLogo":${this.sidebarLogo},
|
"sidebarLogo":${this.sidebarLogo},
|
||||||
"dynamicTitle":${this.dynamicTitle},
|
"dynamicTitle":${this.dynamicTitle},
|
||||||
@@ -249,6 +269,7 @@ export default {
|
|||||||
},
|
},
|
||||||
resetSetting() {
|
resetSetting() {
|
||||||
this.$modal.loading("正在清除设置缓存并刷新,请稍候...")
|
this.$modal.loading("正在清除设置缓存并刷新,请稍候...")
|
||||||
|
this.$cache.local.remove('tags-view-visited')
|
||||||
this.$cache.local.remove("layout-setting")
|
this.$cache.local.remove("layout-setting")
|
||||||
setTimeout("window.location.reload()", 1000)
|
setTimeout("window.location.reload()", 1000)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
|
<div :class="['sidebar-theme-wrapper', {'has-logo':showLogo}, settings.sideTheme]" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
|
||||||
<logo v-if="showLogo" :collapse="isCollapse" />
|
<logo v-if="showLogo" :collapse="isCollapse" />
|
||||||
<el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
|
<el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
|
||||||
<el-menu
|
<el-menu
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const tagAndTagSpacing = 4 // tagAndTagSpacing
|
const tagAndTagSpacing = 4
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ScrollPane',
|
name: 'ScrollPane',
|
||||||
@@ -26,13 +26,44 @@ export default {
|
|||||||
this.scrollWrapper.removeEventListener('scroll', this.emitScroll)
|
this.scrollWrapper.removeEventListener('scroll', this.emitScroll)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
smoothScrollTo(target) {
|
||||||
|
const $scrollWrapper = this.scrollWrapper
|
||||||
|
const start = $scrollWrapper.scrollLeft
|
||||||
|
const distance = target - start
|
||||||
|
const duration = 300
|
||||||
|
let startTime = null
|
||||||
|
|
||||||
|
function ease(t, b, c, d) {
|
||||||
|
t /= d / 2
|
||||||
|
if (t < 1) return c / 2 * t * t + b
|
||||||
|
t--
|
||||||
|
return -c / 2 * (t * (t - 2) - 1) + b
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = this.$emit.bind(this)
|
||||||
|
function step(timestamp) {
|
||||||
|
if (!startTime) startTime = timestamp
|
||||||
|
const elapsed = timestamp - startTime
|
||||||
|
$scrollWrapper.scrollLeft = ease(elapsed, start, distance, duration)
|
||||||
|
if (elapsed < duration) {
|
||||||
|
requestAnimationFrame(step)
|
||||||
|
} else {
|
||||||
|
$scrollWrapper.scrollLeft = target
|
||||||
|
emit('updateArrows')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(step)
|
||||||
|
},
|
||||||
handleScroll(e) {
|
handleScroll(e) {
|
||||||
const eventDelta = e.wheelDelta || -e.deltaY * 40
|
const eventDelta = e.wheelDelta || -e.deltaY * 40
|
||||||
const $scrollWrapper = this.scrollWrapper
|
const $scrollWrapper = this.scrollWrapper
|
||||||
$scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4
|
$scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4
|
||||||
|
this.$emit('updateArrows')
|
||||||
},
|
},
|
||||||
emitScroll() {
|
emitScroll() {
|
||||||
this.$emit('scroll')
|
this.$emit('scroll')
|
||||||
|
this.$emit('updateArrows')
|
||||||
},
|
},
|
||||||
moveToTarget(currentTag) {
|
moveToTarget(currentTag) {
|
||||||
const $container = this.$refs.scrollContainer.$el
|
const $container = this.$refs.scrollContainer.$el
|
||||||
@@ -43,34 +74,56 @@ export default {
|
|||||||
let firstTag = null
|
let firstTag = null
|
||||||
let lastTag = null
|
let lastTag = null
|
||||||
|
|
||||||
// find first tag and last tag
|
|
||||||
if (tagList.length > 0) {
|
if (tagList.length > 0) {
|
||||||
firstTag = tagList[0]
|
firstTag = tagList[0]
|
||||||
lastTag = tagList[tagList.length - 1]
|
lastTag = tagList[tagList.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstTag === currentTag) {
|
if (firstTag === currentTag) {
|
||||||
$scrollWrapper.scrollLeft = 0
|
this.smoothScrollTo(0)
|
||||||
} else if (lastTag === currentTag) {
|
} else if (lastTag === currentTag) {
|
||||||
$scrollWrapper.scrollLeft = $scrollWrapper.scrollWidth - $containerWidth
|
this.smoothScrollTo($scrollWrapper.scrollWidth - $containerWidth)
|
||||||
} else {
|
} else {
|
||||||
// find preTag and nextTag
|
|
||||||
const currentIndex = tagList.findIndex(item => item === currentTag)
|
const currentIndex = tagList.findIndex(item => item === currentTag)
|
||||||
const prevTag = tagList[currentIndex - 1]
|
const prevTag = tagList[currentIndex - 1]
|
||||||
const nextTag = tagList[currentIndex + 1]
|
const nextTag = tagList[currentIndex + 1]
|
||||||
|
|
||||||
// the tag's offsetLeft after of nextTag
|
|
||||||
const afterNextTagOffsetLeft = nextTag.$el.offsetLeft + nextTag.$el.offsetWidth + tagAndTagSpacing
|
const afterNextTagOffsetLeft = nextTag.$el.offsetLeft + nextTag.$el.offsetWidth + tagAndTagSpacing
|
||||||
|
|
||||||
// the tag's offsetLeft before of prevTag
|
|
||||||
const beforePrevTagOffsetLeft = prevTag.$el.offsetLeft - tagAndTagSpacing
|
const beforePrevTagOffsetLeft = prevTag.$el.offsetLeft - tagAndTagSpacing
|
||||||
|
|
||||||
if (afterNextTagOffsetLeft > $scrollWrapper.scrollLeft + $containerWidth) {
|
if (afterNextTagOffsetLeft > $scrollWrapper.scrollLeft + $containerWidth) {
|
||||||
$scrollWrapper.scrollLeft = afterNextTagOffsetLeft - $containerWidth
|
this.smoothScrollTo(afterNextTagOffsetLeft - $containerWidth)
|
||||||
} else if (beforePrevTagOffsetLeft < $scrollWrapper.scrollLeft) {
|
} else if (beforePrevTagOffsetLeft < $scrollWrapper.scrollLeft) {
|
||||||
$scrollWrapper.scrollLeft = beforePrevTagOffsetLeft
|
this.smoothScrollTo(beforePrevTagOffsetLeft)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// 向左滚动固定距离
|
||||||
|
scrollLeft() {
|
||||||
|
const $scrollWrapper = this.scrollWrapper
|
||||||
|
this.smoothScrollTo(Math.max(0, $scrollWrapper.scrollLeft - 200))
|
||||||
|
},
|
||||||
|
// 向右滚动固定距离
|
||||||
|
scrollRight() {
|
||||||
|
const $scrollWrapper = this.scrollWrapper
|
||||||
|
const maxScroll = $scrollWrapper.scrollWidth - $scrollWrapper.clientWidth
|
||||||
|
this.smoothScrollTo(Math.min(maxScroll, $scrollWrapper.scrollLeft + 200))
|
||||||
|
},
|
||||||
|
// 直接平滑滚动到最左端
|
||||||
|
scrollToStart() {
|
||||||
|
this.smoothScrollTo(0)
|
||||||
|
},
|
||||||
|
// 直接平滑滚动到最右端
|
||||||
|
scrollToEnd() {
|
||||||
|
const $scrollWrapper = this.scrollWrapper
|
||||||
|
this.smoothScrollTo($scrollWrapper.scrollWidth - $scrollWrapper.clientWidth)
|
||||||
|
},
|
||||||
|
// 获取是否可以继续向左/右滚动
|
||||||
|
getScrollState() {
|
||||||
|
const $scrollWrapper = this.scrollWrapper
|
||||||
|
return {
|
||||||
|
canLeft: $scrollWrapper.scrollLeft > 0,
|
||||||
|
canRight: $scrollWrapper.scrollLeft < $scrollWrapper.scrollWidth - $scrollWrapper.clientWidth - 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,7 +140,9 @@ export default {
|
|||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
}
|
}
|
||||||
.el-scrollbar__wrap {
|
.el-scrollbar__wrap {
|
||||||
height: 49px;
|
height: 34px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="tags-view-container" class="tags-view-container">
|
<div id="tags-view-container" class="tags-view-container">
|
||||||
<scroll-pane ref="scrollPane" class="tags-view-wrapper" @scroll="handleScroll">
|
<!-- 左切换箭头 -->
|
||||||
|
<span class="tags-nav-btn tags-nav-btn--left" :class="{ disabled: !canScrollLeft }" @click="scrollLeft">
|
||||||
|
<i class="el-icon-arrow-left" />
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<!-- 标签滚动区 -->
|
||||||
|
<scroll-pane ref="scrollPane" class="tags-view-wrapper" @scroll="handleScroll" @updateArrows="updateArrowState">
|
||||||
<router-link
|
<router-link
|
||||||
v-for="tag in visitedViews"
|
v-for="tag in visitedViews"
|
||||||
ref="tag"
|
ref="tag"
|
||||||
@@ -10,15 +16,45 @@
|
|||||||
tag="span"
|
tag="span"
|
||||||
class="tags-view-item"
|
class="tags-view-item"
|
||||||
:style="activeStyle(tag)"
|
:style="activeStyle(tag)"
|
||||||
@click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''"
|
@click.middle.native="!isAffix(tag) ? closeSelectedTag(tag) : ''"
|
||||||
@contextmenu.prevent.native="openMenu(tag,$event)"
|
@contextmenu.prevent.native="openMenu(tag, $event)"
|
||||||
>
|
>
|
||||||
<svg-icon v-if="tagsIcon && tag.meta && tag.meta.icon && tag.meta.icon !== '#'" :icon-class="tag.meta.icon" />
|
<svg-icon v-if="tagsIcon && tag.meta && tag.meta.icon && tag.meta.icon !== '#'" :icon-class="tag.meta.icon" />
|
||||||
{{ tag.title }}
|
{{ tag.title }}
|
||||||
<span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
|
<span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
|
||||||
</router-link>
|
</router-link>
|
||||||
</scroll-pane>
|
</scroll-pane>
|
||||||
<ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu">
|
|
||||||
|
<!-- 右切换箭头 -->
|
||||||
|
<span class="tags-nav-btn tags-nav-btn--right" :class="{ disabled: !canScrollRight }" @click="scrollRight">
|
||||||
|
<i class="el-icon-arrow-right" />
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<!-- 下拉操作菜单 -->
|
||||||
|
<el-dropdown class="tags-action-dropdown" trigger="click" placement="bottom-end" @command="handleDropdownCommand">
|
||||||
|
<span class="tags-action-btn">
|
||||||
|
<i class="el-icon-arrow-down" />
|
||||||
|
</span>
|
||||||
|
<el-dropdown-menu slot="dropdown" class="tags-dropdown-menu">
|
||||||
|
<el-dropdown-item v-if="!isAffix(selectedDropdownTag)" command="close" icon="el-icon-close">关闭当前</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="closeOthers" icon="el-icon-circle-close">关闭其他</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="closeLeft" :disabled="isFirstView()" icon="el-icon-back">关闭左侧</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="closeRight" :disabled="isLastView()" icon="el-icon-right">关闭右侧</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="closeAll" icon="el-icon-circle-close">全部关闭</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="fullscreen" divided>
|
||||||
|
<template v-if="!isFullscreen"><i class="el-icon-full-screen"></i>全屏显示</template>
|
||||||
|
<template v-else><i class="el-icon-close"></i>退出全屏</template>
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
|
|
||||||
|
<!-- 刷新按钮 -->
|
||||||
|
<span class="tags-action-btn tags-refresh-btn" title="刷新页面" @click="refreshSelectedTag(selectedDropdownTag)">
|
||||||
|
<i class="el-icon-refresh-right" /> 刷新
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<!-- 右键上下文菜单 -->
|
||||||
|
<ul v-show="visible" :style="{ left: left + 'px', top: top + 'px' }" class="contextmenu">
|
||||||
<li @click="refreshSelectedTag(selectedTag)"><i class="el-icon-refresh-right"></i> 刷新页面</li>
|
<li @click="refreshSelectedTag(selectedTag)"><i class="el-icon-refresh-right"></i> 刷新页面</li>
|
||||||
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)"><i class="el-icon-close"></i> 关闭当前</li>
|
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)"><i class="el-icon-close"></i> 关闭当前</li>
|
||||||
<li @click="closeOthersTags"><i class="el-icon-circle-close"></i> 关闭其他</li>
|
<li @click="closeOthersTags"><i class="el-icon-circle-close"></i> 关闭其他</li>
|
||||||
@@ -41,7 +77,11 @@ export default {
|
|||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
selectedTag: {},
|
selectedTag: {},
|
||||||
affixTags: []
|
affixTags: [],
|
||||||
|
canScrollLeft: false,
|
||||||
|
canScrollRight: false,
|
||||||
|
isFullscreen: false,
|
||||||
|
hiddenElements: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -56,6 +96,9 @@ export default {
|
|||||||
},
|
},
|
||||||
tagsIcon() {
|
tagsIcon() {
|
||||||
return this.$store.state.settings.tagsIcon
|
return this.$store.state.settings.tagsIcon
|
||||||
|
},
|
||||||
|
selectedDropdownTag() {
|
||||||
|
return this.visitedViews.find(v => this.isActive(v)) || {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -69,13 +112,30 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
document.body.removeEventListener('click', this.closeMenu)
|
document.body.removeEventListener('click', this.closeMenu)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
visitedViews() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.updateArrowState()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initTags()
|
this.initTags()
|
||||||
this.addTags()
|
this.addTags()
|
||||||
|
window.addEventListener('resize', this.updateArrowState)
|
||||||
|
window.addEventListener('keydown', this.handleKeyDown)
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
window.removeEventListener('resize', this.updateArrowState)
|
||||||
|
window.removeEventListener('keydown', this.handleKeyDown)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleKeyDown(event) {
|
||||||
|
// 当按下Esc键且处于全屏状态时,退出全屏
|
||||||
|
if (event.key === 'Escape' && this.isFullscreen) {
|
||||||
|
this.toggleFullscreen()
|
||||||
|
}
|
||||||
|
},
|
||||||
isActive(route) {
|
isActive(route) {
|
||||||
return route.path === this.$route.path
|
return route.path === this.$route.path
|
||||||
},
|
},
|
||||||
@@ -87,18 +147,20 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
isAffix(tag) {
|
isAffix(tag) {
|
||||||
return tag.meta && tag.meta.affix
|
return tag && tag.meta && tag.meta.affix
|
||||||
},
|
},
|
||||||
isFirstView() {
|
isFirstView() {
|
||||||
try {
|
try {
|
||||||
return this.selectedTag.fullPath === '/index' || this.selectedTag.fullPath === this.visitedViews[1].fullPath
|
const tag = this.selectedTag && this.selectedTag.fullPath ? this.selectedTag : this.selectedDropdownTag
|
||||||
|
return tag.fullPath === '/index' || tag.fullPath === this.visitedViews[1].fullPath
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isLastView() {
|
isLastView() {
|
||||||
try {
|
try {
|
||||||
return this.selectedTag.fullPath === this.visitedViews[this.visitedViews.length - 1].fullPath
|
const tag = this.selectedTag && this.selectedTag.fullPath ? this.selectedTag : this.selectedDropdownTag
|
||||||
|
return tag.fullPath === this.visitedViews[this.visitedViews.length - 1].fullPath
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -125,11 +187,13 @@ export default {
|
|||||||
return tags
|
return tags
|
||||||
},
|
},
|
||||||
initTags() {
|
initTags() {
|
||||||
|
if (this.$store.state.settings.tagsViewPersist) {
|
||||||
|
this.$store.dispatch('tagsView/loadPersistedViews')
|
||||||
|
}
|
||||||
const affixTags = this.affixTags = this.filterAffixTags(this.routes)
|
const affixTags = this.affixTags = this.filterAffixTags(this.routes)
|
||||||
for (const tag of affixTags) {
|
for (const tag of affixTags) {
|
||||||
// Must have tag name
|
|
||||||
if (tag.name) {
|
if (tag.name) {
|
||||||
this.$store.dispatch('tagsView/addVisitedView', tag)
|
this.$store.dispatch('tagsView/addAffixView', tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -145,7 +209,6 @@ export default {
|
|||||||
for (const tag of tags) {
|
for (const tag of tags) {
|
||||||
if (tag.to.path === this.$route.path) {
|
if (tag.to.path === this.$route.path) {
|
||||||
this.$refs.scrollPane.moveToTarget(tag)
|
this.$refs.scrollPane.moveToTarget(tag)
|
||||||
// when query is different then update
|
|
||||||
if (tag.to.fullPath !== this.$route.fullPath) {
|
if (tag.to.fullPath !== this.$route.fullPath) {
|
||||||
this.$store.dispatch('tagsView/updateVisitedView', this.$route)
|
this.$store.dispatch('tagsView/updateVisitedView', this.$route)
|
||||||
}
|
}
|
||||||
@@ -154,6 +217,85 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
scrollLeft() {
|
||||||
|
if (!this.canScrollLeft) return
|
||||||
|
this.$refs.scrollPane.scrollToStart()
|
||||||
|
},
|
||||||
|
scrollRight() {
|
||||||
|
if (!this.canScrollRight) return
|
||||||
|
this.$refs.scrollPane.scrollToEnd()
|
||||||
|
},
|
||||||
|
updateArrowState() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.scrollPane) {
|
||||||
|
const state = this.$refs.scrollPane.getScrollState()
|
||||||
|
this.canScrollLeft = state.canLeft
|
||||||
|
this.canScrollRight = state.canRight
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
toggleFullscreen() {
|
||||||
|
const mainContainer = document.querySelector('.main-container')
|
||||||
|
const navbar = document.querySelector('.navbar')
|
||||||
|
const sidebar = document.querySelector('.sidebar-container')
|
||||||
|
if (!mainContainer) return
|
||||||
|
|
||||||
|
if (!this.isFullscreen) {
|
||||||
|
mainContainer.classList.add('fullscreen-mode')
|
||||||
|
document.body.style.overflow = 'hidden'
|
||||||
|
const elementsToHide = [
|
||||||
|
{ el: navbar, originalDisplay: (navbar && navbar.style.display) || '' },
|
||||||
|
{ el: sidebar, originalDisplay: (sidebar && sidebar.style.display) || '' }
|
||||||
|
]
|
||||||
|
elementsToHide.forEach(item => {
|
||||||
|
if (item.el && item.el.style.display !== 'none') {
|
||||||
|
item.originalDisplay = item.el.style.display
|
||||||
|
item.el.style.display = 'none'
|
||||||
|
this.hiddenElements.push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.isFullscreen = true
|
||||||
|
} else {
|
||||||
|
mainContainer.classList.remove('fullscreen-mode')
|
||||||
|
document.body.style.overflow = ''
|
||||||
|
this.hiddenElements.forEach(item => {
|
||||||
|
if (item.el) {
|
||||||
|
item.el.style.display = item.originalDisplay
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.hiddenElements = []
|
||||||
|
const btn = document.querySelector('.tags-action-btn')
|
||||||
|
if (btn) btn.blur()
|
||||||
|
this.isFullscreen = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleDropdownCommand(command) {
|
||||||
|
const tag = this.selectedDropdownTag
|
||||||
|
this.selectedTag = tag
|
||||||
|
switch (command) {
|
||||||
|
case 'refresh':
|
||||||
|
this.refreshSelectedTag(tag)
|
||||||
|
break
|
||||||
|
case 'fullscreen':
|
||||||
|
this.toggleFullscreen()
|
||||||
|
break
|
||||||
|
case 'close':
|
||||||
|
this.closeSelectedTag(tag)
|
||||||
|
break
|
||||||
|
case 'closeOthers':
|
||||||
|
this.closeOthersTags()
|
||||||
|
break
|
||||||
|
case 'closeLeft':
|
||||||
|
this.closeLeftTags()
|
||||||
|
break
|
||||||
|
case 'closeRight':
|
||||||
|
this.closeRightTags()
|
||||||
|
break
|
||||||
|
case 'closeAll':
|
||||||
|
this.closeAllTags(tag)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
},
|
||||||
refreshSelectedTag(view) {
|
refreshSelectedTag(view) {
|
||||||
this.$tab.refreshPage(view)
|
this.$tab.refreshPage(view)
|
||||||
if (this.$route.meta.link) {
|
if (this.$route.meta.link) {
|
||||||
@@ -182,7 +324,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
closeOthersTags() {
|
closeOthersTags() {
|
||||||
this.$router.push(this.selectedTag.fullPath).catch(()=>{})
|
this.$router.push(this.selectedTag.fullPath).catch(() => {})
|
||||||
this.$tab.closeOtherPage(this.selectedTag).then(() => {
|
this.$tab.closeOtherPage(this.selectedTag).then(() => {
|
||||||
this.moveToCurrentTag()
|
this.moveToCurrentTag()
|
||||||
})
|
})
|
||||||
@@ -200,10 +342,7 @@ export default {
|
|||||||
if (latestView) {
|
if (latestView) {
|
||||||
this.$router.push(latestView.fullPath)
|
this.$router.push(latestView.fullPath)
|
||||||
} else {
|
} else {
|
||||||
// now the default is to redirect to the home page if there is no tags-view,
|
if (view && view.name === 'Dashboard') {
|
||||||
// you can adjust it according to your needs.
|
|
||||||
if (view.name === 'Dashboard') {
|
|
||||||
// to reload home page
|
|
||||||
this.$router.replace({ path: '/redirect' + view.fullPath })
|
this.$router.replace({ path: '/redirect' + view.fullPath })
|
||||||
} else {
|
} else {
|
||||||
this.$router.push('/')
|
this.$router.push('/')
|
||||||
@@ -211,18 +350,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
openMenu(tag, e) {
|
openMenu(tag, e) {
|
||||||
const menuMinWidth = 105
|
this.left = e.clientX
|
||||||
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
|
|
||||||
const offsetWidth = this.$el.offsetWidth // container width
|
|
||||||
const maxLeft = offsetWidth - menuMinWidth // left boundary
|
|
||||||
const left = e.clientX - offsetLeft + 15 // 15: margin right
|
|
||||||
|
|
||||||
if (left > maxLeft) {
|
|
||||||
this.left = maxLeft
|
|
||||||
} else {
|
|
||||||
this.left = left
|
|
||||||
}
|
|
||||||
|
|
||||||
this.top = e.clientY
|
this.top = e.clientY
|
||||||
this.visible = true
|
this.visible = true
|
||||||
this.selectedTag = tag
|
this.selectedTag = tag
|
||||||
@@ -232,6 +360,7 @@ export default {
|
|||||||
},
|
},
|
||||||
handleScroll() {
|
handleScroll() {
|
||||||
this.closeMenu()
|
this.closeMenu()
|
||||||
|
this.updateArrowState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,8 +372,52 @@ export default {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-bottom: 1px solid #d8dce5;
|
border-bottom: 1px solid #d8dce5;
|
||||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 0 3px 0 rgba(0, 0, 0, .04);
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
$btn-width: 28px;
|
||||||
|
$btn-color: #71717a;
|
||||||
|
$btn-hover-bg: #f0f2f5;
|
||||||
|
$btn-hover-color: #303133;
|
||||||
|
$btn-disabled-color: #c0c4cc;
|
||||||
|
$divider: 1px solid #d8dce5;
|
||||||
|
|
||||||
|
.tags-nav-btn {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: $btn-width;
|
||||||
|
height: 34px;
|
||||||
|
cursor: pointer;
|
||||||
|
color: $btn-color;
|
||||||
|
font-size: 13px;
|
||||||
|
user-select: none;
|
||||||
|
transition: background 0.15s, color 0.15s;
|
||||||
|
|
||||||
|
&:hover:not(.disabled) {
|
||||||
|
background: $btn-hover-bg;
|
||||||
|
color: $btn-hover-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
color: $btn-disabled-color;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--left {
|
||||||
|
border-right: $divider;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--right {
|
||||||
|
border-left: $divider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.tags-view-wrapper {
|
.tags-view-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
|
||||||
.tags-view-item {
|
.tags-view-item {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -257,9 +430,10 @@ export default {
|
|||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
margin-top: 4px;
|
border-radius: 3px;
|
||||||
|
|
||||||
&:first-of-type {
|
&:first-of-type {
|
||||||
margin-left: 15px;
|
margin-left: 6px;
|
||||||
}
|
}
|
||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
@@ -286,11 +460,40 @@ export default {
|
|||||||
content: none !important;
|
content: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tags-action-dropdown {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-action-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: $btn-width;
|
||||||
|
height: 34px;
|
||||||
|
cursor: pointer;
|
||||||
|
color: $btn-color;
|
||||||
|
font-size: 13px;
|
||||||
|
border-left: $divider;
|
||||||
|
user-select: none;
|
||||||
|
transition: background 0.15s, color 0.15s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: $btn-hover-bg;
|
||||||
|
color: $btn-hover-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-refresh-btn {
|
||||||
|
width: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
.contextmenu {
|
.contextmenu {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
z-index: 3000;
|
z-index: 3000;
|
||||||
position: absolute;
|
position: fixed;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@@ -298,6 +501,7 @@ export default {
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: #333;
|
color: #333;
|
||||||
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, .3);
|
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, .3);
|
||||||
|
|
||||||
li {
|
li {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 7px 16px;
|
padding: 7px 16px;
|
||||||
@@ -311,7 +515,6 @@ export default {
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
//reset element css of el-icon-close
|
|
||||||
.tags-view-wrapper {
|
.tags-view-wrapper {
|
||||||
.tags-view-item {
|
.tags-view-item {
|
||||||
.el-icon-close {
|
.el-icon-close {
|
||||||
@@ -334,4 +537,41 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 页签全屏模式样式 */
|
||||||
|
.main-container.fullscreen-mode {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-container.fullscreen-mode .fixed-header {
|
||||||
|
display: block !important;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 100% !important;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-container.fullscreen-mode .fixed-header .navbar {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-container.fullscreen-mode .app-main {
|
||||||
|
position: fixed;
|
||||||
|
top: 34px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
margin: 0 !important;
|
||||||
|
padding: 0 !important;
|
||||||
|
height: calc(100vh - 34px) !important;
|
||||||
|
min-height: calc(100vh - 34px) !important;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="classObj" class="app-wrapper" :style="{'--current-color': theme}">
|
<div :class="classObj" class="app-wrapper" :style="{'--current-color': theme, '--current-color-light': theme + '1a', '--current-color-dark-bg': theme + '33'}">
|
||||||
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside"/>
|
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside"/>
|
||||||
<sidebar v-if="!sidebar.hide" class="sidebar-container"/>
|
<sidebar v-if="!sidebar.hide" class="sidebar-container"/>
|
||||||
<div :class="{hasTagsView:needTagsView,sidebarHide:sidebar.hide}" class="main-container">
|
<div :class="{hasTagsView:needTagsView,sidebarHide:sidebar.hide}" class="main-container">
|
||||||
|
|||||||
@@ -19,12 +19,19 @@ router.beforeEach((to, from, next) => {
|
|||||||
NProgress.start()
|
NProgress.start()
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
||||||
|
const isLock = store.getters.isLock
|
||||||
/* has token*/
|
/* has token*/
|
||||||
if (to.path === '/login') {
|
if (to.path === '/login') {
|
||||||
next({ path: '/' })
|
next({ path: '/' })
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
} else if (isWhiteList(to.path)) {
|
} else if (isWhiteList(to.path)) {
|
||||||
next()
|
next()
|
||||||
|
} else if (isLock && to.path !== '/lock') {
|
||||||
|
next({ path: '/lock' })
|
||||||
|
NProgress.done()
|
||||||
|
} else if (!isLock && to.path === '/lock') {
|
||||||
|
next({ path: '/' })
|
||||||
|
NProgress.done()
|
||||||
} else {
|
} else {
|
||||||
if (store.getters.roles.length === 0) {
|
if (store.getters.roles.length === 0) {
|
||||||
isRelogin.show = true
|
isRelogin.show = true
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ export default {
|
|||||||
// 刷新当前tab页签
|
// 刷新当前tab页签
|
||||||
refreshPage(obj) {
|
refreshPage(obj) {
|
||||||
const { path, query, matched } = router.currentRoute
|
const { path, query, matched } = router.currentRoute
|
||||||
|
// 防止在重定向过程中重复刷新
|
||||||
|
if (path.startsWith('/redirect/')) {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
if (obj === undefined) {
|
if (obj === undefined) {
|
||||||
matched.forEach((m) => {
|
matched.forEach((m) => {
|
||||||
if (m.components && m.components.default && m.components.default.name) {
|
if (m.components && m.components.default && m.components.default.name) {
|
||||||
|
|||||||
@@ -74,6 +74,12 @@ export const constantRoutes = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/lock',
|
||||||
|
component: () => import('@/views/lock'),
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '锁定屏幕' }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/user',
|
path: '/user',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
tagsView: true,
|
tagsView: true,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 持久化标签页
|
||||||
|
*/
|
||||||
|
tagsViewPersist: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示页签图标
|
* 显示页签图标
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ const getters = {
|
|||||||
size: state => state.app.size,
|
size: state => state.app.size,
|
||||||
device: state => state.app.device,
|
device: state => state.app.device,
|
||||||
dict: state => state.dict.dict,
|
dict: state => state.dict.dict,
|
||||||
|
isLock: state => state.lock.isLock,
|
||||||
|
lockPath: state => state.lock.lockPath,
|
||||||
visitedViews: state => state.tagsView.visitedViews,
|
visitedViews: state => state.tagsView.visitedViews,
|
||||||
cachedViews: state => state.tagsView.cachedViews,
|
cachedViews: state => state.tagsView.cachedViews,
|
||||||
token: state => state.user.token,
|
token: state => state.user.token,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import app from './modules/app'
|
import app from './modules/app'
|
||||||
|
import lock from './modules/lock'
|
||||||
import dict from './modules/dict'
|
import dict from './modules/dict'
|
||||||
import user from './modules/user'
|
import user from './modules/user'
|
||||||
import tagsView from './modules/tagsView'
|
import tagsView from './modules/tagsView'
|
||||||
@@ -13,6 +14,7 @@ Vue.use(Vuex)
|
|||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
modules: {
|
modules: {
|
||||||
app,
|
app,
|
||||||
|
lock,
|
||||||
dict,
|
dict,
|
||||||
user,
|
user,
|
||||||
tagsView,
|
tagsView,
|
||||||
|
|||||||
34
ruoyi-ui/src/store/modules/lock.js
Normal file
34
ruoyi-ui/src/store/modules/lock.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
const LOCK_KEY = 'screen-lock'
|
||||||
|
const LOCK_PATH_KEY = 'screen-lock-path'
|
||||||
|
|
||||||
|
const lock = {
|
||||||
|
namespaced: true,
|
||||||
|
state: {
|
||||||
|
isLock: JSON.parse(localStorage.getItem(LOCK_KEY) || 'false'),
|
||||||
|
lockPath: localStorage.getItem(LOCK_PATH_KEY) || '/index'
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
SET_LOCK(state, status) {
|
||||||
|
state.isLock = status
|
||||||
|
localStorage.setItem(LOCK_KEY, JSON.stringify(status))
|
||||||
|
},
|
||||||
|
SET_LOCK_PATH(state, path) {
|
||||||
|
state.lockPath = path
|
||||||
|
localStorage.setItem(LOCK_PATH_KEY, path)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
// 锁定屏幕,同时记录当前路径
|
||||||
|
lockScreen({ commit }, currentPath) {
|
||||||
|
commit('SET_LOCK_PATH', currentPath || '/index')
|
||||||
|
commit('SET_LOCK', true)
|
||||||
|
},
|
||||||
|
// 解锁屏幕,清除路径
|
||||||
|
unlockScreen({ commit }) {
|
||||||
|
commit('SET_LOCK', false)
|
||||||
|
commit('SET_LOCK_PATH', '/index')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default lock
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import defaultSettings from '@/settings'
|
import defaultSettings from '@/settings'
|
||||||
import { useDynamicTitle } from '@/utils/dynamicTitle'
|
import { useDynamicTitle } from '@/utils/dynamicTitle'
|
||||||
|
|
||||||
const { sideTheme, showSettings, navType, tagsView, tagsIcon, fixedHeader, sidebarLogo, dynamicTitle, footerVisible, footerContent } = defaultSettings
|
const { sideTheme, showSettings, navType, tagsView, tagsViewPersist, tagsIcon, fixedHeader, sidebarLogo, dynamicTitle, footerVisible, footerContent } = defaultSettings
|
||||||
|
|
||||||
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
|
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
|
||||||
const state = {
|
const state = {
|
||||||
@@ -11,6 +11,7 @@ const state = {
|
|||||||
showSettings: showSettings,
|
showSettings: showSettings,
|
||||||
navType: storageSetting.navType === undefined ? navType : storageSetting.navType,
|
navType: storageSetting.navType === undefined ? navType : storageSetting.navType,
|
||||||
tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
|
tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
|
||||||
|
tagsViewPersist: storageSetting.tagsViewPersist === undefined ? tagsViewPersist : storageSetting.tagsViewPersist,
|
||||||
tagsIcon: storageSetting.tagsIcon === undefined ? tagsIcon : storageSetting.tagsIcon,
|
tagsIcon: storageSetting.tagsIcon === undefined ? tagsIcon : storageSetting.tagsIcon,
|
||||||
fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
|
fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
|
||||||
sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
|
sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
|
||||||
|
|||||||
@@ -1,3 +1,26 @@
|
|||||||
|
import store from '@/store'
|
||||||
|
import cache from '@/plugins/cache'
|
||||||
|
|
||||||
|
const PERSIST_KEY = 'tags-view-visited'
|
||||||
|
|
||||||
|
function isPersistEnabled() {
|
||||||
|
return store.state.settings.tagsViewPersist
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveVisitedViews(views) {
|
||||||
|
if (!isPersistEnabled()) return
|
||||||
|
const toSave = views.filter(v => !(v.meta && v.meta.affix)).map(v => ({ path: v.path, fullPath: v.fullPath, name: v.name, title: v.title, query: v.query, meta: v.meta }))
|
||||||
|
cache.local.setJSON(PERSIST_KEY, toSave)
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadVisitedViews() {
|
||||||
|
return cache.local.getJSON(PERSIST_KEY) || []
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearVisitedViews() {
|
||||||
|
cache.local.remove(PERSIST_KEY)
|
||||||
|
}
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
visitedViews: [],
|
visitedViews: [],
|
||||||
cachedViews: [],
|
cachedViews: [],
|
||||||
@@ -20,6 +43,15 @@ const mutations = {
|
|||||||
title: view.meta.title || 'no-name'
|
title: view.meta.title || 'no-name'
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
saveVisitedViews(state.visitedViews)
|
||||||
|
},
|
||||||
|
ADD_VISITED_VIEW_FIRST: (state, view) => {
|
||||||
|
if (state.visitedViews.some(v => v.path === view.path)) return
|
||||||
|
state.visitedViews.unshift(
|
||||||
|
Object.assign({}, view, {
|
||||||
|
title: view.meta.title || 'no-name'
|
||||||
|
})
|
||||||
|
)
|
||||||
},
|
},
|
||||||
ADD_CACHED_VIEW: (state, view) => {
|
ADD_CACHED_VIEW: (state, view) => {
|
||||||
if (state.cachedViews.includes(view.name)) return
|
if (state.cachedViews.includes(view.name)) return
|
||||||
@@ -35,6 +67,7 @@ const mutations = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.iframeViews = state.iframeViews.filter(item => item.path !== view.path)
|
state.iframeViews = state.iframeViews.filter(item => item.path !== view.path)
|
||||||
|
saveVisitedViews(state.visitedViews)
|
||||||
},
|
},
|
||||||
DEL_IFRAME_VIEW: (state, view) => {
|
DEL_IFRAME_VIEW: (state, view) => {
|
||||||
state.iframeViews = state.iframeViews.filter(item => item.path !== view.path)
|
state.iframeViews = state.iframeViews.filter(item => item.path !== view.path)
|
||||||
@@ -49,6 +82,7 @@ const mutations = {
|
|||||||
return v.meta.affix || v.path === view.path
|
return v.meta.affix || v.path === view.path
|
||||||
})
|
})
|
||||||
state.iframeViews = state.iframeViews.filter(item => item.path === view.path)
|
state.iframeViews = state.iframeViews.filter(item => item.path === view.path)
|
||||||
|
saveVisitedViews(state.visitedViews)
|
||||||
},
|
},
|
||||||
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
|
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
|
||||||
const index = state.cachedViews.indexOf(view.name)
|
const index = state.cachedViews.indexOf(view.name)
|
||||||
@@ -63,6 +97,7 @@ const mutations = {
|
|||||||
const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
|
const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
|
||||||
state.visitedViews = affixTags
|
state.visitedViews = affixTags
|
||||||
state.iframeViews = []
|
state.iframeViews = []
|
||||||
|
clearVisitedViews()
|
||||||
},
|
},
|
||||||
DEL_ALL_CACHED_VIEWS: state => {
|
DEL_ALL_CACHED_VIEWS: state => {
|
||||||
state.cachedViews = []
|
state.cachedViews = []
|
||||||
@@ -94,6 +129,7 @@ const mutations = {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
saveVisitedViews(state.visitedViews)
|
||||||
},
|
},
|
||||||
DEL_LEFT_VIEWS: (state, view) => {
|
DEL_LEFT_VIEWS: (state, view) => {
|
||||||
const index = state.visitedViews.findIndex(v => v.path === view.path)
|
const index = state.visitedViews.findIndex(v => v.path === view.path)
|
||||||
@@ -114,6 +150,7 @@ const mutations = {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
saveVisitedViews(state.visitedViews)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +165,9 @@ const actions = {
|
|||||||
addVisitedView({ commit }, view) {
|
addVisitedView({ commit }, view) {
|
||||||
commit('ADD_VISITED_VIEW', view)
|
commit('ADD_VISITED_VIEW', view)
|
||||||
},
|
},
|
||||||
|
addAffixView({ commit }, view) {
|
||||||
|
commit('ADD_VISITED_VIEW_FIRST', view)
|
||||||
|
},
|
||||||
addCachedView({ commit }, view) {
|
addCachedView({ commit }, view) {
|
||||||
commit('ADD_CACHED_VIEW', view)
|
commit('ADD_CACHED_VIEW', view)
|
||||||
},
|
},
|
||||||
@@ -218,6 +258,13 @@ const actions = {
|
|||||||
resolve([...state.visitedViews])
|
resolve([...state.visitedViews])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 恢复持久化的 tags
|
||||||
|
loadPersistedViews({ commit }) {
|
||||||
|
const views = loadVisitedViews()
|
||||||
|
views.forEach(view => {
|
||||||
|
commit('ADD_VISITED_VIEW', view)
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import store from '@/store'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { MessageBox, } from 'element-ui'
|
import { MessageBox, } from 'element-ui'
|
||||||
import { login, logout, getInfo, refreshToken } from '@/api/login'
|
import { login, logout, getInfo, refreshToken } from '@/api/login'
|
||||||
@@ -57,6 +58,7 @@ const user = {
|
|||||||
commit('SET_TOKEN', data.access_token)
|
commit('SET_TOKEN', data.access_token)
|
||||||
setExpiresIn(data.expires_in)
|
setExpiresIn(data.expires_in)
|
||||||
commit('SET_EXPIRES_IN', data.expires_in)
|
commit('SET_EXPIRES_IN', data.expires_in)
|
||||||
|
store.dispatch('lock/unlockScreen')
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
|
|||||||
@@ -108,6 +108,41 @@
|
|||||||
<span>更新日志</span>
|
<span>更新日志</span>
|
||||||
</div>
|
</div>
|
||||||
<el-collapse accordion>
|
<el-collapse accordion>
|
||||||
|
<el-collapse-item title="v3.6.8 - 2026-03-30">
|
||||||
|
<ol>
|
||||||
|
<li>新增锁定屏幕功能</li>
|
||||||
|
<li>首页新增通知公告消息提醒</li>
|
||||||
|
<li>添加持久化标签页开关功能</li>
|
||||||
|
<li>菜单搜索支持文本高亮&数量提示</li>
|
||||||
|
<li>添加菜单路由地址和名称的校验规则</li>
|
||||||
|
<li>字典类型列表新增抽屉效果详细信息</li>
|
||||||
|
<li>升级axios到最新版本0.30.3</li>
|
||||||
|
<li>升级spring-cloud到最新版2025.1.0</li>
|
||||||
|
<li>升级spring-cloud-alibaba到最新版2025.1.0.0</li>
|
||||||
|
<li>升级spring-boot-admin到最新版4.0.2</li>
|
||||||
|
<li>升级dynamic-ds到最新版本4.5.0</li>
|
||||||
|
<li>升级springdoc到最新版本3.0.2</li>
|
||||||
|
<li>升级transmittable-thread-local到最新版本2.14.5</li>
|
||||||
|
<li>升级spring-boot到最新版本4.0.3</li>
|
||||||
|
<li>升级druid到最新版本1.2.28</li>
|
||||||
|
<li>升级pagehelper到最新版2.1.1</li>
|
||||||
|
<li>优化操作日志详细页面</li>
|
||||||
|
<li>部门管理支持批量保存排序</li>
|
||||||
|
<li>菜单管理支持批量保存排序</li>
|
||||||
|
<li>菜单管理列表新增类型显示</li>
|
||||||
|
<li>代码生成模板支持TypeScript版本</li>
|
||||||
|
<li>优化菜单主题风格显示</li>
|
||||||
|
<li>优化点击任务名称查看详细</li>
|
||||||
|
<li>优化字典类型属性提醒说明</li>
|
||||||
|
<li>优化防重提交间隔时间可自定义</li>
|
||||||
|
<li>优化页签功能&支持全屏按钮操作</li>
|
||||||
|
<li>优化RightToolbar搜索栏切换动画</li>
|
||||||
|
<li>修复Excel自定义格式样式污染问题</li>
|
||||||
|
<li>优化isAdmin方法统一到SecurityUtils</li>
|
||||||
|
<li>优化定时任务详情页展示&补充执行时间字段</li>
|
||||||
|
<li>其他细节优化</li>
|
||||||
|
</ol>
|
||||||
|
</el-collapse-item>
|
||||||
<el-collapse-item title="v3.6.7 - 2025-12-22">
|
<el-collapse-item title="v3.6.7 - 2025-12-22">
|
||||||
<ol>
|
<ol>
|
||||||
<li>支持防盗链功能</li>
|
<li>支持防盗链功能</li>
|
||||||
@@ -987,7 +1022,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 版本号
|
// 版本号
|
||||||
version: "3.6.7"
|
version: "3.6.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user