mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2026-01-11 18:57:17 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f67f38ccf5 |
33
CHANGELOG.md
33
CHANGELOG.md
@@ -1,36 +1,3 @@
|
||||
## [v4.0.0](https://github.com/continew-org/continew-admin-ui/compare/v3.7.0...v4.0.0) (2025-07-27)
|
||||
|
||||
### ✨ 新特性
|
||||
|
||||
- 新增多租户模块 (GitHub#75@xtanyu) ([e662565](https://github.com/continew-org/continew-admin-ui/commit/e66256581e5826e03aaad5170cb7de10f5ceabf7)) ([c7a1c1d](https://github.com/continew-org/continew-admin-ui/commit/c7a1c1deba13baa0718aba4f6f3eca7c0cd3e3de)) ([2c60203](https://github.com/continew-org/continew-admin-ui/commit/2c602033bdabbaafc75bcc37a40f809b61469881)) ([6a96eee](https://github.com/continew-org/continew-admin-ui/commit/6a96eee9e965871ded7063fab60d52921865a4b4)) ([112c27e](https://github.com/continew-org/continew-admin-ui/commit/112c27e49c2310910fa97f6b3f000e090fda73d7)) ([87bcf33](https://github.com/continew-org/continew-admin-ui/commit/87bcf33940dc37a9d8a62e0d0bf316e26cee01e8)) ([d4397ff](https://github.com/continew-org/continew-admin-ui/commit/d4397ffd570635c72eb1e214f9aaa9d8256f9dfc)) ([e63bedc](https://github.com/continew-org/continew-admin-ui/commit/e63bedc11b9ea6f59a8afe4284135b42a4dc65e2)) ([3e49bce](https://github.com/continew-org/continew-admin-ui/commit/3e49bce38e1b8d4ae2e181079e07c175b911fea7)) ([a72d122](https://github.com/continew-org/continew-admin-ui/commit/a72d12227ece9882eb5b0f8ccc378eae814fbeac)) ([0c594c1](https://github.com/continew-org/continew-admin-ui/commit/0c594c167e3b57911f09b2c7f43bb7873d462a4e))
|
||||
- 优化登录后的页面重定向逻辑 ([aaefb7f](https://github.com/continew-org/continew-admin-ui/commit/aaefb7f8e4b45c120dc3da2dc8f8671c058409b3))
|
||||
- 菜单列表增加路由地址和权限标识搜索功能 (GitCode#5@onekr-billy) ([900a2af](https://github.com/continew-org/continew-admin-ui/commit/900a2afdb7b369a14c914dcbb08ed48f094af1e9))
|
||||
- 新增查询角色权限树列表接口(替换角色分配权限的菜单树列表接口) ([87e6dea](https://github.com/continew-org/continew-admin-ui/commit/87e6deab4d5f96146e6bfdd4a4b1704be321f813))
|
||||
|
||||
### 💎 功能优化
|
||||
|
||||
- 统一加载图标 ([bb3c082](https://github.com/continew-org/continew-admin-ui/commit/bb3c082146805c664bb8a8d6ffadea9983f942f2))
|
||||
- 优化通知公告相关页面的回退逻辑 ([633f9aa](https://github.com/continew-org/continew-admin-ui/commit/633f9aaa4a27dab2ffa9f580edfb807e6987c75f))
|
||||
- 优化角色权限代码 ([8090861](https://github.com/continew-org/continew-admin-ui/commit/8090861bc6cc8951268e8e758b798f1a9463376f))
|
||||
- 将 common 目录下的 common.ts 文件移动到 system 目录下 ([60c6df2](https://github.com/continew-org/continew-admin-ui/commit/60c6df25747f348201d41d054812f0d935000752))
|
||||
- 更新短信配置和日志接口的 URL ([53aeebe](https://github.com/continew-org/continew-admin-ui/commit/53aeebeb4dd534bec2ad3cfcb09317cc6d8aad44))
|
||||
- 适配后端部分字典接口变化 ([d7937e7](https://github.com/continew-org/continew-admin-ui/commit/d7937e79054f2b7fd2c32fb2b47f7a27b14b1229))
|
||||
- 优化用户表单和菜单列表页面 ([dca7379](https://github.com/continew-org/continew-admin-ui/commit/dca7379c201ae665044d2756aba2c48aba18eaac))
|
||||
- 关于菜单增加更新日志内嵌菜单,移除在线文档外链菜单 ([f3dea88](https://github.com/continew-org/continew-admin-ui/commit/f3dea886adb6591dd7f8d81f835723d2a71c1e09))
|
||||
- 暂时下线查询日志详情功能(Snail Job 日志详情 API 变更为 WebSocket 模式) ([5050126](https://github.com/continew-org/continew-admin-ui/commit/5050126892b8488011aeaf45c37ed99ad22a8a27))
|
||||
|
||||
### 🐛 问题修复
|
||||
|
||||
- 修复用户角色列表单击行选中功能失效的问题 ([8b7ef16](https://github.com/continew-org/continew-admin-ui/commit/8b7ef16687d02d5671201418e0e122c0426b8176))
|
||||
- 修复邮箱配置的启用SSL加密开关初始值错误的问题 (GitCode#4@ali_pay) ([ca304f3](https://github.com/continew-org/continew-admin-ui/commit/ca304f30dcb7cd70ec06477b33147d4c3a205d7a))
|
||||
- 修复混合布局下的菜单过多不能滚动的问题 (GitHub#71@yingshi-7) ([4873418](https://github.com/continew-org/continew-admin-ui/commit/4873418561f746122d8bcee565b937c2d9b1e988))
|
||||
- code generator preview issue (GitHub#73@ppxb) ([fdfa0cd](https://github.com/continew-org/continew-admin-ui/commit/fdfa0cd2d5b9b586fb3ca4838647a8e68c9865c5))
|
||||
- 调整水印 z-index,以修复表格全屏或表单弹出时水印无法覆盖的问题 ([afd1bb7](https://github.com/continew-org/continew-admin-ui/commit/afd1bb7017b8a28b690eee842d69ae1bc35037b2)) ([4cf763e](https://github.com/continew-org/continew-admin-ui/commit/4cf763e8174601c629a09403272621c69ff4b179))
|
||||
- 弹窗报错信息和主题模式的按钮存在显示问题 ([41f458d](https://github.com/continew-org/continew-admin-ui/commit/41f458d2b0fbc9bc155fd7af8cbe52a7fdf19323))
|
||||
- 修复修改部门时上级部门选择的问题 (Gitee#61@lishuyanla) ([47e2dfa](https://github.com/continew-org/continew-admin-ui/commit/47e2dfaff030e181f1a2626218f20efd5f7025cc))
|
||||
- 修复字典项权限标识不一致的问题 (GitCode#5@onekr-billy) ([3ea79ec](https://github.com/continew-org/continew-admin-ui/commit/3ea79ec7e08e70144970d9761d86e564a3f0e806))
|
||||
- 系统内置角色不允许修改权限 ([4b0aea5](https://github.com/continew-org/continew-admin-ui/commit/4b0aea536c20afd4733c811bd9d8e34cde199ce3))
|
||||
|
||||
## [v3.7.0](https://github.com/continew-org/continew-admin-ui/compare/v3.6.0...v3.7.0) (2025-06-13)
|
||||
|
||||
### ✨ 新特性
|
||||
|
||||
89
README.md
89
README.md
@@ -1,7 +1,7 @@
|
||||
# ContiNew Admin UI
|
||||
|
||||
<a href="https://github.com/continew-org/continew-admin-ui" title="Release" target="_blank">
|
||||
<img src="https://img.shields.io/badge/RELEASE-v4.0.0-%23ff3f59.svg" alt="Release" />
|
||||
<img src="https://img.shields.io/badge/RELEASE-v3.7.0-%23ff3f59.svg" alt="Release" />
|
||||
</a>
|
||||
<a href="https://vuejs.org/" title="Vue" target="_blank">
|
||||
<img src="https://img.shields.io/badge/Vue-3.5.4-%236CB52D.svg?logo=Vue.js" alt="Vue" />
|
||||
@@ -41,15 +41,9 @@
|
||||
|
||||
全新 3.0 版本,基于 Gi Demo 前端模板开发的 ContiNew Admin 前端适配项目。
|
||||
|
||||
**AI 编程纪元已经开启,基于 ContiNew 项目开发,让 AI 助手“学习”更优雅的代码规范,“写出”更优质的代码。**
|
||||
ContiNew Admin(Continue New Admin)持续迭代优化的前后端分离中后台管理系统框架。开箱即用,重视每一处代码规范,重视每一种解决方案细节,持续提供舒适的前、后端开发体验。
|
||||
|
||||
ContiNew Admin(Continue New Admin),页面现代美观,且专注设计与代码细节的 **高质量多租户中后台** 管理系统框架。开箱即用,持续迭代优化,持续提供舒适的开发体验。
|
||||
|
||||
当前采用的技术栈:Spring Boot3(Java17)、Vue3 & Arco Design & TS & Vite、Sa-Token、MyBatis Plus、Redisson、FastExcel、CosId、JetCache、JustAuth、Crane4j、Spring Doc、Hutool 等。
|
||||
|
||||
我们始终坚信好的产品必然是反复打磨出来的,而在工作中我们受限于客户需求、开发周期等因素,无法深度打磨、重构我们的代码,这也是架构腐烂的根源。所以,我们希望能在业余时间,通过开源社区的力量来打磨出一个好的产品,一个好的实践,一个好的生态。
|
||||
|
||||
我们的愿景在于,当你将 ContiNew 系列项目应用到工作场景时,不仅仅是得到效率的提高,更可以得到舒适的开发体验,让更多开发者的编程工作多一点“甜”。
|
||||
当前采用的技术栈:Spring Boot3(Java17)、Vue3 & Arco Design & TS & Vite、Sa-Token、MyBatis Plus、Redisson、JetCache、JustAuth、Crane4j、EasyExcel、Liquibase、Hutool 等。
|
||||
|
||||
## 项目源码
|
||||
|
||||
@@ -81,60 +75,44 @@ ContiNew Admin(Continue New Admin),页面现代美观,且专注设计与
|
||||
> [!TIP]
|
||||
> 更为完整的图文描述请查阅[《在线文档》](https://continew.top/admin/guide/why-choose-us.html)。
|
||||
|
||||
**AI 编程纪元已经开启,基于 ContiNew 项目开发,让 AI 助手“学习”更优雅的代码规范,“写出”更优质的代码。**
|
||||
1.**甄选技术栈:** ContiNew(Continue New) 项目致力于持续迭代优化,让技术不掉队。在技术选型时,进行深度广泛地调研,从流行度、成熟度和发展潜力等多方面甄选技术栈。
|
||||
|
||||
**1.长期稳定:** 自 2022 年 12 月 8 日创建,2023 年 3 月 26 日发布 v1.0.0,截至今日,ContiNew Admin 已累计发布 25 个版本,ContiNew Starter 已累计发布 43 个版本。
|
||||
|
||||
**2.甄选技术栈:** ContiNew(Continue New) 项目致力于持续迭代优化,确保技术栈紧跟时代。在技术选型时,我们进行了深度广泛的调研,从流行度、成熟度和发展潜力等多维度精心挑选技术栈。
|
||||
|
||||
**3.Starter 组件:** 从 v2.1.0 版本开始,我们将后端基础组件及各框架集成配置抽取并封装到 ContiNew Starter 项目中,极大降低上手和升级难度。且 **[已发布至 Maven 中央仓库](https://central.sonatype.com/search?q=continew-starter&namespace=top.continew)**,你可以在任意项目中直接引入所需依赖使用。即使你不使用完整的中后台框架,这些能让你搭项目框架更快、更爽、更省力的 Starter 组件,难道不香吗?
|
||||
|
||||
**4.CRUD 套件:** 封装通用增删改查套件,适配后端各分层架构,几分钟即可提供一套完整的 CRUD API,包括新增、修改、批量删除、查询详情、分页列表、全部列表、树型列表、Excel 导出,甚至是字典列表(用于下拉选项场景)。所有 API 均可根据实际需求灵活开放或扩展。
|
||||
2.**Starter 组件:** 从 v2.1.0 版本开始,抽取并封装后端基础组件及各框架集成配置到 ContiNew Starter 项目,且 **[已发布至 Maven 中央仓库](https://central.sonatype.com/search?q=continew-starter&namespace=top.continew)**,可在你的任意项目中直接引入所需依赖使用。即使你不用脚手架项目,难道能让你搭项目框架更快、更爽、更省力的 Starter 也要 Say No 吗?
|
||||
|
||||
3.**CRUD 套件:** 封装通用增删改查套件,适配后端各分层,几分钟即可提供一套 CRUD API,包括新增、修改、批量删除、查询详情、分页列表查询、全部列表查询、树型列表查询、导出到 Excel,且 API 支持按实际所需开放或扩展。
|
||||
```java
|
||||
@Tag(name = "部门管理 API")
|
||||
@RestController
|
||||
@CrudRequestMapping(value = "/system/dept", api = {Api.TREE, Api.GET, Api.CREATE, Api.UPDATE, Api.DELETE, Api.EXPORT, Api.DICT_TREE})
|
||||
@CrudRequestMapping(value = "/system/dept", api = {Api.TREE, Api.GET, Api.CREATE, Api.UPDATE, Api.DELETE, Api.EXPORT})
|
||||
public class DeptController extends BaseController<DeptService, DeptResp, DeptDetailResp, DeptQuery, DeptReq> {}
|
||||
```
|
||||
|
||||
**5.代码生成器:** 同步提供了代码生成器,配套前后端代码生成模板。数据表设计完成后,简单配置即可生成前后端 80% 的代码,包括 CRUD API、权限控制、参数校验、接口文档等内容。若业务不复杂,甚至能覆盖 95% 的代码量。
|
||||
4.**代码生成器:** 提供代码生成器,已配套前、后端代码生成模板,数据表设计完之后,简单配置一下即可生成前、后端 80% 的代码,包含 CRUD API、权限控制、参数校验、接口文档等内容。如果业务不复杂,也可能就是 95% 的代码。
|
||||
|
||||
**6.提升开发体验:** 持续优化并适配各类能提升开发体验的组件。
|
||||
5.**改善开发体验:** 持续优化及适配能改善开发体验的组件。
|
||||
- 适配 ContiNew Starter 组件,针对多数框架进行了深度封装的 starter,改善你在开发每个 Spring Boot Web 项目的体验。
|
||||
- 适配 Crane4j 数据填充组件,减少因为一个用户名而产生的联表回填;
|
||||
- 适配 P6Spy SQL 性能分析组件,开发期间方便监控 SQL 执行;
|
||||
- 适配 TLog 链路追踪组件,方便在杂乱的日志文件中追踪你某次请求的日志记录;
|
||||
- 适配 JetCache 缓存框架(比 Spring Cache 更强大易用),通过注解声明即可快速实现方法级缓存,极大改善编码式缓存体验,且支持灵活的二级缓存配置、分布式自动刷新等能力;
|
||||
- 前端适配 Vue Devtools(Vue 官方提供的调试浏览器插件),极大提高 Vue 开发及调试效率
|
||||
|
||||
- ContiNew Starter 组件集合:针对 Spring 基础配置、通用解决方案及流行框架进行深度封装,改善你开发每个 Spring Boot Web 项目的体验(包含时间日期及枚举参数自动转换、默认线程池、跨域、加密、脱敏、限流、幂等、License、日志、异常及响应通用解决方案等);
|
||||
- Crane4j 数据填充组件:减少因单个字段(如用户名)而产生的联表查询;
|
||||
- SpEL Validator:基于 SpEL 表达式的参数校验,强化复杂场景下的参数验证(如:当某字段为特定值时,另一字段不能为空);
|
||||
- P6Spy SQL 性能分析:开发期间可方便地监控 SQL 执行性能;
|
||||
- TLog 链路追踪:在繁杂的日志中快速定位某次请求的完整日志;
|
||||
- JetCache 缓存框架:通过注解即可实现方法级缓存,支持灵活的二级缓存配置和分布式自动刷新;
|
||||
6.**Almost最佳后端规范:** 后端严格遵循阿里巴巴 Java 编码规范,注释覆盖率 > 45%,接口参数示例 100%,代码分层使用体验佳,变量、方法命名清晰统一,前端代码也使用严格的 ESLint、StyleLint 等检查。良好的设计,代码复用率极高!写代码时,让你有一种无需多写,理应如此的感觉。我是代码洁癖,我实际写的时候很清楚这到底是不是乱吹。
|
||||
|
||||
**7.Almost 最佳后端规范:** 后端严格遵循阿里巴巴 Java 编码规范,注释覆盖率 > 45%,接口参数示例 100%。代码分层清晰,变量与方法命名统一规范,前端代码同样采用严格的 ESLint、StyleLint 等检查。优秀的设计带来极高的代码复用率!开发时,你会有一种“无需多写,理应如此”的流畅感。
|
||||
7.**卓越工程:** 后端采用模块化工程结构,并适配了统一项目版本号、编译项目自动代码格式化、代码混淆等插件,提供了自定义打包部署结构配置(配置文件、三方依赖和主程序分离),提供全套环境及应用的 Docker Compose 部署脚本。为了减少您开发新项目时的改造耗时,项目品牌配置持续进行深度聚合,简单的配置和结构修改即可快速开始独属于你的新项目。
|
||||
|
||||
**8.卓越工程化实践:** 后端采用模块化工程结构,集成了统一版本管理、编译时自动代码格式化等插件。提供自定义打包部署配置(配置文件、第三方依赖与主程序分离),以及全套环境和应用的 Docker Compose 部署脚本。
|
||||
8.**业务脚手架:** 有颜有料,不止是说说而已,持续打磨 UI 设计与色彩主题。提供基于 RBAC 的权限控制、通用数据权限,包含丰富的通用业务功能:第三方登录,邮箱、短信(生产级炸弹漏洞处理方案),个人中心、用户管理、角色管理、部门管理、系统配置(基础站点配置、邮件配置、安全配置)、系统日志、消息中心、通知公告等,设计用心,逻辑合理闭环。
|
||||
> 一个好的脚手架项目,不仅仅是提供一系列组件集成与配置,也不仅仅是封装一堆好用的工具,还更应该提供一系列通用基础业务解决方案及设计,为初创团队项目减负。
|
||||
|
||||
为减少新项目开发的改造成本,我们持续深度聚合项目品牌配置,通过简单的配置和结构修改,即可快速启动你的专属项目。
|
||||
9.**质量与安全:** CI 已集成 Sonar、Codacy,Push 即扫描代码质量,定期扫描 CVE 漏洞,及时解决潜在问题。封装数据库字段加密、JSON 脱敏、XSS 过滤等工具,提供诸多安全解决方案。
|
||||
|
||||
我们还进行了全局 Lombok 配置,继承场景默认自动应用 `@EqualsAndHashCode(callSuper = true)` 和 `@ToString(callSuper = true)`,无需手动添加。同时主动禁用了部分 Lombok 注解(如 `@Val`、`@Log4j` 等),避免“又菜又爱玩”的 partner 滥用。
|
||||
|
||||
**9.全能业务脚手架:** 支持 **SaaS 租户架构**,基于 RBAC 的权限控制与通用数据权限管理。精心设计的 UI 界面与色彩主题,兼具美观与实用性。内置丰富的通用业务解决方案:第三方登录、邮箱/短信服务(含生产级漏洞处理方案)、个人中心、用户管理、角色管理、组织管理、系统配置、系统日志、消息中心、通知公告等,逻辑闭环,开箱即用。
|
||||
|
||||
> 优秀的中后台框架不仅提供组件集成与配置,封装好用的工具,更应提供通用基础业务设计及解决方案,为初创团队减负。
|
||||
|
||||
**10.质量与安全并重:** 我们高度重视项目质量与安全,CI 已集成 Sonar、Codacy,代码提交即自动扫描质量问题。定期扫描 CVE 漏洞,及时解决潜在风险。封装了数据库字段加密、JSON 脱敏、XSS 过滤等工具,提供全方位的安全解决方案。
|
||||
|
||||
许多项目在开发或交付过程中需满足 Sonarqube 等质量指标,使用 ContiNew Admin 框架,让你从一开始就站在高质量的起点。
|
||||
|
||||
---
|
||||
|
||||
由于篇幅有限,且项目正处于高速发展期,更多功能正在持续开发中,敬请关注仓库或加入交流群了解最新动态。至于统一异常处理、错误处理、基础线程池配置(默认线程参数、线程上下文支持异步传递)等基础特性,这里不再赘述,更多细节优化欢迎克隆代码体验。
|
||||
由于篇幅有限,且项目正处于高速发展期,更多功能正在陆续上线(敬请关注仓库或群内动态)。另外像最基本的统一异常、错误处理,基础线程池等配置就不在此赘述,细节优化详情请 clone 代码查看。
|
||||
> Talk is cheap, show the code.
|
||||
|
||||
## 系统功能
|
||||
|
||||
> [!TIP]
|
||||
> 更多功能和优化正在赶来💦,最新项目计划、进展请进群或关注 [需求墙](https://continew.top/admin/other/feature.html) 和 [更新日志](https://continew.top/admin/changelog/)。
|
||||
> 功能不会用?请查看 [功能手册](https://continew.top/admin/function/tenant/management.html)。
|
||||
> 更多功能和优化正在赶来💦,最新项目计划、进展请进群或关注 [需求墙](https://continew.top/admin/other/feature.html) 和 [更新日志](https://continew.top/admin/other/changelog.html)。
|
||||
|
||||
- 仪表盘:提供工作台、分析页,工作台提供功能快捷导航入口、最新公告、动态;分析页提供全面数据可视化能力
|
||||
- 个人中心:支持基础信息修改、密码修改、邮箱绑定、手机号绑定(并提供行为验证码、短信限流等安全处理)、第三方账号绑定/解绑、头像裁剪上传
|
||||
@@ -153,15 +131,13 @@ public class DeptController extends BaseController<DeptService, DeptResp, DeptDe
|
||||
- 邮件配置:提供系统发件箱配置,也支持通过配置文件指定
|
||||
- 短信配置:提供系统短信服务配置,也支持通过配置文件指定
|
||||
- 存储配置:管理文件存储配置,支持本地存储、兼容 S3 协议对象存储
|
||||
- 客户端配置:多端(PC端、小程序端等)认证管理,可设置不同的 token 有效期
|
||||
- 客户端配置:多客户端(PC端、小程序端等)认证管理,可设置不同的 token 有效期
|
||||
- 在线用户:管理当前登录用户,可一键踢除下线
|
||||
- 日志管理:管理系统登录日志、操作日志,支持查看日志详情,包含请求头、响应头等报文信息
|
||||
- 短信日志:管理系统短信发送日志,支持删除、导出
|
||||
- 应用管理:管理第三方系统应用 AK、SK,包含新增、修改、删除、查看密钥、重置密钥等功能,支持设置密钥有效期
|
||||
- 租户管理:管理租户信息,包含新增、修改、删除、分配角色等功能
|
||||
- 租户套餐:管理租户套餐信息,包含新增、修改、删除、查看等功能
|
||||
- 任务管理:管理系统定时任务,包含新增、修改、删除、执行功能,支持 Cron(可配置式生成 Cron 表达式) 和固定频率
|
||||
- 任务日志:管理定时任务执行日志,包含停止、重试指定批次等功能
|
||||
- 任务日志:管理定时任务执行日志,包含停止、重试指定批次,查询集群各节点的详细输出日志等功能
|
||||
- 应用管理:管理第三方系统应用 AK、SK,包含新增、修改、删除、查看密钥、重置密钥等功能,支持设置密钥有效期
|
||||
- 代码生成:提供根据数据库表自动生成相应的前后端 CRUD 代码的功能,支持同步最新表结构及代码生成预览
|
||||
|
||||
## 系统截图
|
||||
@@ -266,7 +242,6 @@ continew-admin-ui
|
||||
│ │ ├─ common # 公共模块
|
||||
│ │ ├─ monitor # 系统监控模块
|
||||
│ │ ├─ open # 能力开放模块
|
||||
│ │ ├─ tenant # 租户模块
|
||||
│ │ ├─ schedule # 任务调度模块
|
||||
│ │ └─ system # 系统管理模块
|
||||
│ ├─ assets # 静态资源
|
||||
@@ -292,9 +267,6 @@ continew-admin-ui
|
||||
│ │ │ └─ workplace # 工作台
|
||||
│ │ ├─ default # 默认页面
|
||||
│ │ ├─ login # 登录模块
|
||||
│ │ ├─ setting # 设置
|
||||
│ │ │ ├─ profile # 个人中心
|
||||
│ │ │ └─ message # 消息中心
|
||||
│ │ ├─ monitor # 系统监控
|
||||
│ │ │ ├─ log # 系统日志
|
||||
│ │ │ │ ├─ login # 登录日志
|
||||
@@ -302,12 +274,9 @@ continew-admin-ui
|
||||
│ │ │ └─ online # 在线用户
|
||||
│ │ ├─ open # 能力开放
|
||||
│ │ │ └─ user # 应用管理
|
||||
│ │ ├─ tenant # 租户管理
|
||||
│ │ │ ├─ management # 租户管理
|
||||
│ │ │ └─ package # 套餐管理
|
||||
│ │ ├─ schedule # 任务调度
|
||||
│ │ │ ├─ job # 任务管理
|
||||
│ │ │ └─ log # 任务日志
|
||||
│ │ ├─ setting # 设置
|
||||
│ │ │ ├─ profile # 个人中心
|
||||
│ │ │ └─ message # 消息中心
|
||||
│ │ └─ system # 系统管理
|
||||
│ │ ├─ config # 系统配置
|
||||
│ │ ├─ dept # 部门管理
|
||||
@@ -349,7 +318,7 @@ ContiNew Admin 致力于提供开箱即用,持续舒适的开发体验。作
|
||||
|
||||
### 分支说明
|
||||
|
||||
ContiNew Admin 的分支目前分为下个大版本的开发分支和上个大版本的维护分支,PR 前请注意对应分支是否处于维护状态,版本支持情况请查看 [更新日志/版本支持](https://continew.top/admin/changelog/)。
|
||||
ContiNew Admin 的分支目前分为下个大版本的开发分支和上个大版本的维护分支,PR 前请注意对应分支是否处于维护状态,版本支持情况请查看 [更新日志/版本支持](https://continew.top/admin/other/changelog.html#%E7%89%88%E6%9C%AC%E6%94%AF%E6%8C%81)。
|
||||
|
||||
| 分支 | 说明 |
|
||||
| ----- | ------------------------------------------------------------ |
|
||||
|
||||
@@ -11,7 +11,7 @@ export default function appInfo(): Plugin {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
boxen(
|
||||
`${bold(green(`${bgGreen('ContiNew Admin v4.0.0')}`))}\n${cyan('在线文档:')}${underline('https://continew.top')}\n${cyan('常见问题:')}${underline('https://continew.top/admin/faq.html')}\n${cyan('更新日志:')}${underline('https://continew.top/admin/changelog/')}\n${cyan('持续迭代优化的,高质量多租户中后台管理系统框架')}`,
|
||||
`${bold(green(`${bgGreen('ContiNew Admin v3.7.0')}`))}\n${cyan('在线文档:')}${underline('https://continew.top')}\n${cyan('常见问题:')}${underline('https://continew.top/admin/faq.html')}\n${cyan('持续迭代优化的前后端分离中后台管理系统框架。')}`,
|
||||
{
|
||||
padding: 1,
|
||||
margin: 1,
|
||||
|
||||
@@ -7,12 +7,16 @@
|
||||
<link rel="stylesheet" href="/static/css/loading.css" type="text/css" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<section class="init-box">
|
||||
<div class="init-loading">
|
||||
<img src="/static/images/loading.svg" class="init-loading-icon" alt="loading" />
|
||||
<div class="init-loading-rect"></div>
|
||||
<div class="init-loading-rect"></div>
|
||||
<div class="init-loading-rect"></div>
|
||||
<div class="init-loading-rect"></div>
|
||||
<div class="init-loading-rect"></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "continew-admin-ui",
|
||||
"type": "module",
|
||||
"version": "4.0.0",
|
||||
"version": "3.7.0",
|
||||
"private": "true",
|
||||
"scripts": {
|
||||
"bootstrap": "pnpm install --registry=https://registry.npmmirror.com",
|
||||
|
||||
@@ -14,14 +14,36 @@ body {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
@keyframes arco-loading-circle {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
.init-loading-rect {
|
||||
background-color: #007aff;
|
||||
height: 100%;
|
||||
width: 15%;
|
||||
animation: init-wave 1.2s infinite ease-in-out;
|
||||
}
|
||||
|
||||
.init-loading-rect:nth-child(1) {
|
||||
animation-delay: -1.2s;
|
||||
}
|
||||
.init-loading-rect:nth-child(2) {
|
||||
animation-delay: -1.1s;
|
||||
}
|
||||
.init-loading-rect:nth-child(3) {
|
||||
animation-delay: -1s;
|
||||
}
|
||||
.init-loading-rect:nth-child(4) {
|
||||
animation-delay: -0.9s;
|
||||
}
|
||||
.init-loading-rect:nth-child(5) {
|
||||
animation-delay: -0.8s;
|
||||
}
|
||||
|
||||
@keyframes init-wave {
|
||||
0%,
|
||||
40%,
|
||||
100% {
|
||||
transform: scaleY(0.4);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
20% {
|
||||
transform: scaleY(1);
|
||||
}
|
||||
}
|
||||
.init-loading-icon {
|
||||
animation: arco-loading-circle 1s infinite cubic-bezier(0,0,1,1);
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
BIN
public/static/images/loading.gif
Normal file
BIN
public/static/images/loading.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
File diff suppressed because one or more lines are too long
@@ -5,29 +5,19 @@ export type * from './type'
|
||||
|
||||
const BASE_URL = '/auth'
|
||||
|
||||
const login = (req: T.AccountLoginReq | T.PhoneLoginReq | T.EmailLoginReq, tenantCode?: string) => {
|
||||
const headers = {}
|
||||
if (tenantCode) {
|
||||
headers['X-Tenant-Code'] = tenantCode
|
||||
}
|
||||
return http.post<T.LoginResp>(`${BASE_URL}/login`, req, {
|
||||
headers,
|
||||
})
|
||||
}
|
||||
|
||||
/** @desc 账号登录 */
|
||||
export function accountLogin(req: T.AccountLoginReq, tenantCode?: string) {
|
||||
return login(req, tenantCode)
|
||||
}
|
||||
|
||||
/** @desc 邮箱登录 */
|
||||
export function emailLogin(req: T.EmailLoginReq, tenantCode?: string) {
|
||||
return login(req, tenantCode)
|
||||
export function accountLogin(req: T.AccountLoginReq) {
|
||||
return http.post<T.LoginResp>(`${BASE_URL}/login`, req)
|
||||
}
|
||||
|
||||
/** @desc 手机号登录 */
|
||||
export function phoneLogin(req: T.PhoneLoginReq, tenantCode?: string) {
|
||||
return login(req, tenantCode)
|
||||
export function phoneLogin(req: T.PhoneLoginReq) {
|
||||
return http.post<T.LoginResp>(`${BASE_URL}/login`, req)
|
||||
}
|
||||
|
||||
/** @desc 邮箱登录 */
|
||||
export function emailLogin(req: T.EmailLoginReq) {
|
||||
return http.post<T.LoginResp>(`${BASE_URL}/login`, req)
|
||||
}
|
||||
|
||||
/** @desc 三方账号登录 */
|
||||
|
||||
@@ -80,7 +80,6 @@ export interface EmailLoginReq extends AuthReq {
|
||||
/** 登录响应类型 */
|
||||
export interface LoginResp {
|
||||
token: string
|
||||
tenantId: string
|
||||
}
|
||||
|
||||
/** 第三方登录授权类型 */
|
||||
|
||||
40
src/apis/common/common.ts
Normal file
40
src/apis/common/common.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { TreeNodeData } from '@arco-design/web-vue'
|
||||
import http from '@/utils/http'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
const BASE_URL = '/common'
|
||||
|
||||
/** @desc 查询部门树 */
|
||||
export function listDeptTree(query: { description: string | unknown }) {
|
||||
return http.get<TreeNodeData[]>(`${BASE_URL}/tree/dept`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询菜单树 */
|
||||
export function listMenuTree(query: { description: string }) {
|
||||
return http.get<TreeNodeData[]>(`${BASE_URL}/tree/menu`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询用户列表 */
|
||||
export function listUserDict(query?: { status: number }) {
|
||||
return http.get<LabelValueState[]>(`${BASE_URL}/dict/user`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询角色列表 */
|
||||
export function listRoleDict(query?: { name: string, status: number }) {
|
||||
return http.get<LabelValueState[]>(`${BASE_URL}/dict/role`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询字典列表 */
|
||||
export function listCommonDict(code: string) {
|
||||
return http.get<LabelValueState[]>(`${BASE_URL}/dict/${code}`)
|
||||
}
|
||||
|
||||
/** @desc 查询系统配置参数 */
|
||||
export function listSiteOptionDict() {
|
||||
return http.get<LabelValueState[]>(`${BASE_URL}/dict/option/site`)
|
||||
}
|
||||
|
||||
/** @desc 上传文件 */
|
||||
export function uploadFile(data: FormData) {
|
||||
return http.post(`${BASE_URL}/file`, data)
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './common'
|
||||
export * from './captcha'
|
||||
export * from './dashboard'
|
||||
|
||||
@@ -3,17 +3,13 @@ export * from './auth'
|
||||
export * from './common'
|
||||
export * from './monitor'
|
||||
export * from './system'
|
||||
export * from './open'
|
||||
export * from './tenant'
|
||||
export * from './schedule'
|
||||
export * from './code'
|
||||
export * from './schedule'
|
||||
|
||||
export * from './area/type'
|
||||
export * from './auth/type'
|
||||
export * from './common/type'
|
||||
export * from './monitor/type'
|
||||
export * from './system/type'
|
||||
export * from './open/type'
|
||||
export * from './tenant/type'
|
||||
export * from './schedule/type'
|
||||
export * from './code/type'
|
||||
export * from './schedule/type'
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export * from './app'
|
||||
@@ -24,3 +24,13 @@ export function stopJob(id: number) {
|
||||
export function retryJob(id: number) {
|
||||
return http.post(`${BASE_URL}/retry/${id}`)
|
||||
}
|
||||
|
||||
/** @desc 查询任务实例列表 */
|
||||
export function listJobInstance(query: T.JobInstanceQuery) {
|
||||
return http.get<T.JobInstanceResp[]>(`${BASE_URL}/instance`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询任务实例日志列表 */
|
||||
export function listJobInstanceLog(query: T.JobInstanceLogQuery) {
|
||||
return http.get<T.JobInstanceLogResp>(`${BASE_URL}/instance/log`, query)
|
||||
}
|
||||
|
||||
@@ -50,3 +50,36 @@ export interface JobLogQuery {
|
||||
datetimeRange?: Array<string>
|
||||
}
|
||||
export interface JobLogPageQuery extends JobLogQuery, PageQuery {}
|
||||
|
||||
/** 任务实例类型 */
|
||||
export interface JobInstanceResp {
|
||||
id: number
|
||||
groupName: string
|
||||
jobId: number
|
||||
taskBatchId: number
|
||||
taskStatus: number
|
||||
retryCount: number
|
||||
resultMessage: string
|
||||
clientInfo: string
|
||||
}
|
||||
export interface JobInstanceQuery {
|
||||
jobId?: string | number
|
||||
taskBatchId?: number | string
|
||||
}
|
||||
|
||||
/** 任务实例日志类型 */
|
||||
export interface JobInstanceLogResp {
|
||||
id: number
|
||||
message: any[]
|
||||
finished: number
|
||||
fromIndex: number
|
||||
nextStartId: number
|
||||
}
|
||||
export interface JobInstanceLogQuery {
|
||||
taskBatchId: number
|
||||
jobId: number
|
||||
taskId: number
|
||||
startId: number
|
||||
fromIndex: number
|
||||
size: number
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import http from '@/utils/http'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
const BASE_URL = '/system/common'
|
||||
|
||||
/** @desc 查询字典列表 */
|
||||
export function listCommonDict(code: string) {
|
||||
return http.get<LabelValueState[]>(`${BASE_URL}/dict/${code}`)
|
||||
}
|
||||
|
||||
/** @desc 查询系统配置参数 */
|
||||
export function listSiteOptionDict() {
|
||||
return http.get<LabelValueState[]>(`${BASE_URL}/dict/option/site`)
|
||||
}
|
||||
|
||||
/** @desc 上传文件 */
|
||||
export function upload(data: FormData) {
|
||||
return http.post(`${BASE_URL}/file`, data)
|
||||
}
|
||||
|
||||
/** @desc 查询租户开启状态 */
|
||||
export function getTenantStatus() {
|
||||
return http.get<boolean>(`${BASE_URL}/dict/option/tenant`)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { TreeNodeData } from '@arco-design/web-vue'
|
||||
import type * as T from './type'
|
||||
import http from '@/utils/http'
|
||||
|
||||
@@ -35,8 +34,3 @@ export function deleteDept(id: string) {
|
||||
export function exportDept(query: T.DeptQuery) {
|
||||
return http.download(`${BASE_URL}/export`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询部门字典树 */
|
||||
export function listDeptDictTree(query: { description: string | unknown }) {
|
||||
return http.get<TreeNodeData[]>(`${BASE_URL}/dict/tree`, query)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from './common'
|
||||
export * from './user'
|
||||
export * from './role'
|
||||
export * from './menu'
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { TreeNodeData } from '@arco-design/web-vue'
|
||||
import type * as T from './type'
|
||||
import http from '@/utils/http'
|
||||
|
||||
@@ -35,8 +34,3 @@ export function deleteMenu(id: string) {
|
||||
export function clearMenuCache() {
|
||||
return http.del(`${BASE_URL}/cache`)
|
||||
}
|
||||
|
||||
/** @desc 查询菜单字典树 */
|
||||
export function listMenuDictTree(query: { description: string }) {
|
||||
return http.get<TreeNodeData[]>(`${BASE_URL}/dict/tree`, query)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type * as T from './type'
|
||||
import http from '@/utils/http'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
export type * from './type'
|
||||
|
||||
@@ -31,11 +30,6 @@ export function deleteRole(id: string) {
|
||||
return http.del(`${BASE_URL}`, { ids: [id] })
|
||||
}
|
||||
|
||||
/** @desc 查询角色权限树 */
|
||||
export function listRolePermissionTree() {
|
||||
return http.get<T.RolePermissionResp[]>(`${BASE_URL}/permission/tree`)
|
||||
}
|
||||
|
||||
/** @desc 修改角色权限 */
|
||||
export function updateRolePermission(id: string, data: any) {
|
||||
return http.put(`${BASE_URL}/${id}/permission`, data)
|
||||
@@ -60,8 +54,3 @@ export function unassignFromUsers(userRoleIds: Array<string | number>) {
|
||||
export function listRoleUserId(id: string) {
|
||||
return http.get(`${BASE_URL}/${id}/user/id`)
|
||||
}
|
||||
|
||||
/** @desc 查询角色字典 */
|
||||
export function listRoleDict(query?: { name: string, status: number }) {
|
||||
return http.get<LabelValueState[]>(`${BASE_URL}/dict`, query)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import http from '@/utils/http'
|
||||
|
||||
export type * from './type'
|
||||
|
||||
const BASE_URL = '/system/sms/config'
|
||||
const BASE_URL = '/system/smsConfig'
|
||||
|
||||
/** @desc 查询短信配置列表 */
|
||||
export function listSmsConfig(query: T.SmsConfigPageQuery) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import http from '@/utils/http'
|
||||
|
||||
export type * from './type'
|
||||
|
||||
const BASE_URL = '/system/sms/log'
|
||||
const BASE_URL = '/system/smsLog'
|
||||
|
||||
/** @desc 查询短信日志列表 */
|
||||
export function listSmsLog(query: T.SmsLogPageQuery) {
|
||||
|
||||
@@ -63,15 +63,6 @@ export type RoleDetailResp = RoleResp & {
|
||||
menuCheckStrictly: boolean
|
||||
deptCheckStrictly: boolean
|
||||
}
|
||||
export interface RolePermissionResp {
|
||||
id: string
|
||||
title: string
|
||||
parentId: string
|
||||
permission?: string
|
||||
children?: RolePermissionResp[]
|
||||
permissions?: RolePermissionResp[]
|
||||
isChecked?: boolean
|
||||
}
|
||||
export interface RoleUserResp {
|
||||
id: string
|
||||
username: string
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type * as T from './type'
|
||||
import http from '@/utils/http'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
const BASE_URL = '/system/user'
|
||||
|
||||
@@ -63,8 +62,3 @@ export function resetUserPwd(data: any, id: string) {
|
||||
export function updateUserRole(data: { roleIds: string[] }, id: string) {
|
||||
return http.patch(`${BASE_URL}/${id}/role`, data)
|
||||
}
|
||||
|
||||
/** @desc 查询用户字典 */
|
||||
export function listUserDict(query?: { status: number }) {
|
||||
return http.get<LabelValueState[]>(`${BASE_URL}/dict`, query)
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import http from '@/utils/http'
|
||||
|
||||
const BASE_URL = '/tenant/common'
|
||||
|
||||
/** @desc 根据域名查询租户 ID */
|
||||
export function getTenantIdByDomain(domain: string) {
|
||||
return http.get<string>(`${BASE_URL}/id`, { domain })
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from './common'
|
||||
export * from './management'
|
||||
export * from './package'
|
||||
@@ -1,36 +0,0 @@
|
||||
import type * as T from './type'
|
||||
import http from '@/utils/http'
|
||||
|
||||
export type * from './type'
|
||||
|
||||
const BASE_URL = '/tenant/management'
|
||||
|
||||
/** @desc 查询租户列表 */
|
||||
export function listTenant(query: T.TenantPageQuery) {
|
||||
return http.get<PageRes<T.TenantResp[]>>(`${BASE_URL}`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询租户详情 */
|
||||
export function getTenant(id: string) {
|
||||
return http.get<T.TenantResp>(`${BASE_URL}/${id}`)
|
||||
}
|
||||
|
||||
/** @desc 新增租户 */
|
||||
export function addTenant(data: any) {
|
||||
return http.post(`${BASE_URL}`, data)
|
||||
}
|
||||
|
||||
/** @desc 修改租户 */
|
||||
export function updateTenant(data: any, id: string) {
|
||||
return http.put(`${BASE_URL}/${id}`, data)
|
||||
}
|
||||
|
||||
/** @desc 删除租户 */
|
||||
export function deleteTenant(id: string) {
|
||||
return http.del(`${BASE_URL}/${id}`)
|
||||
}
|
||||
|
||||
/** @desc 修改租户管理员密码 */
|
||||
export const updateTenantAdminUserPwd = (data: any, id: string) => {
|
||||
return http.put(`${BASE_URL}/${id}/admin/pwd`, data)
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import type * as T from './type'
|
||||
import http from '@/utils/http'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
export type * from './type'
|
||||
|
||||
const BASE_URL = '/tenant/package'
|
||||
|
||||
/** @desc 查询租户套餐列表 */
|
||||
export function listTenantPackage(query: T.TenantPackagePageQuery) {
|
||||
return http.get<PageRes<T.TenantPackageResp[]>>(`${BASE_URL}`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询租户套餐详情 */
|
||||
export function getTenantPackage(id: string) {
|
||||
return http.get<T.TenantPackageResp>(`${BASE_URL}/${id}`)
|
||||
}
|
||||
|
||||
/** @desc 新增租户套餐 */
|
||||
export function addTenantPackage(data: any) {
|
||||
return http.post(`${BASE_URL}`, data)
|
||||
}
|
||||
|
||||
/** @desc 修改租户套餐 */
|
||||
export function updateTenantPackage(data: any, id: string) {
|
||||
return http.put(`${BASE_URL}/${id}`, data)
|
||||
}
|
||||
|
||||
/** @desc 删除租户套餐 */
|
||||
export function deleteTenantPackage(id: string) {
|
||||
return http.del(`${BASE_URL}/${id}`)
|
||||
}
|
||||
|
||||
/** @desc 查询租户套餐字典 */
|
||||
export function listTenantPackageDict(query?: { description: string, status: number }) {
|
||||
return http.get<LabelValueState[]>(`${BASE_URL}/dict`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询套餐菜单 */
|
||||
export function listTenantPackageMenu() {
|
||||
return http.get<any>(`${BASE_URL}/menu/tree`)
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/** 租户 */
|
||||
export interface TenantResp {
|
||||
id: string
|
||||
name: string
|
||||
code: string
|
||||
domain: string
|
||||
expireTime: string
|
||||
description: number
|
||||
status: string
|
||||
packageId: string
|
||||
createUser: string
|
||||
createTime: string
|
||||
updateUser: string
|
||||
updateTime: string
|
||||
createUserString: string
|
||||
updateUserString: string
|
||||
adminUsername: string
|
||||
packageName: string
|
||||
}
|
||||
export interface TenantQuery {
|
||||
description?: string
|
||||
packageId?: string
|
||||
status?: string
|
||||
sort: Array<string>
|
||||
}
|
||||
export interface TenantPageQuery extends TenantQuery, PageQuery {}
|
||||
|
||||
/** 租户套餐 */
|
||||
export interface TenantPackageResp {
|
||||
id: string
|
||||
name: string
|
||||
sort: number
|
||||
menuCheckStrictly: string
|
||||
description: string
|
||||
status: string
|
||||
menuIds: []
|
||||
createUser: string
|
||||
createTime: string
|
||||
updateUser: string
|
||||
updateTime: string
|
||||
createUserString: string
|
||||
updateUserString: string
|
||||
}
|
||||
export interface TenantPackageQuery {
|
||||
description?: string
|
||||
status?: string
|
||||
sort: Array<string>
|
||||
}
|
||||
export interface TenantPackagePageQuery extends TenantPackageQuery, PageQuery {}
|
||||
@@ -1 +0,0 @@
|
||||
<svg width="24" height="24" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M24.958 3.522l19.433 10.6a1 1 0 010 1.756l-19.433 10.6a2 2 0 01-1.916 0L3.61 15.878a1 1 0 010-1.756l19.433-10.6a2 2 0 011.916 0zM5.93 22.23l-.14-.067a2 2 0 00-1.723 3.607l18.991 9.995.146.07.143.056.138.042.145.033.11.017.187.016.108.001.128-.006.172-.022.135-.028.078-.02.175-.06.103-.043c.039-.017.077-.036.115-.056l18.99-9.995a2 2 0 00-1.864-3.54L24 31.74 5.93 22.23zm0 9l-.14-.067a2 2 0 00-1.723 3.607l19 10 .142.067c.42.182.873.207 1.29.1.465.12.974.074 1.431-.167l19-10a2 2 0 00-1.862-3.54l-18.57 9.772L5.932 31.23zM10.353 15L24 7.556 37.647 15 24 22.444 10.353 15z" fill="currentColor"/></svg>
|
||||
|
Before Width: | Height: | Size: 717 B |
@@ -1 +0,0 @@
|
||||
<svg width="24" height="24" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M23 26a1 1 0 011 1v2a1 1 0 01-1 1h-7c-3.73 0-6.86 2.55-7.75 6A8.226 8.226 0 008 38v2h15a1 1 0 011 1v2a1 1 0 01-1 1H6c-1.1 0-2-.895-2-2v-4c0-6.627 5.37-12 12-12h7zm11.5 0c.672 0 1.326.075 1.955.218l.971 2.23a1.2 1.2 0 001.231.712l2.386-.262A9.014 9.014 0 0143 32.32l-1.431 1.976a1.2 1.2 0 000 1.408L43 37.68a9.014 9.014 0 01-1.957 3.422l-2.386-.262a1.2 1.2 0 00-1.23.713l-.972 2.23a8.838 8.838 0 01-3.91 0l-.971-2.23a1.2 1.2 0 00-1.232-.713l-2.385.262A9.014 9.014 0 0126 37.68l1.431-1.976a1.2 1.2 0 000-1.408L26 32.32a9.014 9.014 0 011.957-3.422l2.386.262a1.2 1.2 0 001.23-.713l.972-2.23A8.838 8.838 0 0134.5 26zm0 5.727c-1.788 0-3.238 1.466-3.238 3.273 0 1.807 1.45 3.273 3.238 3.273s3.238-1.466 3.238-3.273c0-1.807-1.45-3.273-3.238-3.273zM21 3c5.52 0 10 4.477 10 10s-4.48 10-10 10-10-4.477-10-10S15.48 3 21 3zm0 4c-3.31 0-6 2.686-6 6s2.69 6 6 6 6-2.686 6-6-2.69-6-6-6z" fill="currentColor"/></svg>
|
||||
|
Before Width: | Height: | Size: 1015 B |
@@ -1,6 +1,6 @@
|
||||
import { ref } from 'vue'
|
||||
import type { TreeNodeData } from '@arco-design/web-vue'
|
||||
import { listDeptDictTree } from '@/apis/system'
|
||||
import { listDeptTree } from '@/apis'
|
||||
|
||||
/** 部门模块 */
|
||||
export function useDept(options?: { onSuccess?: () => void }) {
|
||||
@@ -10,7 +10,7 @@ export function useDept(options?: { onSuccess?: () => void }) {
|
||||
const getDeptList = async (name?: string) => {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await listDeptDictTree({ description: name })
|
||||
const res = await listDeptTree({ description: name })
|
||||
deptList.value = res.data
|
||||
options?.onSuccess && options.onSuccess()
|
||||
} finally {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ref, toRefs } from 'vue'
|
||||
import { listCommonDict } from '@/apis/system'
|
||||
import { listCommonDict } from '@/apis'
|
||||
import { useDictStore } from '@/stores'
|
||||
|
||||
const pendingRequests = new Map<string, Promise<any>>()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ref } from 'vue'
|
||||
import type { TreeNodeData } from '@arco-design/web-vue'
|
||||
import { listMenuDictTree } from '@/apis/system'
|
||||
import { listTenantPackageMenu } from '@/apis/tenant/package'
|
||||
import { listMenuTree } from '@/apis'
|
||||
|
||||
/** 菜单模块 */
|
||||
export function useMenu(options?: { onSuccess?: () => void }) {
|
||||
@@ -11,25 +10,12 @@ export function useMenu(options?: { onSuccess?: () => void }) {
|
||||
const getMenuList = async (name?: string) => {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await listMenuDictTree({ description: name })
|
||||
const res = await listMenuTree({ description: name })
|
||||
menuList.value = res.data
|
||||
options?.onSuccess && options.onSuccess()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 获取租户套餐菜单
|
||||
const getTenantPackageMenuList = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await listTenantPackageMenu()
|
||||
menuList.value = res.data
|
||||
options?.onSuccess && options.onSuccess()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return { menuList, getMenuList, loading, getTenantPackageMenuList }
|
||||
return { menuList, getMenuList, loading }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ref } from 'vue'
|
||||
import { listRoleDict } from '@/apis/system'
|
||||
import { listRoleDict } from '@/apis'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
/** 角色模块 */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { reactive } from 'vue'
|
||||
import { cloneDeep, isFunction } from 'lodash-es'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
|
||||
export function useResetReactive<T extends object>(value: T) {
|
||||
const getInitValue = () => isFunction(value) ? value() : cloneDeep(value)
|
||||
const getInitValue = () => cloneDeep(value)
|
||||
|
||||
const state = reactive(getInitValue())
|
||||
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
:style="appStore.menuDark ? appStore.themeCSSVar : undefined"
|
||||
>
|
||||
<Logo :collapsed="appStore.menuCollapse"></Logo>
|
||||
<div class="menu-container">
|
||||
<Menu :menus="leftMenus" :menu-style="{ width: '220px', flex: 1 }"></Menu>
|
||||
</div>
|
||||
<Menu :menus="leftMenus" :menu-style="{ width: '220px', flex: 1 }"></Menu>
|
||||
<WwAds class="ads" />
|
||||
</section>
|
||||
|
||||
@@ -180,13 +178,6 @@ onMounted(() => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
height: 100vh;
|
||||
|
||||
.menu-container {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
&-right {
|
||||
|
||||
@@ -110,7 +110,7 @@ export const setupRouterGuard = (router: Router) => {
|
||||
} catch (error: any) {
|
||||
// 过程中发生任何错误,都直接重置 Token,并重定向到登录页面
|
||||
await userStore.logoutCallBack()
|
||||
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`)
|
||||
next(`/login?redirect=${to.path}`)
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
@@ -123,7 +123,7 @@ export const setupRouterGuard = (router: Router) => {
|
||||
next()
|
||||
} else {
|
||||
// 其他没有访问权限的页面将被重定向到登录页面
|
||||
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`)
|
||||
next('/login')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,9 +81,8 @@ export const systemRoutes: RouteRecordRaw[] = [
|
||||
meta: { title: '接口文档', icon: 'swagger', hidden: false, keepAlive: true },
|
||||
},
|
||||
{
|
||||
path: '/about/document/changelog',
|
||||
component: () => import('@/views/about/document/changelog/index.vue'),
|
||||
meta: { title: '更新日志', icon: 'continew', hidden: false, keepAlive: true },
|
||||
path: 'https://continew.top',
|
||||
meta: { title: '在线文档', icon: 'continew', hidden: false },
|
||||
},
|
||||
{
|
||||
path: 'https://arco.design/vue/component/button',
|
||||
|
||||
@@ -6,7 +6,6 @@ export * from './modules/route'
|
||||
export * from './modules/tabs'
|
||||
export * from './modules/dict'
|
||||
export * from './modules/user'
|
||||
export * from './modules/tenant'
|
||||
|
||||
const pinia = createPinia()
|
||||
pinia.use(piniaPluginPersistedstate)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, reactive, toRefs } from 'vue'
|
||||
import { generate, getRgbStr } from '@arco-design/color'
|
||||
import { type BasicConfig, listSiteOptionDict } from '@/apis/system'
|
||||
import { type BasicConfig, listSiteOptionDict } from '@/apis'
|
||||
import { getSettings } from '@/config/setting'
|
||||
|
||||
const storeSetup = () => {
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
export const useTenantStore = defineStore('tenant', () => {
|
||||
const tenantEnabled = ref<boolean>(false)
|
||||
const tenantId = ref<string>()
|
||||
|
||||
const setTenantEnable = (status: boolean) => {
|
||||
tenantEnabled.value = status
|
||||
}
|
||||
const setTenantId = (id: string) => {
|
||||
tenantId.value = id
|
||||
}
|
||||
|
||||
// 判断是否需要用户输入租户编码
|
||||
const needInputTenantCode = computed(() => {
|
||||
return tenantEnabled.value && !tenantId.value
|
||||
})
|
||||
|
||||
// 判断租户是否已正确配置
|
||||
const isTenantConfigured = computed(() => {
|
||||
return tenantEnabled.value && !!tenantId.value
|
||||
})
|
||||
|
||||
// 清空租户ID
|
||||
const resetTenantId = () => {
|
||||
tenantId.value = undefined
|
||||
}
|
||||
return {
|
||||
tenantEnabled,
|
||||
tenantId,
|
||||
setTenantEnable,
|
||||
setTenantId,
|
||||
needInputTenantCode,
|
||||
isTenantConfigured,
|
||||
resetTenantId,
|
||||
}
|
||||
}, {
|
||||
persist: { paths: ['tenantEnabled', 'tenantId'], storage: localStorage },
|
||||
})
|
||||
@@ -1,6 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { useTenantStore } from './tenant'
|
||||
import { resetRouter } from '@/router'
|
||||
import {
|
||||
type AccountLoginReq,
|
||||
@@ -19,7 +18,6 @@ import { clearToken, getToken, setToken } from '@/utils/auth'
|
||||
import { resetHasRouteFlag } from '@/router/guard'
|
||||
|
||||
const storeSetup = () => {
|
||||
const tenantStore = useTenantStore()
|
||||
const userInfo = reactive<UserInfo>({
|
||||
id: '',
|
||||
username: '',
|
||||
@@ -43,6 +41,7 @@ const storeSetup = () => {
|
||||
const pwdExpiredShow = ref<boolean>(true)
|
||||
const roles = ref<string[]>([]) // 当前用户角色
|
||||
const permissions = ref<string[]>([]) // 当前角色权限标识集合
|
||||
|
||||
// 重置token
|
||||
const resetToken = () => {
|
||||
token.value = ''
|
||||
@@ -51,34 +50,30 @@ const storeSetup = () => {
|
||||
}
|
||||
|
||||
// 登录
|
||||
const accountLogin = async (req: AccountLoginReq, tenantCode?: string) => {
|
||||
const res = await accountLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.ACCOUNT }, tenantCode)
|
||||
const accountLogin = async (req: AccountLoginReq) => {
|
||||
const res = await accountLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.ACCOUNT })
|
||||
setToken(res.data.token)
|
||||
tenantStore.setTenantId(res.data.tenantId)
|
||||
token.value = res.data.token
|
||||
}
|
||||
|
||||
// 邮箱登录
|
||||
const emailLogin = async (req: EmailLoginReq, tenantCode?: string) => {
|
||||
const res = await emailLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.EMAIL }, tenantCode)
|
||||
const emailLogin = async (req: EmailLoginReq) => {
|
||||
const res = await emailLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.EMAIL })
|
||||
setToken(res.data.token)
|
||||
tenantStore.setTenantId(res.data.tenantId)
|
||||
token.value = res.data.token
|
||||
}
|
||||
|
||||
// 手机号登录
|
||||
const phoneLogin = async (req: PhoneLoginReq, tenantCode?: string) => {
|
||||
const res = await phoneLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.PHONE }, tenantCode)
|
||||
const phoneLogin = async (req: PhoneLoginReq) => {
|
||||
const res = await phoneLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.PHONE })
|
||||
setToken(res.data.token)
|
||||
tenantStore.setTenantId(res.data.tenantId)
|
||||
token.value = res.data.token
|
||||
}
|
||||
|
||||
// 三方账号登录
|
||||
const socialLogin = async (source: string, req: any) => {
|
||||
const res: any = await socialLoginApi({ ...req, source, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.SOCIAL })
|
||||
const res = await socialLoginApi({ ...req, source, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.SOCIAL })
|
||||
setToken(res.data.token)
|
||||
tenantStore.setTenantId(res.data.tenantId)
|
||||
token.value = res.data.token
|
||||
}
|
||||
|
||||
@@ -89,7 +84,6 @@ const storeSetup = () => {
|
||||
pwdExpiredShow.value = true
|
||||
resetToken()
|
||||
resetRouter()
|
||||
tenantStore.resetTenantId()
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import axios from 'axios'
|
||||
import qs from 'query-string'
|
||||
import type { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
|
||||
import { useTenantStore } from '@/stores/modules/tenant'
|
||||
import { useUserStore } from '@/stores'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import modalErrorWrapper from '@/utils/modal-error-wrapper'
|
||||
@@ -52,16 +51,12 @@ const handleError = (msg: string) => {
|
||||
http.interceptors.request.use(
|
||||
(config: AxiosRequestConfig) => {
|
||||
const token = getToken()
|
||||
if (!config.headers) {
|
||||
config.headers = {}
|
||||
}
|
||||
if (token) {
|
||||
if (!config.headers) {
|
||||
config.headers = {}
|
||||
}
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
const tenantStore = useTenantStore()
|
||||
if (tenantStore.tenantEnabled && tenantStore.tenantId) {
|
||||
config.headers['X-Tenant-Id'] = tenantStore.tenantId
|
||||
}
|
||||
return config
|
||||
},
|
||||
(error) => Promise.reject(error),
|
||||
@@ -105,8 +100,7 @@ http.interceptors.response.use(
|
||||
async onOk() {
|
||||
const userStore = useUserStore()
|
||||
await userStore.logoutCallBack()
|
||||
const currentPath = router.currentRoute.value.fullPath
|
||||
await router.replace(`/login?redirect=${encodeURIComponent(currentPath)}`)
|
||||
await router.replace('/login')
|
||||
},
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<template>
|
||||
<GiIframe src="https://continew.top/admin/changelog/"></GiIframe>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
defineOptions({ name: 'AboutDocumentChangelog' })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -157,9 +157,6 @@ const selectedKeys = ref()
|
||||
// 选择文件预览
|
||||
const onSelectPreview = (keys: (string | number)[]) => {
|
||||
if (typeof keys[0] === 'string') {
|
||||
if (keys[0] === selectedKeys.value) {
|
||||
return
|
||||
}
|
||||
currentPreview.value = genPreviewList.value.filter((p) => p.fileName === keys[0])[0]
|
||||
selectedKeys.value = keys
|
||||
} else {
|
||||
|
||||
@@ -28,7 +28,7 @@ const links = [
|
||||
{ text: '项目简介', url: 'https://continew.top/admin/guide/introduction.html' },
|
||||
{ text: '快速开始', url: 'https://continew.top/admin/guide/quick-start.html' },
|
||||
{ text: '常见问题', url: 'https://continew.top/admin/faq.html' },
|
||||
{ text: '更新日志', url: 'https://continew.top/admin/changelog/' },
|
||||
{ text: '更新日志', url: 'https://continew.top/admin/other/changelog.html' },
|
||||
{ text: '贡献指南', url: 'https://continew.top/about/contributing.html' },
|
||||
{ text: '赞助支持 💖', url: 'https://continew.top/sponsor/' },
|
||||
]
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
size="large"
|
||||
@submit="handleLogin"
|
||||
>
|
||||
<a-form-item v-if="tenantStore.needInputTenantCode" field="tenantCode" hide-label>
|
||||
<a-input v-model="tenantCode" placeholder="请输入租户编码(不输入时为默认租户)" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item field="username" hide-label>
|
||||
<a-input v-model="form.username" placeholder="请输入用户名" allow-clear />
|
||||
</a-form-item>
|
||||
@@ -44,7 +41,7 @@
|
||||
import { type FormInstance, Message } from '@arco-design/web-vue'
|
||||
import { useStorage } from '@vueuse/core'
|
||||
import { getImageCaptcha } from '@/apis/common'
|
||||
import { useTabsStore, useTenantStore, useUserStore } from '@/stores'
|
||||
import { useTabsStore, useUserStore } from '@/stores'
|
||||
import { encryptByRsa } from '@/utils/encrypt'
|
||||
|
||||
const loginConfig = useStorage('login-config', {
|
||||
@@ -58,7 +55,7 @@ const loginConfig = useStorage('login-config', {
|
||||
const isCaptchaEnabled = ref(true)
|
||||
// 验证码图片
|
||||
const captchaImgBase64 = ref()
|
||||
const tenantCode = ref()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const form = reactive({
|
||||
username: loginConfig.value.username,
|
||||
@@ -67,7 +64,6 @@ const form = reactive({
|
||||
uuid: '',
|
||||
expired: false,
|
||||
})
|
||||
// 校验规则部分
|
||||
const rules: FormInstance['rules'] = {
|
||||
username: [{ required: true, message: '请输入用户名' }],
|
||||
password: [{ required: true, message: '请输入密码' }],
|
||||
@@ -108,7 +104,6 @@ const getCaptcha = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const tenantStore = useTenantStore()
|
||||
const userStore = useUserStore()
|
||||
const tabsStore = useTabsStore()
|
||||
const router = useRouter()
|
||||
@@ -119,30 +114,22 @@ const handleLogin = async () => {
|
||||
const isInvalid = await formRef.value?.validate()
|
||||
if (isInvalid) return
|
||||
loading.value = true
|
||||
|
||||
await userStore.accountLogin({
|
||||
username: form.username,
|
||||
password: encryptByRsa(form.password) || '',
|
||||
captcha: form.captcha,
|
||||
uuid: form.uuid,
|
||||
}, tenantCode.value)
|
||||
})
|
||||
tabsStore.reset()
|
||||
const { redirect, ...othersQuery } = router.currentRoute.value.query
|
||||
const { rememberMe } = loginConfig.value
|
||||
loginConfig.value.username = rememberMe ? form.username : ''
|
||||
|
||||
// 如果有重定向参数,解码并直接跳转到完整路径
|
||||
if (redirect) {
|
||||
const redirectPath = decodeURIComponent(redirect as string)
|
||||
await router.push(redirectPath)
|
||||
} else {
|
||||
await router.push({
|
||||
path: '/',
|
||||
query: {
|
||||
...othersQuery,
|
||||
},
|
||||
})
|
||||
}
|
||||
await router.push({
|
||||
path: (redirect as string) || '/',
|
||||
query: {
|
||||
...othersQuery,
|
||||
},
|
||||
})
|
||||
Message.success('欢迎使用')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
size="large"
|
||||
@submit="handleLogin"
|
||||
>
|
||||
<a-form-item v-if="tenantStore.needInputTenantCode" field="tenantCode" hide-label>
|
||||
<a-input v-model="tenantCode" placeholder="请输入租户编码(不输入时为默认租户)" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item field="email" hide-label>
|
||||
<a-input v-model="form.email" placeholder="请输入邮箱" allow-clear />
|
||||
</a-form-item>
|
||||
@@ -45,7 +42,7 @@
|
||||
import { type FormInstance, Message } from '@arco-design/web-vue'
|
||||
import type { BehaviorCaptchaReq } from '@/apis'
|
||||
// import { type BehaviorCaptchaReq, getEmailCaptcha } from '@/apis'
|
||||
import { useTabsStore, useTenantStore, useUserStore } from '@/stores'
|
||||
import { useTabsStore, useUserStore } from '@/stores'
|
||||
import * as Regexp from '@/utils/regexp'
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
@@ -53,7 +50,6 @@ const form = reactive({
|
||||
email: '',
|
||||
captcha: '',
|
||||
})
|
||||
const tenantCode = ref()
|
||||
|
||||
const rules: FormInstance['rules'] = {
|
||||
email: [
|
||||
@@ -63,7 +59,6 @@ const rules: FormInstance['rules'] = {
|
||||
captcha: [{ required: true, message: '请输入验证码' }],
|
||||
}
|
||||
|
||||
const tenantStore = useTenantStore()
|
||||
const userStore = useUserStore()
|
||||
const tabsStore = useTabsStore()
|
||||
const router = useRouter()
|
||||
@@ -74,22 +69,15 @@ const handleLogin = async () => {
|
||||
const isInvalid = await formRef.value?.validate()
|
||||
if (isInvalid) return
|
||||
loading.value = true
|
||||
await userStore.emailLogin(form, tenantCode.value)
|
||||
await userStore.emailLogin(form)
|
||||
tabsStore.reset()
|
||||
const { redirect, ...othersQuery } = router.currentRoute.value.query
|
||||
|
||||
// 如果有重定向参数,解码并直接跳转到完整路径
|
||||
if (redirect) {
|
||||
const redirectPath = decodeURIComponent(redirect as string)
|
||||
await router.push(redirectPath)
|
||||
} else {
|
||||
await router.push({
|
||||
path: '/',
|
||||
query: {
|
||||
...othersQuery,
|
||||
},
|
||||
})
|
||||
}
|
||||
await router.push({
|
||||
path: (redirect as string) || '/',
|
||||
query: {
|
||||
...othersQuery,
|
||||
},
|
||||
})
|
||||
Message.success('欢迎使用')
|
||||
} catch (error) {
|
||||
form.captcha = ''
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
size="large"
|
||||
@submit="handleLogin"
|
||||
>
|
||||
<a-form-item v-if="tenantStore.needInputTenantCode" field="tenantCode" hide-label>
|
||||
<a-input v-model="tenantCode" placeholder="请输入租户编码(不输入时为默认租户)" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item field="phone" hide-label>
|
||||
<a-input v-model="form.phone" placeholder="请输入手机号" :max-length="11" allow-clear />
|
||||
</a-form-item>
|
||||
@@ -45,7 +42,7 @@
|
||||
import { type FormInstance, Message } from '@arco-design/web-vue'
|
||||
// import type { BehaviorCaptchaReq } from '@/apis'
|
||||
import { type BehaviorCaptchaReq, getSmsCaptcha } from '@/apis'
|
||||
import { useTabsStore, useTenantStore, useUserStore } from '@/stores'
|
||||
import { useTabsStore, useUserStore } from '@/stores'
|
||||
import * as Regexp from '@/utils/regexp'
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
@@ -53,7 +50,6 @@ const form = reactive({
|
||||
phone: '',
|
||||
captcha: '',
|
||||
})
|
||||
const tenantCode = ref()
|
||||
|
||||
const rules: FormInstance['rules'] = {
|
||||
phone: [
|
||||
@@ -63,7 +59,6 @@ const rules: FormInstance['rules'] = {
|
||||
captcha: [{ required: true, message: '请输入验证码' }],
|
||||
}
|
||||
|
||||
const tenantStore = useTenantStore()
|
||||
const userStore = useUserStore()
|
||||
const tabsStore = useTabsStore()
|
||||
const router = useRouter()
|
||||
@@ -74,22 +69,15 @@ const handleLogin = async () => {
|
||||
if (isInvalid) return
|
||||
try {
|
||||
loading.value = true
|
||||
await userStore.phoneLogin(form, tenantCode.value)
|
||||
await userStore.phoneLogin(form)
|
||||
tabsStore.reset()
|
||||
const { redirect, ...othersQuery } = router.currentRoute.value.query
|
||||
|
||||
// 如果有重定向参数,解码并直接跳转到完整路径
|
||||
if (redirect) {
|
||||
const redirectPath = decodeURIComponent(redirect as string)
|
||||
await router.push(redirectPath)
|
||||
} else {
|
||||
await router.push({
|
||||
path: '/',
|
||||
query: {
|
||||
...othersQuery,
|
||||
},
|
||||
})
|
||||
}
|
||||
await router.push({
|
||||
path: (redirect as string) || '/',
|
||||
query: {
|
||||
...othersQuery,
|
||||
},
|
||||
})
|
||||
Message.success('欢迎使用')
|
||||
} catch (error) {
|
||||
form.captcha = ''
|
||||
|
||||
@@ -78,10 +78,10 @@
|
||||
<div class="list">
|
||||
<div v-if="isEmailLogin" class="mode item" @click="toggleLoginMode"><icon-user /> 账号/手机号登录</div>
|
||||
<div v-else class="mode item" @click="toggleLoginMode"><icon-email /> 邮箱登录</div>
|
||||
<a v-if="!tenantStore.isTenantConfigured" class="item" title="使用 Gitee 账号登录" @click="onOauth('gitee')">
|
||||
<a class="item" title="使用 Gitee 账号登录" @click="onOauth('gitee')">
|
||||
<GiSvgIcon name="gitee" :size="24" />
|
||||
</a>
|
||||
<a v-if="tenantStore.isTenantConfigured" class="item" title="使用 GitHub 账号登录" @click="onOauth('github')">
|
||||
<a class="item" title="使用 GitHub 账号登录" @click="onOauth('github')">
|
||||
<GiSvgIcon name="github" :size="24" />
|
||||
</a>
|
||||
</div>
|
||||
@@ -97,16 +97,12 @@ import PhoneLogin from './components/phone/index.vue'
|
||||
import EmailLogin from './components/email/index.vue'
|
||||
import { socialAuth } from '@/apis/auth'
|
||||
import { useAppStore } from '@/stores'
|
||||
import { useTenantStore } from '@/stores/modules/tenant'
|
||||
import { useDevice } from '@/hooks'
|
||||
import { getTenantIdByDomain, getTenantStatus } from '@/apis'
|
||||
|
||||
defineOptions({ name: 'Login' })
|
||||
|
||||
const appStore = useAppStore()
|
||||
const tenantStore = useTenantStore()
|
||||
|
||||
const { isDesktop } = useDevice()
|
||||
const appStore = useAppStore()
|
||||
const title = computed(() => appStore.getTitle())
|
||||
const logo = computed(() => appStore.getLogo())
|
||||
|
||||
@@ -123,21 +119,6 @@ const onOauth = async (source: string) => {
|
||||
const { data } = await socialAuth(source)
|
||||
window.location.href = data.authorizeUrl
|
||||
}
|
||||
|
||||
// 查询租户状态和租户编码
|
||||
const onGetTenant = async () => {
|
||||
const { data } = await getTenantStatus()
|
||||
tenantStore.setTenantEnable(data)
|
||||
// 开启租户 根据地址(域名)查询租户code
|
||||
if (data) {
|
||||
const domain = window.location.hostname
|
||||
const { data: tenantId } = await getTenantIdByDomain(domain)
|
||||
tenantStore.setTenantId(tenantId)
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
onGetTenant()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -302,12 +283,7 @@ onMounted(() => {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 30px;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
// 新增弹窗层级设置
|
||||
.arco-modal-wrapper {
|
||||
z-index: 1000;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.footer {
|
||||
@@ -371,6 +347,7 @@ onMounted(() => {
|
||||
&-box {
|
||||
width: 86%;
|
||||
max-width: 850px;
|
||||
height: 490px;
|
||||
display: flex;
|
||||
z-index: 999;
|
||||
box-shadow: 0 2px 4px 2px rgba(0, 0, 0, 0.08);
|
||||
@@ -512,12 +489,7 @@ onMounted(() => {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 30px;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
// 新增弹窗层级设置
|
||||
.arco-modal-wrapper {
|
||||
z-index: 1000;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.footer {
|
||||
|
||||
@@ -178,12 +178,7 @@ const logo = computed(() => appStore.getLogo())
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 30px;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
// 新增弹窗层级设置
|
||||
.arco-modal-wrapper {
|
||||
z-index: 1000;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.footer {
|
||||
@@ -247,6 +242,7 @@ const logo = computed(() => appStore.getLogo())
|
||||
&-box {
|
||||
width: 86%;
|
||||
max-width: 850px;
|
||||
height: 490px;
|
||||
display: flex;
|
||||
z-index: 999;
|
||||
box-shadow: 0 2px 4px 2px rgba(0, 0, 0, 0.08);
|
||||
@@ -389,12 +385,7 @@ const logo = computed(() => appStore.getLogo())
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 30px;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
// 新增弹窗层级设置
|
||||
.arco-modal-wrapper {
|
||||
z-index: 1000;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.footer {
|
||||
|
||||
@@ -89,7 +89,7 @@ const columns: TableInstance['columns'] = [
|
||||
{ title: '所属模块', dataIndex: 'module', align: 'center', ellipsis: true, tooltip: true },
|
||||
{
|
||||
title: '状态',
|
||||
// dataIndex: 'status',
|
||||
dataIndex: 'status',
|
||||
slotName: 'status',
|
||||
align: 'center',
|
||||
filterable: {
|
||||
|
||||
@@ -105,7 +105,7 @@ import has from '@/utils/has'
|
||||
defineOptions({ name: 'OpenApp' })
|
||||
|
||||
const queryForm = reactive<AppQuery>({
|
||||
sort: ['createTime,desc'],
|
||||
sort: ['id,desc'],
|
||||
})
|
||||
|
||||
const {
|
||||
|
||||
196
src/views/schedule/log/LogDetailDrawer.vue
Normal file
196
src/views/schedule/log/LogDetailDrawer.vue
Normal file
@@ -0,0 +1,196 @@
|
||||
<template>
|
||||
<a-drawer
|
||||
v-model:visible="visible"
|
||||
title="任务日志详情"
|
||||
:width="width >= 1300 ? 1300 : '100%'"
|
||||
:footer="false"
|
||||
@close="closed"
|
||||
>
|
||||
<div style="display: flex;">
|
||||
<div style="padding: 10px 10px;">
|
||||
<div class="job_list">
|
||||
<div
|
||||
v-for="item in dataList"
|
||||
:key="item.id"
|
||||
:class="`job_list_item ${item.id === activeId ? 'active' : ''}`"
|
||||
@click="onStartInfo(item)"
|
||||
>
|
||||
<div class="content">
|
||||
<span class="title">{{ item.clientInfo.split('@')[1] }}</span>
|
||||
<span class="status">
|
||||
<a-tag bordered :color="statusList[item.taskStatus].color">{{ statusList[item.taskStatus].title }}</a-tag>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="code_view">
|
||||
<GiCodeView :code-json="content" />
|
||||
</div>
|
||||
</div>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import dayjs from 'dayjs'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { type JobInstanceQuery, type JobInstanceResp, type JobLogResp, listJobInstance, listJobInstanceLog } from '@/apis/schedule'
|
||||
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const queryForm = reactive<JobInstanceQuery>({})
|
||||
const dataList = ref<JobInstanceResp[]>([])
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const activeId = ref<string | number>('')
|
||||
const statusList = {
|
||||
1: {
|
||||
title: '待处理',
|
||||
color: 'gray',
|
||||
isRun: false,
|
||||
},
|
||||
2: {
|
||||
title: '运行中',
|
||||
color: 'cyan',
|
||||
isRun: true,
|
||||
},
|
||||
3: {
|
||||
title: '成功',
|
||||
color: 'green',
|
||||
isRun: false,
|
||||
},
|
||||
4: {
|
||||
title: '已失败',
|
||||
color: 'red',
|
||||
isRun: false,
|
||||
},
|
||||
5: {
|
||||
title: '已停止',
|
||||
color: 'purple',
|
||||
isRun: false,
|
||||
},
|
||||
6: {
|
||||
title: '已取消',
|
||||
color: 'orange',
|
||||
isRun: false,
|
||||
},
|
||||
}
|
||||
|
||||
// 格式化日志
|
||||
const formatLog = (log: any) => {
|
||||
const date = new Date(Number.parseInt(log.time_stamp))
|
||||
let formatLog = `${dayjs(date).format('YYYY-MM-DD HH:mm:ss')} ${log.level} [${log.thread}] ${log.location} - ${log.message}`
|
||||
// 增加堆栈信息显示
|
||||
if (log.throwable) {
|
||||
formatLog += `\n ${log.throwable}`
|
||||
}
|
||||
return formatLog
|
||||
}
|
||||
|
||||
const content = ref('')
|
||||
const setIntervalNode = ref<NodeJS.Timeout>()
|
||||
|
||||
// 日志输出
|
||||
const onLogDetail = async (record: JobInstanceResp) => {
|
||||
activeId.value = record?.id
|
||||
try {
|
||||
// todo startId根据第一次查询 如果有返回!=0则需要在查一次
|
||||
const res = await listJobInstanceLog({
|
||||
taskBatchId: record.taskBatchId,
|
||||
jobId: record.jobId,
|
||||
taskId: record.id,
|
||||
startId: 0,
|
||||
fromIndex: 0,
|
||||
size: 50,
|
||||
})
|
||||
if (res.data?.finished) {
|
||||
clearInterval(setIntervalNode.value)
|
||||
}
|
||||
content.value = res.data.message.map(formatLog).join('\n')
|
||||
} catch (error) {
|
||||
content.value = ''
|
||||
}
|
||||
}
|
||||
const onStartInfo = (record: JobInstanceResp) => {
|
||||
content.value = ''
|
||||
clearInterval(setIntervalNode.value)
|
||||
const isRun = statusList[record.taskStatus].isRun
|
||||
if (isRun) {
|
||||
setIntervalNode.value = setInterval(() => {
|
||||
onLogDetail(record)
|
||||
}, 1000)
|
||||
} else {
|
||||
onLogDetail(record)
|
||||
}
|
||||
}
|
||||
// 查询列表数据
|
||||
const getInstanceList = async (query: JobInstanceQuery = { ...queryForm }) => {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await listJobInstance(query)
|
||||
dataList.value = res.data
|
||||
onStartInfo(dataList.value[0])
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const closed = () => {
|
||||
clearInterval(setIntervalNode.value)
|
||||
}
|
||||
onUnmounted(() => {
|
||||
clearInterval(setIntervalNode.value)
|
||||
})
|
||||
|
||||
// 打开
|
||||
const onOpen = async (record: JobLogResp) => {
|
||||
// 更新 queryForm
|
||||
queryForm.jobId = record.jobId
|
||||
queryForm.taskBatchId = record.id
|
||||
visible.value = true
|
||||
await getInstanceList()
|
||||
}
|
||||
|
||||
defineExpose({ onOpen })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.job_list {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
border: 1px solid var(--color-neutral-3);
|
||||
|
||||
.job_list_item {
|
||||
padding: 8px 10px;
|
||||
cursor: pointer;
|
||||
|
||||
&:not(:last-child) {
|
||||
border-bottom: 2px dashed var(--color-neutral-3);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: var(--color-neutral-2);
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
justify-items: center;
|
||||
|
||||
.title {
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.active {
|
||||
border-bottom: 2px solid $color-theme !important;
|
||||
background-color: var(--color-neutral-3) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.code_view {
|
||||
position: relative;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -41,6 +41,7 @@
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
<a-link v-permission="['schedule:log:get']" title="详情" @click="onDetail(record)">详情</a-link>
|
||||
<a-popconfirm content="是否确定停止本次执行?" type="warning" @ok="onStop(record)">
|
||||
<a-link v-if="record.taskBatchStatus === 2" v-permission="['schedule:log:stop']" status="danger" title="停止">停止</a-link>
|
||||
</a-popconfirm>
|
||||
@@ -57,6 +58,8 @@
|
||||
</a-space>
|
||||
</template>
|
||||
</GiTable>
|
||||
|
||||
<LogDetailDrawer ref="LogDetailDrawerRef" />
|
||||
</GiPageLayout>
|
||||
</template>
|
||||
|
||||
@@ -65,6 +68,7 @@ import type { TableInstance } from '@arco-design/web-vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import dayjs from 'dayjs'
|
||||
import LogDetailDrawer from './LogDetailDrawer.vue'
|
||||
import { type JobLogQuery, type JobLogResp, listGroup, listJobLog, retryJob, stopJob } from '@/apis/schedule'
|
||||
import { useTable } from '@/hooks'
|
||||
import { useDict } from '@/hooks/app'
|
||||
@@ -107,7 +111,7 @@ const columns: TableInstance['columns'] = [
|
||||
width: 130,
|
||||
align: 'center',
|
||||
fixed: !isMobile() ? 'right' : undefined,
|
||||
show: has.hasPermOr(['schedule:log:stop', 'schedule:log:retry']),
|
||||
show: has.hasPermOr(['schedule:log:get', 'schedule:log:stop', 'schedule:log:retry']),
|
||||
},
|
||||
]
|
||||
|
||||
@@ -145,6 +149,12 @@ const onRetry = (record: JobLogResp) => {
|
||||
})
|
||||
}
|
||||
|
||||
const LogDetailDrawerRef = ref<InstanceType<typeof LogDetailDrawer>>()
|
||||
// 详情
|
||||
const onDetail = (record: JobLogResp) => {
|
||||
LogDetailDrawerRef.value?.onOpen(record)
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
onMounted(() => {
|
||||
if (route.query) {
|
||||
|
||||
@@ -67,8 +67,8 @@ const columns: ColumnItem[] = reactive([
|
||||
{
|
||||
label: () => (
|
||||
<a-tooltip content="-1 代表不限制,永不冻结">
|
||||
Token 最低活跃频率
|
||||
<icon-question-circle />
|
||||
Token 最低活跃频率
|
||||
<icon-info-circle-fill />
|
||||
</a-tooltip>
|
||||
),
|
||||
field: 'activeTimeout',
|
||||
@@ -87,8 +87,8 @@ const columns: ColumnItem[] = reactive([
|
||||
{
|
||||
label: () => (
|
||||
<a-tooltip content="-1 代表永不过期">
|
||||
Token 有效期
|
||||
<icon-question-circle />
|
||||
Token 有效期
|
||||
<icon-info-circle-fill />
|
||||
</a-tooltip>
|
||||
),
|
||||
field: 'timeout',
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
</a-switch>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
v-if="form.MAIL_SSL_ENABLED === 1"
|
||||
v-if="form.MAIL_SSL_ENABLED === '1'"
|
||||
field="MAIL_SSL_PORT"
|
||||
:label="mailConfig.MAIL_SSL_PORT.name"
|
||||
:help="mailConfig.MAIL_SSL_PORT.description"
|
||||
@@ -123,7 +123,7 @@ const [form] = useResetReactive({
|
||||
MAIL_PORT: 0,
|
||||
MAIL_USERNAME: '',
|
||||
MAIL_PASSWORD: '',
|
||||
MAIL_SSL_ENABLED: 0,
|
||||
MAIL_SSL_ENABLED: '',
|
||||
MAIL_SSL_PORT: 0,
|
||||
})
|
||||
const rules: FormInstance['rules'] = {
|
||||
@@ -152,7 +152,7 @@ const reset = () => {
|
||||
form.MAIL_PORT = mailConfig.value.MAIL_PORT.value || 0
|
||||
form.MAIL_USERNAME = mailConfig.value.MAIL_USERNAME.value || ''
|
||||
form.MAIL_PASSWORD = mailConfig.value.MAIL_PASSWORD?.value || ''
|
||||
form.MAIL_SSL_ENABLED = mailConfig.value.MAIL_SSL_ENABLED.value || 0
|
||||
form.MAIL_SSL_ENABLED = mailConfig.value.MAIL_SSL_ENABLED.value || ''
|
||||
form.MAIL_SSL_PORT = mailConfig.value.MAIL_SSL_PORT.value || 0
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ const getDataList = async () => {
|
||||
loading.value = true
|
||||
const { data } = await listOption(queryForm)
|
||||
mailConfig.value = data.reduce((obj: MailConfig, option: OptionResp) => {
|
||||
obj[option.code] = { ...option, value: ['MAIL_PORT', 'MAIL_SSL_PORT', 'MAIL_SSL_ENABLED'].includes(option.code) ? Number.parseInt(option.value) : option.value }
|
||||
obj[option.code] = { ...option, value: ['MAIL_PORT', 'MAIL_SSL_PORT'].includes(option.code) ? Number.parseInt(option.value) : option.value }
|
||||
return obj
|
||||
}, {})
|
||||
handleCancel()
|
||||
|
||||
@@ -75,9 +75,7 @@ const columns: ColumnItem[] = reactive([
|
||||
},
|
||||
rules: [{ required: true, message: '请选择上级部门' }],
|
||||
hide: (form) => {
|
||||
const tree = deptSelectTree.value || []
|
||||
const hasParentNode = Boolean(tree.find((node) => node?.key === form.parentId))
|
||||
return form.parentId === 0 || (!hasParentNode && isUpdate.value)
|
||||
return form.parentId === 0
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
</a-button>
|
||||
</template>
|
||||
<template #toolbar-right>
|
||||
<a-button v-permission="['system:dictItem:create']" type="primary" @click="onAdd">
|
||||
<a-button v-permission="['system:dict:item:create']" type="primary" @click="onAdd">
|
||||
<template #icon><icon-plus /></template>
|
||||
<template #default>新增</template>
|
||||
</a-button>
|
||||
<a-button v-permission="['system:dictItem:clearCache']" type="outline" status="warning" @click="onClearCache">
|
||||
<a-button v-permission="['system:dict:item:clearCache']" type="outline" status="warning" @click="onClearCache">
|
||||
<template #icon><icon-delete /></template>
|
||||
<template #default>清除缓存</template>
|
||||
</a-button>
|
||||
@@ -46,9 +46,9 @@
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
<a-link v-permission="['system:dictItem:update']" title="修改" @click="onUpdate(record)">修改</a-link>
|
||||
<a-link v-permission="['system:dict:item:update']" title="修改" @click="onUpdate(record)">修改</a-link>
|
||||
<a-link
|
||||
v-permission="['system:dictItem:delete']"
|
||||
v-permission="['system:dict:item:delete']"
|
||||
status="danger"
|
||||
title="删除"
|
||||
@click="onDelete(record)"
|
||||
@@ -119,7 +119,7 @@ const columns: TableInstance['columns'] = [
|
||||
width: 130,
|
||||
align: 'center',
|
||||
fixed: !isMobile() ? 'right' : undefined,
|
||||
show: has.hasPermOr(['system:dictItem:update', 'system:dictItem:delete']),
|
||||
show: has.hasPermOr(['system:dict:item:update', 'system:dict:item:delete']),
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
<a-input v-model="title" placeholder="搜索菜单标题" allow-clear>
|
||||
<template #prefix><icon-search /></template>
|
||||
</a-input>
|
||||
<a-input v-model="path" placeholder="搜索路由地址" allow-clear>
|
||||
<template #prefix><icon-search /></template>
|
||||
</a-input>
|
||||
<a-input v-model="permission" placeholder="搜索权限标识" allow-clear>
|
||||
<template #prefix><icon-search /></template>
|
||||
</a-input>
|
||||
<a-button @click="reset">
|
||||
<template #icon><icon-refresh /></template>
|
||||
<template #default>重置</template>
|
||||
@@ -98,7 +92,7 @@
|
||||
import type { TableInstance } from '@arco-design/web-vue'
|
||||
import { Message, Modal } from '@arco-design/web-vue'
|
||||
import MenuAddModal from './MenuAddModal.vue'
|
||||
import { type MenuResp, clearMenuCache, deleteMenu, listMenu } from '@/apis/system/menu'
|
||||
import { type MenuQuery, type MenuResp, clearMenuCache, deleteMenu, listMenu } from '@/apis/system/menu'
|
||||
import type GiTable from '@/components/GiTable/index.vue'
|
||||
import { useTable } from '@/hooks'
|
||||
import { isMobile } from '@/utils'
|
||||
@@ -106,23 +100,21 @@ import has from '@/utils/has'
|
||||
|
||||
defineOptions({ name: 'SystemMenu' })
|
||||
|
||||
const queryForm = reactive<MenuQuery>({})
|
||||
|
||||
const {
|
||||
tableData,
|
||||
loading,
|
||||
search,
|
||||
handleDelete,
|
||||
} = useTable(() => listMenu(), { immediate: true })
|
||||
} = useTable(() => listMenu(queryForm), { immediate: true })
|
||||
|
||||
// 过滤树
|
||||
const searchData = (title: string, path: string, permission: string) => {
|
||||
const searchData = (title: string) => {
|
||||
const loop = (data: MenuResp[]) => {
|
||||
const result = [] as MenuResp[]
|
||||
data.forEach((item: MenuResp) => {
|
||||
if (
|
||||
(!title || item.title?.toLowerCase().includes(title.toLowerCase()))
|
||||
&& (!path || item.path?.toLowerCase().includes(path.toLowerCase()))
|
||||
&& (!permission || item.permission?.toLowerCase().includes(permission.toLowerCase()))
|
||||
) {
|
||||
if (item.title?.toLowerCase().includes(title.toLowerCase())) {
|
||||
result.push({ ...item })
|
||||
} else if (item.children) {
|
||||
const filterData = loop(item.children)
|
||||
@@ -140,11 +132,9 @@ const searchData = (title: string, path: string, permission: string) => {
|
||||
}
|
||||
|
||||
const title = ref('')
|
||||
const path = ref('')
|
||||
const permission = ref('')
|
||||
const dataList = computed(() => {
|
||||
if (!title.value && !path.value && !permission.value) return tableData.value
|
||||
return searchData(title.value, path.value, permission.value)
|
||||
if (!title.value) return tableData.value
|
||||
return searchData(title.value)
|
||||
})
|
||||
|
||||
const columns: TableInstance['columns'] = [
|
||||
|
||||
@@ -75,7 +75,7 @@ import { Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import AiEditor from './components/index.vue'
|
||||
import { addNotice, getNotice, updateNotice } from '@/apis/system/notice'
|
||||
import { listUserDict } from '@/apis/system'
|
||||
import { listUserDict } from '@/apis'
|
||||
import { type ColumnItem, GiForm } from '@/components/GiForm'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
import { useTabsStore } from '@/stores'
|
||||
@@ -207,8 +207,8 @@ const onUpdate = async (id: string) => {
|
||||
|
||||
// 返回
|
||||
const onBack = () => {
|
||||
router.back()
|
||||
tabsStore.closeCurrent(route.path)
|
||||
router.push('/system/notice')
|
||||
}
|
||||
|
||||
// 保存
|
||||
|
||||
@@ -52,8 +52,8 @@ const content = computed(() => dataDetail.value?.content)
|
||||
|
||||
// 回退
|
||||
const onBack = () => {
|
||||
router.back()
|
||||
tabsStore.closeCurrent(route.path)
|
||||
router.push('/system/notice')
|
||||
}
|
||||
|
||||
// 打开
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
|
||||
:pagination="false"
|
||||
:disabled-tools="['fullscreen', 'size', 'setting']"
|
||||
:row-selection="disabled ? false : { type: 'checkbox', showCheckedAll: showCheckedAll && !disabled, selectRowKeys: selectedKeys }"
|
||||
:row-selection="{ type: 'checkbox', showCheckedAll, selectRowKeys: selectedKeys }"
|
||||
@select="select"
|
||||
@select-all="selectAll"
|
||||
@refresh="refresh"
|
||||
@@ -44,7 +44,7 @@
|
||||
</template>
|
||||
<template #permissions="{ record }">
|
||||
<div v-if="record.permissions && record.permissions.length > 0">
|
||||
<a-checkbox-group v-model="record.checkedPermissions" :disabled="disabled || record.disabled" @change="selectPermission(record)">
|
||||
<a-checkbox-group v-model="record.checkedPermissions" :disabled="disabled" @change="selectPermission(record)">
|
||||
<a-checkbox v-for="permission in record.permissions" :key="permission.id" :value="permission.id">
|
||||
{{ permission.title }}
|
||||
</a-checkbox>
|
||||
@@ -55,12 +55,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { nextTick, ref, watch } from 'vue'
|
||||
import { Message, type TableInstance, type TreeNodeData } from '@arco-design/web-vue'
|
||||
import { nextTick, ref } from 'vue'
|
||||
import { Message, type TableInstance } from '@arco-design/web-vue'
|
||||
import { type MenuResp, listMenu } from '@/apis/system/menu'
|
||||
import { isMobile } from '@/utils'
|
||||
import type GiTable from '@/components/GiTable/index.vue'
|
||||
import { useTable } from '@/hooks'
|
||||
import { type RolePermissionResp, getRole, listRolePermissionTree, updateRolePermission } from '@/apis/system/role'
|
||||
import { getRole, updateRolePermission } from '@/apis'
|
||||
import has from '@/utils/has'
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
@@ -71,12 +72,6 @@ interface Props {
|
||||
roleId: string
|
||||
}
|
||||
|
||||
interface ExtendedRolePermissionResp extends RolePermissionResp {
|
||||
checkedPermissions?: (string | number)[]
|
||||
isChecked?: boolean
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
const tableRef = ref<InstanceType<typeof GiTable>>()
|
||||
// 是否父子联动
|
||||
const isCascade = ref(true)
|
||||
@@ -95,26 +90,25 @@ const onExpanded = () => {
|
||||
*
|
||||
* @param menus 菜单数据
|
||||
*/
|
||||
const transformMenu = (menus: RolePermissionResp[]): ExtendedRolePermissionResp[] => {
|
||||
return menus.map((item): ExtendedRolePermissionResp => {
|
||||
const transformMenu = (menus: MenuResp[]) => {
|
||||
return menus.map((item) => {
|
||||
// 如果当前项有子项,递归处理子项
|
||||
if (item.children && item.children.length > 0) {
|
||||
// 过滤出 permission 不为空的子项
|
||||
const permissions = item.children.filter((child) => child.permission).map((child): RolePermissionResp => ({
|
||||
// 过滤出 type 为 3 的按钮权限
|
||||
const permissions = item.children.filter((child) => child.type === 3 || child.permission).map((child) => ({
|
||||
id: child.id,
|
||||
title: child.title,
|
||||
parentId: child.parentId,
|
||||
permission: child.permission,
|
||||
isChecked: false,
|
||||
}))
|
||||
|
||||
// 过滤出 permission 为空的子项
|
||||
item.children = item.children.filter((child) => !child.permission)
|
||||
// 过滤出 type 不为 3 的子项
|
||||
item.children = item.children.filter((child) => child.type !== 3 && !child.permission)
|
||||
|
||||
// 如果有权限,将其添加到当前项的 permissions 属性中
|
||||
if (permissions.length > 0) {
|
||||
(item as ExtendedRolePermissionResp).permissions = permissions
|
||||
;(item as ExtendedRolePermissionResp).checkedPermissions = permissions.filter((permission) => permission.isChecked).map((permission) => permission.id)
|
||||
item.permissions = permissions
|
||||
item.checkedPermissions = permissions.filter((permission) => permission.isChecked)
|
||||
}
|
||||
|
||||
// 递归处理剩余的子项
|
||||
@@ -131,194 +125,136 @@ const transformMenu = (menus: RolePermissionResp[]): ExtendedRolePermissionResp[
|
||||
}
|
||||
|
||||
// 更新表格数据的选中状态
|
||||
const updateTableDataCheckedStatus = (data: ExtendedRolePermissionResp[], selectedKeys: (string | number)[]) => {
|
||||
const updateTableDataCheckedStatus = (data: MenuResp[], selectedKeys: (string | number)[]) => {
|
||||
data.forEach((item) => {
|
||||
item.disabled = disabled.value
|
||||
// 设置菜单项的选中状态
|
||||
item.isChecked = selectedKeys.includes(item.id)
|
||||
// 设置权限的选中状态
|
||||
if (item.permissions) {
|
||||
item.permissions.forEach((permission) => {
|
||||
permission.isChecked = selectedKeys.includes(permission.id)
|
||||
})
|
||||
item.checkedPermissions = item.permissions
|
||||
.filter((permission) => selectedKeys.includes(permission.id))
|
||||
.map((permission) => permission.id)
|
||||
}
|
||||
// 递归处理子菜单
|
||||
if (item.children) {
|
||||
updateTableDataCheckedStatus(item.children as ExtendedRolePermissionResp[], selectedKeys)
|
||||
updateTableDataCheckedStatus(item.children, selectedKeys)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 查找指定菜单 - 使用 Map 缓存优化查找性能
|
||||
const menuMap = ref<Map<string | number, ExtendedRolePermissionResp>>(new Map())
|
||||
|
||||
// 构建菜单映射缓存
|
||||
const buildMenuMap = (data: ExtendedRolePermissionResp[]) => {
|
||||
const map = new Map<string | number, ExtendedRolePermissionResp>()
|
||||
|
||||
const traverse = (items: ExtendedRolePermissionResp[]) => {
|
||||
items.forEach((item) => {
|
||||
map.set(item.id, item)
|
||||
if (item.children?.length) {
|
||||
traverse(item.children as ExtendedRolePermissionResp[])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
traverse(data)
|
||||
menuMap.value = map
|
||||
}
|
||||
|
||||
const selectedKeys = ref<Set<string | number>>(new Set())
|
||||
|
||||
const {
|
||||
tableData,
|
||||
loading,
|
||||
search,
|
||||
} = useTable(() => listRolePermissionTree(), {
|
||||
} = useTable(() => listMenu(), {
|
||||
immediate: true,
|
||||
formatResult(data: TreeNodeData[]) {
|
||||
formatResult(data) {
|
||||
return transformMenu(data)
|
||||
},
|
||||
onSuccess: () => {
|
||||
nextTick(() => {
|
||||
tableRef.value?.tableRef?.expandAll(true)
|
||||
})
|
||||
// 构建菜单映射缓存
|
||||
buildMenuMap(tableData.value as ExtendedRolePermissionResp[])
|
||||
// 初始加载时应用已选中的权限
|
||||
if (selectedKeys.value.size > 0) {
|
||||
updateTableDataCheckedStatus(tableData.value as ExtendedRolePermissionResp[], Array.from(selectedKeys.value))
|
||||
updateTableDataCheckedStatus(tableData.value, Array.from(selectedKeys.value))
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const columns: TableInstance['columns'] = [
|
||||
{ title: '菜单', dataIndex: 'title', slotName: 'title', width: 170, ellipsis: true, tooltip: true, fixed: !isMobile() ? 'left' : undefined },
|
||||
{ title: '菜单', dataIndex: 'title', slotName: 'title', width: 170, fixed: !isMobile() ? 'left' : undefined },
|
||||
{ title: '权限', dataIndex: 'permissions', slotName: 'permissions' },
|
||||
]
|
||||
|
||||
// 级联选中子项
|
||||
const cascadeSelectChild = (record: ExtendedRolePermissionResp, isCascade: boolean) => {
|
||||
if (!isCascade) return
|
||||
|
||||
// 批量处理子菜单
|
||||
if (record.children && record.children.length > 0) {
|
||||
const cascadeSelectChild = (record: MenuResp, isCascade: boolean) => {
|
||||
if (isCascade && record.children && record.children.length > 0) {
|
||||
record.children.forEach((child) => {
|
||||
const extendedChild = child as ExtendedRolePermissionResp
|
||||
extendedChild.isChecked = record.isChecked
|
||||
tableRef.value?.tableRef?.select(child.id, extendedChild.isChecked)
|
||||
|
||||
// 使用批量操作优化性能
|
||||
if (extendedChild.isChecked) {
|
||||
selectedKeys.value.add(child.id)
|
||||
} else {
|
||||
selectedKeys.value.delete(child.id)
|
||||
}
|
||||
|
||||
// 递归处理子项
|
||||
if (child.children?.length || extendedChild.permissions?.length) {
|
||||
cascadeSelectChild(extendedChild, isCascade)
|
||||
child.isChecked = record.isChecked
|
||||
tableRef.value?.tableRef?.select(child.id, child.isChecked)
|
||||
child.isChecked
|
||||
? selectedKeys.value.add(child.id)
|
||||
: selectedKeys.value.delete(child.id)
|
||||
if ((child.children && child.children.length > 0) || (child.permissions && child.permissions.length > 0)) {
|
||||
cascadeSelectChild(child, isCascade)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 批量处理权限
|
||||
if (record.permissions && record.permissions.length > 0) {
|
||||
const checkedPermissions: (string | number)[] = []
|
||||
// 递归选中权限
|
||||
if (isCascade && record.permissions && record.permissions.length > 0) {
|
||||
record.permissions.forEach((permission) => {
|
||||
permission.isChecked = record.isChecked
|
||||
if (permission.isChecked) {
|
||||
selectedKeys.value.add(permission.id)
|
||||
checkedPermissions.push(permission.id)
|
||||
} else {
|
||||
selectedKeys.value.delete(permission.id)
|
||||
}
|
||||
permission.isChecked
|
||||
? selectedKeys.value.add(permission.id)
|
||||
: selectedKeys.value.delete(permission.id)
|
||||
})
|
||||
record.checkedPermissions = checkedPermissions
|
||||
record.checkedPermissions = record.permissions.filter((permission) => permission.isChecked).map((permission) => permission.id)
|
||||
}
|
||||
}
|
||||
|
||||
// 查找指定菜单
|
||||
const findItem = (id: string | number): ExtendedRolePermissionResp | null => {
|
||||
return menuMap.value.get(id) || null
|
||||
const findItem = (id: string, data: MenuResp[]) => {
|
||||
for (const item of data) {
|
||||
if (item.id === id) return item
|
||||
if (item.children?.length) {
|
||||
const found = findItem(id, item.children)
|
||||
if (found) return found
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// 级联选中父项目
|
||||
const cascadeSelectParent = (record: ExtendedRolePermissionResp, isCascade: boolean) => {
|
||||
if (!isCascade || !record.parentId || record.parentId === '0') return
|
||||
|
||||
const parent = findItem(record.parentId)
|
||||
if (!parent) return
|
||||
|
||||
// 检查父项目的所有子项是否有被选中的
|
||||
const hasCheckedChildren = parent.children?.some((child) => (child as ExtendedRolePermissionResp).isChecked)
|
||||
parent.isChecked = hasCheckedChildren || false
|
||||
|
||||
// 更新表格选中状态
|
||||
tableRef.value?.tableRef?.select(parent.id, parent.isChecked)
|
||||
|
||||
// 更新选中键集合
|
||||
if (parent.isChecked) {
|
||||
selectedKeys.value.add(parent.id)
|
||||
} else {
|
||||
selectedKeys.value.delete(parent.id)
|
||||
}
|
||||
|
||||
// 递归处理父级的父级
|
||||
if (parent.parentId && parent.parentId !== '0') {
|
||||
cascadeSelectParent(parent, isCascade)
|
||||
const cascadeSelectParent = (record: MenuResp, isCascade: boolean) => {
|
||||
if (isCascade && record.parentId && record.parentId !== '0') {
|
||||
const parent = findItem(record.parentId, tableData.value)
|
||||
if (parent) {
|
||||
// 如果父项目的某个子项被选中了,它就依然保持选中状态
|
||||
parent.isChecked = parent.children?.some((child) => child.isChecked)
|
||||
tableRef.value?.tableRef?.select(parent.id, parent.isChecked)
|
||||
if (!parent.isChecked && !record.isChecked) {
|
||||
selectedKeys.value.delete(parent.id)
|
||||
} else {
|
||||
selectedKeys.value.add(parent.id)
|
||||
}
|
||||
if (parent.parentId && parent.parentId !== 0) {
|
||||
cascadeSelectParent(parent, isCascade)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 选中
|
||||
const select: TableInstance['onSelect'] = (rowKeys, checked, record) => {
|
||||
const extendedRecord = record as ExtendedRolePermissionResp
|
||||
|
||||
// 如果处于禁用状态,直接返回,不执行任何逻辑
|
||||
if (disabled.value || extendedRecord.disabled) {
|
||||
return
|
||||
}
|
||||
|
||||
const isChecked = rowKeys.includes(checked)
|
||||
isChecked
|
||||
? selectedKeys.value.add(extendedRecord.id)
|
||||
: selectedKeys.value.delete(extendedRecord.id)
|
||||
extendedRecord.isChecked = isChecked
|
||||
? selectedKeys.value.add(record.id)
|
||||
: selectedKeys.value.delete(record.id)
|
||||
record.isChecked = isChecked
|
||||
// 级联选中子项
|
||||
cascadeSelectChild(extendedRecord, isCascade.value)
|
||||
cascadeSelectChild(record, isCascade.value)
|
||||
// 级联选中父项
|
||||
cascadeSelectParent(extendedRecord, isCascade.value)
|
||||
cascadeSelectParent(record, isCascade.value)
|
||||
}
|
||||
|
||||
// 全选
|
||||
const selectAll: TableInstance['onSelectAll'] = (checked) => {
|
||||
// 如果处于禁用状态,直接返回,不执行任何逻辑
|
||||
if (disabled.value) {
|
||||
return
|
||||
}
|
||||
|
||||
tableData.value.forEach((item) => {
|
||||
const extendedItem = item as ExtendedRolePermissionResp
|
||||
extendedItem.isChecked = checked
|
||||
item.isChecked = checked
|
||||
checked
|
||||
? selectedKeys.value.add(item.id)
|
||||
: selectedKeys.value.delete(item.id)
|
||||
cascadeSelectChild(extendedItem, true)
|
||||
? selectedKeys.value.add(item.id)
|
||||
: selectedKeys.value.delete(item.id)
|
||||
cascadeSelectChild(item, true)
|
||||
})
|
||||
}
|
||||
|
||||
// 选中权限
|
||||
const selectPermission = (record: ExtendedRolePermissionResp) => {
|
||||
// 如果处于禁用状态,直接返回,不执行任何逻辑
|
||||
if (disabled.value || record.disabled) {
|
||||
return
|
||||
}
|
||||
|
||||
const checkPermissions = record.checkedPermissions || []
|
||||
const selectPermission = (record) => {
|
||||
const checkPermissions = record.checkedPermissions
|
||||
// 取消选中
|
||||
if (checkPermissions.length === 0) {
|
||||
if (isCascade.value) {
|
||||
@@ -327,7 +263,7 @@ const selectPermission = (record: ExtendedRolePermissionResp) => {
|
||||
tableRef.value?.tableRef?.select(record.id, record.isChecked)
|
||||
cascadeSelectParent(record, isCascade.value)
|
||||
}
|
||||
record.permissions?.forEach((permission) => {
|
||||
record.permissions.forEach((permission) => {
|
||||
permission.isChecked = false
|
||||
selectedKeys.value.delete(permission.id)
|
||||
})
|
||||
@@ -341,7 +277,7 @@ const selectPermission = (record: ExtendedRolePermissionResp) => {
|
||||
tableRef.value?.tableRef?.select(record.id, record.isChecked)
|
||||
cascadeSelectParent(record, isCascade.value)
|
||||
}
|
||||
record.permissions?.forEach((permission) => {
|
||||
record.permissions.forEach((permission) => {
|
||||
permission.isChecked = checkPermissions.includes(permission.id)
|
||||
permission.isChecked
|
||||
? selectedKeys.value.add(permission.id)
|
||||
@@ -368,15 +304,13 @@ const fetchRole = async (id: string) => {
|
||||
// 查询角色详情
|
||||
const { data } = await getRole(id)
|
||||
if (!disabled.value) {
|
||||
disabled.value = data.isSystem
|
||||
disabled.value = data.isSystem && data.code === 'admin'
|
||||
}
|
||||
isCascade.value = data.menuCheckStrictly
|
||||
// 更新选中键集合
|
||||
selectedKeys.value = new Set(data.menuIds)
|
||||
// 重新构建菜单映射缓存
|
||||
buildMenuMap(tableData.value as ExtendedRolePermissionResp[])
|
||||
// 更新表格数据的选中状态
|
||||
updateTableDataCheckedStatus(tableData.value as ExtendedRolePermissionResp[], data.menuIds)
|
||||
updateTableDataCheckedStatus(tableData.value, data.menuIds)
|
||||
// 手动设置表格行的选中状态,确保组件响应
|
||||
await nextTick(() => {
|
||||
tableRef.value?.tableRef?.selectAll(false)
|
||||
@@ -391,9 +325,7 @@ const fetchRole = async (id: string) => {
|
||||
// 刷新
|
||||
const refresh = () => {
|
||||
search()
|
||||
if (props.roleId) {
|
||||
fetchRole(props.roleId)
|
||||
}
|
||||
fetchRole(props.roleId)
|
||||
}
|
||||
|
||||
// 监听 roleId 的变化
|
||||
|
||||
@@ -43,16 +43,6 @@ const [form, resetForm] = useResetReactive({
|
||||
})
|
||||
|
||||
const columns: ColumnItem[] = reactive([
|
||||
{
|
||||
label: '昵称',
|
||||
field: 'nickname',
|
||||
type: 'input',
|
||||
span: 24,
|
||||
required: true,
|
||||
props: {
|
||||
maxLength: 30,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '用户名',
|
||||
field: 'username',
|
||||
@@ -63,6 +53,16 @@ const columns: ColumnItem[] = reactive([
|
||||
maxLength: 64,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '昵称',
|
||||
field: 'nickname',
|
||||
type: 'input',
|
||||
span: 24,
|
||||
required: true,
|
||||
props: {
|
||||
maxLength: 30,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '密码',
|
||||
field: 'password',
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
</a-button>
|
||||
<template #content>
|
||||
<a-doption v-permission="['system:user:resetPwd']" title="重置密码" @click="onResetPwd(record)">重置密码</a-doption>
|
||||
<a-doption v-permission="['system:user:updateRole']" :disabled="record.isSystem" title="分配角色" @click="onUpdateRole(record)">分配角色</a-doption>
|
||||
<a-doption v-permission="['system:user:updateRole']" title="分配角色" @click="onUpdateRole(record)">分配角色</a-doption>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</a-space>
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
<template>
|
||||
<a-modal
|
||||
v-model:visible="visible"
|
||||
:title="title"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:width="width >= 500 ? 500 : '100%'"
|
||||
draggable
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
<GiForm ref="formRef" v-model="form" :columns="columns" />
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { addTenant, getTenant, updateTenant } from '@/apis/tenant/management'
|
||||
import { type ColumnItem, GiForm } from '@/components/GiForm'
|
||||
import { useResetReactive } from '@/hooks'
|
||||
import { encryptByRsa } from '@/utils/encrypt'
|
||||
import { listTenantPackageDict } from '@/apis/tenant'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'save-success'): void
|
||||
}>()
|
||||
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const dataId = ref('')
|
||||
const visible = ref(false)
|
||||
const isUpdate = computed(() => !!dataId.value)
|
||||
const title = computed(() => (isUpdate.value ? '修改租户' : '新增租户'))
|
||||
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||
|
||||
const packageList = ref<LabelValueState[]>([])
|
||||
// 查询租户套餐
|
||||
const getPackageList = async () => {
|
||||
const { data } = await listTenantPackageDict()
|
||||
packageList.value = data
|
||||
}
|
||||
|
||||
const [form, resetForm] = useResetReactive({
|
||||
status: 1,
|
||||
})
|
||||
|
||||
const columns: ColumnItem[] = reactive([
|
||||
{
|
||||
label: '名称',
|
||||
field: 'name',
|
||||
type: 'input',
|
||||
span: 24,
|
||||
required: true,
|
||||
props: {
|
||||
maxLength: 30,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: () => (
|
||||
<a-tooltip content="例如:example.com">
|
||||
域名
|
||||
<icon-question-circle />
|
||||
</a-tooltip>
|
||||
),
|
||||
field: 'domain',
|
||||
type: 'input',
|
||||
span: 24,
|
||||
slots: {
|
||||
prepend: () => (
|
||||
<span style={{ textAlign: 'center' }}>http(s)://</span>
|
||||
),
|
||||
},
|
||||
props: {
|
||||
placeholder: '请输入域名',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '过期时间',
|
||||
field: 'expireTime',
|
||||
type: 'date-picker',
|
||||
span: 24,
|
||||
props: {
|
||||
showTime: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: () => (
|
||||
<a-tooltip content="自动初始化管理员用户">
|
||||
管理员用户
|
||||
<icon-question-circle />
|
||||
</a-tooltip>
|
||||
),
|
||||
field: 'adminUsername',
|
||||
type: 'input',
|
||||
span: 24,
|
||||
required: true,
|
||||
props: {
|
||||
placeholder: '请输入管理员用户',
|
||||
maxLength: 64,
|
||||
},
|
||||
hide: () => {
|
||||
return isUpdate.value
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '管理员密码',
|
||||
field: 'adminPassword',
|
||||
type: 'input-password',
|
||||
span: 24,
|
||||
required: true,
|
||||
props: {
|
||||
maxLength: 32,
|
||||
},
|
||||
hide: () => {
|
||||
return isUpdate.value
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '套餐',
|
||||
field: 'packageId',
|
||||
type: 'select',
|
||||
span: 24,
|
||||
required: true,
|
||||
hide: () => {
|
||||
return isUpdate.value
|
||||
},
|
||||
props: {
|
||||
options: packageList,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '描述',
|
||||
field: 'description',
|
||||
type: 'textarea',
|
||||
span: 24,
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'status',
|
||||
type: 'switch',
|
||||
span: 24,
|
||||
props: {
|
||||
type: 'round',
|
||||
checkedValue: 1,
|
||||
uncheckedValue: 2,
|
||||
checkedText: '启用',
|
||||
uncheckedText: '禁用',
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
resetForm()
|
||||
getPackageList()
|
||||
}
|
||||
|
||||
// 保存
|
||||
const save = async () => {
|
||||
try {
|
||||
const isInvalid = await formRef.value?.formRef?.validate()
|
||||
if (isInvalid) return false
|
||||
if (isUpdate.value) {
|
||||
await updateTenant(form, dataId.value)
|
||||
Message.success('修改成功')
|
||||
} else {
|
||||
await addTenant({
|
||||
...form,
|
||||
adminPassword: encryptByRsa(form.adminPassword),
|
||||
})
|
||||
Message.success('新增成功')
|
||||
}
|
||||
emit('save-success')
|
||||
return true
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 新增
|
||||
const onAdd = async () => {
|
||||
reset()
|
||||
dataId.value = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = async (id: string) => {
|
||||
reset()
|
||||
dataId.value = id
|
||||
const { data } = await getTenant(id)
|
||||
Object.assign(form, data)
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ onAdd, onUpdate })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -1,82 +0,0 @@
|
||||
<template>
|
||||
<a-modal
|
||||
v-model:visible="visible"
|
||||
title="修改租户管理员密码"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:width="width >= 500 ? 500 : '100%'"
|
||||
draggable
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
<GiForm ref="formRef" v-model="form" :columns="columns" />
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { updateTenantAdminUserPwd } from '@/apis/tenant/management'
|
||||
import { type ColumnItem, GiForm } from '@/components/GiForm'
|
||||
import { useResetReactive } from '@/hooks'
|
||||
import { encryptByRsa } from '@/utils/encrypt'
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'save-success'): void
|
||||
}>()
|
||||
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const dataId = ref('')
|
||||
const visible = ref(false)
|
||||
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||
|
||||
const [form, resetForm] = useResetReactive({
|
||||
password: undefined,
|
||||
})
|
||||
|
||||
const columns: ColumnItem[] = reactive([
|
||||
{
|
||||
label: '新密码',
|
||||
field: 'password',
|
||||
type: 'input-password',
|
||||
span: 24,
|
||||
required: true,
|
||||
props: {
|
||||
maxLength: 32,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
resetForm()
|
||||
}
|
||||
|
||||
// 保存
|
||||
const save = async () => {
|
||||
try {
|
||||
const isInvalid = await formRef.value?.formRef?.validate()
|
||||
if (isInvalid) return false
|
||||
await updateTenantAdminUserPwd({
|
||||
password: encryptByRsa(form.password) || '',
|
||||
}, dataId.value)
|
||||
Message.success('修改成功')
|
||||
emit('save-success')
|
||||
return true
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const open = async (id: string) => {
|
||||
reset()
|
||||
dataId.value = id
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -1,67 +0,0 @@
|
||||
<template>
|
||||
<a-drawer v-model:visible="visible" title="租户详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
|
||||
<a-descriptions :column="2" size="large" class="general-description">
|
||||
<a-descriptions-item label="ID">
|
||||
<a-typography-paragraph copyable>{{ dataDetail?.id }}</a-typography-paragraph>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="编码">
|
||||
<a-typography-paragraph copyable>{{ dataDetail?.code }}</a-typography-paragraph>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="名称">{{ dataDetail?.name }}</a-descriptions-item>
|
||||
<a-descriptions-item label="套餐">{{ dataDetail?.packageName }}</a-descriptions-item>
|
||||
<a-descriptions-item label="域名">
|
||||
<a v-if="dataDetail?.domain" style="color: rgb(var(--arcoblue-7))">{{ dataDetail?.domain }}</a>
|
||||
<span v-else style="color: red" class="text-red-4">未设置</span>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="过期时间">
|
||||
<span v-if="!dataDetail?.expireTime">
|
||||
<span>永不过期</span>
|
||||
</span>
|
||||
<span v-else>{{ dataDetail?.expireTime }}</span>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="管理员用户">{{ dataDetail?.adminUsername }}</a-descriptions-item>
|
||||
<a-descriptions-item label="状态">
|
||||
<a-tag v-if="dataDetail?.status === 1" color="green">启用</a-tag>
|
||||
<a-tag v-else color="red">禁用</a-tag>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="创建人">{{ dataDetail?.createUserString }}</a-descriptions-item>
|
||||
<a-descriptions-item label="创建时间">{{ dataDetail?.createTime }}</a-descriptions-item>
|
||||
<a-descriptions-item label="修改人">{{ dataDetail?.updateUserString }}</a-descriptions-item>
|
||||
<a-descriptions-item label="修改时间">{{ dataDetail?.updateTime }}</a-descriptions-item>
|
||||
<a-descriptions-item label="描述" :span="2">{{ dataDetail?.description }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { type TenantResp, getTenant as getDetail } from '@/apis/tenant/management'
|
||||
import { useMenu } from '@/hooks/app'
|
||||
|
||||
const { menuList, getTenantPackageMenuList } = useMenu()
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const dataId = ref('')
|
||||
const dataDetail = ref<TenantResp>()
|
||||
const visible = ref(false)
|
||||
|
||||
// 查询详情
|
||||
const getDataDetail = async () => {
|
||||
const { data } = await getDetail(dataId.value)
|
||||
dataDetail.value = data
|
||||
}
|
||||
|
||||
// 打开
|
||||
const onOpen = async (id: string) => {
|
||||
dataId.value = id
|
||||
if (!menuList.value.length) {
|
||||
await getTenantPackageMenuList()
|
||||
}
|
||||
await getDataDetail()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ onOpen })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -1,194 +0,0 @@
|
||||
<template>
|
||||
<GiPageLayout>
|
||||
<GiTable
|
||||
row-key="id"
|
||||
:data="dataList"
|
||||
:columns="columns"
|
||||
:loading="loading"
|
||||
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
|
||||
:pagination="pagination"
|
||||
:disabled-tools="['size']"
|
||||
:disabled-column-keys="['name']"
|
||||
@refresh="search"
|
||||
>
|
||||
<template #toolbar-left>
|
||||
<a-input-search v-model="queryForm.description" placeholder="搜索名称/描述" allow-clear @search="search" />
|
||||
<a-select
|
||||
v-model="queryForm.packageId"
|
||||
:options="packageList"
|
||||
placeholder="请选择套餐"
|
||||
style="width: 200px"
|
||||
allow-clear
|
||||
@change="search"
|
||||
/>
|
||||
<a-button @click="reset">
|
||||
<template #icon><icon-refresh /></template>
|
||||
<template #default>重置</template>
|
||||
</a-button>
|
||||
</template>
|
||||
<template #toolbar-right>
|
||||
<a-button v-permission="['tenant:management:create']" type="primary" @click="onAdd">
|
||||
<template #icon><icon-plus /></template>
|
||||
<template #default>新增</template>
|
||||
</a-button>
|
||||
</template>
|
||||
|
||||
<template #code="{ record }">
|
||||
<CellCopy :content="record.code" />
|
||||
</template>
|
||||
<template #status="{ record }">
|
||||
<GiCellStatus :status="record.status" />
|
||||
</template>
|
||||
<template #expireTime="{ record }">
|
||||
<span v-if="!record.expireTime">
|
||||
<span>永不过期</span>
|
||||
</span>
|
||||
<span v-else>{{ record.expireTime }}</span>
|
||||
</template>
|
||||
<template #domain="{ record }">
|
||||
<a v-if="record.domain" style="color: rgb(var(--arcoblue-7))" :href="record.domain">{{ record.domain }}</a>
|
||||
<span v-else style="color: red" class="text-red-4">未设置</span>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
<a-link v-permission="['tenant:management:get']" title="详情" @click="onDetail(record)">详情</a-link>
|
||||
<a-link v-permission="['tenant:management:update']" title="修改" @click="onUpdate(record)">修改</a-link>
|
||||
<a-dropdown>
|
||||
<a-button v-if="has.hasPermOr(['tenant:management:updateAdminUserPwd', 'tenant:management:delete'])" type="text" size="mini" title="更多">
|
||||
<template #icon>
|
||||
<icon-more :size="16" />
|
||||
</template>
|
||||
</a-button>
|
||||
<template #content>
|
||||
<a-doption v-permission="['tenant:management:updateAdminUserPwd']" title="修改管理员密码" @click="onUpdateAdminUserPwd(record)">修改管理员密码</a-doption>
|
||||
<a-doption
|
||||
v-permission="['tenant:management:delete']"
|
||||
:disabled="record.disabled"
|
||||
:title="record.disabled ? '禁止删除' : '删除'"
|
||||
@click="onDelete(record)"
|
||||
>
|
||||
删除
|
||||
</a-doption>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</a-space>
|
||||
</template>
|
||||
</GiTable>
|
||||
|
||||
<AddModal ref="AddModalRef" @save-success="search" />
|
||||
<DetailDrawer ref="DetailDrawerRef" />
|
||||
<AdminUserPwdUpdateModal ref="AdminUserPwdUpdateModalRef" @save-success="search" />
|
||||
</GiPageLayout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { TableInstance } from '@arco-design/web-vue'
|
||||
import AddModal from './AddModal.vue'
|
||||
import AdminUserPwdUpdateModal from './AdminUserPwdUpdateModal.vue'
|
||||
import DetailDrawer from './DetailDrawer.vue'
|
||||
import { type TenantQuery, type TenantResp, deleteTenant, listTenant } from '@/apis/tenant/management'
|
||||
import { useTable } from '@/hooks'
|
||||
import { isMobile } from '@/utils'
|
||||
import has from '@/utils/has'
|
||||
import { listTenantPackageDict } from '@/apis/tenant'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
defineOptions({ name: 'TenantManagement' })
|
||||
|
||||
const queryForm = reactive<TenantQuery>({
|
||||
description: undefined,
|
||||
packageId: undefined,
|
||||
status: undefined,
|
||||
sort: ['createTime,desc'],
|
||||
})
|
||||
|
||||
const {
|
||||
tableData: dataList,
|
||||
loading,
|
||||
pagination,
|
||||
search,
|
||||
handleDelete,
|
||||
} = useTable((page) => listTenant({ ...queryForm, ...page }), { immediate: true })
|
||||
const columns: TableInstance['columns'] = [
|
||||
{
|
||||
title: '序号',
|
||||
width: 66,
|
||||
align: 'center',
|
||||
render: ({ rowIndex }) => h('span', {}, rowIndex + 1 + (pagination.current - 1) * pagination.pageSize),
|
||||
fixed: !isMobile() ? 'left' : undefined,
|
||||
},
|
||||
{ title: '编码', dataIndex: 'code', slotName: 'code', width: 150 },
|
||||
{ title: '名称', dataIndex: 'name', slotName: 'name', ellipsis: true, tooltip: true },
|
||||
{ title: '套餐', dataIndex: 'packageName', slotName: 'packageName' },
|
||||
{ title: '域名', dataIndex: 'domain', slotName: 'domain', ellipsis: true, tooltip: true },
|
||||
{ title: '过期时间', dataIndex: 'expireTime', slotName: 'expireTime', width: 180 },
|
||||
{ title: '管理员用户', dataIndex: 'adminUsername', slotName: 'adminUsername', ellipsis: true, tooltip: true },
|
||||
{ title: '状态', dataIndex: 'status', slotName: 'status' },
|
||||
{ title: '描述', dataIndex: 'description', ellipsis: true, tooltip: true },
|
||||
{ title: '创建人', dataIndex: 'createUserString', ellipsis: true, tooltip: true, show: false },
|
||||
{ title: '创建时间', dataIndex: 'createTime', width: 180 },
|
||||
{ title: '修改人', dataIndex: 'updateUserString', ellipsis: true, tooltip: true, show: false },
|
||||
{ title: '修改时间', dataIndex: 'updateTime', width: 180, show: false },
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
slotName: 'action',
|
||||
width: 160,
|
||||
align: 'center',
|
||||
fixed: !isMobile() ? 'right' : undefined,
|
||||
show: has.hasPermOr(['tenant:management:get', 'tenant:management:update', 'tenant:management:delete', 'tenant:management:updateAdminUserPwd']),
|
||||
},
|
||||
]
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
queryForm.description = undefined
|
||||
queryForm.packageId = undefined
|
||||
queryForm.status = undefined
|
||||
search()
|
||||
}
|
||||
|
||||
// 删除
|
||||
const onDelete = (record: TenantResp) => {
|
||||
return handleDelete(() => deleteTenant(record.id), {
|
||||
content: `是否确定删除租户「${record.name}(${record.code})」?`,
|
||||
showModal: true,
|
||||
})
|
||||
}
|
||||
|
||||
const AddModalRef = ref<InstanceType<typeof AddModal>>()
|
||||
// 新增
|
||||
const onAdd = () => {
|
||||
AddModalRef.value?.onAdd()
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = (record: TenantResp) => {
|
||||
AddModalRef.value?.onUpdate(record.id)
|
||||
}
|
||||
|
||||
const DetailDrawerRef = ref<InstanceType<typeof DetailDrawer>>()
|
||||
// 详情
|
||||
const onDetail = (record: TenantResp) => {
|
||||
DetailDrawerRef.value?.onOpen(record.id)
|
||||
}
|
||||
|
||||
const AdminUserPwdUpdateModalRef = ref<InstanceType<typeof AdminUserPwdUpdateModal>>()
|
||||
// 修改管理员密码
|
||||
const onUpdateAdminUserPwd = (record: TenantResp) => {
|
||||
AdminUserPwdUpdateModalRef.value?.open(record.id)
|
||||
}
|
||||
|
||||
const packageList = ref<LabelValueState[]>([])
|
||||
// 查询套餐列表
|
||||
const getPackageList = async () => {
|
||||
const { data } = await listTenantPackageDict()
|
||||
packageList.value = data
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getPackageList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -1,170 +0,0 @@
|
||||
<template>
|
||||
<a-modal
|
||||
v-model:visible="visible"
|
||||
:title="title"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:width="width >= 500 ? 500 : '100%'"
|
||||
draggable
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
<a-form ref="formRef" :model="form" :rules="rules" auto-label-width size="large">
|
||||
<a-form-item field="name" label="名称">
|
||||
<a-input v-model.trim="form.name" placeholder="请输入名称" />
|
||||
</a-form-item>
|
||||
<a-form-item label="排序" field="sort">
|
||||
<a-input-number v-model="form.sort" placeholder="请输入排序" :min="1" mode="button" />
|
||||
</a-form-item>
|
||||
<a-form-item label="描述" field="description">
|
||||
<a-textarea
|
||||
v-model.trim="form.description"
|
||||
placeholder="请输入描述"
|
||||
show-word-limit
|
||||
:max-length="200"
|
||||
:auto-size="{ minRows: 3, maxRows: 5 }"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item field="status" label="状态">
|
||||
<a-switch
|
||||
v-model="form.status" type="round" :checked-value="1" :unchecked-value="2" checked-text="启用"
|
||||
unchecked-text="禁用"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item field="menuIds" label="关联菜单">
|
||||
<a-space>
|
||||
<a-checkbox v-model="isMenuExpanded" @change="onExpanded">展开/折叠</a-checkbox>
|
||||
<a-checkbox v-model="isMenuCheckAll" @change="onCheckAll">全选/全不选</a-checkbox>
|
||||
<a-checkbox v-model="form.menuCheckStrictly">父子联动</a-checkbox>
|
||||
</a-space>
|
||||
<template #extra>
|
||||
<a-tree
|
||||
ref="menuTreeRef"
|
||||
:data="menuList"
|
||||
class="scrollable-container"
|
||||
:default-expand-all="isMenuExpanded"
|
||||
:check-strictly="!form.menuCheckStrictly"
|
||||
checkable
|
||||
/>
|
||||
</template>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance, TreeNodeData } from '@arco-design/web-vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { addTenantPackage, getTenantPackage, updateTenantPackage } from '@/apis/tenant/package'
|
||||
import { useResetReactive } from '@/hooks'
|
||||
import { useMenu } from '@/hooks/app'
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'save-success'): void
|
||||
}>()
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const dataId = ref('')
|
||||
const visible = ref(false)
|
||||
const isUpdate = computed(() => !!dataId.value)
|
||||
const title = computed(() => (isUpdate.value ? '修改套餐' : '新增套餐'))
|
||||
const formRef = ref<FormInstance>()
|
||||
const { menuList, getTenantPackageMenuList } = useMenu()
|
||||
const rules: FormInstance['rules'] = {
|
||||
name: [{ required: true, message: '请输入名称' }],
|
||||
status: [{ required: true, message: '请选择状态' }],
|
||||
}
|
||||
|
||||
const [form, resetForm] = useResetReactive({
|
||||
sort: 999,
|
||||
menuCheckStrictly: true,
|
||||
status: 1,
|
||||
})
|
||||
|
||||
const menuTreeRef = ref()
|
||||
const isMenuExpanded = ref(false)
|
||||
const isMenuCheckAll = ref(false)
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
isMenuExpanded.value = false
|
||||
isMenuCheckAll.value = false
|
||||
menuTreeRef.value?.expandAll(isMenuExpanded.value)
|
||||
menuTreeRef.value?.checkAll(false)
|
||||
formRef.value?.resetFields()
|
||||
resetForm()
|
||||
}
|
||||
|
||||
// 获取所有选中的菜单
|
||||
const getMenuAllCheckedKeys = () => {
|
||||
// 获取目前被选中的菜单
|
||||
const checkedNodes = menuTreeRef.value?.getCheckedNodes()
|
||||
const checkedKeys = checkedNodes.map((item: TreeNodeData) => item.key)
|
||||
// 获取半选中的菜单
|
||||
const halfCheckedNodes = menuTreeRef.value?.getHalfCheckedNodes()
|
||||
const halfCheckedKeys = halfCheckedNodes.map((item: TreeNodeData) => item.key)
|
||||
checkedKeys.unshift(...halfCheckedKeys)
|
||||
return checkedKeys
|
||||
}
|
||||
|
||||
// 保存
|
||||
const save = async () => {
|
||||
try {
|
||||
const isInvalid = await formRef.value?.validate()
|
||||
if (isInvalid) return false
|
||||
form.menuIds = getMenuAllCheckedKeys()
|
||||
if (isUpdate.value) {
|
||||
await updateTenantPackage(form, dataId.value)
|
||||
Message.success('修改成功')
|
||||
} else {
|
||||
await addTenantPackage(form)
|
||||
Message.success('新增成功')
|
||||
}
|
||||
emit('save-success')
|
||||
return true
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 新增
|
||||
const onAdd = async () => {
|
||||
reset()
|
||||
await getTenantPackageMenuList()
|
||||
dataId.value = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = async (id: string) => {
|
||||
reset()
|
||||
await getTenantPackageMenuList()
|
||||
dataId.value = id
|
||||
const { data } = await getTenantPackage(id)
|
||||
Object.assign(form, data)
|
||||
menuTreeRef.value?.checkNode(form.menuIds, true, true)
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 展开/折叠
|
||||
const onExpanded = () => {
|
||||
menuTreeRef.value?.expandAll(isMenuExpanded.value)
|
||||
}
|
||||
|
||||
// 全选/全不选
|
||||
const onCheckAll = () => {
|
||||
menuTreeRef.value?.checkAll(isMenuCheckAll.value)
|
||||
}
|
||||
|
||||
defineExpose({ onAdd, onUpdate })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.scrollable-container {
|
||||
height: 280px;
|
||||
overflow-y: auto;
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
}
|
||||
</style>
|
||||
@@ -1,72 +0,0 @@
|
||||
<template>
|
||||
<a-drawer v-model:visible="visible" title="套餐详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
|
||||
<a-descriptions title="基础信息" :column="2" size="large" class="general-description">
|
||||
<a-descriptions-item label="ID" :span="2">
|
||||
<a-typography-paragraph copyable>{{ dataDetail?.id }}</a-typography-paragraph>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="名称">{{ dataDetail?.name }}</a-descriptions-item>
|
||||
<a-descriptions-item label="排序">{{ dataDetail?.sort }}</a-descriptions-item>
|
||||
<a-descriptions-item label="状态">
|
||||
<a-tag v-if="dataDetail?.status === 1" color="green">启用</a-tag>
|
||||
<a-tag v-else color="red">禁用</a-tag>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item />
|
||||
<a-descriptions-item label="创建人">{{ dataDetail?.createUserString }}</a-descriptions-item>
|
||||
<a-descriptions-item label="创建时间">{{ dataDetail?.createTime }}</a-descriptions-item>
|
||||
<a-descriptions-item label="修改人">{{ dataDetail?.updateUserString }}</a-descriptions-item>
|
||||
<a-descriptions-item label="修改时间">{{ dataDetail?.updateTime }}</a-descriptions-item>
|
||||
<a-descriptions-item label="描述" :span="2">{{ dataDetail?.description }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
|
||||
<a-descriptions
|
||||
title="关联菜单"
|
||||
:column="2"
|
||||
size="large"
|
||||
class="permission general-description"
|
||||
style="margin-top: 20px; position: relative"
|
||||
>
|
||||
<a-descriptions-item :span="2">
|
||||
<a-tree
|
||||
:checked-keys="dataDetail?.menuIds"
|
||||
:data="menuList"
|
||||
default-expand-all
|
||||
check-strictly
|
||||
checkable
|
||||
/>
|
||||
</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { type TenantPackageResp, getTenantPackage as getDetail } from '@/apis/tenant/package'
|
||||
import { useMenu } from '@/hooks/app'
|
||||
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const dataId = ref('')
|
||||
const dataDetail = ref<TenantPackageResp>()
|
||||
const visible = ref(false)
|
||||
const { menuList, getTenantPackageMenuList } = useMenu()
|
||||
|
||||
// 查询详情
|
||||
const getDataDetail = async () => {
|
||||
const { data } = await getDetail(dataId.value)
|
||||
dataDetail.value = data
|
||||
}
|
||||
|
||||
// 打开
|
||||
const onOpen = async (id: string) => {
|
||||
dataId.value = id
|
||||
if (!menuList.value.length) {
|
||||
await getTenantPackageMenuList()
|
||||
}
|
||||
await getDataDetail()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ onOpen })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -1,141 +0,0 @@
|
||||
<template>
|
||||
<GiPageLayout>
|
||||
<GiTable
|
||||
row-key="id"
|
||||
:data="dataList"
|
||||
:columns="columns"
|
||||
:loading="loading"
|
||||
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
|
||||
:pagination="pagination"
|
||||
:disabled-tools="['size']"
|
||||
:disabled-column-keys="['name']"
|
||||
@refresh="search"
|
||||
>
|
||||
<template #toolbar-left>
|
||||
<a-input-search v-model="queryForm.description" placeholder="搜索名称/描述" allow-clear @search="search" />
|
||||
<a-button @click="reset">
|
||||
<template #icon><icon-refresh /></template>
|
||||
<template #default>重置</template>
|
||||
</a-button>
|
||||
</template>
|
||||
<template #toolbar-right>
|
||||
<a-button v-permission="['tenant:package:create']" type="primary" @click="onAdd">
|
||||
<template #icon><icon-plus /></template>
|
||||
<template #default>新增</template>
|
||||
</a-button>
|
||||
</template>
|
||||
<template #status="{ record }">
|
||||
<GiCellStatus :status="record.status" />
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
<a-link v-permission="['tenant:package:get']" title="详情" @click="onDetail(record)">详情</a-link>
|
||||
<a-link v-permission="['tenant:package:update']" title="修改" @click="onUpdate(record)">修改</a-link>
|
||||
<a-link
|
||||
v-permission="['tenant:package:delete']"
|
||||
status="danger"
|
||||
:disabled="record.disabled"
|
||||
:title="record.disabled ? '不可删除' : '删除'"
|
||||
@click="onDelete(record)"
|
||||
>
|
||||
删除
|
||||
</a-link>
|
||||
</a-space>
|
||||
</template>
|
||||
</GiTable>
|
||||
|
||||
<AddModal ref="AddModalRef" @save-success="search" />
|
||||
<DetailDrawer ref="DetailDrawerRef" />
|
||||
</GiPageLayout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { TableInstance } from '@arco-design/web-vue'
|
||||
import AddModal from './AddModal.vue'
|
||||
import DetailDrawer from './DetailDrawer.vue'
|
||||
import {
|
||||
type TenantPackageQuery,
|
||||
type TenantPackageResp,
|
||||
deleteTenantPackage,
|
||||
listTenantPackage,
|
||||
} from '@/apis/tenant/package'
|
||||
import { useTable } from '@/hooks'
|
||||
import { isMobile } from '@/utils'
|
||||
import has from '@/utils/has'
|
||||
|
||||
defineOptions({ name: 'TenantPackage' })
|
||||
|
||||
const queryForm = reactive<TenantPackageQuery>({
|
||||
description: undefined,
|
||||
status: undefined,
|
||||
sort: ['createTime,desc'],
|
||||
})
|
||||
|
||||
const {
|
||||
tableData: dataList,
|
||||
loading,
|
||||
pagination,
|
||||
search,
|
||||
handleDelete,
|
||||
} = useTable((page) => listTenantPackage({ ...queryForm, ...page }), { immediate: true })
|
||||
const columns: TableInstance['columns'] = [
|
||||
{
|
||||
title: '序号',
|
||||
width: 66,
|
||||
align: 'center',
|
||||
render: ({ rowIndex }) => h('span', {}, rowIndex + 1 + (pagination.current - 1) * pagination.pageSize),
|
||||
fixed: !isMobile() ? 'left' : undefined,
|
||||
},
|
||||
{ title: '名称', dataIndex: 'name', slotName: 'name', ellipsis: true, tooltip: true, fixed: !isMobile() ? 'left' : undefined },
|
||||
{ title: '状态', dataIndex: 'status', slotName: 'status' },
|
||||
{ title: '排序', dataIndex: 'sort', align: 'center' },
|
||||
{ title: '描述', dataIndex: 'description', ellipsis: true, tooltip: true },
|
||||
{ title: '创建人', dataIndex: 'createUserString', ellipsis: true, tooltip: true, show: false },
|
||||
{ title: '创建时间', dataIndex: 'createTime', width: 180 },
|
||||
{ title: '修改人', dataIndex: 'updateUserString', ellipsis: true, tooltip: true, show: false },
|
||||
{ title: '修改时间', dataIndex: 'updateTime', width: 180, show: false },
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
slotName: 'action',
|
||||
width: 160,
|
||||
align: 'center',
|
||||
fixed: !isMobile() ? 'right' : undefined,
|
||||
show: has.hasPermOr(['tenant:package:get', 'tenant:package:update', 'tenant:package:delete']),
|
||||
},
|
||||
]
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
queryForm.description = undefined
|
||||
queryForm.status = undefined
|
||||
search()
|
||||
}
|
||||
|
||||
// 删除
|
||||
const onDelete = (record: TenantPackageResp) => {
|
||||
return handleDelete(() => deleteTenantPackage(record.id), {
|
||||
content: `是否确定删除套餐「${record.name}」?`,
|
||||
showModal: true,
|
||||
})
|
||||
}
|
||||
|
||||
const AddModalRef = ref<InstanceType<typeof AddModal>>()
|
||||
// 新增
|
||||
const onAdd = () => {
|
||||
AddModalRef.value?.onAdd()
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = (record: TenantPackageResp) => {
|
||||
AddModalRef.value?.onUpdate(record.id)
|
||||
}
|
||||
|
||||
const DetailDrawerRef = ref<InstanceType<typeof DetailDrawer>>()
|
||||
// 详情
|
||||
const onDetail = (record: TenantPackageResp) => {
|
||||
DetailDrawerRef.value?.onOpen(record.id)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -59,8 +59,8 @@ const [form, resetForm] = useResetReactive({
|
||||
|
||||
// 回退
|
||||
const onBack = () => {
|
||||
router.back()
|
||||
tabsStore.closeCurrent(route.path)
|
||||
router.push({ path: '/user/message', query: { tab: 'notice' } })
|
||||
}
|
||||
|
||||
// 打开
|
||||
|
||||
@@ -28,10 +28,10 @@ const userInfo = computed(() => userStore.userInfo)
|
||||
const visible = ref(false)
|
||||
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||
|
||||
const [form, resetForm] = useResetReactive(() => ({
|
||||
const [form, resetForm] = useResetReactive({
|
||||
nickname: userInfo.value.nickname,
|
||||
gender: userInfo.value.gender,
|
||||
}))
|
||||
})
|
||||
|
||||
const columns: ColumnItem[] = reactive([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user