merge: integrate latest field updates into shadow v3
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -197,7 +197,11 @@
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-bom</artifactId>
|
||||
@@ -251,6 +255,7 @@
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>fortucky-algorithm</module>
|
||||
<module>ruoyi-license</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.ruoyi.web.controller.system.license;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.license.domain.SysLicense;
|
||||
import com.ruoyi.license.service.ISysLicenseService;
|
||||
import com.ruoyi.license.util.LicenseUtils;
|
||||
|
||||
/**
|
||||
* 授权码Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/license")
|
||||
public class SysLicenseController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysLicenseService sysLicenseService;
|
||||
|
||||
/**
|
||||
* 查询授权码列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysLicense sysLicense)
|
||||
{
|
||||
startPage();
|
||||
List<SysLicense> list = sysLicenseService.selectSysLicenseList(sysLicense);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增授权码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:add')")
|
||||
@Log(title = "授权码", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(SysLicense sysLicense)
|
||||
{
|
||||
return toAjax(sysLicenseService.insertSysLicense(sysLicense));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改授权码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:edit')")
|
||||
@Log(title = "授权码", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(SysLicense sysLicense)
|
||||
{
|
||||
return toAjax(sysLicenseService.updateSysLicense(sysLicense));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除授权码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:remove')")
|
||||
@Log(title = "授权码", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/remove")
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
return toAjax(sysLicenseService.deleteSysLicenseByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 激活授权码(无需登录)
|
||||
*/
|
||||
@Log(title = "激活授权码", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/active")
|
||||
public AjaxResult active(String licenseCode)
|
||||
{
|
||||
if (!LicenseUtils.validateFormat(licenseCode))
|
||||
{
|
||||
return error("授权码格式不正确");
|
||||
}
|
||||
int result = sysLicenseService.activeLicense(licenseCode);
|
||||
if (result > 0)
|
||||
{
|
||||
return success("授权码激活成功");
|
||||
}
|
||||
return error("授权码激活失败,请检查授权码是否正确或已过期");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前授权信息
|
||||
* license 未开启或无有效授权时返回 code=200 data=null,前端静默处理
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
public AjaxResult info()
|
||||
{
|
||||
SysLicense license = sysLicenseService.getActiveLicense();
|
||||
return AjaxResult.success(license);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成授权码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:add')")
|
||||
@GetMapping("/generate")
|
||||
public AjaxResult generate(String type, String projectNo)
|
||||
{
|
||||
if (StringUtils.isEmpty(type) || StringUtils.isEmpty(projectNo))
|
||||
{
|
||||
return error("授权类型和项目编号不能为空");
|
||||
}
|
||||
String licenseCode = LicenseUtils.generateLicense(type, projectNo);
|
||||
if (licenseCode == null)
|
||||
{
|
||||
return error("授权码生成失败");
|
||||
}
|
||||
return AjaxResult.success("授权码生成成功", licenseCode);
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,10 @@ token:
|
||||
# 令牌有效期(默认30分钟)
|
||||
expireTime: 43800
|
||||
|
||||
# 授权码配置
|
||||
license:
|
||||
# 首次部署需先执行 sql/sys_license.sql 并激活授权码,再改为 true 启用拦截
|
||||
enabled: false
|
||||
|
||||
|
||||
# MyBatis配置
|
||||
|
||||
@@ -58,14 +58,14 @@ public class SecurityConfig
|
||||
@Autowired
|
||||
private PermitAllUrlProperties permitAllUrl;
|
||||
|
||||
/**
|
||||
* 身份验证实现
|
||||
*/
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception
|
||||
{
|
||||
return authenticationConfiguration.getAuthenticationManager();
|
||||
}
|
||||
/**
|
||||
* 身份验证实现
|
||||
*/
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception
|
||||
{
|
||||
return authenticationConfiguration.getAuthenticationManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* anyRequest | 匹配所有请求路径
|
||||
@@ -86,36 +86,36 @@ public class SecurityConfig
|
||||
protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception
|
||||
{
|
||||
return httpSecurity
|
||||
// CSRF禁用,因为不使用session
|
||||
.csrf(csrf -> csrf.disable())
|
||||
// 禁用HTTP响应标头
|
||||
.headers((headersCustomizer) -> {
|
||||
headersCustomizer.cacheControl(cache -> cache.disable()).frameOptions(options -> options.sameOrigin());
|
||||
})
|
||||
// 认证失败处理类
|
||||
.exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler))
|
||||
// 基于token,所以不需要session
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
// 注解标记允许匿名访问的url
|
||||
.authorizeHttpRequests((requests) -> {
|
||||
permitAllUrl.getUrls().forEach(url -> requests.requestMatchers(url).permitAll());
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
requests.requestMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.requestMatchers(HttpMethod.GET, "/", "/*.html", "/**.html", "/**.css", "/**.js", "/profile/**").permitAll()
|
||||
.requestMatchers("/swagger-ui.html", "/v3/api-docs/**", "/swagger-ui/**", "/druid/**").permitAll()
|
||||
.requestMatchers("/api/**","/api2wms/**","api2erp/**").permitAll()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated();
|
||||
})
|
||||
// 添加Logout filter
|
||||
.logout(logout -> logout.logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler))
|
||||
// 添加JWT filter
|
||||
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
// 添加CORS filter
|
||||
.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class)
|
||||
.addFilterBefore(corsFilter, LogoutFilter.class)
|
||||
.build();
|
||||
// CSRF禁用,因为不使用session
|
||||
.csrf(csrf -> csrf.disable())
|
||||
// 禁用HTTP响应标头
|
||||
.headers((headersCustomizer) -> {
|
||||
headersCustomizer.cacheControl(cache -> cache.disable()).frameOptions(options -> options.sameOrigin());
|
||||
})
|
||||
// 认证失败处理类
|
||||
.exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler))
|
||||
// 基于token,所以不需要session
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
// 注解标记允许匿名访问的url
|
||||
.authorizeHttpRequests((requests) -> {
|
||||
permitAllUrl.getUrls().forEach(url -> requests.requestMatchers(url).permitAll());
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
requests.requestMatchers("/login", "/register", "/captchaImage", "/system/license/active").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.requestMatchers(HttpMethod.GET, "/", "/*.html", "/**.html", "/**.css", "/**.js", "/profile/**").permitAll()
|
||||
.requestMatchers("/swagger-ui.html", "/v3/api-docs/**", "/swagger-ui/**", "/druid/**").permitAll()
|
||||
.requestMatchers("/api/**","/api2wms/**","api2erp/**").permitAll()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated();
|
||||
})
|
||||
// 添加Logout filter
|
||||
.logout(logout -> logout.logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler))
|
||||
// 添加JWT filter
|
||||
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
// 添加CORS filter
|
||||
.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class)
|
||||
.addFilterBefore(corsFilter, LogoutFilter.class)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
270
ruoyi-license/CHANGES.md
Normal file
270
ruoyi-license/CHANGES.md
Normal file
@@ -0,0 +1,270 @@
|
||||
# 授权码模块集成改动说明
|
||||
|
||||
> 本文档记录引入 `ruoyi-license` 授权码模块时,对原有项目文件的所有改动(不含 `ruoyi-license` 模块本身及 `SysLicenseController`)。
|
||||
|
||||
---
|
||||
|
||||
## 1. 根模块 `pom.xml`
|
||||
|
||||
**文件路径:** `wms/pom.xml`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
1. `<modules>` 中注册 `ruoyi-license` 子模块:
|
||||
|
||||
```xml
|
||||
<modules>
|
||||
<module>ruoyi-admin</module>
|
||||
<module>ruoyi-framework</module>
|
||||
<module>ruoyi-system</module>
|
||||
<module>ruoyi-quartz</module>
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>ruoyi-license</module> <!-- 新增 -->
|
||||
</modules>
|
||||
```
|
||||
|
||||
2. `<dependencyManagement>` 中声明 `ruoyi-license` 依赖版本:
|
||||
|
||||
```xml
|
||||
<!-- 授权码模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. `ruoyi-admin/pom.xml`
|
||||
|
||||
**文件路径:** `wms/ruoyi-admin/pom.xml`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
引入 `ruoyi-license` 依赖,使授权拦截器和配置能被 Spring Boot 扫描加载:
|
||||
|
||||
```xml
|
||||
<!-- 授权码模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. `SecurityConfig.java`
|
||||
|
||||
**文件路径:** `wms/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
在 Spring Security 匿名白名单中加入 `/system/license/active`,允许未登录用户调用激活授权码接口:
|
||||
|
||||
```java
|
||||
// 改动前
|
||||
requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
|
||||
// 改动后
|
||||
requests.antMatchers("/login", "/register", "/captchaImage", "/system/license/active").permitAll()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. 前端 `api/license.js`(新建)
|
||||
|
||||
**文件路径:** `wms/ui/src/api/license.js`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
新建文件,封装授权码相关接口:
|
||||
|
||||
```js
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 激活授权码(无需登录)
|
||||
export function activeLicense(licenseCode) {
|
||||
return request({
|
||||
url: '/system/license/active',
|
||||
method: 'post',
|
||||
params: { licenseCode }
|
||||
})
|
||||
}
|
||||
|
||||
// 查询当前授权信息(需登录)
|
||||
export function getLicenseInfo() {
|
||||
return request({
|
||||
url: '/system/license/info',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. 登录页 `login.vue`
|
||||
|
||||
**文件路径:** `wms/ui/src/views/login.vue`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
### 5.1 模板部分
|
||||
|
||||
在登录按钮下方新增"激活授权码"按钮,以及激活弹窗:
|
||||
|
||||
```html
|
||||
<!-- 激活授权码按钮 -->
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button
|
||||
size="medium"
|
||||
type="warning"
|
||||
style="width:100%;"
|
||||
@click.native.prevent="openLicenseDialog"
|
||||
>激活授权码</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 激活授权码弹窗 -->
|
||||
<el-dialog title="激活授权码" :visible.sync="licenseDialogVisible" width="420px" append-to-body>
|
||||
<el-input v-model="licenseCode" type="textarea" :rows="4" placeholder="请输入授权码" />
|
||||
<span slot="footer">
|
||||
<el-button @click="licenseDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="licenseLoading" @click="handleActiveLicense">激 活</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
```
|
||||
|
||||
### 5.2 Script 部分
|
||||
|
||||
新增 import、data 字段和方法:
|
||||
|
||||
```js
|
||||
// 新增 import
|
||||
import { activeLicense } from "@/api/license"
|
||||
|
||||
// 新增 data 字段
|
||||
licenseDialogVisible: false,
|
||||
licenseCode: '',
|
||||
licenseLoading: false
|
||||
|
||||
// 新增方法
|
||||
openLicenseDialog() {
|
||||
this.licenseCode = ''
|
||||
this.licenseDialogVisible = true
|
||||
},
|
||||
handleActiveLicense() {
|
||||
if (!this.licenseCode.trim()) {
|
||||
this.$message.warning('请输入授权码')
|
||||
return
|
||||
}
|
||||
this.licenseLoading = true
|
||||
activeLicense(this.licenseCode.trim()).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success(res.msg || '授权码激活成功')
|
||||
this.licenseDialogVisible = false
|
||||
} else {
|
||||
this.$message.error(res.msg || '授权码激活失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message.error('授权码激活失败')
|
||||
}).finally(() => {
|
||||
this.licenseLoading = false
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. 顶部导航栏 `Navbar.vue`
|
||||
|
||||
**文件路径:** `wms/ui/src/layout/components/Navbar.vue`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
### 6.1 模板部分
|
||||
|
||||
在 navbar 中间插入授权到期警告条(剩余不足 30 天时显示):
|
||||
|
||||
```html
|
||||
<div v-if="licenseWarning" class="license-warning">
|
||||
<i class="el-icon-warning-outline" />
|
||||
系统授权将于 {{ licenseExpireText }} 后过期,请及时联系管理员续期
|
||||
</div>
|
||||
```
|
||||
|
||||
### 6.2 Script 部分
|
||||
|
||||
```js
|
||||
// 新增 import
|
||||
import { getLicenseInfo } from '@/api/license'
|
||||
|
||||
// 新增 data 字段
|
||||
licenseWarning: false,
|
||||
licenseExpireText: '',
|
||||
licenseTimer: null
|
||||
|
||||
// 新增生命周期钩子
|
||||
mounted() {
|
||||
this.checkLicenseExpire()
|
||||
this.licenseTimer = setInterval(() => this.checkLicenseExpire(), 60 * 1000)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.licenseTimer) clearInterval(this.licenseTimer)
|
||||
},
|
||||
|
||||
// 新增方法
|
||||
checkLicenseExpire() {
|
||||
getLicenseInfo().then(res => {
|
||||
if (res.code === 200 && res.data && res.data.expireTime) {
|
||||
const expireTime = new Date(res.data.expireTime).getTime()
|
||||
const now = Date.now()
|
||||
const diffMs = expireTime - now
|
||||
const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))
|
||||
if (diffMs > 0 && diffDays <= 30) {
|
||||
this.licenseWarning = true
|
||||
if (diffMs < 1000 * 60 * 60 * 24) {
|
||||
const hours = Math.floor(diffMs / (1000 * 60 * 60))
|
||||
const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60))
|
||||
this.licenseExpireText = hours > 0 ? `${hours} 小时 ${minutes} 分钟` : `${minutes} 分钟`
|
||||
} else if (diffDays < 7) {
|
||||
this.licenseExpireText = diffDays + ' 天'
|
||||
} else {
|
||||
this.licenseExpireText = Math.ceil(diffDays / 7) + ' 周'
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
```
|
||||
|
||||
### 6.3 样式部分
|
||||
|
||||
```scss
|
||||
.license-warning {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
top: 0;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
font-size: 13px;
|
||||
color: #e6a23c;
|
||||
font-weight: 500;
|
||||
pointer-events: none;
|
||||
i { margin-right: 4px; }
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 改动文件汇总
|
||||
|
||||
| 文件 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| `wms/pom.xml` | 修改 | 注册模块 + 声明依赖版本 |
|
||||
| `wms/ruoyi-admin/pom.xml` | 修改 | 引入 ruoyi-license 依赖 |
|
||||
| `ruoyi-framework/.../SecurityConfig.java` | 修改 | 白名单加入激活授权码接口 |
|
||||
| `ui/src/api/license.js` | 新建 | 封装激活和查询授权信息接口 |
|
||||
| `ui/src/views/login.vue` | 修改 | 新增激活授权码按钮和弹窗 |
|
||||
| `ui/src/layout/components/Navbar.vue` | 修改 | 新增授权到期倒计时警告条 |
|
||||
250
ruoyi-license/DEPLOYMENT_CHECKLIST.md
Normal file
250
ruoyi-license/DEPLOYMENT_CHECKLIST.md
Normal file
@@ -0,0 +1,250 @@
|
||||
# 授权码模块部署检查清单
|
||||
|
||||
## 📋 部署前检查
|
||||
|
||||
### 1. 文件完整性检查
|
||||
- [ ] ruoyi-license 模块目录存在
|
||||
- [ ] pom.xml 已添加 license 模块
|
||||
- [ ] ruoyi-admin/pom.xml 已添加 license 依赖
|
||||
- [ ] SysLicenseController.java 已创建
|
||||
- [ ] license.html 和 active.html 已创建
|
||||
- [ ] login.html 和 login.js 已修改
|
||||
- [ ] sys_license.sql 脚本已准备
|
||||
|
||||
### 2. 数据库准备
|
||||
- [ ] 创建 sys_license 表
|
||||
- [ ] 插入授权管理菜单数据
|
||||
- [ ] 验证表结构正确
|
||||
- [ ] 检查菜单权限配置
|
||||
|
||||
### 3. 代码配置
|
||||
- [ ] 修改 LicenseUtils.java 中的密钥(生产环境必须)
|
||||
- [ ] 确认拦截器路径配置正确
|
||||
- [ ] 确认定时任务cron表达式
|
||||
- [ ] 启动类添加 @EnableScheduling 注解
|
||||
|
||||
## 🔧 部署步骤
|
||||
|
||||
### 步骤1: 执行数据库脚本
|
||||
```bash
|
||||
mysql -u root -p your_database < sql/sys_license.sql
|
||||
```
|
||||
- [ ] 执行成功
|
||||
- [ ] 表创建成功
|
||||
- [ ] 菜单数据插入成功
|
||||
|
||||
### 步骤2: 修改启动类
|
||||
```java
|
||||
@SpringBootApplication
|
||||
@EnableScheduling // 添加此注解
|
||||
public class RuoYiApplication {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
- [ ] 注解已添加
|
||||
|
||||
### 步骤3: 编译项目
|
||||
```bash
|
||||
mvn clean install
|
||||
```
|
||||
- [ ] 编译成功
|
||||
- [ ] 无错误信息
|
||||
- [ ] JAR包生成
|
||||
|
||||
### 步骤4: 启动应用
|
||||
```bash
|
||||
java -jar ruoyi-admin.jar
|
||||
```
|
||||
- [ ] 启动成功
|
||||
- [ ] 无异常日志
|
||||
- [ ] 端口正常监听
|
||||
|
||||
### 步骤5: 生成授权码
|
||||
**方式A: 使用独立工具**
|
||||
```bash
|
||||
java com.ruoyi.license.util.LicenseGenerator
|
||||
```
|
||||
- [ ] 工具运行成功
|
||||
- [ ] 授权码生成成功
|
||||
- [ ] 授权码已保存
|
||||
|
||||
**方式B: 使用系统界面**
|
||||
- [ ] 登录系统
|
||||
- [ ] 访问授权管理
|
||||
- [ ] 点击生成授权码
|
||||
- [ ] 输入天数并生成
|
||||
|
||||
### 步骤6: 激活授权码
|
||||
- [ ] 访问登录页
|
||||
- [ ] 点击"激活授权码"
|
||||
- [ ] 输入授权码
|
||||
- [ ] 激活成功
|
||||
|
||||
## ✅ 功能测试
|
||||
|
||||
### 测试1: 授权码生成
|
||||
- [ ] 系统界面生成授权码成功
|
||||
- [ ] 独立工具生成授权码成功
|
||||
- [ ] 授权码格式正确
|
||||
|
||||
### 测试2: 授权码激活
|
||||
- [ ] 登录页激活成功
|
||||
- [ ] 系统内激活成功
|
||||
- [ ] 数据库记录正确
|
||||
|
||||
### 测试3: 授权验证
|
||||
- [ ] 有效授权可正常登录
|
||||
- [ ] 无授权无法登录
|
||||
- [ ] 过期授权无法登录
|
||||
|
||||
### 测试4: 授权拦截
|
||||
- [ ] 未授权访问被拦截
|
||||
- [ ] 有效授权可正常访问
|
||||
- [ ] 静态资源不被拦截
|
||||
|
||||
### 测试5: 定时检查
|
||||
- [ ] 定时任务正常执行
|
||||
- [ ] 授权过期自动更新状态
|
||||
- [ ] 在线用户被踢出
|
||||
|
||||
### 测试6: 授权管理
|
||||
- [ ] 授权列表查询正常
|
||||
- [ ] 授权信息显示正确
|
||||
- [ ] 授权删除功能正常
|
||||
|
||||
## 🔍 问题排查
|
||||
|
||||
### 问题1: 编译失败
|
||||
**检查项:**
|
||||
- [ ] Maven依赖是否正确
|
||||
- [ ] JDK版本是否匹配
|
||||
- [ ] pom.xml配置是否正确
|
||||
|
||||
**解决方案:**
|
||||
```bash
|
||||
mvn clean
|
||||
mvn dependency:resolve
|
||||
mvn install
|
||||
```
|
||||
|
||||
### 问题2: 启动失败
|
||||
**检查项:**
|
||||
- [ ] 数据库连接是否正常
|
||||
- [ ] 端口是否被占用
|
||||
- [ ] 配置文件是否正确
|
||||
|
||||
**解决方案:**
|
||||
- 检查 application.yml 配置
|
||||
- 查看启动日志错误信息
|
||||
- 确认数据库表已创建
|
||||
|
||||
### 问题3: 无法激活授权码
|
||||
**检查项:**
|
||||
- [ ] 授权码格式是否正确
|
||||
- [ ] 授权码是否已过期
|
||||
- [ ] 密钥是否一致
|
||||
|
||||
**解决方案:**
|
||||
- 重新生成授权码
|
||||
- 检查 LicenseUtils 密钥配置
|
||||
- 查看后台错误日志
|
||||
|
||||
### 问题4: 授权验证不生效
|
||||
**检查项:**
|
||||
- [ ] 拦截器是否注册
|
||||
- [ ] 数据库授权记录是否正确
|
||||
- [ ] 定时任务是否执行
|
||||
|
||||
**解决方案:**
|
||||
- 检查 LicenseConfig 配置
|
||||
- 验证数据库 status 字段
|
||||
- 确认 @EnableScheduling 已添加
|
||||
|
||||
### 问题5: 在线用户未被踢出
|
||||
**检查项:**
|
||||
- [ ] SessionDAO 是否注入
|
||||
- [ ] 定时任务是否执行
|
||||
- [ ] Shiro配置是否正确
|
||||
|
||||
**解决方案:**
|
||||
- 检查 LicenseCheckTask 日志
|
||||
- 验证 SessionDAO bean
|
||||
- 重启应用服务器
|
||||
|
||||
## 📊 监控指标
|
||||
|
||||
### 运行时监控
|
||||
- [ ] 授权状态正常
|
||||
- [ ] 定时任务执行正常
|
||||
- [ ] 无异常日志
|
||||
- [ ] 内存使用正常
|
||||
- [ ] CPU使用正常
|
||||
|
||||
### 业务监控
|
||||
- [ ] 授权激活次数
|
||||
- [ ] 授权过期提醒
|
||||
- [ ] 用户登录成功率
|
||||
- [ ] 授权拦截次数
|
||||
|
||||
## 🔐 安全检查
|
||||
|
||||
### 配置安全
|
||||
- [ ] 生产环境已修改默认密钥
|
||||
- [ ] 数据库密码已加密
|
||||
- [ ] 授权码传输使用HTTPS
|
||||
- [ ] 敏感日志已脱敏
|
||||
|
||||
### 权限安全
|
||||
- [ ] 授权管理菜单仅管理员可见
|
||||
- [ ] 授权激活操作有日志记录
|
||||
- [ ] 授权码生成有权限控制
|
||||
- [ ] 数据库访问有权限限制
|
||||
|
||||
### 数据安全
|
||||
- [ ] 授权码加密存储
|
||||
- [ ] 定期备份授权数据
|
||||
- [ ] 授权日志完整保存
|
||||
- [ ] 敏感信息不输出到日志
|
||||
|
||||
## 📝 上线清单
|
||||
|
||||
### 上线前
|
||||
- [ ] 所有测试通过
|
||||
- [ ] 代码已提交版本库
|
||||
- [ ] 数据库脚本已准备
|
||||
- [ ] 部署文档已编写
|
||||
- [ ] 回滚方案已准备
|
||||
|
||||
### 上线中
|
||||
- [ ] 备份现有数据
|
||||
- [ ] 执行数据库脚本
|
||||
- [ ] 部署新版本代码
|
||||
- [ ] 生成初始授权码
|
||||
- [ ] 激活授权码
|
||||
|
||||
### 上线后
|
||||
- [ ] 验证功能正常
|
||||
- [ ] 检查日志无异常
|
||||
- [ ] 监控系统运行状态
|
||||
- [ ] 通知相关人员
|
||||
- [ ] 更新运维文档
|
||||
|
||||
## 📞 应急联系
|
||||
|
||||
### 技术支持
|
||||
- 开发负责人: ___________
|
||||
- 运维负责人: ___________
|
||||
- 数据库管理员: ___________
|
||||
|
||||
### 应急预案
|
||||
1. 授权失效 -> 立即激活新授权码
|
||||
2. 系统无法登录 -> 检查授权状态
|
||||
3. 数据丢失 -> 从备份恢复
|
||||
4. 性能问题 -> 调整定时任务频率
|
||||
|
||||
---
|
||||
|
||||
**检查人**: ___________
|
||||
**检查日期**: ___________
|
||||
**部署环境**: [ ] 开发 [ ] 测试 [ ] 生产
|
||||
**部署状态**: [ ] 成功 [ ] 失败 [ ] 部分成功
|
||||
231
ruoyi-license/INTEGRATION.md
Normal file
231
ruoyi-license/INTEGRATION.md
Normal file
@@ -0,0 +1,231 @@
|
||||
# RuoYi 授权码模块集成指南
|
||||
|
||||
## 一、模块说明
|
||||
|
||||
本授权码模块已完成开发,包含以下文件:
|
||||
|
||||
```
|
||||
ruoyi-license/ # 授权模块(独立模块)
|
||||
├── src/main/java/com/ruoyi/license/
|
||||
│ ├── config/
|
||||
│ │ └── LicenseConfig.java # 拦截器配置
|
||||
│ ├── domain/
|
||||
│ │ └── SysLicense.java # 授权实体
|
||||
│ ├── interceptor/
|
||||
│ │ └── LicenseInterceptor.java # 授权拦截器
|
||||
│ ├── mapper/
|
||||
│ │ └── SysLicenseMapper.java # 数据访问接口
|
||||
│ ├── service/
|
||||
│ │ ├── ISysLicenseService.java # 服务接口
|
||||
│ │ └── impl/
|
||||
│ │ └── SysLicenseServiceImpl.java # 服务实现
|
||||
│ ├── task/
|
||||
│ │ └── LicenseCheckTask.java # 定时检查任务
|
||||
│ └── util/
|
||||
│ ├── LicenseUtils.java # 授权工具类
|
||||
│ └── LicenseGenerator.java # 授权码生成器
|
||||
├── src/main/resources/mapper/license/
|
||||
│ └── SysLicenseMapper.xml # MyBatis映射
|
||||
├── pom.xml # 模块依赖
|
||||
└── README.md # 使用说明
|
||||
|
||||
sql/
|
||||
└── sys_license.sql # 数据库脚本
|
||||
|
||||
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/license/
|
||||
└── SysLicenseController.java # 授权控制器
|
||||
|
||||
ruoyi-admin/src/main/resources/templates/system/license/
|
||||
├── license.html # 授权列表页
|
||||
└── active.html # 激活页面
|
||||
|
||||
修改的文件:
|
||||
- pom.xml # 添加license模块
|
||||
- ruoyi-admin/pom.xml # 添加license依赖
|
||||
- login.html # 添加激活入口
|
||||
- login.js # 添加激活功能
|
||||
```
|
||||
|
||||
## 二、部署步骤
|
||||
|
||||
### 1. 执行数据库脚本
|
||||
|
||||
```bash
|
||||
# 在MySQL中执行
|
||||
mysql -u root -p your_database < sql/sys_license.sql
|
||||
```
|
||||
|
||||
或手动执行 `sql/sys_license.sql` 中的SQL语句。
|
||||
|
||||
### 2. 启用定时任务
|
||||
|
||||
在启动类上添加 `@EnableScheduling` 注解:
|
||||
|
||||
```java
|
||||
@SpringBootApplication
|
||||
@EnableScheduling // 添加此注解
|
||||
public class RuoYiApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RuoYiApplication.class, args);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3. 编译项目
|
||||
|
||||
```bash
|
||||
cd d:\fortucky\project\RuoYi-master
|
||||
mvn clean install
|
||||
```
|
||||
|
||||
### 4. 生成授权码
|
||||
|
||||
**方式一:使用独立工具生成**
|
||||
```bash
|
||||
cd ruoyi-license/src/main/java
|
||||
javac com/ruoyi/license/util/LicenseUtils.java
|
||||
javac com/ruoyi/license/util/LicenseGenerator.java
|
||||
java com.ruoyi.license.util.LicenseGenerator
|
||||
```
|
||||
|
||||
**方式二:启动系统后在界面生成**
|
||||
- 登录系统
|
||||
- 进入"系统管理 -> 授权管理"
|
||||
- 点击"生成授权码"按钮
|
||||
|
||||
### 5. 激活授权码
|
||||
|
||||
**首次激活(登录页):**
|
||||
1. 访问登录页
|
||||
2. 点击"激活授权码"链接
|
||||
3. 输入生成的授权码
|
||||
4. 提交激活
|
||||
|
||||
**系统内激活:**
|
||||
1. 登录系统(需要先有有效授权)
|
||||
2. 进入"系统管理 -> 授权管理"
|
||||
3. 点击"激活授权码"
|
||||
4. 输入新的授权码
|
||||
|
||||
## 三、功能验证
|
||||
|
||||
### 1. 验证授权拦截
|
||||
|
||||
- 未激活授权码时,访问任何页面应跳转到登录页并提示"授权已过期"
|
||||
- 激活授权码后,可正常访问系统
|
||||
|
||||
### 2. 验证定时检查
|
||||
|
||||
- 修改数据库中授权码的 `expire_time` 为过去时间
|
||||
- 等待5分钟(或重启系统)
|
||||
- 在线用户应被强制退出
|
||||
- 尝试登录应提示授权过期
|
||||
|
||||
### 3. 验证授权管理
|
||||
|
||||
- 访问"系统管理 -> 授权管理"
|
||||
- 查看授权列表
|
||||
- 生成新授权码
|
||||
- 激活授权码
|
||||
- 删除过期授权
|
||||
|
||||
## 四、复用到其他项目
|
||||
|
||||
### 方式一:Maven依赖(推荐)
|
||||
|
||||
1. 将 `ruoyi-license` 模块复制到目标项目
|
||||
2. 在父pom.xml添加模块声明
|
||||
3. 在需要的模块添加依赖
|
||||
4. 执行数据库脚本
|
||||
5. 复制Controller和前端页面
|
||||
|
||||
### 方式二:JAR包依赖
|
||||
|
||||
1. 打包license模块:
|
||||
```bash
|
||||
cd ruoyi-license
|
||||
mvn clean package
|
||||
```
|
||||
|
||||
2. 安装到本地仓库:
|
||||
```bash
|
||||
mvn install:install-file -Dfile=target/ruoyi-license-4.8.2.jar \
|
||||
-DgroupId=com.ruoyi -DartifactId=ruoyi-license \
|
||||
-Dversion=4.8.2 -Dpackaging=jar
|
||||
```
|
||||
|
||||
3. 在目标项目添加依赖:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>4.8.2</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## 五、配置说明
|
||||
|
||||
### 1. 修改密钥(重要)
|
||||
|
||||
生产环境必须修改默认密钥:
|
||||
|
||||
```java
|
||||
// LicenseUtils.java
|
||||
private static final String SECRET_KEY = "YourCustomKey123"; // 改为16位自定义密钥
|
||||
```
|
||||
|
||||
### 2. 调整检查频率
|
||||
|
||||
```java
|
||||
// LicenseCheckTask.java
|
||||
@Scheduled(cron = "0 */5 * * * ?") // 每5分钟,可根据需要调整
|
||||
```
|
||||
|
||||
### 3. 自定义拦截路径
|
||||
|
||||
```java
|
||||
// LicenseConfig.java
|
||||
.excludePathPatterns(
|
||||
"/login",
|
||||
"/your-path/**" // 添加需要排除的路径
|
||||
)
|
||||
```
|
||||
|
||||
## 六、注意事项
|
||||
|
||||
1. **首次部署**:必须先生成并激活授权码,否则无法登录
|
||||
2. **时间同步**:确保服务器时间准确,避免授权判断错误
|
||||
3. **密钥安全**:生产环境务必修改默认密钥
|
||||
4. **数据备份**:定期备份 `sys_license` 表数据
|
||||
5. **权限控制**:授权管理菜单仅授予超级管理员
|
||||
|
||||
## 七、故障排查
|
||||
|
||||
### 问题1:无法激活授权码
|
||||
- 检查授权码格式是否正确
|
||||
- 检查授权码是否已过期
|
||||
- 查看后台日志错误信息
|
||||
|
||||
### 问题2:授权有效但仍被拦截
|
||||
- 检查数据库中授权状态是否为"1"
|
||||
- 检查 `expire_time` 是否大于当前时间
|
||||
- 重启应用服务器
|
||||
|
||||
### 问题3:定时任务不执行
|
||||
- 确认启动类添加了 `@EnableScheduling`
|
||||
- 检查日志是否有定时任务执行记录
|
||||
|
||||
### 问题4:在线用户未被踢出
|
||||
- 检查 `SessionDAO` 是否正确注入
|
||||
- 查看定时任务是否正常执行
|
||||
- 检查Shiro配置是否正确
|
||||
|
||||
## 八、技术支持
|
||||
|
||||
如遇到问题,请提供以下信息:
|
||||
1. 错误日志
|
||||
2. 数据库授权记录
|
||||
3. 系统环境信息
|
||||
4. 操作步骤
|
||||
|
||||
联系方式:参考RuoYi官方文档
|
||||
168
ruoyi-license/LICENSE_FILTER_CONFIG.md
Normal file
168
ruoyi-license/LICENSE_FILTER_CONFIG.md
Normal file
@@ -0,0 +1,168 @@
|
||||
# 授权码全局拦截配置说明
|
||||
|
||||
## 功能说明
|
||||
|
||||
通过自定义 Shiro Filter,实现授权码失效时,**所有接口**(包括 `anon` 匿名访问的接口)都无法访问。
|
||||
|
||||
## 实现原理
|
||||
|
||||
1. 创建 `LicenseValidateFilter` 继承 `AccessControlFilter`
|
||||
2. 在 Shiro 过滤链的**最前面**添加此过滤器
|
||||
3. 所有请求都会先经过授权码验证,验证失败则拒绝访问
|
||||
|
||||
## 已完成的修改
|
||||
|
||||
### 1. 新增文件
|
||||
- `ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/license/LicenseValidateFilter.java`
|
||||
|
||||
### 2. 修改文件
|
||||
- `ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java`
|
||||
- 导入 `LicenseValidateFilter`
|
||||
- 注册过滤器:`filters.put("licenseValidate", licenseValidateFilter())`
|
||||
- 添加到过滤链:`filterChainDefinitionMap.put("/**", "licenseValidate,user,kickout,onlineSession,syncOnlineSession")`
|
||||
|
||||
## 白名单配置
|
||||
|
||||
以下路径即使授权失效也可以访问(必要的登录和静态资源):
|
||||
|
||||
```java
|
||||
private static final String[] WHITE_LIST = {
|
||||
"/login", // 登录页
|
||||
"/captcha/captchaImage", // 验证码
|
||||
"/css/", // 样式文件
|
||||
"/js/", // 脚本文件
|
||||
"/img/", // 图片资源
|
||||
"/fonts/", // 字体文件
|
||||
"/ajax/", // Ajax资源
|
||||
"/ruoyi/", // 若依资源
|
||||
"/favicon.ico", // 网站图标
|
||||
"/system/license/active" // 授权激活页面(必须放行)
|
||||
};
|
||||
```
|
||||
|
||||
## 自定义白名单
|
||||
|
||||
如果需要添加其他路径到白名单,修改 `LicenseValidateFilter.java`:
|
||||
|
||||
```java
|
||||
private static final String[] WHITE_LIST = {
|
||||
// ... 原有配置
|
||||
"/your-custom-path/**", // 添加你的自定义路径
|
||||
};
|
||||
```
|
||||
|
||||
## 拦截效果
|
||||
|
||||
### 授权有效时
|
||||
- 所有接口正常访问(包括 `/board/**`、`/agv/api/**` 等 anon 接口)
|
||||
|
||||
### 授权失效时
|
||||
- **普通请求**:重定向到 `/login?license=expired`
|
||||
- **Ajax请求**:返回 JSON `{"code":401,"msg":"授权已过期,请联系管理员激活授权码"}`
|
||||
- **白名单路径**:仍可访问(用于激活授权码)
|
||||
|
||||
## 测试步骤
|
||||
|
||||
### 1. 启用授权功能
|
||||
在 `application.yml` 中配置:
|
||||
```yaml
|
||||
license:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
### 2. 配置项目编号
|
||||
在数据库 `sys_config` 表中添加:
|
||||
```sql
|
||||
INSERT INTO sys_config (config_name, config_key, config_value, config_type, create_by, create_time, remark)
|
||||
VALUES ('项目编号', 'fortucky.project.no', 'FT507', 'Y', 'admin', NOW(), '用于授权码验证');
|
||||
```
|
||||
|
||||
### 3. 测试授权失效场景
|
||||
|
||||
**方式一:不激活授权码**
|
||||
- 启动系统
|
||||
- 访问 `/board/**` 接口
|
||||
- 预期:被拦截,重定向到登录页
|
||||
|
||||
**方式二:授权码过期**
|
||||
- 生成5分钟测试授权码并激活
|
||||
- 等待5分钟后访问 `/board/**` 接口
|
||||
- 预期:被拦截
|
||||
|
||||
### 4. 测试授权有效场景
|
||||
- 生成并激活有效授权码
|
||||
- 访问 `/board/**` 接口
|
||||
- 预期:正常访问
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **白名单必须包含授权激活页面**
|
||||
- `/system/license/active` 必须在白名单中
|
||||
- 否则授权失效后无法激活新授权码
|
||||
|
||||
2. **静态资源必须放行**
|
||||
- CSS、JS、图片等资源必须在白名单
|
||||
- 否则登录页面无法正常显示
|
||||
|
||||
3. **过滤器顺序很重要**
|
||||
- `licenseValidate` 必须在最前面
|
||||
- 确保所有请求都先经过授权验证
|
||||
|
||||
4. **开发环境可关闭授权**
|
||||
```yaml
|
||||
license:
|
||||
enabled: false # 开发时可关闭
|
||||
```
|
||||
|
||||
## 与原有拦截器的区别
|
||||
|
||||
### 原有 LicenseInterceptor(Spring MVC 拦截器)
|
||||
- 在 Spring MVC 层拦截
|
||||
- 只拦截进入 Controller 的请求
|
||||
- 无法拦截 Shiro 已放行的 `anon` 接口
|
||||
|
||||
### 新增 LicenseValidateFilter(Shiro 过滤器)
|
||||
- 在 Shiro 层拦截
|
||||
- 拦截所有请求(包括 `anon` 接口)
|
||||
- 优先级高于 Shiro 的其他过滤器
|
||||
|
||||
## 建议
|
||||
|
||||
1. **保留两个拦截器**
|
||||
- `LicenseValidateFilter`:全局拦截(包括 anon 接口)
|
||||
- `LicenseInterceptor`:作为二次验证(可选)
|
||||
|
||||
2. **生产环境必须启用**
|
||||
```yaml
|
||||
license:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
3. **定期检查白名单**
|
||||
- 确保白名单路径最小化
|
||||
- 避免过度放行
|
||||
|
||||
## 故障排查
|
||||
|
||||
### 问题1:所有请求都被拦截
|
||||
- 检查 `license.enabled` 是否为 `true`
|
||||
- 检查是否有有效授权码
|
||||
- 查看后台日志 `[授权验证]` 相关信息
|
||||
|
||||
### 问题2:anon 接口仍可访问
|
||||
- 检查过滤器是否注册:`filters.put("licenseValidate", ...)`
|
||||
- 检查过滤链配置:`"licenseValidate,user,..."`
|
||||
- 确认 `licenseValidate` 在最前面
|
||||
|
||||
### 问题3:无法激活授权码
|
||||
- 检查 `/system/license/active` 是否在白名单
|
||||
- 检查白名单匹配逻辑是否正确
|
||||
|
||||
## 完成标志
|
||||
|
||||
✅ 授权失效时,`/board/**` 接口无法访问
|
||||
✅ 授权失效时,`/agv/api/**` 接口无法访问
|
||||
✅ 授权失效时,仍可访问登录页和激活页
|
||||
✅ 授权有效时,所有接口正常访问
|
||||
✅ Ajax 请求返回 JSON 错误信息
|
||||
✅ 普通请求重定向到登录页
|
||||
193
ruoyi-license/README.md
Normal file
193
ruoyi-license/README.md
Normal file
@@ -0,0 +1,193 @@
|
||||
# RuoYi 授权码模块
|
||||
|
||||
## 模块简介
|
||||
|
||||
ruoyi-license 是一个独立的授权码管理模块,用于控制系统的使用期限。当授权码过期后,系统将无法登录,已登录用户会被强制退出。
|
||||
|
||||
## 功能特性
|
||||
|
||||
- ✅ 授权码加密存储
|
||||
- ✅ 登录时验证授权有效性
|
||||
- ✅ 定时检查授权状态(每5分钟)
|
||||
- ✅ 授权过期自动踢出在线用户
|
||||
- ✅ 系统管理界面查看/激活授权
|
||||
- ✅ 登录页面激活授权码
|
||||
- ✅ 授权码生成工具
|
||||
- ✅ 独立模块,方便其他项目复用
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 执行数据库脚本
|
||||
|
||||
```sql
|
||||
-- 执行 sql/sys_license.sql 创建授权表和菜单
|
||||
```
|
||||
|
||||
### 2. 添加模块依赖
|
||||
|
||||
在需要使用授权功能的项目中,添加依赖:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>4.8.2</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### 3. 配置包扫描
|
||||
|
||||
确保Spring能扫描到授权模块的包:
|
||||
|
||||
```java
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.ruoyi"})
|
||||
public class RuoYiApplication {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### 4. 生成授权码
|
||||
|
||||
访问系统管理 -> 授权管理,点击"生成授权码"按钮,输入授权天数(如365天),系统会生成加密的授权码。
|
||||
|
||||
### 5. 激活授权码
|
||||
|
||||
**方式一:登录页激活**
|
||||
- 在登录页面点击"激活授权码"链接
|
||||
- 输入授权码并提交
|
||||
|
||||
**方式二:系统内激活**
|
||||
- 登录系统后,进入"系统管理 -> 授权管理"
|
||||
- 点击"激活授权码"按钮
|
||||
- 输入授权码并提交
|
||||
|
||||
## 核心类说明
|
||||
|
||||
### 1. 实体类
|
||||
- `SysLicense`: 授权码实体,包含授权码、开始时间、结束时间、状态等信息
|
||||
|
||||
### 2. 工具类
|
||||
- `LicenseUtils`: 授权码工具类
|
||||
- `generateLicense()`: 生成授权码
|
||||
- `encrypt()`: 加密数据
|
||||
- `decrypt()`: 解密数据
|
||||
- `validateFormat()`: 验证授权码格式
|
||||
|
||||
### 3. 服务类
|
||||
- `ISysLicenseService`: 授权服务接口
|
||||
- `activeLicense()`: 激活授权码
|
||||
- `checkLicenseValid()`: 检查授权是否有效
|
||||
- `getActiveLicense()`: 获取当前有效授权
|
||||
|
||||
### 4. 拦截器
|
||||
- `LicenseInterceptor`: 授权拦截器,在每次请求时验证授权有效性
|
||||
|
||||
### 5. 定时任务
|
||||
- `LicenseCheckTask`: 每5分钟检查授权状态,过期自动踢出在线用户
|
||||
|
||||
## 授权码格式
|
||||
|
||||
授权码采用AES加密,格式为:
|
||||
```
|
||||
加密(开始时间戳|结束时间戳)
|
||||
```
|
||||
|
||||
示例:
|
||||
```
|
||||
原始数据: 1704067200000|1735689600000
|
||||
加密后: Xj8K9mN2pQ5rT7vW1yZ3aB4cD6eF8gH0iJ2kL4mN6oP8qR0sT2uV4wX6yZ8
|
||||
```
|
||||
|
||||
## 集成到其他项目
|
||||
|
||||
### 步骤1:复制模块
|
||||
将 `ruoyi-license` 文件夹复制到目标项目根目录
|
||||
|
||||
### 步骤2:修改pom.xml
|
||||
在父pom.xml中添加:
|
||||
```xml
|
||||
<modules>
|
||||
<module>ruoyi-license</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
```
|
||||
|
||||
### 步骤3:添加依赖
|
||||
在启动模块的pom.xml中添加:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### 步骤4:执行SQL脚本
|
||||
执行 `sql/sys_license.sql` 创建数据库表
|
||||
|
||||
### 步骤5:配置Controller
|
||||
将 `SysLicenseController.java` 复制到项目的controller包中
|
||||
|
||||
### 步骤6:配置前端页面
|
||||
将 `templates/system/license/` 目录复制到项目的templates目录
|
||||
|
||||
### 步骤7:修改登录页面
|
||||
参考 `login.html` 和 `login.js` 的修改,添加授权码激活入口
|
||||
|
||||
## 自定义配置
|
||||
|
||||
### 修改密钥
|
||||
编辑 `LicenseUtils.java`:
|
||||
```java
|
||||
private static final String SECRET_KEY = "YourSecretKey123"; // 16位密钥
|
||||
```
|
||||
|
||||
### 修改检查频率
|
||||
编辑 `LicenseCheckTask.java`:
|
||||
```java
|
||||
@Scheduled(cron = "0 */10 * * * ?") // 改为每10分钟检查
|
||||
```
|
||||
|
||||
### 自定义拦截规则
|
||||
编辑 `LicenseConfig.java`,添加或排除拦截路径:
|
||||
```java
|
||||
.excludePathPatterns(
|
||||
"/login",
|
||||
"/your-custom-path/**"
|
||||
)
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **密钥安全**:生产环境务必修改默认密钥
|
||||
2. **时间同步**:确保服务器时间准确
|
||||
3. **数据备份**:定期备份授权表数据
|
||||
4. **权限控制**:授权管理菜单仅授予管理员
|
||||
5. **测试环境**:建议先在测试环境验证功能
|
||||
|
||||
## 常见问题
|
||||
|
||||
**Q: 授权码激活失败?**
|
||||
A: 检查授权码格式是否正确,是否已过期
|
||||
|
||||
**Q: 如何延长授权期限?**
|
||||
A: 生成新的授权码并激活即可
|
||||
|
||||
**Q: 授权过期后如何恢复?**
|
||||
A: 在登录页点击"激活授权码",输入新的授权码
|
||||
|
||||
**Q: 可以同时激活多个授权码吗?**
|
||||
A: 系统只使用最新激活且未过期的授权码
|
||||
|
||||
## 技术支持
|
||||
|
||||
如有问题,请联系技术支持或查看RuoYi官方文档。
|
||||
239
ruoyi-license/SUMMARY.md
Normal file
239
ruoyi-license/SUMMARY.md
Normal file
@@ -0,0 +1,239 @@
|
||||
# RuoYi 授权码模块 - 项目总结
|
||||
|
||||
## 📦 已完成的工作
|
||||
|
||||
### 1. 核心模块开发 ✅
|
||||
|
||||
**ruoyi-license 独立模块**
|
||||
- ✅ Maven模块配置 (pom.xml)
|
||||
- ✅ 授权实体类 (SysLicense.java)
|
||||
- ✅ 数据访问层 (SysLicenseMapper.java + XML)
|
||||
- ✅ 业务逻辑层 (ISysLicenseService.java + Impl)
|
||||
- ✅ 授权工具类 (LicenseUtils.java)
|
||||
- ✅ 授权拦截器 (LicenseInterceptor.java)
|
||||
- ✅ 拦截器配置 (LicenseConfig.java)
|
||||
- ✅ 定时检查任务 (LicenseCheckTask.java)
|
||||
- ✅ 授权码生成器 (LicenseGenerator.java)
|
||||
- ✅ 测试工具 (LicenseTest.java)
|
||||
|
||||
### 2. 控制器和前端 ✅
|
||||
|
||||
**后端控制器**
|
||||
- ✅ SysLicenseController.java (授权管理控制器)
|
||||
- 授权列表查询
|
||||
- 授权码激活
|
||||
- 授权码生成
|
||||
- 授权信息查看
|
||||
- 授权删除
|
||||
|
||||
**前端页面**
|
||||
- ✅ license.html (授权列表页)
|
||||
- ✅ active.html (激活页面)
|
||||
- ✅ login.html (添加激活入口)
|
||||
- ✅ login.js (添加激活功能)
|
||||
|
||||
### 3. 数据库脚本 ✅
|
||||
|
||||
- ✅ sys_license.sql
|
||||
- 授权表结构
|
||||
- 菜单权限配置
|
||||
|
||||
### 4. 项目集成 ✅
|
||||
|
||||
- ✅ 主pom.xml (添加license模块)
|
||||
- ✅ ruoyi-admin/pom.xml (添加license依赖)
|
||||
|
||||
### 5. 文档编写 ✅
|
||||
|
||||
- ✅ README.md (使用说明)
|
||||
- ✅ INTEGRATION.md (集成指南)
|
||||
|
||||
## 🎯 功能特性
|
||||
|
||||
### 核心功能
|
||||
1. **授权码加密存储** - AES加密,安全可靠
|
||||
2. **登录验证** - 登录时自动验证授权有效性
|
||||
3. **拦截器保护** - 所有请求都经过授权验证
|
||||
4. **定时检查** - 每5分钟自动检查授权状态
|
||||
5. **自动踢出** - 授权过期自动踢出所有在线用户
|
||||
6. **管理界面** - 完整的授权管理功能
|
||||
7. **登录页激活** - 无需登录即可激活授权码
|
||||
8. **授权码生成** - 内置生成工具,支持自定义天数
|
||||
|
||||
### 技术亮点
|
||||
- 🔒 AES加密算法保护授权码
|
||||
- 🔄 Spring拦截器实现全局授权验证
|
||||
- ⏰ Spring定时任务自动检查授权
|
||||
- 🎨 完整的前后端交互界面
|
||||
- 📦 独立模块设计,方便复用
|
||||
- 🛠️ 提供测试工具和生成工具
|
||||
|
||||
## 📂 文件清单
|
||||
|
||||
```
|
||||
ruoyi-license/
|
||||
├── src/main/java/com/ruoyi/license/
|
||||
│ ├── config/
|
||||
│ │ └── LicenseConfig.java (拦截器配置)
|
||||
│ ├── domain/
|
||||
│ │ └── SysLicense.java (授权实体)
|
||||
│ ├── interceptor/
|
||||
│ │ └── LicenseInterceptor.java (授权拦截器)
|
||||
│ ├── mapper/
|
||||
│ │ └── SysLicenseMapper.java (Mapper接口)
|
||||
│ ├── service/
|
||||
│ │ ├── ISysLicenseService.java (服务接口)
|
||||
│ │ └── impl/
|
||||
│ │ └── SysLicenseServiceImpl.java (服务实现)
|
||||
│ ├── task/
|
||||
│ │ └── LicenseCheckTask.java (定时任务)
|
||||
│ └── util/
|
||||
│ ├── LicenseUtils.java (工具类)
|
||||
│ ├── LicenseGenerator.java (生成器)
|
||||
│ └── LicenseTest.java (测试工具)
|
||||
├── src/main/resources/mapper/license/
|
||||
│ └── SysLicenseMapper.xml (MyBatis映射)
|
||||
├── pom.xml (模块配置)
|
||||
├── README.md (使用说明)
|
||||
└── INTEGRATION.md (集成指南)
|
||||
|
||||
sql/
|
||||
└── sys_license.sql (数据库脚本)
|
||||
|
||||
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/license/
|
||||
└── SysLicenseController.java (控制器)
|
||||
|
||||
ruoyi-admin/src/main/resources/templates/system/license/
|
||||
├── license.html (列表页)
|
||||
└── active.html (激活页)
|
||||
|
||||
修改的文件:
|
||||
├── pom.xml (添加模块)
|
||||
├── ruoyi-admin/pom.xml (添加依赖)
|
||||
├── ruoyi-admin/src/main/resources/templates/login.html
|
||||
└── ruoyi-admin/src/main/resources/static/ruoyi/login.js
|
||||
```
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 1. 执行数据库脚本
|
||||
```sql
|
||||
source sql/sys_license.sql;
|
||||
```
|
||||
|
||||
### 2. 启用定时任务
|
||||
在 RuoYiApplication.java 添加 @EnableScheduling
|
||||
|
||||
### 3. 编译项目
|
||||
```bash
|
||||
mvn clean install
|
||||
```
|
||||
|
||||
### 4. 生成授权码
|
||||
运行 LicenseGenerator.java 或在系统界面生成
|
||||
|
||||
### 5. 激活授权码
|
||||
登录页点击"激活授权码"输入授权码
|
||||
|
||||
## 🔧 使用场景
|
||||
|
||||
### 场景1:软件交付
|
||||
- 开发完成后生成授权码
|
||||
- 交付给客户时提供授权码
|
||||
- 客户激活后可使用指定期限
|
||||
|
||||
### 场景2:试用版本
|
||||
- 生成30天试用授权码
|
||||
- 客户试用满意后购买正式授权
|
||||
- 激活正式授权码延长使用期限
|
||||
|
||||
### 场景3:订阅服务
|
||||
- 按年生成授权码
|
||||
- 到期前提醒客户续费
|
||||
- 续费后激活新授权码
|
||||
|
||||
### 场景4:多项目复用
|
||||
- 将license模块复制到其他项目
|
||||
- 修改密钥和配置
|
||||
- 快速实现授权功能
|
||||
|
||||
## ⚙️ 自定义配置
|
||||
|
||||
### 修改密钥(必须)
|
||||
```java
|
||||
// LicenseUtils.java
|
||||
private static final String SECRET_KEY = "YourKey16Chars!!";
|
||||
```
|
||||
|
||||
### 调整检查频率
|
||||
```java
|
||||
// LicenseCheckTask.java
|
||||
@Scheduled(cron = "0 */10 * * * ?") // 改为10分钟
|
||||
```
|
||||
|
||||
### 自定义拦截路径
|
||||
```java
|
||||
// LicenseConfig.java
|
||||
.excludePathPatterns("/api/**", "/public/**")
|
||||
```
|
||||
|
||||
## 📊 数据库表结构
|
||||
|
||||
```sql
|
||||
sys_license (授权表)
|
||||
├── license_id (授权ID - 主键)
|
||||
├── license_code (授权码 - 加密存储)
|
||||
├── start_time (开始时间)
|
||||
├── expire_time (结束时间)
|
||||
├── status (状态: 0未激活 1已激活 2已过期)
|
||||
├── active_time (激活时间)
|
||||
├── active_by (激活人)
|
||||
├── create_by (创建者)
|
||||
├── create_time (创建时间)
|
||||
├── update_by (更新者)
|
||||
├── update_time (更新时间)
|
||||
└── remark (备注)
|
||||
```
|
||||
|
||||
## 🔐 安全建议
|
||||
|
||||
1. **生产环境必须修改默认密钥**
|
||||
2. **授权码通过安全渠道传递**
|
||||
3. **定期备份授权表数据**
|
||||
4. **限制授权管理菜单权限**
|
||||
5. **监控授权激活日志**
|
||||
|
||||
## 📝 后续优化建议
|
||||
|
||||
1. **硬件绑定** - 绑定服务器MAC地址或CPU序列号
|
||||
2. **在线验证** - 连接授权服务器在线验证
|
||||
3. **授权分级** - 不同授权码对应不同功能权限
|
||||
4. **自动续费** - 集成支付接口自动续费
|
||||
5. **授权统计** - 统计授权使用情况和到期提醒
|
||||
|
||||
## ✅ 测试清单
|
||||
|
||||
- [ ] 数据库表创建成功
|
||||
- [ ] 菜单权限配置正确
|
||||
- [ ] 授权码生成功能正常
|
||||
- [ ] 授权码加密解密正确
|
||||
- [ ] 登录页激活功能正常
|
||||
- [ ] 系统内激活功能正常
|
||||
- [ ] 授权拦截器生效
|
||||
- [ ] 定时任务执行正常
|
||||
- [ ] 授权过期自动踢出
|
||||
- [ ] 授权列表查询正常
|
||||
|
||||
## 📞 技术支持
|
||||
|
||||
如有问题,请查看:
|
||||
1. README.md - 使用说明
|
||||
2. INTEGRATION.md - 集成指南
|
||||
3. RuoYi官方文档
|
||||
|
||||
---
|
||||
|
||||
**开发完成时间**: 2024
|
||||
**模块版本**: 1.0.0
|
||||
**适用框架**: RuoYi v4.8.2
|
||||
**技术栈**: SpringBoot + MyBatis + Shiro + Thymeleaf
|
||||
45
ruoyi-license/pom.xml
Normal file
45
ruoyi-license/pom.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.9.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
|
||||
<description>
|
||||
授权码管理模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 框架模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Web-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.license.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import com.ruoyi.framework.config.properties.PermitAllUrlProperties;
|
||||
import com.ruoyi.license.interceptor.LicenseInterceptor;
|
||||
|
||||
/**
|
||||
* 授权模块配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Configuration
|
||||
public class LicenseConfig implements WebMvcConfigurer
|
||||
{
|
||||
@Autowired
|
||||
private LicenseInterceptor licenseInterceptor;
|
||||
|
||||
@Autowired
|
||||
private PermitAllUrlProperties permitAllUrl;
|
||||
|
||||
@Value("${license.enabled:false}")
|
||||
private boolean licenseEnabled;
|
||||
|
||||
private static final List<String> BASE_EXCLUDE = Arrays.asList(
|
||||
"/login",
|
||||
"/logout",
|
||||
"/register",
|
||||
"/captchaImage",
|
||||
"/system/license/active",
|
||||
"/swagger-ui.html",
|
||||
"/swagger-resources/**",
|
||||
"/webjars/**",
|
||||
"/*/api-docs",
|
||||
"/druid/**",
|
||||
"/*.html",
|
||||
"/**/*.html",
|
||||
"/**/*.css",
|
||||
"/**/*.js",
|
||||
"/profile/**"
|
||||
);
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry)
|
||||
{
|
||||
if (licenseEnabled)
|
||||
{
|
||||
List<String> excludeList = new ArrayList<>(BASE_EXCLUDE);
|
||||
excludeList.addAll(permitAllUrl.getUrls());
|
||||
registry.addInterceptor(licenseInterceptor)
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(excludeList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.ruoyi.license.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统授权码对象 sys_license
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysLicense extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 授权ID */
|
||||
private Long licenseId;
|
||||
|
||||
/** 授权码 */
|
||||
private String licenseCode;
|
||||
|
||||
/** 授权开始时间 */
|
||||
private Date startTime;
|
||||
|
||||
/** 授权结束时间 */
|
||||
private Date expireTime;
|
||||
|
||||
/** 授权状态(0未激活 1已激活 2已过期) */
|
||||
private String status;
|
||||
|
||||
/** 激活时间 */
|
||||
private Date activeTime;
|
||||
|
||||
/** 激活人 */
|
||||
private String activeBy;
|
||||
|
||||
public Long getLicenseId()
|
||||
{
|
||||
return licenseId;
|
||||
}
|
||||
|
||||
public void setLicenseId(Long licenseId)
|
||||
{
|
||||
this.licenseId = licenseId;
|
||||
}
|
||||
|
||||
public String getLicenseCode()
|
||||
{
|
||||
return licenseCode;
|
||||
}
|
||||
|
||||
public void setLicenseCode(String licenseCode)
|
||||
{
|
||||
this.licenseCode = licenseCode;
|
||||
}
|
||||
|
||||
public Date getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getExpireTime()
|
||||
{
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
public void setExpireTime(Date expireTime)
|
||||
{
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getActiveTime()
|
||||
{
|
||||
return activeTime;
|
||||
}
|
||||
|
||||
public void setActiveTime(Date activeTime)
|
||||
{
|
||||
this.activeTime = activeTime;
|
||||
}
|
||||
|
||||
public String getActiveBy()
|
||||
{
|
||||
return activeBy;
|
||||
}
|
||||
|
||||
public void setActiveBy(String activeBy)
|
||||
{
|
||||
this.activeBy = activeBy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.license.interceptor;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import com.ruoyi.license.service.ISysLicenseService;
|
||||
|
||||
/**
|
||||
* 授权拦截器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
public class LicenseInterceptor implements HandlerInterceptor
|
||||
{
|
||||
@Autowired
|
||||
private ISysLicenseService licenseService;
|
||||
|
||||
@Value("${license.enabled:false}")
|
||||
private boolean licenseEnabled;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
|
||||
{
|
||||
if (!licenseEnabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!licenseService.checkLicenseValid())
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
PrintWriter writer = response.getWriter();
|
||||
writer.write("{\"code\":500,\"msg\":\"\u7cfb\u7edf\u6388\u6743\u5df2\u8fc7\u671f\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u6fc0\u6d3b\u6388\u6743\u7801\"}");
|
||||
writer.flush();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.ruoyi.license.mapper;
|
||||
|
||||
import com.ruoyi.license.domain.SysLicense;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 授权码Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysLicenseMapper
|
||||
{
|
||||
/**
|
||||
* 查询授权码
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 授权码
|
||||
*/
|
||||
public SysLicense selectSysLicenseById(Long licenseId);
|
||||
|
||||
/**
|
||||
* 查询授权码列表
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 授权码集合
|
||||
*/
|
||||
public List<SysLicense> selectSysLicenseList(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 查询当前有效的授权码
|
||||
*
|
||||
* @return 授权码
|
||||
*/
|
||||
public SysLicense selectActiveLicense();
|
||||
|
||||
/**
|
||||
* 新增授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysLicense(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 修改授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysLicense(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 删除授权码
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysLicenseById(Long licenseId);
|
||||
|
||||
/**
|
||||
* 批量删除授权码
|
||||
*
|
||||
* @param licenseIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysLicenseByIds(String[] licenseIds);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.ruoyi.license.service;
|
||||
|
||||
import com.ruoyi.license.domain.SysLicense;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 授权码Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysLicenseService
|
||||
{
|
||||
/**
|
||||
* 查询授权码
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 授权码
|
||||
*/
|
||||
public SysLicense selectSysLicenseById(Long licenseId);
|
||||
|
||||
/**
|
||||
* 查询授权码列表
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 授权码集合
|
||||
*/
|
||||
public List<SysLicense> selectSysLicenseList(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 新增授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysLicense(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 修改授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysLicense(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 批量删除授权码
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysLicenseByIds(String ids);
|
||||
|
||||
/**
|
||||
* 删除授权码信息
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysLicenseById(Long licenseId);
|
||||
|
||||
/**
|
||||
* 激活授权码
|
||||
*
|
||||
* @param licenseCode 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int activeLicense(String licenseCode);
|
||||
|
||||
/**
|
||||
* 检查授权是否有效
|
||||
*
|
||||
* @return true有效 false无效
|
||||
*/
|
||||
public boolean checkLicenseValid();
|
||||
|
||||
/**
|
||||
* 获取当前有效授权信息
|
||||
*
|
||||
* @return 授权信息
|
||||
*/
|
||||
public SysLicense getActiveLicense();
|
||||
|
||||
/**
|
||||
* 更新过期授权码状态
|
||||
*/
|
||||
public void updateExpiredLicenses();
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
package com.ruoyi.license.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.license.domain.SysLicense;
|
||||
import com.ruoyi.license.mapper.SysLicenseMapper;
|
||||
import com.ruoyi.license.service.ISysLicenseService;
|
||||
import com.ruoyi.license.util.LicenseUtils;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
|
||||
/**
|
||||
* 授权码Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysLicenseServiceImpl implements ISysLicenseService
|
||||
{
|
||||
@Autowired
|
||||
private SysLicenseMapper sysLicenseMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService sysConfigService;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Value("${license.enabled:false}")
|
||||
private boolean licenseEnabled;
|
||||
|
||||
/**
|
||||
* 查询授权码
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 授权码
|
||||
*/
|
||||
@Override
|
||||
public SysLicense selectSysLicenseById(Long licenseId)
|
||||
{
|
||||
return sysLicenseMapper.selectSysLicenseById(licenseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询授权码列表
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 授权码
|
||||
*/
|
||||
@Override
|
||||
public List<SysLicense> selectSysLicenseList(SysLicense sysLicense)
|
||||
{
|
||||
return sysLicenseMapper.selectSysLicenseList(sysLicense);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysLicense(SysLicense sysLicense)
|
||||
{
|
||||
sysLicense.setCreateTime(new Date());
|
||||
return sysLicenseMapper.insertSysLicense(sysLicense);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysLicense(SysLicense sysLicense)
|
||||
{
|
||||
sysLicense.setUpdateTime(new Date());
|
||||
return sysLicenseMapper.updateSysLicense(sysLicense);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除授权码对象
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysLicenseByIds(String ids)
|
||||
{
|
||||
return sysLicenseMapper.deleteSysLicenseByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除授权码信息
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysLicenseById(Long licenseId)
|
||||
{
|
||||
return sysLicenseMapper.deleteSysLicenseById(licenseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 激活授权码
|
||||
*
|
||||
* @param licenseCode 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int activeLicense(String licenseCode)
|
||||
{
|
||||
if (StringUtils.isEmpty(licenseCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 验证授权码格式
|
||||
if (!LicenseUtils.validateFormat(licenseCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 从配置表获取项目编号
|
||||
String projectNo = sysConfigService.selectConfigByKey("fortucky.project.no");
|
||||
if (StringUtils.isEmpty(projectNo))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 解析授权码
|
||||
long expireTime = LicenseUtils.parseLicense(licenseCode, projectNo);
|
||||
if (expireTime == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
Date startTime = now;
|
||||
Date expireDate = new Date(expireTime);
|
||||
|
||||
// 验证是否已过期
|
||||
if (expireDate.before(now))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 创建授权记录
|
||||
SysLicense license = new SysLicense();
|
||||
license.setLicenseCode(licenseCode);
|
||||
license.setStartTime(startTime);
|
||||
license.setExpireTime(expireDate);
|
||||
license.setStatus("1");
|
||||
license.setActiveTime(now);
|
||||
license.setCreateTime(now);
|
||||
|
||||
return sysLicenseMapper.insertSysLicense(license);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查授权是否有效
|
||||
*
|
||||
* @return true有效 false无效
|
||||
*/
|
||||
@Override
|
||||
public boolean checkLicenseValid()
|
||||
{
|
||||
// 如果授权码功能未启用,直接返回true
|
||||
if (!licenseEnabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
SysLicense license = sysLicenseMapper.selectActiveLicense();
|
||||
if (license == null)
|
||||
{
|
||||
System.out.println("[授权检查] 没有找到激活的授权码");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 从配置表获取项目编号
|
||||
String projectNo = sysConfigService.selectConfigByKey("fortucky.project.no");
|
||||
if (StringUtils.isEmpty(projectNo))
|
||||
{
|
||||
System.out.println("[授权检查] 项目编号未配置");
|
||||
return false;
|
||||
}
|
||||
|
||||
System.out.println("[授权检查] 授权码: " + license.getLicenseCode());
|
||||
System.out.println("[授权检查] 项目编号: " + projectNo);
|
||||
|
||||
// 从授权码解析过期时间
|
||||
long expireTime = LicenseUtils.parseLicense(license.getLicenseCode(), projectNo);
|
||||
if (expireTime == 0)
|
||||
{
|
||||
System.out.println("[授权检查] 授权码解析失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
System.out.println("[授权检查] 当前时间: " + now.getTime());
|
||||
System.out.println("[授权检查] 过期时间: " + expireTime);
|
||||
|
||||
if (expireTime < now.getTime())
|
||||
{
|
||||
System.out.println("[授权检查] 授权已过期");
|
||||
// 更新为过期状态
|
||||
license.setStatus("2");
|
||||
sysLicenseMapper.updateSysLicense(license);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前有效授权信息
|
||||
*
|
||||
* @return 授权信息
|
||||
*/
|
||||
@Override
|
||||
public SysLicense getActiveLicense()
|
||||
{
|
||||
return sysLicenseMapper.selectActiveLicense();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新过期授权码状态
|
||||
*/
|
||||
@Override
|
||||
public void updateExpiredLicenses()
|
||||
{
|
||||
SysLicense query = new SysLicense();
|
||||
query.setStatus("1");
|
||||
List<SysLicense> licenses = sysLicenseMapper.selectSysLicenseList(query);
|
||||
|
||||
// 从配置表获取项目编号
|
||||
String projectNo = sysConfigService.selectConfigByKey("fortucky.project.no");
|
||||
if (StringUtils.isEmpty(projectNo))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
for (SysLicense license : licenses)
|
||||
{
|
||||
// 从授权码解析过期时间
|
||||
long expireTime = LicenseUtils.parseLicense(license.getLicenseCode(), projectNo);
|
||||
if (expireTime > 0 && expireTime < now.getTime())
|
||||
{
|
||||
license.setStatus("2");
|
||||
license.setUpdateTime(now);
|
||||
sysLicenseMapper.updateSysLicense(license);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.ruoyi.license.task;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.license.service.ISysLicenseService;
|
||||
|
||||
/**
|
||||
* 授权检查定时任务
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
public class LicenseCheckTask
|
||||
{
|
||||
@Autowired
|
||||
private ISysLicenseService licenseService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Value("${license.enabled:false}")
|
||||
private boolean licenseEnabled;
|
||||
|
||||
/**
|
||||
* 每5分钟检查一次授权状态
|
||||
*/
|
||||
@Scheduled(cron = "0 */5 * * * ?")
|
||||
public void checkLicense()
|
||||
{
|
||||
if (!licenseEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!licenseService.checkLicenseValid())
|
||||
{
|
||||
// 授权无效,删除 Redis 中所有登录 token,强制踢出所有在线用户
|
||||
redisCache.deleteObject(redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"));
|
||||
}
|
||||
|
||||
licenseService.updateExpiredLicenses();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.ruoyi.license.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* 授权码生成工具(独立运行)
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class LicenseGenerator
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
System.out.println("========================================");
|
||||
System.out.println(" RuoYi 授权码生成工具");
|
||||
System.out.println("========================================");
|
||||
System.out.println();
|
||||
|
||||
try
|
||||
{
|
||||
// 选择授权类型
|
||||
System.out.println("请选择授权类型:");
|
||||
System.out.println("1. 5分钟测试");
|
||||
System.out.println("2. 1个月授权");
|
||||
System.out.println("3. 3个月授权");
|
||||
System.out.println("4. 1年授权");
|
||||
System.out.println("5. 5年授权");
|
||||
System.out.println("6. 长期授权");
|
||||
System.out.print("请输入选项(1-6): ");
|
||||
String typeChoice = scanner.nextLine().trim();
|
||||
|
||||
String type;
|
||||
String typeDesc;
|
||||
long expireTime;
|
||||
|
||||
switch (typeChoice)
|
||||
{
|
||||
case "1":
|
||||
type = LicenseUtils.TYPE_TEST;
|
||||
typeDesc = "5分钟测试";
|
||||
expireTime = System.currentTimeMillis() + 5 * 60 * 1000L;
|
||||
break;
|
||||
case "2":
|
||||
type = LicenseUtils.TYPE_MONTH;
|
||||
typeDesc = "1个月授权";
|
||||
expireTime = System.currentTimeMillis() + 30L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
case "3":
|
||||
type = LicenseUtils.TYPE_THREE;
|
||||
typeDesc = "3个月授权";
|
||||
expireTime = System.currentTimeMillis() + 90L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
case "4":
|
||||
type = LicenseUtils.TYPE_YEAR;
|
||||
typeDesc = "1年授权";
|
||||
expireTime = System.currentTimeMillis() + 365L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
case "5":
|
||||
type = LicenseUtils.TYPE_FIVE;
|
||||
typeDesc = "5年授权";
|
||||
expireTime = System.currentTimeMillis() + 5 * 365L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
case "6":
|
||||
type = LicenseUtils.TYPE_FOREVER;
|
||||
typeDesc = "长期授权";
|
||||
expireTime = System.currentTimeMillis() + 100 * 365L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
default:
|
||||
System.out.println("错误:无效的选项");
|
||||
return;
|
||||
}
|
||||
|
||||
// 输入项目编号
|
||||
System.out.print("请输入项目编号: ");
|
||||
String projectNo = scanner.nextLine().trim();
|
||||
|
||||
if (projectNo.isEmpty())
|
||||
{
|
||||
System.out.println("错误:项目编号不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 生成授权码
|
||||
String licenseCode = LicenseUtils.generateLicense(type, projectNo);
|
||||
|
||||
if (licenseCode == null)
|
||||
{
|
||||
System.out.println("错误:授权码生成失败");
|
||||
return;
|
||||
}
|
||||
|
||||
// 格式化日期
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now = new Date();
|
||||
Date expire = new Date(expireTime);
|
||||
|
||||
System.out.println();
|
||||
System.out.println("========================================");
|
||||
System.out.println("授权码生成成功!");
|
||||
System.out.println("========================================");
|
||||
System.out.println("授权类型: " + typeDesc);
|
||||
System.out.println("项目编号: " + projectNo);
|
||||
System.out.println("当前时间: " + sdf.format(now));
|
||||
System.out.println("过期时间: " + sdf.format(expire));
|
||||
System.out.println("----------------------------------------");
|
||||
System.out.println("授权码:");
|
||||
System.out.println(licenseCode);
|
||||
System.out.println("========================================");
|
||||
System.out.println();
|
||||
System.out.println("请妥善保管授权码,在系统中激活后即可使用。");
|
||||
System.out.println("注意:系统配置中的项目编号必须与此处一致才能激活。");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("错误:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.ruoyi.license.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 授权码测试工具
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class LicenseTest
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println("========================================");
|
||||
System.out.println(" 授权码功能测试");
|
||||
System.out.println("========================================");
|
||||
System.out.println();
|
||||
|
||||
String projectNo = "TEST001";
|
||||
|
||||
// 测试1:生成各类型授权码
|
||||
System.out.println("【测试1】生成各类型授权码");
|
||||
String testCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_TEST, projectNo);
|
||||
String yearCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_YEAR, projectNo);
|
||||
String fiveCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_FIVE, projectNo);
|
||||
String foreverCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_FOREVER, projectNo);
|
||||
|
||||
System.out.println("5分钟测试: " + testCode);
|
||||
System.out.println("1年授权: " + yearCode);
|
||||
System.out.println("5年授权: " + fiveCode);
|
||||
System.out.println("长期授权: " + foreverCode);
|
||||
System.out.println("结果: ✓ 通过");
|
||||
System.out.println();
|
||||
|
||||
// 测试2:验证授权码格式
|
||||
System.out.println("【测试2】验证授权码格式");
|
||||
boolean isValid = LicenseUtils.validateFormat(yearCode);
|
||||
System.out.println("格式验证: " + (isValid ? "✓ 通过" : "✗ 失败"));
|
||||
System.out.println();
|
||||
|
||||
// 测试3:解析授权码
|
||||
System.out.println("【测试3】解析授权码");
|
||||
long expireTime = LicenseUtils.parseLicense(yearCode, projectNo);
|
||||
if (expireTime > 0)
|
||||
{
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date expire = new Date(expireTime);
|
||||
System.out.println("过期时间: " + sdf.format(expire));
|
||||
System.out.println("结果: ✓ 通过");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("结果: ✗ 失败");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
// 测试4:项目编号验证
|
||||
System.out.println("【测试4】项目编号验证");
|
||||
long validResult = LicenseUtils.parseLicense(yearCode, projectNo);
|
||||
long invalidResult = LicenseUtils.parseLicense(yearCode, "WRONG001");
|
||||
System.out.println("正确项目编号: " + (validResult > 0 ? "✓ 通过" : "✗ 失败"));
|
||||
System.out.println("错误项目编号: " + (invalidResult == 0 ? "✓ 通过(正确拒绝)" : "✗ 失败"));
|
||||
System.out.println();
|
||||
|
||||
// 测试5:授权码格式展示
|
||||
System.out.println("【测试5】授权码格式展示");
|
||||
System.out.println("授权码: " + yearCode);
|
||||
String[] parts = yearCode.split("_");
|
||||
if (parts.length == 5)
|
||||
{
|
||||
System.out.println("前缀: " + parts[0]);
|
||||
System.out.println("类型: " + parts[1] + " (" + LicenseUtils.getTypeDesc(parts[1]) + ")");
|
||||
System.out.println("项目编号: " + parts[2]);
|
||||
System.out.println("加密时间: " + parts[3]);
|
||||
System.out.println("校验码: " + parts[4]);
|
||||
System.out.println("结果: ✓ 通过");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("结果: ✗ 失败");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
System.out.println("========================================");
|
||||
System.out.println("测试完成!");
|
||||
System.out.println("========================================");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
package com.ruoyi.license.util;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/**
|
||||
* 授权码工具类
|
||||
* 格式: FORTUCKY_授权类型_项目编号_加密时间_校验码
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class LicenseUtils
|
||||
{
|
||||
// 密钥(16位)
|
||||
private static final String SECRET_KEY = "RuoYiLicense2024";
|
||||
|
||||
// 授权类型
|
||||
public static final String TYPE_TEST = "TEST"; // 5分钟测试
|
||||
public static final String TYPE_MONTH = "MONTH"; // 1个月
|
||||
public static final String TYPE_THREE = "THREE"; // 3个月
|
||||
public static final String TYPE_YEAR = "YEAR"; // 1年
|
||||
public static final String TYPE_FIVE = "FIVE"; // 5年
|
||||
public static final String TYPE_FOREVER = "FOREVER"; // 长期
|
||||
|
||||
/**
|
||||
* 生成授权码
|
||||
*
|
||||
* @param type 授权类型
|
||||
* @param projectNo 项目编号
|
||||
* @return 授权码
|
||||
*/
|
||||
public static String generateLicense(String type, String projectNo)
|
||||
{
|
||||
try
|
||||
{
|
||||
long expireTime = calculateExpireTime(type);
|
||||
if (expireTime == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// 加密过期时间
|
||||
String encryptedTime = encrypt(String.valueOf(expireTime));
|
||||
if (encryptedTime == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// 生成校验码(取加密时间的前8位MD5)
|
||||
String checkCode = generateCheckCode(type, projectNo, encryptedTime);
|
||||
|
||||
// 拼接授权码: FORTUCKY_类型_项目编号_加密时间_校验码
|
||||
return "FORTUCKY_" + type + "_" + projectNo + "_" + encryptedTime + "_" + checkCode;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证授权码格式
|
||||
*
|
||||
* @param licenseCode 授权码
|
||||
* @return true有效 false无效
|
||||
*/
|
||||
public static boolean validateFormat(String licenseCode)
|
||||
{
|
||||
if (licenseCode == null || licenseCode.trim().isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String[] parts = licenseCode.split("_");
|
||||
if (parts.length != 5)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!"FORTUCKY".equals(parts[0]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 验证授权类型
|
||||
String type = parts[1];
|
||||
if (!TYPE_TEST.equals(type) && !TYPE_MONTH.equals(type) && !TYPE_THREE.equals(type) &&
|
||||
!TYPE_YEAR.equals(type) && !TYPE_FIVE.equals(type) && !TYPE_FOREVER.equals(type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析授权码
|
||||
*
|
||||
* @param licenseCode 授权码
|
||||
* @param projectNo 系统项目编号
|
||||
* @return 过期时间戳,0表示解析失败
|
||||
*/
|
||||
public static long parseLicense(String licenseCode, String projectNo)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!validateFormat(licenseCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
String[] parts = licenseCode.split("_");
|
||||
String type = parts[1];
|
||||
String codeProjectNo = parts[2];
|
||||
String encryptedTime = parts[3];
|
||||
String checkCode = parts[4];
|
||||
|
||||
// 验证项目编号
|
||||
if (!codeProjectNo.equals(projectNo))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 验证校验码
|
||||
String expectedCheckCode = generateCheckCode(type, codeProjectNo, encryptedTime);
|
||||
if (!checkCode.equals(expectedCheckCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 解密时间
|
||||
String decrypted = decrypt(encryptedTime);
|
||||
if (decrypted == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Long.parseLong(decrypted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权类型描述
|
||||
*
|
||||
* @param type 授权类型
|
||||
* @return 描述
|
||||
*/
|
||||
public static String getTypeDesc(String type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TYPE_TEST: return "5分钟测试";
|
||||
case TYPE_MONTH: return "1个月授权";
|
||||
case TYPE_THREE: return "3个月授权";
|
||||
case TYPE_YEAR: return "1年授权";
|
||||
case TYPE_FIVE: return "5年授权";
|
||||
case TYPE_FOREVER: return "长期授权";
|
||||
default: return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算过期时间
|
||||
*
|
||||
* @param type 授权类型
|
||||
* @return 过期时间戳
|
||||
*/
|
||||
private static long calculateExpireTime(String type)
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TYPE_TEST:
|
||||
return now + 5 * 60 * 1000L; // 5分钟
|
||||
case TYPE_MONTH:
|
||||
return now + 30L * 24 * 60 * 60 * 1000; // 1个月
|
||||
case TYPE_THREE:
|
||||
return now + 90L * 24 * 60 * 60 * 1000; // 3个月
|
||||
case TYPE_YEAR:
|
||||
return now + 365L * 24 * 60 * 60 * 1000; // 1年
|
||||
case TYPE_FIVE:
|
||||
return now + 5 * 365L * 24 * 60 * 60 * 1000; // 5年
|
||||
case TYPE_FOREVER:
|
||||
return now + 100 * 365L * 24 * 60 * 60 * 1000; // 100年(视为长期)
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成校验码
|
||||
*
|
||||
* @param type 授权类型
|
||||
* @param projectNo 项目编号
|
||||
* @param encryptedTime 加密时间
|
||||
* @return 校验码
|
||||
*/
|
||||
private static String generateCheckCode(String type, String projectNo, String encryptedTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
String data = type + projectNo + encryptedTime;
|
||||
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
|
||||
byte[] hash = md.digest(data.getBytes("UTF-8"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < Math.min(4, hash.length); i++)
|
||||
{
|
||||
sb.append(String.format("%02x", hash[i]));
|
||||
}
|
||||
return sb.toString().toUpperCase();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return "00000000";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*
|
||||
* @param data 原始数据
|
||||
* @return 加密后的数据
|
||||
*/
|
||||
private static String encrypt(String data)
|
||||
{
|
||||
try
|
||||
{
|
||||
SecretKeySpec key = new SecretKeySpec(SECRET_KEY.getBytes("UTF-8"), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
byte[] encrypted = cipher.doFinal(data.getBytes("UTF-8"));
|
||||
return Base64.getEncoder().encodeToString(encrypted).replace("+", "-").replace("/", ".").replace("=", "");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param encryptedData 加密数据
|
||||
* @return 解密后的数据
|
||||
*/
|
||||
private static String decrypt(String encryptedData)
|
||||
{
|
||||
try
|
||||
{
|
||||
String base64Data = encryptedData.replace("-", "+").replace(".", "/");
|
||||
int padding = (4 - base64Data.length() % 4) % 4;
|
||||
for (int i = 0; i < padding; i++)
|
||||
{
|
||||
base64Data += "=";
|
||||
}
|
||||
|
||||
SecretKeySpec key = new SecretKeySpec(SECRET_KEY.getBytes("UTF-8"), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, key);
|
||||
byte[] decrypted = cipher.doFinal(Base64.getDecoder().decode(base64Data));
|
||||
return new String(decrypted, "UTF-8");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?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.license.mapper.SysLicenseMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.license.domain.SysLicense" id="SysLicenseResult">
|
||||
<result property="licenseId" column="license_id" />
|
||||
<result property="licenseCode" column="license_code" />
|
||||
<result property="startTime" column="start_time" />
|
||||
<result property="expireTime" column="expire_time" />
|
||||
<result property="status" column="status" />
|
||||
<result property="activeTime" column="active_time" />
|
||||
<result property="activeBy" column="active_by" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysLicenseVo">
|
||||
select license_id, license_code, start_time, expire_time, status, active_time, active_by, create_by, create_time, update_by, update_time, remark from sys_license
|
||||
</sql>
|
||||
|
||||
<select id="selectSysLicenseList" parameterType="com.ruoyi.license.domain.SysLicense" resultMap="SysLicenseResult">
|
||||
<include refid="selectSysLicenseVo"/>
|
||||
<where>
|
||||
<if test="licenseCode != null and licenseCode != ''"> and license_code = #{licenseCode}</if>
|
||||
<if test="startTime != null "> and start_time = #{startTime}</if>
|
||||
<if test="expireTime != null "> and expire_time = #{expireTime}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectSysLicenseById" parameterType="Long" resultMap="SysLicenseResult">
|
||||
<include refid="selectSysLicenseVo"/>
|
||||
where license_id = #{licenseId}
|
||||
</select>
|
||||
|
||||
<select id="selectActiveLicense" resultMap="SysLicenseResult">
|
||||
<include refid="selectSysLicenseVo"/>
|
||||
where status = '1'
|
||||
order by create_time desc
|
||||
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
|
||||
</select>
|
||||
|
||||
<insert id="insertSysLicense" parameterType="com.ruoyi.license.domain.SysLicense" useGeneratedKeys="true" keyProperty="licenseId">
|
||||
insert into sys_license
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="licenseCode != null and licenseCode != ''">license_code,</if>
|
||||
<if test="startTime != null">start_time,</if>
|
||||
<if test="expireTime != null">expire_time,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="activeTime != null">active_time,</if>
|
||||
<if test="activeBy != null">active_by,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="licenseCode != null and licenseCode != ''">#{licenseCode},</if>
|
||||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="expireTime != null">#{expireTime},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="activeTime != null">#{activeTime},</if>
|
||||
<if test="activeBy != null">#{activeBy},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysLicense" parameterType="com.ruoyi.license.domain.SysLicense">
|
||||
update sys_license
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="licenseCode != null and licenseCode != ''">license_code = #{licenseCode},</if>
|
||||
<if test="startTime != null">start_time = #{startTime},</if>
|
||||
<if test="expireTime != null">expire_time = #{expireTime},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="activeTime != null">active_time = #{activeTime},</if>
|
||||
<if test="activeBy != null">active_by = #{activeBy},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where license_id = #{licenseId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysLicenseById" parameterType="Long">
|
||||
delete from sys_license where license_id = #{licenseId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysLicenseByIds" parameterType="String">
|
||||
delete from sys_license where license_id in
|
||||
<foreach item="licenseId" collection="array" open="(" separator="," close=")">
|
||||
#{licenseId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -1,5 +1,5 @@
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = "ForTucky WMS system"
|
||||
VUE_APP_TITLE = "艾度 WMS system"
|
||||
|
||||
# 开发环境配置
|
||||
ENV = 'development'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = "ForTucky WMS system"
|
||||
VUE_APP_TITLE = "艾度 WMS system"
|
||||
|
||||
# 生产环境配置
|
||||
ENV = 'production'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = "ForTucky WMS system"
|
||||
VUE_APP_TITLE = "艾度 WMS system"
|
||||
|
||||
BABEL_ENV = production
|
||||
|
||||
|
||||
44
ruoyi-ui/src/api/agvPoint/point.js
Normal file
44
ruoyi-ui/src/api/agvPoint/point.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询agv站点管理列表
|
||||
export function listPoint(query) {
|
||||
return request({
|
||||
url: '/bas/agvPoint/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询agv站点管理详细
|
||||
export function getPoint(id) {
|
||||
return request({
|
||||
url: '/bas/agvPoint' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增agv站点管理
|
||||
export function addPoint(data) {
|
||||
return request({
|
||||
url: '/bas/agvPoint',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改agv站点管理
|
||||
export function updatePoint(data) {
|
||||
return request({
|
||||
url: '/bas/agvPoint',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除agv站点管理
|
||||
export function delPoint(id) {
|
||||
return request({
|
||||
url: '/bas/agvPoint' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
40
ruoyi-ui/src/api/license.js
Normal file
40
ruoyi-ui/src/api/license.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listLicense(query) {
|
||||
return request({
|
||||
url: '/system/license/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function delLicense(ids) {
|
||||
return request({
|
||||
url: '/system/license/remove',
|
||||
method: 'post',
|
||||
params: { ids }
|
||||
})
|
||||
}
|
||||
|
||||
export function activeLicense(licenseCode) {
|
||||
return request({
|
||||
url: '/system/license/active',
|
||||
method: 'post',
|
||||
params: { licenseCode }
|
||||
})
|
||||
}
|
||||
|
||||
export function getLicenseInfo() {
|
||||
return request({
|
||||
url: '/system/license/info',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function generateLicense(type, projectNo) {
|
||||
return request({
|
||||
url: '/system/license/generate',
|
||||
method: 'get',
|
||||
params: { type, projectNo }
|
||||
})
|
||||
}
|
||||
@@ -9,6 +9,30 @@ export function listLog(query) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function getMethod() {
|
||||
return request({
|
||||
url: '/requestInterface/log/getMethod',
|
||||
method: 'get'
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
export function getSource() {
|
||||
return request({
|
||||
url: '/requestInterface/log/getSource',
|
||||
method: 'get'
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
export function getTarget() {
|
||||
return request({
|
||||
url: '/requestInterface/log/getTarget',
|
||||
method: 'get'
|
||||
|
||||
})
|
||||
}
|
||||
// 查询接口记录详细
|
||||
export function getLog(requestId) {
|
||||
return request({
|
||||
|
||||
@@ -10,10 +10,11 @@ export function listManagement(query) {
|
||||
}
|
||||
|
||||
// 查询库存信息详细
|
||||
export function getManagement(stockId) {
|
||||
export function getManagement(stockId, warehouseCode) {
|
||||
return request({
|
||||
url: '/stock/management/' + stockId,
|
||||
method: 'get'
|
||||
method: 'get',
|
||||
params: {"warehouseCode": warehouseCode}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -45,12 +46,14 @@ export function updateManagement(data) {
|
||||
}
|
||||
|
||||
// 删除库存信息
|
||||
export function delManagement(stockId) {
|
||||
export function delManagement(stockId, warehouseCode) {
|
||||
return request({
|
||||
url: '/stock/management/' + stockId,
|
||||
method: 'delete'
|
||||
method: 'delete',
|
||||
params: {"warehouseCode": warehouseCode}
|
||||
})
|
||||
}
|
||||
|
||||
//重置盘点记录
|
||||
export function resetPdRecord() {
|
||||
return request({
|
||||
|
||||
@@ -36,7 +36,7 @@ export default {
|
||||
pageSizes: {
|
||||
type: Array,
|
||||
default() {
|
||||
return [10, 20, 30, 50]
|
||||
return [10, 50, 100, 1000]
|
||||
}
|
||||
},
|
||||
// 移动端页码按钮的数量端默认值5
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
<breadcrumb v-if="!topNav" id="breadcrumb-container" class="breadcrumb-container" />
|
||||
<top-nav v-if="topNav" id="topmenu-container" class="topmenu-container" />
|
||||
|
||||
<div v-if="licenseWarning" class="license-warning">
|
||||
<i class="el-icon-warning-outline" />
|
||||
系统授权将于 {{ licenseExpireText }} 后过期,请及时联系管理员续期
|
||||
</div>
|
||||
|
||||
<div class="right-menu">
|
||||
<template v-if="device!=='mobile'">
|
||||
<search id="header-search" class="right-menu-item" />
|
||||
@@ -48,6 +53,7 @@ import Hamburger from '@/components/Hamburger'
|
||||
import Screenfull from '@/components/Screenfull'
|
||||
import SizeSelect from '@/components/SizeSelect'
|
||||
import Search from '@/components/HeaderSearch'
|
||||
import { getLicenseInfo } from '@/api/license'
|
||||
// import RuoYiGit from '@/components/RuoYi/Git'
|
||||
// import RuoYiDoc from '@/components/RuoYi/Doc'
|
||||
|
||||
@@ -63,6 +69,13 @@ export default {
|
||||
// RuoYiGit,
|
||||
// RuoYiDoc
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
licenseWarning: false,
|
||||
licenseExpireText: '',
|
||||
licenseTimer: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'sidebar',
|
||||
@@ -81,7 +94,41 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.checkLicenseExpire()
|
||||
this.licenseTimer = setInterval(this.checkLicenseExpire, 60 * 1000)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.licenseTimer) {
|
||||
clearInterval(this.licenseTimer)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkLicenseExpire() {
|
||||
getLicenseInfo().then(response => {
|
||||
this.licenseWarning = false
|
||||
this.licenseExpireText = ''
|
||||
if (response.code !== 200 || !response.data || !response.data.expireTime) {
|
||||
return
|
||||
}
|
||||
const expireTime = new Date(response.data.expireTime).getTime()
|
||||
const diffMs = expireTime - Date.now()
|
||||
const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))
|
||||
if (diffMs <= 0 || diffDays > 30) {
|
||||
return
|
||||
}
|
||||
this.licenseWarning = true
|
||||
if (diffMs < 1000 * 60 * 60 * 24) {
|
||||
const hours = Math.floor(diffMs / (1000 * 60 * 60))
|
||||
const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60))
|
||||
this.licenseExpireText = hours > 0 ? `${hours} 小时 ${minutes} 分钟` : `${minutes} 分钟`
|
||||
} else if (diffDays < 7) {
|
||||
this.licenseExpireText = `${diffDays} 天`
|
||||
} else {
|
||||
this.licenseExpireText = `${Math.ceil(diffDays / 7)} 周`
|
||||
}
|
||||
}).catch(() => {})
|
||||
},
|
||||
toggleSideBar() {
|
||||
this.$store.dispatch('app/toggleSideBar')
|
||||
},
|
||||
@@ -113,6 +160,27 @@ export default {
|
||||
color: var(--navbar-color, #5a5e66);
|
||||
box-shadow: 0 1px 4px rgba(0,21,41,.08);
|
||||
|
||||
.license-warning {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 0;
|
||||
max-width: calc(100% - 420px);
|
||||
height: 44px;
|
||||
overflow: hidden;
|
||||
color: #e6a23c;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 44px;
|
||||
pointer-events: none;
|
||||
text-overflow: ellipsis;
|
||||
transform: translateX(-50%);
|
||||
white-space: nowrap;
|
||||
|
||||
i {
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.hamburger-container {
|
||||
line-height: 46px;
|
||||
height: 100%;
|
||||
|
||||
@@ -45,6 +45,10 @@ const user = {
|
||||
const password = userInfo.password
|
||||
const code = userInfo.code
|
||||
const uuid = userInfo.uuid
|
||||
removeToken()
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
return new Promise((resolve, reject) => {
|
||||
login(username, password, code, uuid).then(res => {
|
||||
setToken(res.token)
|
||||
@@ -85,14 +89,18 @@ const user = {
|
||||
// 退出系统
|
||||
LogOut({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
logout(state.token).then(() => {
|
||||
const clearLocalSession = () => {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
removeToken()
|
||||
}
|
||||
logout(state.token).then(() => {
|
||||
clearLocalSession()
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
clearLocalSession()
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -101,6 +109,8 @@ const user = {
|
||||
FedLogOut({ commit }) {
|
||||
return new Promise(resolve => {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
removeToken()
|
||||
resolve()
|
||||
})
|
||||
|
||||
@@ -74,19 +74,19 @@ service.interceptors.request.use(config => {
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(res => {
|
||||
// 未设置状态码则默认成功状态
|
||||
const code = res.status|| 200
|
||||
const code = res.data && res.data.code !== undefined ? res.data.code : (res.status || 200)
|
||||
// 获取错误信息
|
||||
const msg = errorCode[code] || res.data.msg || errorCode['default']
|
||||
// 二进制数据则直接返回
|
||||
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
|
||||
return res.data
|
||||
}
|
||||
if (code === 401) {
|
||||
if (code === 401 || res.status === 401) {
|
||||
if (!isRelogin.show) {
|
||||
isRelogin.show = true
|
||||
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
|
||||
isRelogin.show = false
|
||||
store.dispatch('LogOut').then(() => {
|
||||
store.dispatch('FedLogOut').then(() => {
|
||||
location.href = '/index'
|
||||
})
|
||||
}).catch(() => {
|
||||
|
||||
314
ruoyi-ui/src/views/agvPoint/point/index.vue
Normal file
314
ruoyi-ui/src/views/agvPoint/point/index.vue
Normal file
@@ -0,0 +1,314 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="站点" prop="station">
|
||||
<el-input
|
||||
v-model="queryParams.station"
|
||||
placeholder="请输入站点"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="站点类型" prop="type">
|
||||
<el-select v-model="queryParams.type" placeholder="请选择单据来源" clearable>
|
||||
<el-option
|
||||
v-for="item in typeOption"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="1" prop="spare2">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.spare2"-->
|
||||
<!-- placeholder="请输入1"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="1" prop="spare3">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.spare3"-->
|
||||
<!-- placeholder="请输入1"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @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="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['agvPoint:point:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="success"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="single"-->
|
||||
<!-- @click="handleUpdate"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="danger"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="multiple"-->
|
||||
<!-- @click="handleDelete"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="warning"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-download"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleExport"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:export']"-->
|
||||
<!-- >导出</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="pointList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" prop="id" />
|
||||
<el-table-column label="站点" align="center" prop="station" />
|
||||
<!-- <el-table-column label="站点类型" align="center" prop="type" />-->
|
||||
<el-table-column label="站点类型" align="center" prop="type" >
|
||||
<template slot-scope="scope">
|
||||
<!-- if 判断:type=1 显示入库,type=2 显示出库 -->
|
||||
<span v-if="scope.row.type === '1'">源站</span>
|
||||
<span v-else-if="scope.row.type === '2'">目标站</span>
|
||||
<!-- 兜底:其他值显示未知类型,避免空白 -->
|
||||
<span v-else>未知类型</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="1" align="center" prop="remark" />-->
|
||||
<!-- <el-table-column label="1" align="center" prop="spare1" />-->
|
||||
<!-- <el-table-column label="1" align="center" prop="spare2" />-->
|
||||
<!-- <el-table-column label="1" align="center" prop="spare3" />-->
|
||||
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <el-button-->
|
||||
<!-- size="mini"-->
|
||||
<!-- type="text"-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- @click="handleUpdate(scope.row)"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- <el-button-->
|
||||
<!-- size="mini"-->
|
||||
<!-- type="text"-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- @click="handleDelete(scope.row)"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改agv站点管理对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="站点" prop="station">
|
||||
<el-input v-model="form.station" placeholder="请输入站点" />
|
||||
</el-form-item>
|
||||
<el-form-item label="站点类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择站点类型" clearable>
|
||||
<el-option
|
||||
v-for="item in typeOption"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="1" prop="spare1">-->
|
||||
<!-- <el-input v-model="form.spare1" placeholder="请输入1" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="1" prop="spare2">-->
|
||||
<!-- <el-input v-model="form.spare2" placeholder="请输入1" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="1" prop="spare3">-->
|
||||
<!-- <el-input v-model="form.spare3" placeholder="请输入1" />-->
|
||||
<!-- </el-form-item>-->
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listPoint, getPoint, delPoint, addPoint, updatePoint } from "@/api/agvPoint/point"
|
||||
|
||||
export default {
|
||||
name: "Point",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// agv站点管理表格数据
|
||||
pointList: [],
|
||||
typeOption:[{label:'源站',value:'1'},{label:'目标站',value:'2'}],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
station: null,
|
||||
type: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
/** 查询agv站点管理列表 */
|
||||
getList() {
|
||||
this.loading = true
|
||||
listPoint(this.queryParams).then(response => {
|
||||
this.pointList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
this.reset()
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
station: null,
|
||||
type: null,
|
||||
remark: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null
|
||||
}
|
||||
this.resetForm("form")
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm")
|
||||
this.handleQuery()
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset()
|
||||
this.open = true
|
||||
this.title = "添加agv站点管理"
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
const id = row.id || this.ids
|
||||
getPoint(id).then(response => {
|
||||
this.form = response.data
|
||||
this.open = true
|
||||
this.title = "修改agv站点管理"
|
||||
})
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updatePoint(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addPoint(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids
|
||||
this.$modal.confirm('是否确认删除agv站点管理编号为"' + ids + '"的数据项?').then(function() {
|
||||
return delPoint(ids)
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('agvPoint/point/export', {
|
||||
...this.queryParams
|
||||
}, `point_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,22 +1,22 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" >
|
||||
<!-- <el-form-item label="格式ID" prop="formatId">-->
|
||||
<!--<!– <el-input-->
|
||||
<!-- v-model="queryParams.formatId"-->
|
||||
<!-- placeholder="请输入格式ID"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />–>-->
|
||||
<!-- <el-select v-model="queryParams.formatId" placeholder="请选择格式ID">-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="item in traycodeFormatList"-->
|
||||
<!-- :key="item.id"-->
|
||||
<!-- :label="item.remarks"-->
|
||||
<!-- :value="item.id"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="格式ID" prop="formatId">-->
|
||||
<!--<!– <el-input-->
|
||||
<!-- v-model="queryParams.formatId"-->
|
||||
<!-- placeholder="请输入格式ID"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />–>-->
|
||||
<!-- <el-select v-model="queryParams.formatId" placeholder="请选择格式ID">-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="item in traycodeFormatList"-->
|
||||
<!-- :key="item.id"-->
|
||||
<!-- :label="item.remarks"-->
|
||||
<!-- :value="item.id"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="条码" prop="trayCode">
|
||||
<el-input
|
||||
v-model="queryParams.trayCode"
|
||||
@@ -101,16 +101,16 @@
|
||||
|
||||
<el-table ref="table" v-loading="loading" :data="traycodeList" @selection-change="handleSelectionChange" max-height="700">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<!-- <el-table-column label="序号" align="center" prop="id" />-->
|
||||
<!-- <el-table-column label="格式ID" align="left" prop="formatName" />-->
|
||||
<!-- <el-table-column label="序号" align="center" prop="id" />-->
|
||||
<!-- <el-table-column label="格式ID" align="left" prop="formatName" />-->
|
||||
<el-table-column label="条码" align="center" prop="trayCode" />
|
||||
<!-- <el-table-column label="Spare Field 1" align="center" prop="spare1" />-->
|
||||
<!-- <el-table-column label="Spare Field 1" align="center" prop="spare1" />-->
|
||||
<el-table-column label="是否可用" align="center" prop="spare2" >
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.spare2"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="Spare Field 3" align="center" prop="spare3" />-->
|
||||
<!-- <el-table-column label="Spare Field 3" align="center" prop="spare3" />-->
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
@@ -161,7 +161,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="数量" prop="spare1" v-if="form.id == null">
|
||||
<el-form-item label="数量" prop="spare1" v-if="form.id == null">
|
||||
<el-input v-model="form.spare1" placeholder="请输入数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="托盘编码" prop="trayCode" v-if="form.id != null" >
|
||||
@@ -187,14 +187,27 @@
|
||||
|
||||
|
||||
<!-- 打印模板 -->
|
||||
<!-- <vue-easy-print v-show="true" ref="easyPrint2">-->
|
||||
<!-- <div v-for="item in printData" :key="item.id" style="page-break-after:always" class="vue-easy-print">-->
|
||||
<!-- <vue-barcode-->
|
||||
<!-- :value=item.trayCode-->
|
||||
<!-- format="CODE39"-->
|
||||
<!-- width="2"-->
|
||||
<!-- height="100"-->
|
||||
<!-- display-value-->
|
||||
<!-- margin="2"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
<!-- </vue-easy-print>-->
|
||||
<vue-easy-print v-show="true" ref="easyPrint2">
|
||||
<div v-for="item in printData" :key="item.id" style="page-break-after:always" class="vue-easy-print">
|
||||
<vue-barcode
|
||||
:value=item.trayCode
|
||||
format="CODE39"
|
||||
width="2"
|
||||
height="100"
|
||||
format="CODE128"
|
||||
width="4"
|
||||
height="150"
|
||||
display-value
|
||||
margin="5"
|
||||
/>
|
||||
</div>
|
||||
</vue-easy-print>
|
||||
@@ -205,6 +218,7 @@
|
||||
import { listTraycode, getTraycode, delTraycode, addTraycode, updateTraycode } from "@/api/bas/traycode"
|
||||
import { listTraycodeFormat } from "@/api/bas/traycodeFormat"
|
||||
import vueEasyPrint from 'vue-easy-print'
|
||||
import VueQr from 'vue-qr'
|
||||
import VueBarcode from 'vue-barcode'
|
||||
|
||||
export default {
|
||||
@@ -450,6 +464,11 @@ export default {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
.vue-qr {
|
||||
display: block;
|
||||
margin: 20px auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
@@ -462,7 +481,7 @@ export default {
|
||||
}
|
||||
|
||||
.vue-easy-print {
|
||||
padding: 5px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.num {
|
||||
@@ -470,5 +489,8 @@ export default {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.vue-qr {
|
||||
margin: 10px auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
474
ruoyi-ui/src/views/bas/traycode/index1.vue
Normal file
474
ruoyi-ui/src/views/bas/traycode/index1.vue
Normal file
@@ -0,0 +1,474 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" >
|
||||
<!-- <el-form-item label="格式ID" prop="formatId">-->
|
||||
<!--<!– <el-input-->
|
||||
<!-- v-model="queryParams.formatId"-->
|
||||
<!-- placeholder="请输入格式ID"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />–>-->
|
||||
<!-- <el-select v-model="queryParams.formatId" placeholder="请选择格式ID">-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="item in traycodeFormatList"-->
|
||||
<!-- :key="item.id"-->
|
||||
<!-- :label="item.remarks"-->
|
||||
<!-- :value="item.id"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="条码" prop="trayCode">
|
||||
<el-input
|
||||
v-model="queryParams.trayCode"
|
||||
placeholder="请输入条码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否可用" prop="spare2">
|
||||
<el-select v-model="queryParams.spare2" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="dict in dict.type.sys_yes_no"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @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="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['bas:traycode:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['bas:traycode:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['bas:traycode:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['bas:traycode:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
icon="el-icon-printer"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleBatchPrint"
|
||||
v-hasPermi="['bas:traycode:print']"
|
||||
>批量打印</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table ref="table" v-loading="loading" :data="traycodeList" @selection-change="handleSelectionChange" max-height="700">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<!-- <el-table-column label="序号" align="center" prop="id" />-->
|
||||
<!-- <el-table-column label="格式ID" align="left" prop="formatName" />-->
|
||||
<el-table-column label="条码" align="center" prop="trayCode" />
|
||||
<!-- <el-table-column label="Spare Field 1" align="center" prop="spare1" />-->
|
||||
<el-table-column label="是否可用" align="center" prop="spare2" >
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.spare2"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="Spare Field 3" align="center" prop="spare3" />-->
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['bas:traycode:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['bas:traycode:remove']"
|
||||
>删除</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-printer"
|
||||
@click="printBarcode(scope.row)"
|
||||
v-hasPermi="['bas:traycode:print']"
|
||||
>打印</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
|
||||
<!-- 添加或修改条码信息对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="格式ID" prop="formatId">
|
||||
<el-select v-model="form.formatId" placeholder="请选择格式ID">
|
||||
<el-option
|
||||
v-for="item in traycodeFormatList"
|
||||
:key="item.id"
|
||||
:label="item.remarks"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="数量" prop="spare1" v-if="form.id == null">
|
||||
<el-input v-model="form.spare1" placeholder="请输入数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="托盘编码" prop="trayCode" v-if="form.id != null" >
|
||||
|
||||
<el-input v-model="form.trayCode" placeholder="请输入托盘编码" disabled/>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否可用" prop="spare2" v-if="form.id != null">
|
||||
<el-select v-model="form.spare2" placeholder="请选择" >
|
||||
<el-option
|
||||
v-for="dict in dict.type.sys_yes_no"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确定</el-button>
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
|
||||
<!-- 打印模板 -->
|
||||
<vue-easy-print v-show="true" ref="easyPrint2">
|
||||
<div v-for="item in printData" :key="item.id" style="page-break-after:always" class="vue-easy-print">
|
||||
<vue-barcode
|
||||
:value=item.trayCode
|
||||
format="CODE39"
|
||||
width="2"
|
||||
height="100"
|
||||
display-value
|
||||
/>
|
||||
</div>
|
||||
</vue-easy-print>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listTraycode, getTraycode, delTraycode, addTraycode, updateTraycode } from "@/api/bas/traycode"
|
||||
import { listTraycodeFormat } from "@/api/bas/traycodeFormat"
|
||||
import vueEasyPrint from 'vue-easy-print'
|
||||
import VueBarcode from 'vue-barcode'
|
||||
|
||||
export default {
|
||||
name: "Traycode",
|
||||
dicts:['sys_yes_no'],
|
||||
components: {
|
||||
vueEasyPrint,
|
||||
VueQr,
|
||||
VueBarcode
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 设置标题
|
||||
title: this.$t('traycode.title'),
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 条码信息表格数据
|
||||
traycodeList: [],
|
||||
traycodeFormatList: [],
|
||||
printData:[],
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
formatId: null,
|
||||
trayCode: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null
|
||||
},
|
||||
queryTrayCodeFormatParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 99,
|
||||
},
|
||||
// Form parameters
|
||||
form: {},
|
||||
// Form validation
|
||||
rules: {
|
||||
formatId: [
|
||||
{ required: true, message: "请输入格式ID", trigger: "blur" }
|
||||
],
|
||||
trayCode: [
|
||||
{ required: true, message: "请输入托盘编码", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTrayCodeFormatList()
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
/** 查询条码信息列表 */
|
||||
getTrayCodeFormatList() {
|
||||
this.loading = true
|
||||
listTraycodeFormat(this.queryTrayCodeFormatParams).then(response => {
|
||||
this.traycodeFormatList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
/** 查询条码信息列表 */
|
||||
getList() {
|
||||
this.loading = true
|
||||
listTraycode(this.queryParams).then(response => {
|
||||
this.traycodeList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
this.reset()
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
formatId: null,
|
||||
trayCode: null,
|
||||
createTime: null,
|
||||
updateTime: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null
|
||||
}
|
||||
this.resetForm("form")
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm")
|
||||
this.handleQuery()
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset()
|
||||
this.open = true
|
||||
this.title = "新增托盘编码"
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
const id = row.id || this.ids
|
||||
getTraycode(id).then(response => {
|
||||
this.form = response.data
|
||||
this.open = true
|
||||
this.title = "修改托盘编码"
|
||||
})
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateTraycode(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addTraycode(this.form).then(response => {
|
||||
this.$modal.msgSuccess("添加成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids
|
||||
this.$modal.confirm('是否确认删除选中的数据项?').then(function() {
|
||||
return delTraycode(ids)
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('bas/traycode/export', {
|
||||
...this.queryParams
|
||||
}, `traycode_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 打印条码 */
|
||||
printBarcode: function (row) {
|
||||
const yesValItem = (this.dict && this.dict.type && this.dict.type.sys_yes_no) ? (this.dict.type.sys_yes_no.find(i => i.label === '是') || this.dict.type.sys_yes_no.find(i => i.value === 'Y' || i.value === '1')) : null
|
||||
const yesVal = yesValItem ? yesValItem.value : 'Y'
|
||||
if (row.spare2 !== yesVal) {
|
||||
this.$modal.msgError("该托盘不可打印:仅“是”可用")
|
||||
return;
|
||||
}
|
||||
this.printData = [row]
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.easyPrint2.print()
|
||||
const noValItem = (this.dict && this.dict.type && this.dict.type.sys_yes_no) ? (this.dict.type.sys_yes_no.find(i => i.label === '否') || this.dict.type.sys_yes_no.find(i => i.value === 'N' || i.value === '0')) : null
|
||||
const noVal = noValItem ? noValItem.value : 'N'
|
||||
const data = Object.assign({}, row, { spare2: noVal })
|
||||
updateTraycode(data).then(() => {
|
||||
this.$modal.msgSuccess("打印完成,已标记为不可用")
|
||||
this.getList()
|
||||
}).catch(() => {})
|
||||
}, 100)
|
||||
})
|
||||
},
|
||||
/** 批量打印按钮操作 */
|
||||
handleBatchPrint() {
|
||||
const selection = this.$refs.table.selection;
|
||||
if (selection.length === 0) {
|
||||
this.$modal.msgError("请选择要打印的数据项");
|
||||
return;
|
||||
}
|
||||
const yesValItem = (this.dict && this.dict.type && this.dict.type.sys_yes_no) ? (this.dict.type.sys_yes_no.find(i => i.label === '是') || this.dict.type.sys_yes_no.find(i => i.value === 'Y' || i.value === '1')) : null
|
||||
const yesVal = yesValItem ? yesValItem.value : 'Y'
|
||||
const invalid = selection.filter(item => item.spare2 !== yesVal)
|
||||
if (invalid.length > 0) {
|
||||
this.$modal.msgError("存在不可打印项(非“是”),请重新选择")
|
||||
return;
|
||||
}
|
||||
this.printData = selection;
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.easyPrint2.print()
|
||||
const noValItem = (this.dict && this.dict.type && this.dict.type.sys_yes_no) ? (this.dict.type.sys_yes_no.find(i => i.label === '否') || this.dict.type.sys_yes_no.find(i => i.value === 'N' || i.value === '0')) : null
|
||||
const noVal = noValItem ? noValItem.value : 'N'
|
||||
const updates = selection.map(item => {
|
||||
const data = Object.assign({}, item, { spare2: noVal })
|
||||
return updateTraycode(data)
|
||||
})
|
||||
Promise.all(updates).then(() => {
|
||||
this.$modal.msgSuccess("批量打印完成,已标记为不可用")
|
||||
this.getList()
|
||||
}).catch(() => {})
|
||||
}, 100)
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
/* 统一表单控件宽度 */
|
||||
.el-select,
|
||||
.el-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 打印样式 */
|
||||
.vue-easy-print {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.num {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
margin-top: 15px;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
size: 80mm 50mm;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.vue-easy-print {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.num {
|
||||
font-size: 14px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<el-select v-model="queryParams.warehouseId" placeholder="请选择仓库" clearable>
|
||||
<el-option v-for="item in warehouseOptions" :key="item.warehouseId" :label="item.warehouseName" :value="item.warehouseId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="作业状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择任务状态" clearable>
|
||||
@@ -293,13 +298,16 @@ export default {
|
||||
created() {
|
||||
// 获取字典数据后,设置默认值
|
||||
this.getList()
|
||||
//this.getWarehouseList()
|
||||
this.getWarehouseList()
|
||||
},
|
||||
methods: {
|
||||
/** 获取仓库列表 */
|
||||
getWarehouseList() {
|
||||
listWarehouse(this.queryWarehouseParams).then(response => {
|
||||
this.warehouseOptions = response.rows;
|
||||
this.warehouseOptions = [
|
||||
{ warehouseId: '01', warehouseName: '立库' },
|
||||
{ warehouseId: '02', warehouseName: '平库' }
|
||||
];
|
||||
if (this.warehouseOptions.length > 0) {
|
||||
this.handleQuery();
|
||||
}
|
||||
@@ -433,7 +441,7 @@ export default {
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('job/mydoJob/export', {
|
||||
this.download('job/inmydoJob/export', {
|
||||
...this.queryParams
|
||||
}, `mydoJob_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
|
||||
@@ -31,25 +31,42 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目号" prop="departmentNo">
|
||||
<el-form-item label="项目号" prop="spare4">
|
||||
<el-input
|
||||
v-model="queryParams.departmentNo"
|
||||
v-model="queryParams.spare4"
|
||||
placeholder="请输入项目号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="合同号" prop="spare1">
|
||||
</el-form-item>
|
||||
<el-form-item label="条码号" prop="stockinDetailId">
|
||||
<el-input
|
||||
v-model="queryParams.spare1"
|
||||
placeholder="请输入合同号"
|
||||
v-model="queryParams.stockinDetailId"
|
||||
placeholder="请输入条码号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="销售订单号" prop="spare2">
|
||||
<el-form-item label="组件号" prop="cargoNo">
|
||||
<el-input
|
||||
v-model="queryParams.cargoNo"
|
||||
placeholder="请输入组件号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
|
||||
</el-form-item>
|
||||
<el-form-item label="wms单据号" prop="stockinId">
|
||||
<el-input
|
||||
v-model="queryParams.spare2"
|
||||
v-model="queryParams.stockinId"
|
||||
placeholder="请输入单据号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="erp单据号" prop="erpBill">
|
||||
<el-input
|
||||
v-model="queryParams.erpBill"
|
||||
placeholder="请输入销售订单号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
@@ -65,15 +82,25 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="批次号" prop="lotNo"><!--品名-->
|
||||
<el-form-item label="存货编码" prop="productId"><!--品名-->
|
||||
<el-input
|
||||
v-model="queryParams.lotNo"
|
||||
placeholder="请输入批次号"
|
||||
v-model="queryParams.productId"
|
||||
placeholder="请输入存货编码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<!-- <el-form-item label="批次号" prop="lotNo"><!–品名–>-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.lotNo"-->
|
||||
<!-- placeholder="请输入批次号"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
|
||||
<el-form-item :label="'单据时间'" prop="dateRange">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
@@ -170,23 +197,14 @@
|
||||
<el-table v-loading="loading" :data="stockInList" @selection-change="handleSelectionChange"
|
||||
@row-click="handleRowClick" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="序号" width="60" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="GUID" align="center" prop="stockinGuid" v-if="false"/>
|
||||
<el-table-column label="入库单据号" align="left" prop="stockinId" width="150" sortable/><!--入库订单-->
|
||||
<el-table-column label="单据类型" align="left" prop="inType"><!--入库类型-->
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.in_bill_type" :value="scope.row.inType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单据状态" align="left" prop="status"><!--单据状态-->
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.in_bill_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单据来源" align="left" prop="stockSource"><!--单据来源-->
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.bill_resource" :value="scope.row.stockSource"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="erp单据号" align="left" prop="erpBill" width="150" sortable/>
|
||||
<el-table-column label="仓库" align="left" prop="warehouseName"/><!--仓库-->
|
||||
<el-table-column label="供应商代码" align="left" prop="supplierNo"/><!--仓库-->
|
||||
<el-table-column label="供应商名称" align="left" prop="classNo" /><!--供应商-->
|
||||
@@ -219,8 +237,8 @@
|
||||
<el-table-column label="单位" align="left" prop="unit"/><!--机型-->
|
||||
<el-table-column label="规格型号" align="left" prop="spec"/><!--规格-->
|
||||
<el-table-column label="层级关系" align="left" prop="spare1"/><!--型号-->
|
||||
<el-table-column label="上层物料" align="left" prop="spare2"/><!--净重-->
|
||||
<el-table-column label="顶层物料" align="left" prop="spare3"/><!--颜色-->
|
||||
<el-table-column label="组件号" align="left" prop="cargoNo"/><!--净重-->
|
||||
<el-table-column label="项目号" align="left" prop="spare4"/><!--颜色-->
|
||||
<el-table-column label="计划数量" align="left" prop="quantity" sortable/><!--计划数量-->
|
||||
<el-table-column label="扫码数量" align="left" prop="scanNum" sortable/><!--扫码数量-->
|
||||
<el-table-column label="实际数量" align="left" prop="assignNum" sortable/><!--实际数量-->
|
||||
@@ -328,7 +346,10 @@ export default {
|
||||
spare2: null,
|
||||
spare4: null,
|
||||
spare3: null,
|
||||
spare5: null
|
||||
spare5: null,
|
||||
cargoNo:null,
|
||||
productId:null,
|
||||
stockinDetailId:null
|
||||
},
|
||||
queryDetailParams: {
|
||||
pageNum: 1,
|
||||
|
||||
@@ -60,6 +60,14 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目号" prop="lineId">
|
||||
<el-input
|
||||
v-model="queryParams.lineId"
|
||||
placeholder="请输入存货编码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始时间" prop="startTime"> <!-- 开始时间 -->
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.startTime"
|
||||
@@ -268,7 +276,10 @@ export default {
|
||||
getWarehouseOptions() {
|
||||
|
||||
listWarehouse().then(response => {
|
||||
this.warehouseOptions = response.rows;
|
||||
this.warehouseOptions = [
|
||||
{ warehouseId: '01', warehouseName: '立库' },
|
||||
{ warehouseId: '02', warehouseName: '平库' }
|
||||
];
|
||||
});
|
||||
},
|
||||
/** 查询任务表列表 */
|
||||
@@ -347,7 +358,7 @@ export default {
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('job/mydoJob/export', {
|
||||
this.download('job/outmydoJob/export', {
|
||||
...this.queryParams
|
||||
}, `mydoJob_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
|
||||
@@ -56,8 +56,18 @@
|
||||
<router-link class="link-type" :to="'/register'">立即注册</router-link>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button size="medium" type="warning" plain class="license-button" @click.native.prevent="openLicenseDialog">激活授权码</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-dialog title="激活授权码" :visible.sync="licenseDialogVisible" width="420px" append-to-body>
|
||||
<el-input v-model="licenseCode" type="textarea" :rows="4" placeholder="请输入授权码" />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="licenseDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="licenseLoading" @click="handleActiveLicense">激 活</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<!-- 底部 -->
|
||||
<div class="el-login-footer">
|
||||
<span>{{ $t('login.bottom') }}</span>
|
||||
@@ -70,6 +80,7 @@ import LangSelect from '@/components/LangSelect'
|
||||
import { getCodeImg } from "@/api/login";
|
||||
import Cookies from "js-cookie";
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
import { activeLicense } from '@/api/license'
|
||||
|
||||
export default {
|
||||
name: "Login",
|
||||
@@ -98,7 +109,10 @@ export default {
|
||||
captchaEnabled: true,
|
||||
// 注册开关
|
||||
register: false,
|
||||
redirect: undefined
|
||||
redirect: undefined,
|
||||
licenseDialogVisible: false,
|
||||
licenseCode: '',
|
||||
licenseLoading: false
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -156,6 +170,30 @@ export default {
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
openLicenseDialog() {
|
||||
this.licenseCode = ''
|
||||
this.licenseDialogVisible = true
|
||||
},
|
||||
handleActiveLicense() {
|
||||
const licenseCode = this.licenseCode.trim()
|
||||
if (!licenseCode) {
|
||||
this.$message.warning('请输入授权码')
|
||||
return
|
||||
}
|
||||
this.licenseLoading = true
|
||||
activeLicense(licenseCode).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message.success(response.msg || '授权码激活成功')
|
||||
this.licenseDialogVisible = false
|
||||
} else {
|
||||
this.$message.error(response.msg || '授权码激活失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message.error('授权码激活失败')
|
||||
}).finally(() => {
|
||||
this.licenseLoading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -177,7 +215,13 @@ export default {
|
||||
padding: 40px;
|
||||
padding-top: 50px;
|
||||
width: 480px;
|
||||
height: 500px;
|
||||
min-height: 560px;
|
||||
}
|
||||
|
||||
.license-button {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.title {
|
||||
|
||||
@@ -353,7 +353,13 @@ export default {
|
||||
pageNum: 1,
|
||||
pageSize: 100
|
||||
}).then(response => {
|
||||
this.warehouseOptions = response.rows;
|
||||
this.warehouseOptions = response.rows || [];
|
||||
if (!this.warehouseOptions.some(item => String(item.warehouseId) === '2')) {
|
||||
this.warehouseOptions.push({
|
||||
warehouseId: '2',
|
||||
warehouseName: '平库'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 打开客商选择弹窗 */
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'erp单据号'" prop="erpStockoutId"> <!-- 出库单编号 -->
|
||||
<el-input
|
||||
v-model="queryParams.erpStockoutId"
|
||||
:placeholder="'请输入erp单据号'"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'出库类型'" prop="outType"> <!-- 出库类型 -->
|
||||
<el-select v-model="queryParams.outType" :placeholder="'请选择出库类型'" clearable>
|
||||
<el-option
|
||||
@@ -53,6 +61,22 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'项目号'" prop="spare4">
|
||||
<el-input
|
||||
v-model="queryParams.spare4"
|
||||
:placeholder="'请输入项目号'"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'存货编码'" prop="productId">
|
||||
<el-input
|
||||
v-model="queryParams.productId"
|
||||
:placeholder="'请输入存货编码'"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'存货名称'" prop="productName">
|
||||
<el-input
|
||||
v-model="queryParams.productName"
|
||||
@@ -74,8 +98,9 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{'搜索'}}</el-button> <!-- 搜索 -->
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{'重置'}}</el-button> <!-- 重置 -->
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ '搜索' }}</el-button>
|
||||
<!-- 搜索 -->
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ '重置' }}</el-button> <!-- 重置 -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -89,7 +114,8 @@
|
||||
size="mini"
|
||||
@click="handleAudit(2)"
|
||||
v-hasPermi="['out:outStockout:changeStatus']"
|
||||
>{{'单据审核'}}</el-button> <!-- 单据审核 -->
|
||||
>{{ '单据审核' }}
|
||||
</el-button> <!-- 单据审核 -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -99,7 +125,8 @@
|
||||
size="mini"
|
||||
@click="handleAudit(4)"
|
||||
v-hasPermi="['out:outStockout:changeStatus']"
|
||||
>{{'单据确认'}}</el-button> <!-- 单据确认 -->
|
||||
>{{ '单据确认' }}
|
||||
</el-button> <!-- 单据确认 -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -109,7 +136,8 @@
|
||||
size="mini"
|
||||
@click="handleAudit(5)"
|
||||
v-hasPermi="['out:outStockout:changeStatus']"
|
||||
>{{'单据作废'}}</el-button> <!-- 单据作废 -->
|
||||
>{{ '单据作废' }}
|
||||
</el-button> <!-- 单据作废 -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -119,7 +147,8 @@
|
||||
size="mini"
|
||||
@click="handleAutoAllot"
|
||||
v-hasPermi="['out:outStockout:autoAllot']"
|
||||
>{{'自动分配'}}</el-button> <!-- 自动分配 -->
|
||||
>{{ '自动分配' }}
|
||||
</el-button> <!-- 自动分配 -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -129,14 +158,22 @@
|
||||
size="mini"
|
||||
@click="handleManualAllot"
|
||||
v-hasPermi="['out:outStockout:manualAllot']"
|
||||
>{{'手动分配'}}</el-button> <!-- 手动分配 -->
|
||||
>{{ '手动分配' }}
|
||||
</el-button> <!-- 手动分配 -->
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 主表数据 -->
|
||||
<el-table v-loading="loading" :data="outStockoutList" @selection-change="handleSelectionChange" @row-click="handleRowClick" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column :label="'出库单编号'" align="left" prop="stockoutId" />
|
||||
<el-table v-loading="loading" :data="outStockoutList" @selection-change="handleSelectionChange"
|
||||
@row-click="handleRowClick" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="序号" width="60" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="'出库单编号'" align="left" prop="stockoutId"/>
|
||||
<el-table-column :label="'erp单据号'" align="left" prop="erpStockoutId"/>
|
||||
<el-table-column :label="'出库类型'" align="left" prop="outType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.out_bill_type" :value="scope.row.outType"/>
|
||||
@@ -147,10 +184,11 @@
|
||||
<dict-tag :options="dict.type.out_bill_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="'项目号'" align="left" prop="departmentNo" />
|
||||
|
||||
<el-table-column :label="'项目号'" align="left" prop="departmentNo"/>
|
||||
<el-table-column :label="'客商代号'" align="left" prop="customerNo"/>
|
||||
<el-table-column :label="'客商名称'" align="left" prop="classNowId"/>
|
||||
<el-table-column :label="'建单人'" align="left" prop="createManId" />
|
||||
<el-table-column :label="'建单人'" align="left" prop="createManId"/>
|
||||
<el-table-column :label="'出库方式'" align="left" prop="carNumber">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.out_method" :value="scope.row.carNumber"/>
|
||||
@@ -161,16 +199,17 @@
|
||||
<dict-tag :options="dict.type.bill_resource" :value="scope.row.stockoutSource"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="'仓库编码'" align="left" prop="warehouseId"/>
|
||||
<el-table-column :label="'仓库名称'" align="left" prop="warehouseName"/>
|
||||
<!-- <el-table-column :label="'合同号'" align="left" prop="spare1" />-->
|
||||
<!-- <el-table-column :label="'销售订单号'" align="left" prop="spare2" />-->
|
||||
<el-table-column :label="'审核时间'" align="left" prop="spare3" />
|
||||
<el-table-column :label="'审核人'" align="left" prop="spare4" />
|
||||
<el-table-column :label="'审核时间'" align="left" prop="spare3"/>
|
||||
<el-table-column :label="'审核人'" align="left" prop="spare4"/>
|
||||
<el-table-column :label="'创建时间'" align="left" prop="createDate" width="160" sortable/>
|
||||
<el-table-column :label="'开始时间'" align="left" prop="startDate" width="160" sortable/>
|
||||
<el-table-column :label="'确认时间'" align="left" prop="finishDate" width="160" sortable/>
|
||||
<el-table-column :label="'备注'" align="left" prop="spare5" />
|
||||
<el-table-column :label="'备注'" align="left" prop="spare5"/>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
@@ -182,11 +221,12 @@
|
||||
/>
|
||||
|
||||
<!-- 子表数据 -->
|
||||
<el-table v-loading="detailLoading" :data="outStockDetailList" style="margin-top: 20px;" @selection-change="handleDetailSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column :label="'出库子单编号'" align="center" prop="stockoutDetailId" width="160" /> <!-- 出库子单编号 -->
|
||||
<el-table v-loading="detailLoading" :data="outStockDetailList" style="margin-top: 20px;"
|
||||
@selection-change="handleDetailSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column :label="'出库子单编号'" align="center" prop="stockoutDetailId" width="160"/> <!-- 出库子单编号 -->
|
||||
<el-table-column :label="'存货编码'" align="center" prop="productId" sortable/>
|
||||
<el-table-column :label="'存货名称'" align="center" prop="productName" />
|
||||
<el-table-column :label="'存货名称'" align="center" prop="productName"/>
|
||||
<el-table-column :label="'批次号'" align="center" prop="lotNo"/>
|
||||
<el-table-column :label="'供应商编码'" align="center" prop="fid"/>
|
||||
<el-table-column :label="'计量单位'" align="center" prop="unit"/>
|
||||
@@ -203,13 +243,13 @@
|
||||
<!-- <el-table-column :label="'备注'" align="center" prop="remark"/>-->
|
||||
</el-table>
|
||||
|
||||
<!-- <pagination-->
|
||||
<!-- v-show="detailTotal>0"-->
|
||||
<!-- :total="detailTotal"-->
|
||||
<!-- :page.sync="detailQueryParams.pageNum"-->
|
||||
<!-- :limit.sync="detailQueryParams.pageSize"-->
|
||||
<!-- @pagination="getDetailList"-->
|
||||
<!-- />-->
|
||||
<!-- <pagination-->
|
||||
<!-- v-show="detailTotal>0"-->
|
||||
<!-- :total="detailTotal"-->
|
||||
<!-- :page.sync="detailQueryParams.pageNum"-->
|
||||
<!-- :limit.sync="detailQueryParams.pageSize"-->
|
||||
<!-- @pagination="getDetailList"-->
|
||||
<!-- />-->
|
||||
|
||||
<!-- 审核弹窗 -->
|
||||
<el-dialog :title="'审核'" :visible.sync="auditDialogVisible" width="400px" append-to-body>
|
||||
@@ -226,8 +266,8 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitAudit">{{"确认"}}</el-button>
|
||||
<el-button @click="cancelAudit">{{"取消"}}</el-button>
|
||||
<el-button type="primary" @click="submitAudit">{{ "确认" }}</el-button>
|
||||
<el-button @click="cancelAudit">{{ "取消" }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
@@ -237,7 +277,9 @@
|
||||
<el-row style="margin-bottom: 15px; padding: 10px; background-color: #f5f7fa; border-radius: 4px;">
|
||||
<el-col :span="8">
|
||||
<span style="font-weight: bold;">计划数量: </span>
|
||||
<span style="color: #409EFF; font-size: 16px;">{{ selectedDetailRows.length > 0 ? selectedDetailRows[0].quantity : 0 }}</span>
|
||||
<span style="color: #409EFF; font-size: 16px;">{{
|
||||
selectedDetailRows.length > 0 ? selectedDetailRows[0].quantity : 0
|
||||
}}</span>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<span style="font-weight: bold;">已选库存数量: </span>
|
||||
@@ -245,7 +287,9 @@
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<span style="font-weight: bold;">剩余可分配: </span>
|
||||
<span :style="{ color: remainingQuantity >= 0 ? '#67C23A' : '#F56C6C', fontSize: '16px' }">{{ remainingQuantity }}</span>
|
||||
<span :style="{ color: remainingQuantity >= 0 ? '#67C23A' : '#F56C6C', fontSize: '16px' }">{{
|
||||
remainingQuantity
|
||||
}}</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
@@ -283,27 +327,28 @@
|
||||
</el-form>
|
||||
|
||||
<!-- 库存明细表格 -->
|
||||
<el-table ref="stockTable" v-loading="stockLoading" :data="stockList" @selection-change="handleStockSelectionChange" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="库存编码" align="center" prop="stockId" />
|
||||
<el-table-column label="货位名称" align="center" prop="cargoSpaceName" />
|
||||
<el-table-column label="批次号" align="center" prop="lotNo" />
|
||||
<el-table-column label="品号" align="center" prop="productId" />
|
||||
<el-table-column label="品名" align="center" prop="productName" />
|
||||
<el-table-column label="数量" align="center" prop="quantity" width="80" />
|
||||
<el-table-column label="规格" align="center" prop="spare1" />
|
||||
<el-table-column label="单位" align="center" prop="spare3" />
|
||||
<el-table-column label="型号" align="center" prop="spare4" />
|
||||
<el-table-column label="颜色" align="center" prop="spare5" />
|
||||
<el-table-column label="序列号" align="center" prop="spare6" />
|
||||
<el-table-column label="电压" align="center" prop="voltage" />
|
||||
<el-table-column label="功率" align="center" prop="power" />
|
||||
<el-table-column label="相位" align="center" prop="phase" />
|
||||
<el-table-column label="净重" align="center" prop="netWeight" />
|
||||
<el-table-column label="毛重" align="center" prop="grossWeight" />
|
||||
<el-table-column label="分销" align="center" prop="distribution" />
|
||||
<el-table-column label="机型" align="center" prop="model" />
|
||||
<el-table-column label="订单号" align="center" prop="orderId" />
|
||||
<el-table ref="stockTable" v-loading="stockLoading" :data="stockList"
|
||||
@selection-change="handleStockSelectionChange" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="库存编码" align="center" prop="stockId"/>
|
||||
<el-table-column label="货位名称" align="center" prop="cargoSpaceName"/>
|
||||
<el-table-column label="批次号" align="center" prop="lotNo"/>
|
||||
<el-table-column label="品号" align="center" prop="productId"/>
|
||||
<el-table-column label="品名" align="center" prop="productName"/>
|
||||
<el-table-column label="数量" align="center" prop="quantity" width="80"/>
|
||||
<el-table-column label="规格" align="center" prop="spare1"/>
|
||||
<el-table-column label="单位" align="center" prop="spare3"/>
|
||||
<el-table-column label="型号" align="center" prop="spare4"/>
|
||||
<el-table-column label="颜色" align="center" prop="spare5"/>
|
||||
<el-table-column label="序列号" align="center" prop="spare6"/>
|
||||
<el-table-column label="电压" align="center" prop="voltage"/>
|
||||
<el-table-column label="功率" align="center" prop="power"/>
|
||||
<el-table-column label="相位" align="center" prop="phase"/>
|
||||
<el-table-column label="净重" align="center" prop="netWeight"/>
|
||||
<el-table-column label="毛重" align="center" prop="grossWeight"/>
|
||||
<el-table-column label="分销" align="center" prop="distribution"/>
|
||||
<el-table-column label="机型" align="center" prop="model"/>
|
||||
<el-table-column label="订单号" align="center" prop="orderId"/>
|
||||
|
||||
</el-table>
|
||||
|
||||
@@ -342,7 +387,7 @@ export default {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
detailLoading: false,
|
||||
warehouseOptions:[],
|
||||
warehouseOptions: [],
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
@@ -374,13 +419,13 @@ export default {
|
||||
// 审核表单验证规则
|
||||
auditRules: {
|
||||
exitId: [
|
||||
{ required: true, message: '请选择出口', trigger: 'change' }
|
||||
{required: true, message: '请选择出口', trigger: 'change'}
|
||||
]
|
||||
},
|
||||
// 出口选项
|
||||
exitOptions: [
|
||||
{ exitId: '1', exitName: '一楼'},
|
||||
{ exitId: '2', exitName: '二楼'},
|
||||
{exitId: '1', exitName: '一楼'},
|
||||
{exitId: '2', exitName: '二楼'},
|
||||
|
||||
],
|
||||
|
||||
@@ -399,14 +444,17 @@ export default {
|
||||
productName: null,
|
||||
startDate: null,
|
||||
finishDate: null,
|
||||
status: null
|
||||
status: null,
|
||||
spare4: null,
|
||||
erpStockoutId: null,
|
||||
productId: null
|
||||
},
|
||||
// 子表分页参数
|
||||
detailQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 99,
|
||||
status:null,
|
||||
stockoutGuid:null
|
||||
status: null,
|
||||
stockoutGuid: null
|
||||
|
||||
},
|
||||
warehouseQueryParams: {
|
||||
@@ -432,7 +480,7 @@ export default {
|
||||
// 计算选中库存的总数量
|
||||
selectedStockQuantity() {
|
||||
return this.selectedStockRows.reduce((total, stock) => {
|
||||
console.log(total+ + (parseFloat(stock.quantity)))
|
||||
console.log(total + +(parseFloat(stock.quantity)))
|
||||
return total + (parseFloat(stock.quantity) || 0)
|
||||
}, 0)
|
||||
},
|
||||
@@ -466,7 +514,7 @@ export default {
|
||||
// 如果有数据,自动选中第一行
|
||||
if (this.outStockoutList.length > 0) {
|
||||
this.handleRowClick(this.outStockoutList[0]);
|
||||
}else {
|
||||
} else {
|
||||
this.outStockDetailList = []
|
||||
this.detailLoading = false
|
||||
}
|
||||
@@ -474,7 +522,7 @@ export default {
|
||||
})
|
||||
},
|
||||
/** 查询子表数据 */
|
||||
getDetailList(stockoutGuid,status) {
|
||||
getDetailList(stockoutGuid, status) {
|
||||
this.detailLoading = true
|
||||
this.detailQueryParams.stockoutGuid = stockoutGuid
|
||||
this.detailQueryParams.status = status
|
||||
@@ -510,7 +558,7 @@ export default {
|
||||
},
|
||||
/** 点击行加载明细数据 */
|
||||
handleRowClick(row) {
|
||||
this.getDetailList(row.stockoutGuid,row.status)
|
||||
this.getDetailList(row.stockoutGuid, row.status)
|
||||
},
|
||||
/** 多选框选中数据 */
|
||||
handleSelectionChange(selection) {
|
||||
@@ -527,22 +575,21 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
for(var i=0;i<this.selectedRows.length;i++){
|
||||
if (this.selectedRows[i].status != "1" && status == 2) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId+'单据已审核')
|
||||
return
|
||||
}
|
||||
for (var i = 0; i < this.selectedRows.length; i++) {
|
||||
if (this.selectedRows[i].status != "1" && status == 2) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId + '单据已审核')
|
||||
return
|
||||
}
|
||||
|
||||
if (Number(this.selectedRows[i].status) < 3 && status == 4) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId+"单据未开始,无法确认")
|
||||
return
|
||||
if (Number(this.selectedRows[i].status) < 3 && status == 4) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId + "单据未开始,无法确认")
|
||||
return
|
||||
}
|
||||
if (this.selectedRows[i].status != "1" && status == 5) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId + '单据已审核,无法作废')
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.selectedRows[i].status != "1" && status == 5){
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId+'单据已审核,无法作废')
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 如果是审核操作(status=2),显示弹窗选择出口
|
||||
@@ -582,15 +629,16 @@ export default {
|
||||
let outstock = this.selectedRows[0]
|
||||
if (outstock.status != "2" && outstock.status != "3") {
|
||||
this.$modal.msgError('请先审核出库单')
|
||||
return
|
||||
return
|
||||
}
|
||||
let data = {
|
||||
stockoutId: stockoutIds[0]
|
||||
}
|
||||
console.log("进入自动分配")
|
||||
autoAllot(data).then(response => {
|
||||
if (response.code !== 200){
|
||||
if (response.code !== 200) {
|
||||
this.$modal.msgError(response.msg)
|
||||
}else {
|
||||
} else {
|
||||
this.$modal.msgSuccess(response.msg)
|
||||
}
|
||||
this.getList()
|
||||
@@ -607,7 +655,7 @@ export default {
|
||||
return
|
||||
}
|
||||
// 检查主表状态
|
||||
if(this.selectedRows.length >1){
|
||||
if (this.selectedRows.length > 1) {
|
||||
this.$modal.msgError('只能选择一条主表数据进行手动分配')
|
||||
return
|
||||
}
|
||||
@@ -624,7 +672,7 @@ export default {
|
||||
this.$modal.msgError('单据已结束,无法手动分配!')
|
||||
return
|
||||
}
|
||||
if(this.selectedDetailRows[0].allotQuantity==this.selectedDetailRows[0].quantity){
|
||||
if (this.selectedDetailRows[0].allotQuantity == this.selectedDetailRows[0].quantity) {
|
||||
this.$modal.msgError('该单据已分配完成,无法手动分配')
|
||||
return
|
||||
}
|
||||
@@ -645,7 +693,7 @@ export default {
|
||||
newStatus: this.currentAuditStatus,
|
||||
exitId: this.auditForm.exitId
|
||||
}
|
||||
// console.log("单据状态修改(含出口信息):", params)
|
||||
// console.log("单据状态修改(含出口信息):", params)
|
||||
|
||||
//调用单据状态改变接口
|
||||
updateOutStockStatus(params).then(response => {
|
||||
@@ -727,7 +775,7 @@ export default {
|
||||
},
|
||||
|
||||
/** 确认分配 */
|
||||
confirmStockAllot() {
|
||||
confirmStockAllot() {
|
||||
if (this.selectedStockRows.length === 0) {
|
||||
this.$modal.msgError('请选择要分配的库存')
|
||||
return
|
||||
@@ -755,19 +803,18 @@ export default {
|
||||
console.log('手动分配参数:', allotParams)
|
||||
// 这里添加实际的分配API调用
|
||||
manualAllot(allotParams).then(response => {
|
||||
if(response.code=="200"){
|
||||
if (response.code == "200") {
|
||||
this.$modal.msgSuccess('分配成功')
|
||||
this.stockDialogVisible = false
|
||||
this.getList()
|
||||
this.getDetailList(this.selectedRows[0].stockoutGuid, this.selectedRows[0].status)
|
||||
}else{
|
||||
} else {
|
||||
this.$modal.msgError(response.msg)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
/** 取消分配 */
|
||||
@@ -778,8 +825,6 @@ export default {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -27,6 +27,44 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="'接口名称'" prop="endpoint">
|
||||
<el-select v-model="queryParams.endpoint" :placeholder="'请选择接口名称'" clearable>
|
||||
<el-option
|
||||
v-for="item in methodOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="'源系统'" prop="sourceSystem">
|
||||
<el-select v-model="queryParams.sourceSystem" :placeholder="'请选择源系统'" clearable>
|
||||
<el-option
|
||||
v-for="item in sourceSystemOption"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item :label="'目标系统'" prop="targetSystem">
|
||||
<el-select v-model="queryParams.targetSystem" :placeholder="'请选择目标系统'" clearable>
|
||||
<el-option
|
||||
v-for="item in targetSystemOption"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ '搜索' }}</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ '重置' }}</el-button>
|
||||
@@ -34,90 +72,29 @@
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-plus"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleAdd"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:add']"-->
|
||||
<!-- >新增</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="success"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="single"-->
|
||||
<!-- @click="handleUpdate"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="danger"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="multiple"-->
|
||||
<!-- @click="handleDelete"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="warning"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-download"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleExport"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:export']"-->
|
||||
<!-- >导出</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="logList" @selection-change="handleSelectionChange" >
|
||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||
<el-table-column width="120" :label="'请求ID'" align="left" prop="requestId" show-overflow-tooltip />
|
||||
<el-table-column width="160" :label="'请求时间'" align="left" prop="requestTime" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'源系统'" align="left" prop="sourceSystem" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'目标系统'" align="left" prop="targetSystem" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'接口名称'" align="left" prop="endpoint" show-overflow-tooltip />
|
||||
<el-table-column width="300" :label="'请求URL'" align="left" prop="requestUrl" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'请求方法'" align="left" prop="requestMethod" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'请求头'" align="left" prop="requestHeaders" show-overflow-tooltip />
|
||||
<el-table-column width="300" :label="'请求体'" align="left" prop="requestBody" show-overflow-tooltip />
|
||||
<el-table-column width="160" :label="'响应时间'" align="left" prop="responseTime" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'响应体'" align="left" prop="responseBody" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'响应状态'" align="left" prop="responseStatus" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'错误详情'" align="left" prop="errorDetails" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'持续时间'" align="left" prop="duration" show-overflow-tooltip />
|
||||
<el-table v-loading="loading" :data="logList" @selection-change="handleSelectionChange">
|
||||
<el-table-column width="120" :label="'请求ID'" align="left" prop="requestId" show-overflow-tooltip/>
|
||||
<el-table-column width="160" :label="'请求时间'" align="left" sortable prop="requestTime" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'源系统'" align="left" prop="sourceSystem" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'目标系统'" align="left" prop="targetSystem" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'接口名称'" align="left" prop="endpoint" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'请求URL'" align="left" prop="requestUrl" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'请求方法'" align="left" prop="requestMethod" show-overflow-tooltip/>
|
||||
<!-- <el-table-column width="120" :label="'请求头'" align="left" prop="requestHeaders" show-overflow-tooltip/>-->
|
||||
<el-table-column width="300" :label="'请求体'" align="left" prop="requestBody" show-overflow-tooltip/>
|
||||
<el-table-column width="160" :label="'响应时间'" align="left" prop="responseTime" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'响应体'" align="left" prop="responseBody" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'响应状态'" align="left" prop="responseStatus" show-overflow-tooltip/>
|
||||
<!-- <el-table-column width="120" :label="'错误详情'" align="left" prop="errorDetails" show-overflow-tooltip/>-->
|
||||
<el-table-column width="120" :label="'持续时间'" align="left" prop="duration" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'是否成功'" align="left" prop="isSuccessful" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.is_available" :value="scope.row.isSuccessful"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <el-button-->
|
||||
<!-- size="mini"-->
|
||||
<!-- type="text"-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- @click="handleUpdate(scope.row)"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- <el-button-->
|
||||
<!-- size="mini"-->
|
||||
<!-- type="text"-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- @click="handleDelete(scope.row)"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
@@ -132,34 +109,34 @@
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item :label="'源系统'" prop="sourceSystem">
|
||||
<el-input v-model="form.sourceSystem" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.sourceSystem" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'目标系统'" prop="targetSystem">
|
||||
<el-input v-model="form.targetSystem" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.targetSystem" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'接口名称'" prop="endpoint">
|
||||
<el-input v-model="form.endpoint" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.endpoint" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'请求URL'" prop="requestUrl">
|
||||
<el-input v-model="form.requestUrl" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.requestUrl" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'请求方法'" prop="requestMethod">
|
||||
<el-input v-model="form.requestMethod" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.requestMethod" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'请求头'" prop="requestHeaders">
|
||||
<el-input v-model="form.requestHeaders" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.requestHeaders" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'请求体'" prop="requestBody">
|
||||
<el-input v-model="form.requestBody" :placeholder="'请输入请求参数'" />
|
||||
<el-input v-model="form.requestBody" :placeholder="'请输入请求参数'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'响应体'" prop="responseBody">
|
||||
<el-input v-model="form.responseBody" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.responseBody" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'错误详情'" prop="errorDetails">
|
||||
<el-input v-model="form.errorDetails" :placeholder="'请输入错误信息'" />
|
||||
<el-input v-model="form.errorDetails" :placeholder="'请输入错误信息'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'持续时间'" prop="duration">
|
||||
<el-input v-model="form.duration" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.duration" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'是否成功'" prop="isSuccessful">
|
||||
<el-select v-model="form.isSuccessful" :placeholder="'请选择是否成功'">
|
||||
@@ -181,32 +158,25 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listLog, getLog, delLog, addLog, updateLog } from "@/api/requestInterface/log"
|
||||
import {listLog, getLog, delLog, addLog, updateLog, getMethod, getSource, getTarget} from "@/api/requestInterface/log"
|
||||
|
||||
export default {
|
||||
name: "Log",
|
||||
dicts: ['is_available'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
methodOptions: [], // 下拉框选项
|
||||
sourceSystemOption:[],
|
||||
targetSystemOption:[],
|
||||
total: 0,
|
||||
// 接口记录表格数据
|
||||
logList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
@@ -225,15 +195,15 @@ export default {
|
||||
duration: null,
|
||||
isSuccessful: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
}
|
||||
rules: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.getMethod() // 现在可以正常调用了
|
||||
this.getSource()
|
||||
this.getTarget()
|
||||
},
|
||||
methods: {
|
||||
/** 查询接口记录列表 */
|
||||
@@ -245,6 +215,43 @@ export default {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// ✅ 【核心修复】getMethod 移入 methods 内部
|
||||
getMethod() {
|
||||
getMethod().then(response => {
|
||||
console.log("接口返回:", response.data)
|
||||
// 后端返回 String数组,转换为 el-select 需要的 label/value 格式
|
||||
this.methodOptions = response.data.map(item => ({
|
||||
label: item,
|
||||
value: item
|
||||
}))
|
||||
}).catch(err => {
|
||||
console.error("获取方法列表失败:", err)
|
||||
})
|
||||
},
|
||||
getSource() {
|
||||
getSource().then(response => {
|
||||
console.log("接口返回:", response.data)
|
||||
// 后端返回 String数组,转换为 el-select 需要的 label/value 格式
|
||||
this.sourceSystemOption = response.data.map(item => ({
|
||||
label: item,
|
||||
value: item
|
||||
}))
|
||||
}).catch(err => {
|
||||
console.error("获取方法列表失败:", err)
|
||||
})
|
||||
},
|
||||
getTarget() {
|
||||
getTarget().then(response => {
|
||||
console.log("接口返回:", response.data)
|
||||
// 后端返回 String数组,转换为 el-select 需要的 label/value 格式
|
||||
this.targetSystemOption = response.data.map(item => ({
|
||||
label: item,
|
||||
value: item
|
||||
}))
|
||||
}).catch(err => {
|
||||
console.error("获取方法列表失败:", err)
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
@@ -284,7 +291,7 @@ export default {
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.requestId)
|
||||
this.single = selection.length!==1
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
@@ -326,12 +333,13 @@ export default {
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const requestIds = row.requestId || this.ids
|
||||
this.$modal.confirm('是否确认删除接口记录编号为"' + requestIds + '"的数据项?').then(function() {
|
||||
this.$modal.confirm('是否确认删除接口记录编号为"' + requestIds + '"的数据项?').then(function () {
|
||||
return delLog(requestIds)
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
@@ -342,3 +350,6 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<el-select v-model="queryParams.warehouseId" placeholder="请选择仓库" clearable>
|
||||
<el-option v-for="item in warehouseOptions" :key="item.warehouseId" :label="item.warehouseName" :value="item.warehouseId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="作业ID" prop="jobId">
|
||||
<el-input
|
||||
v-model="queryParams.jobId"
|
||||
@@ -702,6 +707,10 @@ export default {
|
||||
total: 0,
|
||||
// 入库作业流水表格数据
|
||||
ViewInJobFlowList: [],
|
||||
warehouseOptions: [
|
||||
{ warehouseId: '01', warehouseName: '立库' },
|
||||
{ warehouseId: '02', warehouseName: '平库' }
|
||||
],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<el-select v-model="queryParams.warehouseId" placeholder="请选择仓库" clearable>
|
||||
<el-option v-for="item in warehouseOptions" :key="item.warehouseId" :label="item.warehouseName" :value="item.warehouseId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="作业ID" prop="jobId">
|
||||
<el-input
|
||||
v-model="queryParams.jobId"
|
||||
@@ -701,6 +706,10 @@ export default {
|
||||
total: 0,
|
||||
// 出库作业流水表格数据
|
||||
ViewOutJobFlowList: [],
|
||||
warehouseOptions: [
|
||||
{ warehouseId: '01', warehouseName: '立库' },
|
||||
{ warehouseId: '02', warehouseName: '平库' }
|
||||
],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
|
||||
@@ -25,6 +25,43 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="托盘条码" prop="trayCode"><!-- 货位id -->
|
||||
<el-input
|
||||
v-model="queryParams.trayCode"
|
||||
placeholder="请输入托盘条码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="项目号" prop="spare4"><!-- 货位id -->
|
||||
<el-input
|
||||
v-model="queryParams.spare4"
|
||||
placeholder="请输入组件号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="存货编码" prop="productId"><!-- 货位id -->
|
||||
<el-input
|
||||
v-model="queryParams.productId"
|
||||
placeholder="请输入存货编码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="托盘类型" prop="ktpType"><!-- 库存状态 -->
|
||||
<el-select v-model="queryParams.ktpType" placeholder="请选择托盘类型" clearable>
|
||||
<el-option
|
||||
v-for="item in ktpType"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="库存状态" prop="stockStatus"><!-- 库存状态 -->
|
||||
<el-select v-model="queryParams.stockStatus" placeholder="请选择库存状态" clearable>
|
||||
<el-option
|
||||
@@ -36,14 +73,36 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="入库时间" prop="startDate"><!– 入库时间 –>
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.inDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="请选择入库时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>-->
|
||||
|
||||
<el-form-item label="物料类型" prop="model"><!--单据来源-->
|
||||
<el-select v-model="queryParams.model" placeholder="请选择单据来源" clearable>
|
||||
<el-option
|
||||
v-for="dict in productType"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库选择" prop="warehouseCode"><!--单据来源-->
|
||||
<el-select v-model="queryParams.warehouseCode" placeholder="请选择单据来源" clearable>
|
||||
<el-option
|
||||
v-for="item in warehouseCodeOptions"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="入库时间" prop="startDate"><!– 入库时间 –>
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.inDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="请选择入库时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>-->
|
||||
|
||||
|
||||
<el-form-item label="存货名称" prop="productName"><!-- 存货名称 -->
|
||||
@@ -99,36 +158,36 @@
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="managementList" @selection-change="handleSelectionChange" max-height="650">
|
||||
<el-table-column type="selection" align="center" />
|
||||
<el-table-column type="selection" align="center"/>
|
||||
<el-table-column label="库存编码" align="left" prop="stockId" width="180" sortable/>
|
||||
<el-table-column label="货位名称" align="left" prop="cargoSpaceName" width="180"/>
|
||||
<el-table-column width="180" label="库存状态" align="center" prop="stockStatus" >
|
||||
<el-table-column width="180" label="库存状态" align="center" prop="stockStatus">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.stock_status" :value="scope.row.stockStatus"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="180" label="物料编码" align="left" prop="productId" />
|
||||
<el-table-column width="180" label="物料名称" align="left" prop="productName" />
|
||||
<el-table-column width="180" label="批次号" align="left" prop="lotNo" />
|
||||
<!-- <el-table-column label="订单号" align="center" prop="orderId" width="160" sortable/>-->
|
||||
<el-table-column width="180" label="入库时间" align="left" prop="inDate" sortable/>
|
||||
<el-table-column width="180" label="物料编码" align="left" prop="productId"/>
|
||||
<el-table-column width="180" label="物料名称" align="left" prop="productName"/>
|
||||
<el-table-column width="180" label="批次号" align="left" prop="lotNo"/>
|
||||
<!-- <el-table-column label="订单号" align="center" prop="orderId" width="160" sortable/>-->
|
||||
<el-table-column width="180" label="入库时间" align="left" prop="inDate" sortable/>
|
||||
<el-table-column width="100" label="数量" align="left" prop="quantity" sortable/>
|
||||
<el-table-column width="180" label="作业ID" align="left" prop="jobId" sortable/>
|
||||
<el-table-column width="180" label="出库数量" align="left" prop="outQuantity" />
|
||||
<el-table-column width="180" label="入库单ID" align="left" prop="stockinId" sortable/>
|
||||
<el-table-column width="180" label="作业ID" align="left" prop="jobId" sortable/>
|
||||
<el-table-column width="180" label="出库数量" align="left" prop="outQuantity"/>
|
||||
<el-table-column width="180" label="入库单ID" align="left" prop="stockinId" sortable/>
|
||||
<el-table-column width="180" label="入库子单ID" align="left" prop="stockinDetailId" sortable/>
|
||||
<!-- <el-table-column label="入库类型" align="center" prop="inType" />-->
|
||||
<!-- <el-table-column label="仓库编码" align="center" prop="warehouseId" />-->
|
||||
<el-table-column width="180" label="层级关系" align="left" prop="spare1" />
|
||||
<el-table-column width="180" label="上层物料" align="left" prop="spare2" />
|
||||
<el-table-column width="180" label="顶层物料" align="left" prop="spare3" />
|
||||
<el-table-column width="180" label="项目号" align="left" prop="spare4" />
|
||||
<el-table-column width="180" label="合同号" align="left" prop="spare5" />
|
||||
<el-table-column width="180" label="销售订单" align="left" prop="spare6" />
|
||||
<el-table-column width="180" label="供应商编码" align="left" prop="voltage" />
|
||||
<el-table-column width="180" label="规格型号" align="left" prop="power" />
|
||||
<el-table-column width="180" label="计量单位" align="left" prop="phase" />
|
||||
<!-- <el-table-column label="净重" align="center" prop="netWeight" />-->
|
||||
<!-- <el-table-column label="入库类型" align="center" prop="inType" />-->
|
||||
<!-- <el-table-column label="仓库编码" align="center" prop="warehouseId" />-->
|
||||
<el-table-column width="180" label="托盘条码" align="left" prop="trayCode"/>
|
||||
<!-- <el-table-column width="180" label="上层物料" align="left" prop="spare2"/>-->
|
||||
<!-- <el-table-column width="180" label="顶层物料" align="left" prop="spare3"/>-->
|
||||
<el-table-column width="180" label="项目号" align="left" prop="spare4"/>
|
||||
<!-- <el-table-column width="180" label="合同号" align="left" prop="spare5"/>-->
|
||||
<!-- <el-table-column width="180" label="销售订单" align="left" prop="spare6"/>-->
|
||||
<el-table-column width="180" label="供应商编码" align="left" prop="voltage"/>
|
||||
<el-table-column width="180" label="规格型号" align="left" prop="power"/>
|
||||
<el-table-column width="180" label="计量单位" align="left" prop="phase"/>
|
||||
<!-- <el-table-column label="净重" align="center" prop="netWeight" />-->
|
||||
<el-table-column width=120 label="操作" align="center" class-name="small-padding fixed-width"> <!-- 操作 -->
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
@@ -160,12 +219,12 @@
|
||||
<!-- 添加或修改库存信息对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<!-- <el-form-item label="库存ID" prop="stockId"> <!– 库存id –>-->
|
||||
<!-- <el-input v-model="form.stockId" placeholder="请输入库存ID" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="货位ID" prop="cargoSpaceId"> <!– 货位id –>-->
|
||||
<!-- <el-input v-model="form.cargoSpaceId" placeholder="请输入货位ID" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="库存ID" prop="stockId"> <!– 库存id –>-->
|
||||
<!-- <el-input v-model="form.stockId" placeholder="请输入库存ID" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="货位ID" prop="cargoSpaceId"> <!– 货位id –>-->
|
||||
<!-- <el-input v-model="form.cargoSpaceId" placeholder="请输入货位ID" />-->
|
||||
<!-- </el-form-item>-->
|
||||
|
||||
<el-form-item label="物料" prop="productId"> <!-- 物料 -->
|
||||
<el-input
|
||||
@@ -207,7 +266,7 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="库存数量" prop="quantity"> <!-- 库存数量 -->
|
||||
<el-input v-model="form.quantity" placeholder="请输入库存数量" />
|
||||
<el-input v-model="form.quantity" placeholder="请输入库存数量"/>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
@@ -248,11 +307,11 @@
|
||||
@row-click="handleProductRowClick"
|
||||
highlight-current-row
|
||||
max-height="400">
|
||||
<el-table-column label="品号" align="center" prop="productId" />
|
||||
<el-table-column label="品名" align="center" prop="productName" />
|
||||
<el-table-column label="规格" align="center" prop="spec" />
|
||||
<el-table-column label="型号" align="center" prop="spare1" />
|
||||
<el-table-column label="单位" align="center" prop="unit" />
|
||||
<el-table-column label="品号" align="center" prop="productId"/>
|
||||
<el-table-column label="品名" align="center" prop="productName"/>
|
||||
<el-table-column label="规格" align="center" prop="spec"/>
|
||||
<el-table-column label="型号" align="center" prop="spare1"/>
|
||||
<el-table-column label="单位" align="center" prop="unit"/>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
@@ -288,7 +347,7 @@
|
||||
@keyup.enter.native="getCargoSpaceList"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<el-form-item label="仓库" prop="warehouseCode">
|
||||
<el-select v-model="cargoSpaceQueryParams.warehouseId" placeholder="请选择仓库" clearable>
|
||||
<el-option
|
||||
v-for="item in warehouseOptions"
|
||||
@@ -310,17 +369,17 @@
|
||||
@row-click="handleCargoSpaceRowClick"
|
||||
highlight-current-row
|
||||
max-height="400">
|
||||
<el-table-column label="货位编码" align="center" prop="cargoSpaceId" />
|
||||
<el-table-column label="货位名称" align="center" prop="cargoSpaceName" />
|
||||
<el-table-column label="仓库名称" align="center" prop="warehouseName" />
|
||||
<el-table-column label="货位编码" align="center" prop="cargoSpaceId"/>
|
||||
<el-table-column label="货位名称" align="center" prop="cargoSpaceName"/>
|
||||
<el-table-column label="仓库名称" align="center" prop="warehouseName"/>
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.cargo_space_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="排" align="center" prop="thePlatoon" />
|
||||
<el-table-column label="列" align="center" prop="theColumn" />
|
||||
<el-table-column label="层" align="center" prop="theFloor" />
|
||||
<el-table-column label="排" align="center" prop="thePlatoon"/>
|
||||
<el-table-column label="列" align="center" prop="theColumn"/>
|
||||
<el-table-column label="层" align="center" prop="theFloor"/>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
@@ -340,13 +399,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listManagement, getManagement, delManagement, addManagement, updateManagement } from "@/api/stock/management"
|
||||
import {listManagement, getManagement, delManagement, addManagement, updateManagement} from "@/api/stock/management"
|
||||
import {listWarehouse} from "@/api/bas/warehouse"
|
||||
import { listBasProduct } from "@/api/bas/BasProduct"
|
||||
import { listCargoSpace } from "@/api/bas/cargoSpace"
|
||||
import {listBasProduct} from "@/api/bas/BasProduct"
|
||||
import {listCargoSpace} from "@/api/bas/cargoSpace"
|
||||
|
||||
export default {
|
||||
name: "Management",
|
||||
dicts: ['product_status', 'stock_status','cargo_space_status','cargo_space_lock_status'],
|
||||
dicts: ['product_status', 'stock_status', 'cargo_space_status', 'cargo_space_lock_status'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
@@ -365,6 +425,9 @@ export default {
|
||||
managementList: [],
|
||||
// 仓库选项
|
||||
warehouseOptions: [],
|
||||
warehouseCodeOptions: [{label: '立库', value: '1'}, {label: '平库', value: '2'}],
|
||||
productType:[{label:"满托",value:'1'},{label:"半托",value:'0'}],
|
||||
ktpType:[{label:"物料",value:'2'},{label:"托盘",value:'1'}],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
@@ -397,10 +460,15 @@ export default {
|
||||
spare3: null,
|
||||
spare4: null,
|
||||
spare5: null,
|
||||
spare6: null
|
||||
spare6: null,
|
||||
model: null,
|
||||
ktpType: "1",
|
||||
warehouseCode: "1",
|
||||
|
||||
|
||||
},
|
||||
queryWarehouse: {
|
||||
pageNum:1,
|
||||
pageNum: 1,
|
||||
pageSize: 99
|
||||
},
|
||||
// 表单参数
|
||||
@@ -511,7 +579,7 @@ export default {
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.stockId)
|
||||
this.single = selection.length!==1
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
@@ -524,7 +592,8 @@ export default {
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
const stockId = row.stockId || this.ids
|
||||
getManagement(stockId).then(response => {
|
||||
const warehouseCode=this.queryParams.warehouseCode;
|
||||
getManagement(stockId,warehouseCode).then(response => {
|
||||
this.form = response.data
|
||||
this.open = true
|
||||
this.title = "修改库存信息" // 修改库存信息
|
||||
@@ -535,6 +604,7 @@ export default {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.stockId != null) {
|
||||
this.form.warehouseCode=this.queryParams.warehouseCode;
|
||||
updateManagement(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功") // 修改成功
|
||||
this.open = false
|
||||
@@ -553,12 +623,14 @@ export default {
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const stockIds = row.stockId || this.ids
|
||||
this.$modal.confirm("是否确认删除库存信息编号为" + stockIds).then(function() { // 是否确认删除库存信息编号为
|
||||
return delManagement(stockIds)
|
||||
const warehouseCode =this.queryParams.warehouseCode;
|
||||
this.$modal.confirm("是否确认删除库存信息编号为" + stockIds).then(function () { // 是否确认删除库存信息编号为
|
||||
return delManagement(stockIds,warehouseCode)
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess("删除成功") // 删除成功
|
||||
}).catch(() => {})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
|
||||
205
ruoyi-ui/src/views/system/license/index.vue
Normal file
205
ruoyi-ui/src/views/system/license/index.vue
Normal file
@@ -0,0 +1,205 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form ref="queryForm" :model="queryParams" size="small" :inline="true" v-show="showSearch" label-width="80px">
|
||||
<el-form-item label="授权码" prop="licenseCode">
|
||||
<el-input v-model="queryParams.licenseCode" placeholder="请输入授权码" clearable style="width: 260px" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 160px">
|
||||
<el-option label="未激活" value="0" />
|
||||
<el-option label="已激活" value="1" />
|
||||
<el-option label="已过期" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @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="el-icon-key" size="mini" @click="handleActive" v-hasPermi="['system:license:add']">激活授权码</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="el-icon-plus" size="mini" @click="handleGenerate" v-hasPermi="['system:license:add']">生成授权码</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:license:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="licenseList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="授权ID" align="center" prop="licenseId" width="90" />
|
||||
<el-table-column label="授权码" align="center" prop="licenseCode" min-width="360" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="状态" align="center" prop="status" width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="statusTagType(scope.row.status)">{{ statusText(scope.row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="开始时间" align="center" prop="startTime" width="180">
|
||||
<template slot-scope="scope"><span>{{ parseTime(scope.row.startTime) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="过期时间" align="center" prop="expireTime" width="180">
|
||||
<template slot-scope="scope"><span>{{ parseTime(scope.row.expireTime) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="激活时间" align="center" prop="activeTime" width="180">
|
||||
<template slot-scope="scope"><span>{{ parseTime(scope.row.activeTime) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:license:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<el-dialog title="激活授权码" :visible.sync="activeOpen" width="520px" append-to-body>
|
||||
<el-input v-model="activeForm.licenseCode" type="textarea" :rows="5" placeholder="请输入授权码" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="activeOpen = false">取消</el-button>
|
||||
<el-button type="primary" :loading="activeLoading" @click="submitActive">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="生成授权码" :visible.sync="generateOpen" width="560px" append-to-body>
|
||||
<el-form ref="generateForm" :model="generateForm" :rules="generateRules" label-width="100px">
|
||||
<el-form-item label="授权类型" prop="type">
|
||||
<el-select v-model="generateForm.type" placeholder="请选择授权类型" style="width: 100%">
|
||||
<el-option label="5分钟测试" value="TEST" />
|
||||
<el-option label="1个月授权" value="MONTH" />
|
||||
<el-option label="3个月授权" value="THREE" />
|
||||
<el-option label="1年授权" value="YEAR" />
|
||||
<el-option label="5年授权" value="FIVE" />
|
||||
<el-option label="长期授权" value="FOREVER" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目编号" prop="projectNo">
|
||||
<el-input v-model="generateForm.projectNo" placeholder="请输入项目编号,如 FT546" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="generatedCode" label="授权码">
|
||||
<el-input v-model="generatedCode" type="textarea" :rows="5" readonly />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="generateOpen = false">关闭</el-button>
|
||||
<el-button type="primary" :loading="generateLoading" @click="submitGenerate">生成</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listLicense, delLicense, activeLicense, generateLicense } from '@/api/license'
|
||||
|
||||
export default {
|
||||
name: 'License',
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
activeLoading: false,
|
||||
generateLoading: false,
|
||||
ids: [],
|
||||
multiple: true,
|
||||
showSearch: true,
|
||||
total: 0,
|
||||
licenseList: [],
|
||||
activeOpen: false,
|
||||
generateOpen: false,
|
||||
generatedCode: '',
|
||||
queryParams: { pageNum: 1, pageSize: 10, licenseCode: undefined, status: undefined },
|
||||
activeForm: { licenseCode: '' },
|
||||
generateForm: { type: 'YEAR', projectNo: 'FT546' },
|
||||
generateRules: {
|
||||
type: [{ required: true, message: '请选择授权类型', trigger: 'change' }],
|
||||
projectNo: [{ required: true, message: '请输入项目编号', trigger: 'blur' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
getList() {
|
||||
this.loading = true
|
||||
listLicense(this.queryParams).then(response => {
|
||||
this.licenseList = response.rows
|
||||
this.total = response.total
|
||||
}).finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
resetQuery() {
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.licenseId)
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
handleActive() {
|
||||
this.activeForm.licenseCode = ''
|
||||
this.activeOpen = true
|
||||
},
|
||||
submitActive() {
|
||||
const licenseCode = this.activeForm.licenseCode.trim()
|
||||
if (!licenseCode) {
|
||||
this.$modal.msgWarning('请输入授权码')
|
||||
return
|
||||
}
|
||||
this.activeLoading = true
|
||||
activeLicense(licenseCode).then(response => {
|
||||
if (response.code !== 200) {
|
||||
this.$modal.msgError(response.msg || '授权码激活失败')
|
||||
return
|
||||
}
|
||||
this.$modal.msgSuccess(response.msg || '授权码激活成功')
|
||||
this.activeOpen = false
|
||||
this.getList()
|
||||
}).finally(() => {
|
||||
this.activeLoading = false
|
||||
})
|
||||
},
|
||||
handleGenerate() {
|
||||
this.generatedCode = ''
|
||||
this.generateForm = { type: 'YEAR', projectNo: 'FT546' }
|
||||
this.generateOpen = true
|
||||
this.$nextTick(() => this.resetForm('generateForm'))
|
||||
},
|
||||
submitGenerate() {
|
||||
this.$refs.generateForm.validate(valid => {
|
||||
if (!valid) return
|
||||
this.generateLoading = true
|
||||
generateLicense(this.generateForm.type, this.generateForm.projectNo.trim()).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.generatedCode = response.data
|
||||
this.$modal.msgSuccess(response.msg || '授权码生成成功')
|
||||
}
|
||||
}).finally(() => {
|
||||
this.generateLoading = false
|
||||
})
|
||||
})
|
||||
},
|
||||
handleDelete(row) {
|
||||
const licenseIds = row.licenseId || this.ids
|
||||
this.$modal.confirm(`确认删除授权编号为【${licenseIds}】的数据项?`).then(() => delLicense(licenseIds)).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
}).catch(() => {})
|
||||
},
|
||||
statusText(status) {
|
||||
return { '0': '未激活', '1': '已激活', '2': '已过期' }[status] || '未知'
|
||||
},
|
||||
statusTagType(status) {
|
||||
return { '0': 'info', '1': 'success', '2': 'danger' }[status] || 'warning'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -9,7 +9,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
|
||||
|
||||
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
|
||||
|
||||
const baseUrl = 'http://localhost:8080' // 后端接口
|
||||
const baseUrl = 'http://127.0.0.1:8080' // 后端接口
|
||||
|
||||
const port = process.env.port || process.env.npm_config_port || 80 // 端口
|
||||
|
||||
|
||||
Reference in New Issue
Block a user