mirror of
https://github.com/veops/cmdb.git
synced 2025-09-14 07:26:54 +08:00
Compare commits
52 Commits
config_ruf
...
v2.5.3
Author | SHA1 | Date | |
---|---|---|---|
|
e93d894f04 | ||
|
081f35816f | ||
|
a8fadb2785 | ||
|
72c37c995d | ||
|
f8fbbe4b9a | ||
|
155ba67ecc | ||
|
9c67b1e56a | ||
|
88df3355d8 | ||
|
549056a42d | ||
|
365fdf2bab | ||
|
6bf01786d8 | ||
|
e180f549c8 | ||
|
3a7f4a31d0 | ||
|
be4fc62218 | ||
|
ff4ce4dbe0 | ||
|
dda1fce46a | ||
|
fbf59e7b44 | ||
|
4ae67d1f0f | ||
|
b56cf5bb3d | ||
|
53e8d34c68 | ||
|
c62e4032e3 | ||
|
108c11071a | ||
|
debb25f65b | ||
|
f26dd65d07 | ||
|
cb2726c890 | ||
|
2003fd4a48 | ||
|
1bbf8c10b5 | ||
|
93e919b73f | ||
|
435bb2a2c8 | ||
|
5ceb8ff6f9 | ||
|
47332aca3c | ||
|
f24cb55585 | ||
|
f1594550e0 | ||
|
a025c844bc | ||
|
1a03a0b800 | ||
|
e35efea712 | ||
|
3f1e8beae8 | ||
|
3ea81987a1 | ||
|
6a20e2f578 | ||
|
f6de9b42ab | ||
|
25f6bbcc3e | ||
|
bc3201656c | ||
|
89db5a060e | ||
|
b669775cd6 | ||
|
655b642930 | ||
|
b253fdfea0 | ||
|
d0129439cd | ||
|
aaa4ca1327 | ||
|
747475b6a6 | ||
|
ada23262bb | ||
|
0c57b2b83d | ||
|
d782ceddab |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -78,4 +78,3 @@ cmdb-ui/npm-debug.log*
|
||||
cmdb-ui/yarn-debug.log*
|
||||
cmdb-ui/yarn-error.log*
|
||||
cmdb-ui/package-lock.json
|
||||
start.sh
|
||||
|
13
CODE_OF_CONDUCT.md
Normal file
13
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
||||
|
||||
We are committed to making participation in this project a harassment-free experience for everyone, regardless of the level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
||||
|
||||
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
196
README.md
196
README.md
@@ -1,116 +1,138 @@
|
||||
|
||||
<p align="center">
|
||||
<a href="https://veops.cn"><img src="docs/images/logo.png" alt="维易CMDB" width="300"/></a>
|
||||
<a href="https://veops.cn">
|
||||
<img src="https://github.com/user-attachments/assets/c5cfb272-899b-418d-9e69-8e1dd07db0f6" alt="维易CMDB"/>
|
||||
</a>
|
||||
</p>
|
||||
<h3 align="center">简单、轻量、通用的运维配置管理数据库</h3>
|
||||
|
||||
<h4 align="center">简单、轻量、通用的运维配置管理数据库</h4>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/veops/cmdb/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-AGPLv3-brightgreen" alt="License: GPLv3"></a>
|
||||
<a href="https:https://github.com/sendya/ant-design-pro-vue"><img src="https://img.shields.io/badge/UI-Ant%20Design%20Pro%20Vue-brightgreen" alt="UI"></a>
|
||||
<a href="https://github.com/pallets/flask"><img src="https://img.shields.io/badge/API-Flask-brightgreen" alt="API"></a>
|
||||
<a href="https://github.com/veops/cmdb/releases"><img alt="the latest release version" src="https://img.shields.io/github/v/release/veops/cmdb?color=75C1C4&include_prereleases&label=Release&logo=github&logoColor=white"></a>
|
||||
<a href="https:https://github.com/sendya/ant-design-pro-vue"><img src="https://img.shields.io/badge/UI-Ant%20Design%20Pro%20Vue-green" alt="UI"></a>
|
||||
<a href="https://github.com/pallets/flask"><img src="https://img.shields.io/badge/API-Flask-bright" alt="API"></a>
|
||||
<a href="https://github.com/veops/cmdb/stargazers"><img src="https://img.shields.io/github/stars/veops/cmdb" alt="Stars Badge"/></a>
|
||||
<a href="https://github.com/veops/cmdb"><img src="https://img.shields.io/github/forks/veops/cmdb" alt="Forks Badge"/></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
中文(简体) · <a href="docs/README_en.md">English</a>
|
||||
</p>
|
||||
|
||||
|
||||
------------------------------
|
||||
|
||||
[English](docs/README_en.md) / [中文](README.md)
|
||||
- 产品文档:https://veops.cn/docs/
|
||||
- 在线体验:<a href="https://cmdb.veops.cn" target="_blank">CMDB</a>
|
||||
- username: demo 或者 admin
|
||||
- password: 123456
|
||||
|
||||
> **重要提示**: `master` 分支在开发过程中可能处于 _不稳定的状态_ 。
|
||||
> 请通过[releases](https://github.com/veops/cmdb/releases)获取
|
||||
|
||||
## 系统介绍
|
||||
|
||||
### 系统概览
|
||||
维易CMDB是一个简洁、轻量且高度可定制的运维配置管理数据库(CMDB)。它支持灵活的模型配置和资源自动发现,旨在为企业提供便捷的资产管理解决方案,帮助运维团队高效地管理 IT 基础设施和服务。
|
||||
|
||||
<img src=docs/images/dashboard.png />
|
||||
|
||||
|
||||
### 相关文章
|
||||
|
||||
- <a href="https://mp.weixin.qq.com/s/v3eANth64UBW5xdyOkK3tg" target="_blank">概要设计</a>
|
||||
- <a href="https://github.com/veops/cmdb/tree/master/docs/cmdb_api.md" target="_blank">API 文档</a>
|
||||
- <a href="https://mp.weixin.qq.com/s/rQaf4AES7YJsyNQG_MKOLg" target="_blank">自动发现</a>
|
||||
- 更多文章可以在公众号 **维易科技OneOps** 里查看
|
||||
|
||||
### 特点
|
||||
|
||||
- 灵活性
|
||||
1. 配置灵活,不设定任何运维场景,有内置模板
|
||||
2. 自动发现、入库 IT 资产
|
||||
- 安全性
|
||||
1. 细粒度权限控制
|
||||
2. 完备操作日志
|
||||
- 多应用
|
||||
1. 丰富视图展示维度
|
||||
2. API简单强大
|
||||
3. 支持定义属性触发器、计算属性
|
||||
- 产品文档:[https://veops.cn/docs/](https://veops.cn/docs/)
|
||||
- 在线体验:[https://cmdb.veops.cn](https://cmdb.veops.cn)
|
||||
- 用户名:demo 或者 admin
|
||||
- 密码:123456
|
||||
- **重要提示**:`master` 分支在开发过程中可能处于**不稳定的状态**。请通过 [releases](https://github.com/veops/cmdb/releases) 获取最新稳定版本。
|
||||
|
||||
### 主要功能
|
||||
|
||||
- 自定义模型和模型关系,模型属性支持下拉列表、字体颜色、计算属性等高级特性
|
||||
- 支持计算机、网络设备、存储设备、数据库、中间件、公有云资源等自动发现
|
||||
- 支持资源、层级、关系视图展示
|
||||
- 细粒度访问控制,完备的操作日志
|
||||
- 通用的资源搜索和关系搜索
|
||||
- 支持IP地址管理(IPAM), 数据中心基础设施管理(DCIM)
|
||||
- **自定义模型和模型关系**:支持模型属性的自定义,包括下拉列表、字体颜色、计算属性等高级功能,满足不同业务需求。
|
||||
- **自动发现资源**:支持计算机、网络设备、存储设备、数据库、中间件、公有云资源等自动发现。
|
||||
- **多维度视图展示**:包括资源视图、层级视图、关系视图等,帮助运维人员全面管理资源。
|
||||
- **细粒度权限控制**:通过精确的访问控制和完备的操作日志保障系统的安全性。
|
||||
- **全面的资源搜索功能**:支持灵活的资源和关系搜索,快速定位和操作资源。
|
||||
- **集成 IP 地址管理(IPAM)和数据中心基础设施管理(DCIM)**:简化网络资源和数据中心设备的管理。
|
||||
|
||||
更多详细功能,请移步 [维易科技官网](https://veops.cn) 进行了解。
|
||||
|
||||
### 系统优势
|
||||
|
||||
### 更多功能
|
||||
- 灵活性
|
||||
+ 无需指定固定运维场景,支持自由配置并内置多种模板
|
||||
+ 支持自动发现和入库 IT 资产,快速搭建资产管理系统
|
||||
- 安全性
|
||||
+ 细粒度的权限控制机制,确保资源管理的安全性
|
||||
+ 完整的操作日志记录,便于审计和问题追踪
|
||||
- 多应用
|
||||
+ 提供多种视图展示方式,满足不同场景的需求
|
||||
+ 强大的 API 接口,支持深度集成
|
||||
+ 支持定义属性触发器和计算属性,增强数据处理能力
|
||||
|
||||
> 也欢迎移步[维易科技官网](https://veops.cn),发现更多免费运维系统。
|
||||
### 技术栈
|
||||
|
||||
+ 后端:Python [3.8-3.11]
|
||||
+ 数据存储:MySQL、Redis
|
||||
+ 前端:Vue.js
|
||||
+ UI组件库:Ant Design Vue
|
||||
|
||||
### 系统概览
|
||||
|
||||
<table style="border-collapse: collapse;">
|
||||
<tr>
|
||||
<td style="padding: 5px;background-color:#fff;">
|
||||
<img width="400" src="https://github.com/user-attachments/assets/6d2df835-ae93-4d91-9bd9-213c270eca7a"/>
|
||||
</td>
|
||||
<td style="padding: 5px;background-color:#fff;">
|
||||
<img width="400" src="https://github.com/user-attachments/assets/cb8b598a-a1f9-4c74-adf1-6e59aea2c9b3"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="padding: 5px;background-color:#fff;">
|
||||
<img width="400" src="https://github.com/user-attachments/assets/b440224f-53c3-4b7f-a9be-285d7a4b848f"/>
|
||||
</td>
|
||||
<td style="padding: 5px;background-color:#fff;">
|
||||
<img width="400" src="https://github.com/user-attachments/assets/f457d5a0-b60b-4949-b94e-020f4c61444b"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 关注我们
|
||||
|
||||
欢迎 Star 加关注,第一时间获取更新动态!
|
||||
|
||||

|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 搭建
|
||||
|
||||
+ 方案一:Docker 一键快速构建
|
||||
|
||||
- 第1步: 安装 Docker 环境和 Docker Compose(v2)
|
||||
- 第2步: 拷贝项目代码, `git clone https://github.com/veops/cmdb.git`
|
||||
- 第3步:进入主目录并启动, `docker compose up -d`
|
||||
|
||||
+ 方案二:[本地开发环境搭建](docs/local.md)
|
||||
+ 方案三:[Makefile 安装](docs/makefile.md)
|
||||
|
||||
### 2. 访问
|
||||
- 打开浏览器并访问: [http://127.0.0.1:8000](http://127.0.0.1:8000)
|
||||
- 用户名: demo 或者 admin
|
||||
- 密码: 123456
|
||||
|
||||
## 接入公司
|
||||
|
||||
> 欢迎使用开源CMDB的公司,在 [#112](https://github.com/veops/cmdb/issues/112) 登记
|
||||
+ 欢迎使用开源CMDB的公司和团队,在 [#112](https://github.com/veops/cmdb/issues/112) 登记
|
||||
|
||||
## 安装
|
||||
## 代码贡献
|
||||
我们欢迎所有开发者贡献代码,改善和扩展这个项目。请先阅读我们的[贡献指南](docs/CONTRIBUTING.md)。此外,您还可以通过社交媒体、活动和分享来支持 Veops 的开源。
|
||||
|
||||
### Docker 一键快速构建
|
||||
<a href="https://github.com/veops/cmdb/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=veops/cmdb" />
|
||||
</a>
|
||||
|
||||
[//]: # (> 方法一)
|
||||
- 第一步: 先安装 Docker 环境, 以及Docker Compose (v2)
|
||||
- 第二步: 拷贝项目
|
||||
```shell
|
||||
git clone https://github.com/veops/cmdb.git
|
||||
```
|
||||
- 第三步:进入主目录,执行:
|
||||
```
|
||||
docker compose up -d
|
||||
```
|
||||
## 更多开源
|
||||
|
||||
[//]: # (> 方法二, 该方法适用于linux系统)
|
||||
- [OneTerm](https://github.com/veops/oneterm): 一款简单、轻量、灵活的堡垒机服务。
|
||||
- [messenger](https://github.com/veops/messenger): 一个简单轻量的消息发送服务。
|
||||
- [ACL](https://github.com/veops/acl): 一个简单通用的权限管理系统设计与实践。
|
||||
|
||||
[//]: # (- 第一步: 先安装 Docker 环境, 以及Docker Compose (v2))
|
||||
## 相关文章
|
||||
|
||||
[//]: # (- 第二步: 直接使用项目根目录下的install.sh 文件进行 `安装`、`启动`、`暂停`、`查状态`、`删除`、`卸载`)
|
||||
- <a href="https://mp.weixin.qq.com/s/v3eANth64UBW5xdyOkK3tg" target="_blank">尽可能通用的运维CMDB的设计与实践(Ⅰ) - 概览</a>
|
||||
- <a href="https://mp.weixin.qq.com/s/rQaf4AES7YJsyNQG_MKOLg" target="_blank">尽可能通用的运维CMDB的设计与实践(ⅠⅠ) - 自动发现</a>
|
||||
- <a href="https://github.com/veops/cmdb/tree/master/docs/cmdb_api.md" target="_blank">CMDB接口文档</a>
|
||||
|
||||
[//]: # (```shell)
|
||||
更多文章可以在公众号 **维易科技OneOps** 里查看
|
||||
|
||||
[//]: # (curl -so install.sh https://raw.githubusercontent.com/veops/cmdb/deploy_on_kylin_docker/install.sh)
|
||||
## 与我联系
|
||||
|
||||
[//]: # (sh install.sh install)
|
||||
|
||||
[//]: # (```)
|
||||
|
||||
### [本地开发环境搭建](docs/local.md)
|
||||
|
||||
### [Makefile 安装](docs/makefile.md)
|
||||
|
||||
## 验证
|
||||
- 浏览器打开: [http://127.0.0.1:8000](http://127.0.0.1:8000)
|
||||
- username: demo 或者 admin
|
||||
- password: 123456
|
||||
|
||||
|
||||
---
|
||||
|
||||
_**欢迎关注公众号(维易科技OneOps),关注后可加入微信群,进行产品和技术交流。**_
|
||||
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/images/wechat.png" alt="公众号: 维易科技OneOps" />
|
||||
</p>
|
||||
+ 邮箱: <a href="mailto:bd@veops.cn">bd@veops.cn</a>
|
||||
+ 公众号:**维易科技OneOps**。关注后可以加入微信群,参与产品和技术交流
|
||||
<img src="docs/images/wechat.png" alt="公众号: 维易科技OneOps" />
|
@@ -228,6 +228,12 @@ def cmdb_trigger():
|
||||
"""
|
||||
from api.lib.cmdb.ci import CITriggerManager
|
||||
|
||||
current_app.test_request_context().push()
|
||||
if not UserCache.get('worker'):
|
||||
from api.lib.perm.acl.user import UserCRUD
|
||||
UserCRUD.add(username='worker', password=uuid.uuid4().hex, email='worker@xxx.com')
|
||||
login_user(UserCache.get('worker'))
|
||||
|
||||
current_day = datetime.datetime.today().strftime("%Y-%m-%d")
|
||||
trigger2cis = dict()
|
||||
trigger2completed = dict()
|
||||
|
@@ -12,6 +12,7 @@ from sqlalchemy import func
|
||||
from api.extensions import db
|
||||
from api.lib.cmdb.auto_discovery.const import CLOUD_MAP
|
||||
from api.lib.cmdb.auto_discovery.const import DEFAULT_INNER
|
||||
from api.lib.cmdb.auto_discovery.const import NET_DEVICE_NAMES
|
||||
from api.lib.cmdb.auto_discovery.const import PRIVILEGED_USERS
|
||||
from api.lib.cmdb.cache import AttributeCache
|
||||
from api.lib.cmdb.cache import AutoDiscoveryMappingCache
|
||||
@@ -252,6 +253,7 @@ class AutoDiscoveryCITypeCRUD(DBMixin):
|
||||
:return:
|
||||
"""
|
||||
result = []
|
||||
db.session.commit()
|
||||
rules = cls.cls.get_by(to_dict=True)
|
||||
|
||||
for rule in rules:
|
||||
@@ -718,6 +720,12 @@ class AutoDiscoveryCICRUD(DBMixin):
|
||||
|
||||
build_relations_for_ad_accept.apply_async(args=(adc.to_dict(), ci_id, ad_key2attr), queue=CMDB_QUEUE)
|
||||
|
||||
ci_type = CITypeCache.get(adc.type_id)
|
||||
if ci_type and ci_type.name in NET_DEVICE_NAMES and 'ports' in adc.instance:
|
||||
from api.tasks.cmdb import add_net_device_ports
|
||||
add_net_device_ports.apply_async(args=(ci_id, adc.instance['ports']),
|
||||
queue=CMDB_QUEUE)
|
||||
|
||||
adc.update(is_accept=True,
|
||||
accept_by=nickname or current_user.nickname,
|
||||
accept_time=datetime.datetime.now(),
|
||||
|
@@ -4,6 +4,8 @@ from api.lib.cmdb.const import AutoDiscoveryType
|
||||
|
||||
PRIVILEGED_USERS = ("cmdb_agent", "worker", "admin")
|
||||
|
||||
NET_DEVICE_NAMES = {"switch", 'router', 'firewall', 'printer'}
|
||||
|
||||
DEFAULT_INNER = [
|
||||
dict(name="阿里云", en="aliyun", type=AutoDiscoveryType.HTTP, is_inner=True, is_plugin=False,
|
||||
option={'icon': {'name': 'caise-aliyun'}, "en": "aliyun"}),
|
||||
@@ -41,8 +43,12 @@ DEFAULT_INNER = [
|
||||
option={'icon': {'name': 'caise-luyouqi'}}),
|
||||
dict(name="防火墙", type=AutoDiscoveryType.SNMP, is_inner=True, is_plugin=False,
|
||||
option={'icon': {'name': 'caise-fanghuoqiang'}}),
|
||||
dict(name="打印机", type=AutoDiscoveryType.SNMP, is_inner=True, is_plugin=False,
|
||||
option={'icon': {'name': 'caise-dayinji'}}),
|
||||
# dict(name="打印机", type=AutoDiscoveryType.SNMP, is_inner=True, is_plugin=False,
|
||||
# option={'icon': {'name': 'caise-dayinji'}}),
|
||||
dict(name="光纤交换机", type=AutoDiscoveryType.SNMP, is_inner=True, is_plugin=False,
|
||||
option={'icon': {'name': 'caise-fiber'}}),
|
||||
dict(name="F5", type=AutoDiscoveryType.SNMP, is_inner=True, is_plugin=False,
|
||||
option={'icon': {'name': 'caise-F5'}}),
|
||||
]
|
||||
|
||||
CLOUD_MAP = {
|
||||
|
@@ -1,37 +1,74 @@
|
||||
[{
|
||||
"name":"manufacturer",
|
||||
"type": "文本",
|
||||
"example":"HUAWEI Technology Co.,Ltd",
|
||||
"desc":"制造产商"
|
||||
},{
|
||||
"name":"sn",
|
||||
"type": "文本",
|
||||
"example":"102030059898",
|
||||
"desc":"设备序列号"
|
||||
},{
|
||||
"name":"device_name",
|
||||
"type": "文本",
|
||||
"example":"USG6525E",
|
||||
"desc":"设备名称"
|
||||
},{
|
||||
"name":"device_model",
|
||||
"type": "文本",
|
||||
"example":"2011.2.321.1.205",
|
||||
"desc":"设备细分类型 结合相关产商获取相应的产品类型"
|
||||
},{
|
||||
"name":"description",
|
||||
"type": "文本",
|
||||
"example":"Huawei Vwersatile Routing Platform Software",
|
||||
"desc":"设备描述"
|
||||
},{
|
||||
"name":"manager_ip",
|
||||
"type": "文本",
|
||||
"example":"192.168.1.1",
|
||||
"desc":"管理ip"
|
||||
}, {
|
||||
"name":"ips",
|
||||
"type": "文本、多值",
|
||||
"example":"192.168.1.1, 192.168.1.2",
|
||||
"desc":"ips"
|
||||
}
|
||||
[
|
||||
{
|
||||
"name": "manufacturer",
|
||||
"type": "文本",
|
||||
"example": "Huawei",
|
||||
"desc": "制造产商"
|
||||
},
|
||||
{
|
||||
"name": "sn",
|
||||
"type": "文本",
|
||||
"example": "102030059898",
|
||||
"desc": "设备序列号"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": "文本",
|
||||
"example": "USG6525E",
|
||||
"desc": "设备名称"
|
||||
},
|
||||
{
|
||||
"name": "model",
|
||||
"type": "文本",
|
||||
"example": "2011.2.321.1.205",
|
||||
"desc": "设备细分类型 结合相关产商获取相应的产品类型"
|
||||
},
|
||||
{
|
||||
"name": "description",
|
||||
"type": "文本",
|
||||
"example": "Huawei Vwersatile Routing Platform Software",
|
||||
"desc": "设备描述"
|
||||
},
|
||||
{
|
||||
"name": "manager_ip",
|
||||
"type": "文本",
|
||||
"example": "192.168.1.1",
|
||||
"desc": "管理ip"
|
||||
},
|
||||
{
|
||||
"name": "ips",
|
||||
"type": "文本、多值",
|
||||
"example": "192.168.1.1, 192.168.1.2",
|
||||
"desc": "ips"
|
||||
},
|
||||
{
|
||||
"name": "uptime",
|
||||
"type": "文本",
|
||||
"example": "2023-04-15 10:00:00",
|
||||
"desc": "启动时间"
|
||||
},
|
||||
{
|
||||
"name": "snmp_version",
|
||||
"type": "文本",
|
||||
"example": "v2c",
|
||||
"desc": "SNMP版本"
|
||||
},
|
||||
{
|
||||
"name": "port_num",
|
||||
"type": "整数",
|
||||
"example": 24,
|
||||
"desc": "端口数量"
|
||||
},
|
||||
{
|
||||
"name": "ports",
|
||||
"type": "json",
|
||||
"example": "",
|
||||
"desc": "设备的端口列表"
|
||||
},
|
||||
{
|
||||
"name": "neighbors",
|
||||
"type": "json",
|
||||
"example": "",
|
||||
"desc": "设备的邻居列表"
|
||||
}
|
||||
]
|
@@ -524,10 +524,14 @@ class CIManager(object):
|
||||
raw_dict = copy.deepcopy(ci_dict)
|
||||
|
||||
ci_attr2type_attr = {type_attr.attr_id: type_attr for type_attr, _ in attrs}
|
||||
unique_name = None
|
||||
for _, attr in attrs:
|
||||
if attr.default and attr.default.get('default') == AttributeDefaultValueEnum.UPDATED_AT:
|
||||
ci_dict[attr.name] = now
|
||||
|
||||
if attr.id == ci_type.unique_id:
|
||||
unique_name = attr.name
|
||||
|
||||
value_manager = AttributeValueManager()
|
||||
|
||||
password_dict = dict()
|
||||
@@ -557,7 +561,8 @@ class CIManager(object):
|
||||
|
||||
ci_dict = {k: v for k, v in ci_dict.items() if k in ci_type_attrs_name}
|
||||
key2attr = value_manager.valid_attr_value(ci_dict, ci.type_id, ci.id, ci_type_attrs_name,
|
||||
ci_attr2type_attr=ci_attr2type_attr)
|
||||
ci_attr2type_attr=ci_attr2type_attr,
|
||||
unique_name=unique_name)
|
||||
|
||||
if computed_attrs:
|
||||
value_manager.handle_ci_compute_attributes(ci_dict, computed_attrs, ci)
|
||||
|
@@ -722,9 +722,6 @@ class CITypeAttributeManager(object):
|
||||
|
||||
ci_cache.apply_async(args=(ci.id, None, None), queue=CMDB_QUEUE)
|
||||
|
||||
for item in PreferenceShowAttributes.get_by(type_id=type_id, attr_id=attr_id, to_dict=False):
|
||||
item.soft_delete(commit=False)
|
||||
|
||||
child_ids = CITypeInheritanceManager.recursive_children(type_id)
|
||||
for _type_id in [type_id] + child_ids:
|
||||
for item in CITypeUniqueConstraint.get_by(type_id=_type_id, to_dict=False):
|
||||
@@ -740,6 +737,9 @@ class CITypeAttributeManager(object):
|
||||
item = CITypeTrigger.get_by(type_id=_type_id, attr_id=attr_id, to_dict=False, first=True)
|
||||
item and item.soft_delete(commit=False)
|
||||
|
||||
for item in PreferenceShowAttributes.get_by(type_id=_type_id, attr_id=attr_id, to_dict=False):
|
||||
item.soft_delete(commit=False)
|
||||
|
||||
for item in (CITypeRelation.get_by(parent_id=type_id, to_dict=False) +
|
||||
CITypeRelation.get_by(child_id=type_id, to_dict=False)):
|
||||
if item.parent_id == type_id and attr_id in (item.parent_attr_ids or []):
|
||||
@@ -1145,13 +1145,14 @@ class CITypeAttributeGroupManager(object):
|
||||
else:
|
||||
group_pos = group2pos[group['name']]
|
||||
|
||||
attr = None
|
||||
for i in items:
|
||||
if i.attr_id in id2attr:
|
||||
attr = id2attr[i.attr_id]
|
||||
attr['inherited'] = group['inherited']
|
||||
attr['inherited_from'] = group.get('inherited_from')
|
||||
result[group_pos]['attributes'].append(attr)
|
||||
else:
|
||||
continue
|
||||
|
||||
if i.attr_id in attr2pos:
|
||||
result[attr2pos[i.attr_id][0]]['attributes'].remove(attr2pos[i.attr_id][1])
|
||||
@@ -1398,6 +1399,7 @@ class CITypeTemplateManager(object):
|
||||
i.pop('order', None)
|
||||
i.pop('choice_web_hook', None)
|
||||
i.pop('choice_other', None)
|
||||
i.pop('choice_builtin', None)
|
||||
i.pop('order', None)
|
||||
i.pop('inherited_from', None)
|
||||
choice_value = i.pop('choice_value', None)
|
||||
|
@@ -43,7 +43,7 @@ class ScanHistoryManager(DBMixin):
|
||||
|
||||
if kwargs.get('ips'):
|
||||
from api.lib.cmdb.ipam.address import IpAddressManager
|
||||
IpAddressManager().assign_ips(kwargs['ips'], None, kwargs.get('cidr'),
|
||||
IpAddressManager().assign_ips(kwargs['ips'], ci_id, kwargs.get('cidr'),
|
||||
**{IPAddressBuiltinAttributes.IS_USED: 1})
|
||||
|
||||
scan_rule = IPAMSubnetScan.get_by(ci_id=ci_id, first=True, to_dict=False)
|
||||
|
@@ -107,3 +107,12 @@ FROM
|
||||
WHERE c_value_index_datetime.value LIKE "{0}") AS {1}
|
||||
GROUP BY {1}.ci_id
|
||||
"""
|
||||
|
||||
QUERY_CI_BY_NO_ATTR_IN = """
|
||||
SELECT *
|
||||
FROM
|
||||
(SELECT c_value_index_texts.ci_id
|
||||
FROM c_value_index_texts
|
||||
WHERE c_value_index_texts.value in ({0})) AS {1}
|
||||
GROUP BY {1}.ci_id
|
||||
"""
|
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||
import copy
|
||||
import six
|
||||
import time
|
||||
from flask import abort
|
||||
from flask import current_app
|
||||
from flask_login import current_user
|
||||
from jinja2 import Template
|
||||
@@ -27,6 +28,7 @@ from api.lib.cmdb.search.ci.db.query_sql import FACET_QUERY
|
||||
from api.lib.cmdb.search.ci.db.query_sql import QUERY_CI_BY_ATTR_NAME
|
||||
from api.lib.cmdb.search.ci.db.query_sql import QUERY_CI_BY_ID
|
||||
from api.lib.cmdb.search.ci.db.query_sql import QUERY_CI_BY_NO_ATTR
|
||||
from api.lib.cmdb.search.ci.db.query_sql import QUERY_CI_BY_NO_ATTR_IN
|
||||
from api.lib.cmdb.search.ci.db.query_sql import QUERY_CI_BY_TYPE
|
||||
from api.lib.cmdb.search.ci.db.query_sql import QUERY_UNION_CI_ATTRIBUTE_IS_NULL
|
||||
from api.lib.cmdb.utils import TableMap
|
||||
@@ -141,7 +143,7 @@ class Search(object):
|
||||
if str(ci_type.id) in self.type_id_list:
|
||||
self.type_id_list.remove(str(ci_type.id))
|
||||
type_id_list.remove(str(ci_type.id))
|
||||
sub.extend([i for i in queries[1:] if isinstance(i, six.string_types)])
|
||||
sub.extend([i for i in queries[1:] if isinstance(i, (six.string_types, list))])
|
||||
|
||||
sub.insert(0, "_type:{}".format(ci_type.id))
|
||||
queries.append(dict(operator="|", queries=sub))
|
||||
@@ -151,7 +153,9 @@ class Search(object):
|
||||
if not self.fl:
|
||||
self.fl = set(self.type2filter_perms[ci_type.id]['attr_filter'])
|
||||
else:
|
||||
self.fl = set(self.fl) & set(self.type2filter_perms[ci_type.id]['attr_filter'])
|
||||
fl = set(self.fl) & set(self.type2filter_perms[ci_type.id]['attr_filter'])
|
||||
not fl and abort(400, ErrFormat.ci_filter_perm_attr_no_permission.format(self.fl))
|
||||
self.fl = fl
|
||||
else:
|
||||
self.fl = self.fl or {}
|
||||
if not self.fl or isinstance(self.fl, dict):
|
||||
@@ -433,11 +437,14 @@ class Search(object):
|
||||
if not q.startswith("("):
|
||||
raise SearchError(ErrFormat.ci_search_Parentheses_invalid)
|
||||
|
||||
operator, q = self._operator_proc(q)
|
||||
if q.endswith(")"):
|
||||
result.append(dict(operator=operator, queries=[q[1:-1]]))
|
||||
if ":" not in q: # multi-line search
|
||||
result.append(q[1:-1].split(';'))
|
||||
else:
|
||||
operator, q = self._operator_proc(q)
|
||||
if q.endswith(")"):
|
||||
result.append(dict(operator=operator, queries=[q[1:-1]]))
|
||||
|
||||
sub = dict(operator=operator, queries=[q[1:]])
|
||||
sub = dict(operator=operator, queries=[q[1:]])
|
||||
elif q.endswith(")") and sub:
|
||||
sub['queries'].append(q[:-1])
|
||||
result.append(copy.deepcopy(sub))
|
||||
@@ -525,22 +532,31 @@ class Search(object):
|
||||
query_sql = ""
|
||||
|
||||
for q in queries:
|
||||
# current_app.logger.debug(q)
|
||||
_query_sql = ""
|
||||
if isinstance(q, dict):
|
||||
alias, _query_sql, operator = self.__query_build_by_field(q['queries'], True, True, alias, is_sub=True)
|
||||
# current_app.logger.info(_query_sql)
|
||||
# current_app.logger.info((operator, is_first, alias))
|
||||
operator = q['operator']
|
||||
if len(q['queries']) == 1 and ";" in q['queries'][0]:
|
||||
values = q['queries'][0].split(";")
|
||||
in_values = ",".join("'{0}'".format(v) for v in values)
|
||||
_query_sql = QUERY_CI_BY_NO_ATTR_IN.format(in_values, alias)
|
||||
operator = q['operator']
|
||||
else:
|
||||
alias, _query_sql, operator = self.__query_build_by_field(q['queries'], True, True, alias,
|
||||
is_sub=True)
|
||||
operator = q['operator']
|
||||
|
||||
elif ":" in q and not q.startswith("*"):
|
||||
alias, _query_sql, operator = self.__query_by_attr(q, queries, alias, is_sub)
|
||||
elif q == "*":
|
||||
continue
|
||||
elif q:
|
||||
q = q.replace("'", "\\'")
|
||||
q = q.replace('"', '\\"')
|
||||
q = q.replace("*", "%").replace('\\n', '%')
|
||||
_query_sql = QUERY_CI_BY_NO_ATTR.format(q, alias)
|
||||
if not isinstance(q, list):
|
||||
q = q.replace("'", "\\'")
|
||||
q = q.replace('"', '\\"')
|
||||
q = q.replace("*", "%").replace('\\n', '%')
|
||||
_query_sql = QUERY_CI_BY_NO_ATTR.format(q, alias)
|
||||
else:
|
||||
_query_sql = QUERY_CI_BY_NO_ATTR_IN.format(",".join("'{0}'".format(v) for v in q), alias)
|
||||
|
||||
if is_first and _query_sql and not self.only_type_query:
|
||||
query_sql = "SELECT * FROM ({0}) AS {1}".format(_query_sql, alias)
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import imp
|
||||
import importlib.util
|
||||
|
||||
import copy
|
||||
import jinja2
|
||||
@@ -136,7 +136,7 @@ class AttributeValueManager(object):
|
||||
if not re.compile(expr).match(str(value)):
|
||||
return abort(400, ErrFormat.attribute_value_invalid2.format(alias, value))
|
||||
|
||||
def _validate(self, attr, value, value_table, ci=None, type_id=None, ci_id=None, type_attr=None):
|
||||
def _validate(self, attr, value, value_table, ci=None, type_id=None, ci_id=None, type_attr=None, unique_name=None):
|
||||
if not attr.is_reference:
|
||||
ci = ci or {}
|
||||
v = self._deserialize_value(attr.alias, attr.value_type, value)
|
||||
@@ -146,7 +146,7 @@ class AttributeValueManager(object):
|
||||
else:
|
||||
v = value or None
|
||||
|
||||
attr.is_unique and self._check_is_unique(
|
||||
(attr.is_unique or attr.name == unique_name) and self._check_is_unique(
|
||||
value_table, attr, ci and ci.id or ci_id, ci and ci.type_id or type_id, v)
|
||||
self._check_is_required(ci and ci.type_id or type_id, attr, v, type_attr=type_attr)
|
||||
if attr.is_reference:
|
||||
@@ -180,14 +180,15 @@ class AttributeValueManager(object):
|
||||
|
||||
@staticmethod
|
||||
def _compute_attr_value_from_expr(expr, ci_dict):
|
||||
t = jinja2.Template(expr).render(ci_dict)
|
||||
|
||||
try:
|
||||
return eval(t)
|
||||
result = jinja2.Template(expr).render(ci_dict)
|
||||
return result
|
||||
except Exception as e:
|
||||
current_app.logger.warning(str(e))
|
||||
return t
|
||||
|
||||
current_app.logger.warning(
|
||||
f"Expression evaluation error - Expression: '{expr}'"
|
||||
f"Input parameters: {ci_dict}, Error type: {type(e).__name__}, Error message: {str(e)}"
|
||||
)
|
||||
return None
|
||||
@staticmethod
|
||||
def _compute_attr_value_from_script(script, ci_dict):
|
||||
script = jinja2.Template(script).render(ci_dict)
|
||||
@@ -198,11 +199,11 @@ class AttributeValueManager(object):
|
||||
|
||||
try:
|
||||
path = script_f.name
|
||||
dir_name, name = os.path.dirname(path), os.path.basename(path)[:-3]
|
||||
name = os.path.basename(path)[:-3]
|
||||
|
||||
fp, path, desc = imp.find_module(name, [dir_name])
|
||||
|
||||
mod = imp.load_module(name, fp, path, desc)
|
||||
spec = importlib.util.spec_from_file_location(name, path)
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
|
||||
if hasattr(mod, 'computed'):
|
||||
return mod.computed()
|
||||
@@ -237,7 +238,10 @@ class AttributeValueManager(object):
|
||||
if computed_value is not None:
|
||||
ci_dict[attr['name']] = computed_value
|
||||
|
||||
def valid_attr_value(self, ci_dict, type_id, ci_id, name2attr, alias2attr=None, ci_attr2type_attr=None):
|
||||
def valid_attr_value(self, ci_dict, type_id, ci_id, name2attr,
|
||||
alias2attr=None,
|
||||
ci_attr2type_attr=None,
|
||||
unique_name=None):
|
||||
key2attr = dict()
|
||||
alias2attr = alias2attr or {}
|
||||
ci_attr2type_attr = ci_attr2type_attr or {}
|
||||
@@ -268,7 +272,8 @@ class AttributeValueManager(object):
|
||||
|
||||
else:
|
||||
value = self._validate(attr, value, value_table, ci=None, type_id=type_id, ci_id=ci_id,
|
||||
type_attr=ci_attr2type_attr.get(attr.id))
|
||||
type_attr=ci_attr2type_attr.get(attr.id),
|
||||
unique_name=unique_name)
|
||||
ci_dict[key] = value
|
||||
except BadRequest as e:
|
||||
raise
|
||||
|
@@ -376,6 +376,29 @@ def build_relations_for_ad_accept(adc, ci_id, ad_key2attr):
|
||||
pass
|
||||
|
||||
|
||||
@celery.task(name="cmdb.add_net_device_ports", queue=CMDB_QUEUE)
|
||||
@reconnect_db
|
||||
def add_net_device_ports(ci_id, ports):
|
||||
from api.lib.cmdb.ci import CIRelationManager
|
||||
from api.lib.cmdb.ci import CIManager
|
||||
from api.lib.cmdb.cache import CITypeCache
|
||||
|
||||
port_type = CITypeCache.get("net_port")
|
||||
if not port_type:
|
||||
current_app.logger.warning("CIType net port is not found")
|
||||
return
|
||||
|
||||
for port in ports:
|
||||
try:
|
||||
port_id = CIManager.add(port_type.id, is_auto_discovery=True, _is_admin=True, **port)
|
||||
|
||||
CIRelationManager.add(ci_id, port_id,
|
||||
valid=False,
|
||||
source=RelationSourceEnum.AUTO_DISCOVERY)
|
||||
except Exception as e:
|
||||
current_app.logger.warning("add_net_device_ports failed: {}".format(e))
|
||||
|
||||
|
||||
@celery.task(name="cmdb.dcim_calc_u_free_count", queue=CMDB_QUEUE)
|
||||
@reconnect_db
|
||||
def dcim_calc_u_free_count():
|
||||
|
@@ -30,6 +30,7 @@ from api.lib.cmdb.search import SearchError
|
||||
from api.lib.cmdb.search.ci import search as ci_search
|
||||
from api.lib.decorator import args_required
|
||||
from api.lib.decorator import args_validate
|
||||
from api.lib.exception import AbortException
|
||||
from api.lib.perm.acl.acl import has_perm_from_args
|
||||
from api.lib.utils import AESCrypto
|
||||
from api.lib.utils import get_page
|
||||
@@ -296,7 +297,10 @@ class AutoDiscoveryRuleSyncView(APIView):
|
||||
|
||||
rules, last_update_at1 = AutoDiscoveryCITypeCRUD.get(None, oneagent_id, oneagent_name, last_update_at)
|
||||
|
||||
subnet_scan_rules, last_update_at2 = SubnetManager().scan_rules(oneagent_id, last_update_at)
|
||||
try:
|
||||
subnet_scan_rules, last_update_at2 = SubnetManager().scan_rules(oneagent_id, last_update_at)
|
||||
except AbortException:
|
||||
subnet_scan_rules, last_update_at2 = [], ""
|
||||
|
||||
return self.jsonify(rules=rules,
|
||||
subnet_scan_rules=subnet_scan_rules,
|
||||
|
@@ -64,9 +64,13 @@ class CITypeView(APIView):
|
||||
ci_type['unique_name'] = ci_type['unique_id'] and AttributeCache.get(ci_type['unique_id']).name
|
||||
ci_types.append(ci_type)
|
||||
elif type_name is not None:
|
||||
ci_type = CITypeCache.get(type_name).to_dict()
|
||||
ci_type['parent_ids'] = CITypeInheritanceManager.get_parents(ci_type['id'])
|
||||
ci_types = [ci_type]
|
||||
ci_type = CITypeCache.get(type_name)
|
||||
if ci_type is not None:
|
||||
ci_type = ci_type.to_dict()
|
||||
ci_type['parent_ids'] = CITypeInheritanceManager.get_parents(ci_type['id'])
|
||||
ci_types = [ci_type]
|
||||
else:
|
||||
ci_types = []
|
||||
else:
|
||||
ci_types = CITypeManager().get_ci_types(q)
|
||||
count = len(ci_types)
|
||||
|
37
cmdb-api/api/views/common_setting/system_language.py
Normal file
37
cmdb-api/api/views/common_setting/system_language.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import os
|
||||
|
||||
from api.resource import APIView
|
||||
from api.lib.perm.auth import auth_abandoned
|
||||
|
||||
prefix = "/system"
|
||||
|
||||
|
||||
class SystemLanguageView(APIView):
|
||||
url_prefix = (f"{prefix}/language",)
|
||||
|
||||
method_decorators = []
|
||||
|
||||
@auth_abandoned
|
||||
def get(self):
|
||||
"""Get system default language
|
||||
Read from environment variable SYSTEM_DEFAULT_LANGUAGE, default to Chinese if not set
|
||||
"""
|
||||
default_language = os.environ.get("SYSTEM_DEFAULT_LANGUAGE", "")
|
||||
|
||||
return self.jsonify(
|
||||
{
|
||||
"language": default_language,
|
||||
"language_name": self._get_language_name(default_language),
|
||||
}
|
||||
)
|
||||
|
||||
def _get_language_name(self, language_code):
|
||||
"""Return language name based on language code"""
|
||||
language_mapping = {
|
||||
"zh-CN": "中文(简体)",
|
||||
"zh-TW": "中文(繁体)",
|
||||
"en-US": "English",
|
||||
"ja-JP": "日本語",
|
||||
"ko-KR": "한국어",
|
||||
}
|
||||
return language_mapping.get(language_code, "")
|
@@ -54,6 +54,198 @@
|
||||
<div class="content unicode" style="display: block;">
|
||||
<ul class="icon_lists dib-box">
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">onterm-symbolic_link</div>
|
||||
<div class="code-name">&#xea23;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">oneterm-batch_execution</div>
|
||||
<div class="code-name">&#xea20;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">oneterm-file_log-selected</div>
|
||||
<div class="code-name">&#xea21;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">oneterm-file_log</div>
|
||||
<div class="code-name">&#xea22;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">file</div>
|
||||
<div class="code-name">&#xea1f;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">folder</div>
|
||||
<div class="code-name">&#xea1e;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">mongoDB (1)</div>
|
||||
<div class="code-name">&#xea1b;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">postgreSQL (1)</div>
|
||||
<div class="code-name">&#xea1c;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">telnet (1)</div>
|
||||
<div class="code-name">&#xea1d;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">command_interception (1)</div>
|
||||
<div class="code-name">&#xea17;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">quick_commands</div>
|
||||
<div class="code-name">&#xea18;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">terminal_settings</div>
|
||||
<div class="code-name">&#xea19;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">basic_settings</div>
|
||||
<div class="code-name">&#xea1a;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">asset_management</div>
|
||||
<div class="code-name">&#xea16;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">ai-seek</div>
|
||||
<div class="code-name">&#xea15;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">ai-hate1</div>
|
||||
<div class="code-name">&#xea13;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">ai-like1</div>
|
||||
<div class="code-name">&#xea14;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">ai-like2</div>
|
||||
<div class="code-name">&#xea11;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">ai-hate2</div>
|
||||
<div class="code-name">&#xea12;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">ai-top_up</div>
|
||||
<div class="code-name">&#xea10;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">ai-top_down</div>
|
||||
<div class="code-name">&#xea0f;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">autoflow-script</div>
|
||||
<div class="code-name">&#xea0d;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">autoflow-dag</div>
|
||||
<div class="code-name">&#xea0e;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">itsm-default_line</div>
|
||||
<div class="code-name">&#xea0c;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">veops-servicetree</div>
|
||||
<div class="code-name">&#xea0b;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">veops-switch (1)</div>
|
||||
<div class="code-name">&#xea0a;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">veops-label</div>
|
||||
<div class="code-name">&#xea09;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">top_acl</div>
|
||||
<div class="code-name">&#xea08;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">top_ticket</div>
|
||||
<div class="code-name">&#xea06;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">top_agent</div>
|
||||
<div class="code-name">&#xea07;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">itsm-table_download</div>
|
||||
<div class="code-name">&#xea05;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">itsm-image_download</div>
|
||||
<div class="code-name">&#xea04;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">veops-rear</div>
|
||||
@@ -6162,9 +6354,9 @@
|
||||
<pre><code class="language-css"
|
||||
>@font-face {
|
||||
font-family: 'iconfont';
|
||||
src: url('iconfont.woff2?t=1732673294759') format('woff2'),
|
||||
url('iconfont.woff?t=1732673294759') format('woff'),
|
||||
url('iconfont.ttf?t=1732673294759') format('truetype');
|
||||
src: url('iconfont.woff2?t=1749393321370') format('woff2'),
|
||||
url('iconfont.woff?t=1749393321370') format('woff'),
|
||||
url('iconfont.ttf?t=1749393321370') format('truetype');
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
|
||||
@@ -6190,6 +6382,294 @@
|
||||
<div class="content font-class">
|
||||
<ul class="icon_lists dib-box">
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont onterm-symbolic_link"></span>
|
||||
<div class="name">
|
||||
onterm-symbolic_link
|
||||
</div>
|
||||
<div class="code-name">.onterm-symbolic_link
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont oneterm-batch_execution"></span>
|
||||
<div class="name">
|
||||
oneterm-batch_execution
|
||||
</div>
|
||||
<div class="code-name">.oneterm-batch_execution
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ops-oneterm-file_log-selected"></span>
|
||||
<div class="name">
|
||||
oneterm-file_log-selected
|
||||
</div>
|
||||
<div class="code-name">.ops-oneterm-file_log-selected
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ops-oneterm-file_log"></span>
|
||||
<div class="name">
|
||||
oneterm-file_log
|
||||
</div>
|
||||
<div class="code-name">.ops-oneterm-file_log
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont file"></span>
|
||||
<div class="name">
|
||||
file
|
||||
</div>
|
||||
<div class="code-name">.file
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont folder1"></span>
|
||||
<div class="name">
|
||||
folder
|
||||
</div>
|
||||
<div class="code-name">.folder1
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont a-mongoDB1"></span>
|
||||
<div class="name">
|
||||
mongoDB (1)
|
||||
</div>
|
||||
<div class="code-name">.a-mongoDB1
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont a-postgreSQL1"></span>
|
||||
<div class="name">
|
||||
postgreSQL (1)
|
||||
</div>
|
||||
<div class="code-name">.a-postgreSQL1
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont a-telnet1"></span>
|
||||
<div class="name">
|
||||
telnet (1)
|
||||
</div>
|
||||
<div class="code-name">.a-telnet1
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont a-command_interception1"></span>
|
||||
<div class="name">
|
||||
command_interception (1)
|
||||
</div>
|
||||
<div class="code-name">.a-command_interception1
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont quick_commands"></span>
|
||||
<div class="name">
|
||||
quick_commands
|
||||
</div>
|
||||
<div class="code-name">.quick_commands
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont terminal_settings"></span>
|
||||
<div class="name">
|
||||
terminal_settings
|
||||
</div>
|
||||
<div class="code-name">.terminal_settings
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont basic_settings"></span>
|
||||
<div class="name">
|
||||
basic_settings
|
||||
</div>
|
||||
<div class="code-name">.basic_settings
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ops-oneterm-asset-management"></span>
|
||||
<div class="name">
|
||||
asset_management
|
||||
</div>
|
||||
<div class="code-name">.ops-oneterm-asset-management
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ai-seek"></span>
|
||||
<div class="name">
|
||||
ai-seek
|
||||
</div>
|
||||
<div class="code-name">.ai-seek
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ai-hate1"></span>
|
||||
<div class="name">
|
||||
ai-hate1
|
||||
</div>
|
||||
<div class="code-name">.ai-hate1
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ai-like1"></span>
|
||||
<div class="name">
|
||||
ai-like1
|
||||
</div>
|
||||
<div class="code-name">.ai-like1
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ai-like2"></span>
|
||||
<div class="name">
|
||||
ai-like2
|
||||
</div>
|
||||
<div class="code-name">.ai-like2
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ai-hate2"></span>
|
||||
<div class="name">
|
||||
ai-hate2
|
||||
</div>
|
||||
<div class="code-name">.ai-hate2
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ai-top_up"></span>
|
||||
<div class="name">
|
||||
ai-top_up
|
||||
</div>
|
||||
<div class="code-name">.ai-top_up
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont ai-top_down"></span>
|
||||
<div class="name">
|
||||
ai-top_down
|
||||
</div>
|
||||
<div class="code-name">.ai-top_down
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont autoflow-script"></span>
|
||||
<div class="name">
|
||||
autoflow-script
|
||||
</div>
|
||||
<div class="code-name">.autoflow-script
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont autoflow-dag"></span>
|
||||
<div class="name">
|
||||
autoflow-dag
|
||||
</div>
|
||||
<div class="code-name">.autoflow-dag
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont itsm-default_line"></span>
|
||||
<div class="name">
|
||||
itsm-default_line
|
||||
</div>
|
||||
<div class="code-name">.itsm-default_line
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont veops-servicetree"></span>
|
||||
<div class="name">
|
||||
veops-servicetree
|
||||
</div>
|
||||
<div class="code-name">.veops-servicetree
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont veops-switch1"></span>
|
||||
<div class="name">
|
||||
veops-switch (1)
|
||||
</div>
|
||||
<div class="code-name">.veops-switch1
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont veops-label"></span>
|
||||
<div class="name">
|
||||
veops-label
|
||||
</div>
|
||||
<div class="code-name">.veops-label
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont top_acl"></span>
|
||||
<div class="name">
|
||||
top_acl
|
||||
</div>
|
||||
<div class="code-name">.top_acl
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont top_ticket"></span>
|
||||
<div class="name">
|
||||
top_ticket
|
||||
</div>
|
||||
<div class="code-name">.top_ticket
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont top_agent"></span>
|
||||
<div class="name">
|
||||
top_agent
|
||||
</div>
|
||||
<div class="code-name">.top_agent
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont itsm-table_download"></span>
|
||||
<div class="name">
|
||||
itsm-table_download
|
||||
</div>
|
||||
<div class="code-name">.itsm-table_download
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont itsm-image_download"></span>
|
||||
<div class="name">
|
||||
itsm-image_download
|
||||
</div>
|
||||
<div class="code-name">.itsm-image_download
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont veops-rear"></span>
|
||||
<div class="name">
|
||||
@@ -15352,6 +15832,262 @@
|
||||
<div class="content symbol">
|
||||
<ul class="icon_lists dib-box">
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#onterm-symbolic_link"></use>
|
||||
</svg>
|
||||
<div class="name">onterm-symbolic_link</div>
|
||||
<div class="code-name">#onterm-symbolic_link</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#oneterm-batch_execution"></use>
|
||||
</svg>
|
||||
<div class="name">oneterm-batch_execution</div>
|
||||
<div class="code-name">#oneterm-batch_execution</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ops-oneterm-file_log-selected"></use>
|
||||
</svg>
|
||||
<div class="name">oneterm-file_log-selected</div>
|
||||
<div class="code-name">#ops-oneterm-file_log-selected</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ops-oneterm-file_log"></use>
|
||||
</svg>
|
||||
<div class="name">oneterm-file_log</div>
|
||||
<div class="code-name">#ops-oneterm-file_log</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#file"></use>
|
||||
</svg>
|
||||
<div class="name">file</div>
|
||||
<div class="code-name">#file</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#folder1"></use>
|
||||
</svg>
|
||||
<div class="name">folder</div>
|
||||
<div class="code-name">#folder1</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#a-mongoDB1"></use>
|
||||
</svg>
|
||||
<div class="name">mongoDB (1)</div>
|
||||
<div class="code-name">#a-mongoDB1</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#a-postgreSQL1"></use>
|
||||
</svg>
|
||||
<div class="name">postgreSQL (1)</div>
|
||||
<div class="code-name">#a-postgreSQL1</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#a-telnet1"></use>
|
||||
</svg>
|
||||
<div class="name">telnet (1)</div>
|
||||
<div class="code-name">#a-telnet1</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#a-command_interception1"></use>
|
||||
</svg>
|
||||
<div class="name">command_interception (1)</div>
|
||||
<div class="code-name">#a-command_interception1</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#quick_commands"></use>
|
||||
</svg>
|
||||
<div class="name">quick_commands</div>
|
||||
<div class="code-name">#quick_commands</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#terminal_settings"></use>
|
||||
</svg>
|
||||
<div class="name">terminal_settings</div>
|
||||
<div class="code-name">#terminal_settings</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#basic_settings"></use>
|
||||
</svg>
|
||||
<div class="name">basic_settings</div>
|
||||
<div class="code-name">#basic_settings</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ops-oneterm-asset-management"></use>
|
||||
</svg>
|
||||
<div class="name">asset_management</div>
|
||||
<div class="code-name">#ops-oneterm-asset-management</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ai-seek"></use>
|
||||
</svg>
|
||||
<div class="name">ai-seek</div>
|
||||
<div class="code-name">#ai-seek</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ai-hate1"></use>
|
||||
</svg>
|
||||
<div class="name">ai-hate1</div>
|
||||
<div class="code-name">#ai-hate1</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ai-like1"></use>
|
||||
</svg>
|
||||
<div class="name">ai-like1</div>
|
||||
<div class="code-name">#ai-like1</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ai-like2"></use>
|
||||
</svg>
|
||||
<div class="name">ai-like2</div>
|
||||
<div class="code-name">#ai-like2</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ai-hate2"></use>
|
||||
</svg>
|
||||
<div class="name">ai-hate2</div>
|
||||
<div class="code-name">#ai-hate2</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ai-top_up"></use>
|
||||
</svg>
|
||||
<div class="name">ai-top_up</div>
|
||||
<div class="code-name">#ai-top_up</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#ai-top_down"></use>
|
||||
</svg>
|
||||
<div class="name">ai-top_down</div>
|
||||
<div class="code-name">#ai-top_down</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#autoflow-script"></use>
|
||||
</svg>
|
||||
<div class="name">autoflow-script</div>
|
||||
<div class="code-name">#autoflow-script</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#autoflow-dag"></use>
|
||||
</svg>
|
||||
<div class="name">autoflow-dag</div>
|
||||
<div class="code-name">#autoflow-dag</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#itsm-default_line"></use>
|
||||
</svg>
|
||||
<div class="name">itsm-default_line</div>
|
||||
<div class="code-name">#itsm-default_line</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#veops-servicetree"></use>
|
||||
</svg>
|
||||
<div class="name">veops-servicetree</div>
|
||||
<div class="code-name">#veops-servicetree</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#veops-switch1"></use>
|
||||
</svg>
|
||||
<div class="name">veops-switch (1)</div>
|
||||
<div class="code-name">#veops-switch1</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#veops-label"></use>
|
||||
</svg>
|
||||
<div class="name">veops-label</div>
|
||||
<div class="code-name">#veops-label</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#top_acl"></use>
|
||||
</svg>
|
||||
<div class="name">top_acl</div>
|
||||
<div class="code-name">#top_acl</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#top_ticket"></use>
|
||||
</svg>
|
||||
<div class="name">top_ticket</div>
|
||||
<div class="code-name">#top_ticket</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#top_agent"></use>
|
||||
</svg>
|
||||
<div class="name">top_agent</div>
|
||||
<div class="code-name">#top_agent</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#itsm-table_download"></use>
|
||||
</svg>
|
||||
<div class="name">itsm-table_download</div>
|
||||
<div class="code-name">#itsm-table_download</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#itsm-image_download"></use>
|
||||
</svg>
|
||||
<div class="name">itsm-image_download</div>
|
||||
<div class="code-name">#itsm-image_download</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#veops-rear"></use>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 3857903 */
|
||||
src: url('iconfont.woff2?t=1732673294759') format('woff2'),
|
||||
url('iconfont.woff?t=1732673294759') format('woff'),
|
||||
url('iconfont.ttf?t=1732673294759') format('truetype');
|
||||
src: url('iconfont.woff2?t=1749393321370') format('woff2'),
|
||||
url('iconfont.woff?t=1749393321370') format('woff'),
|
||||
url('iconfont.ttf?t=1749393321370') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
@@ -13,6 +13,134 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.onterm-symbolic_link:before {
|
||||
content: "\ea23";
|
||||
}
|
||||
|
||||
.oneterm-batch_execution:before {
|
||||
content: "\ea20";
|
||||
}
|
||||
|
||||
.ops-oneterm-file_log-selected:before {
|
||||
content: "\ea21";
|
||||
}
|
||||
|
||||
.ops-oneterm-file_log:before {
|
||||
content: "\ea22";
|
||||
}
|
||||
|
||||
.file:before {
|
||||
content: "\ea1f";
|
||||
}
|
||||
|
||||
.folder1:before {
|
||||
content: "\ea1e";
|
||||
}
|
||||
|
||||
.a-mongoDB1:before {
|
||||
content: "\ea1b";
|
||||
}
|
||||
|
||||
.a-postgreSQL1:before {
|
||||
content: "\ea1c";
|
||||
}
|
||||
|
||||
.a-telnet1:before {
|
||||
content: "\ea1d";
|
||||
}
|
||||
|
||||
.a-command_interception1:before {
|
||||
content: "\ea17";
|
||||
}
|
||||
|
||||
.quick_commands:before {
|
||||
content: "\ea18";
|
||||
}
|
||||
|
||||
.terminal_settings:before {
|
||||
content: "\ea19";
|
||||
}
|
||||
|
||||
.basic_settings:before {
|
||||
content: "\ea1a";
|
||||
}
|
||||
|
||||
.ops-oneterm-asset-management:before {
|
||||
content: "\ea16";
|
||||
}
|
||||
|
||||
.ai-seek:before {
|
||||
content: "\ea15";
|
||||
}
|
||||
|
||||
.ai-hate1:before {
|
||||
content: "\ea13";
|
||||
}
|
||||
|
||||
.ai-like1:before {
|
||||
content: "\ea14";
|
||||
}
|
||||
|
||||
.ai-like2:before {
|
||||
content: "\ea11";
|
||||
}
|
||||
|
||||
.ai-hate2:before {
|
||||
content: "\ea12";
|
||||
}
|
||||
|
||||
.ai-top_up:before {
|
||||
content: "\ea10";
|
||||
}
|
||||
|
||||
.ai-top_down:before {
|
||||
content: "\ea0f";
|
||||
}
|
||||
|
||||
.autoflow-script:before {
|
||||
content: "\ea0d";
|
||||
}
|
||||
|
||||
.autoflow-dag:before {
|
||||
content: "\ea0e";
|
||||
}
|
||||
|
||||
.itsm-default_line:before {
|
||||
content: "\ea0c";
|
||||
}
|
||||
|
||||
.veops-servicetree:before {
|
||||
content: "\ea0b";
|
||||
}
|
||||
|
||||
.veops-switch1:before {
|
||||
content: "\ea0a";
|
||||
}
|
||||
|
||||
.veops-label:before {
|
||||
content: "\ea09";
|
||||
}
|
||||
|
||||
.top_acl:before {
|
||||
content: "\ea08";
|
||||
}
|
||||
|
||||
.top_ticket:before {
|
||||
content: "\ea06";
|
||||
}
|
||||
|
||||
.top_agent:before {
|
||||
content: "\ea07";
|
||||
}
|
||||
|
||||
.itsm-table_download:before {
|
||||
content: "\ea05";
|
||||
}
|
||||
|
||||
.itsm-image_download:before {
|
||||
content: "\ea04";
|
||||
}
|
||||
|
||||
.veops-rear:before {
|
||||
content: "\ea02";
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@@ -5,6 +5,230 @@
|
||||
"css_prefix_text": "",
|
||||
"description": "",
|
||||
"glyphs": [
|
||||
{
|
||||
"icon_id": "44501032",
|
||||
"name": "onterm-symbolic_link",
|
||||
"font_class": "onterm-symbolic_link",
|
||||
"unicode": "ea23",
|
||||
"unicode_decimal": 59939
|
||||
},
|
||||
{
|
||||
"icon_id": "44497221",
|
||||
"name": "oneterm-batch_execution",
|
||||
"font_class": "oneterm-batch_execution",
|
||||
"unicode": "ea20",
|
||||
"unicode_decimal": 59936
|
||||
},
|
||||
{
|
||||
"icon_id": "44497220",
|
||||
"name": "oneterm-file_log-selected",
|
||||
"font_class": "ops-oneterm-file_log-selected",
|
||||
"unicode": "ea21",
|
||||
"unicode_decimal": 59937
|
||||
},
|
||||
{
|
||||
"icon_id": "44497219",
|
||||
"name": "oneterm-file_log",
|
||||
"font_class": "ops-oneterm-file_log",
|
||||
"unicode": "ea22",
|
||||
"unicode_decimal": 59938
|
||||
},
|
||||
{
|
||||
"icon_id": "44455092",
|
||||
"name": "file",
|
||||
"font_class": "file",
|
||||
"unicode": "ea1f",
|
||||
"unicode_decimal": 59935
|
||||
},
|
||||
{
|
||||
"icon_id": "44455100",
|
||||
"name": "folder",
|
||||
"font_class": "folder1",
|
||||
"unicode": "ea1e",
|
||||
"unicode_decimal": 59934
|
||||
},
|
||||
{
|
||||
"icon_id": "44315758",
|
||||
"name": "mongoDB (1)",
|
||||
"font_class": "a-mongoDB1",
|
||||
"unicode": "ea1b",
|
||||
"unicode_decimal": 59931
|
||||
},
|
||||
{
|
||||
"icon_id": "44315757",
|
||||
"name": "postgreSQL (1)",
|
||||
"font_class": "a-postgreSQL1",
|
||||
"unicode": "ea1c",
|
||||
"unicode_decimal": 59932
|
||||
},
|
||||
{
|
||||
"icon_id": "44315755",
|
||||
"name": "telnet (1)",
|
||||
"font_class": "a-telnet1",
|
||||
"unicode": "ea1d",
|
||||
"unicode_decimal": 59933
|
||||
},
|
||||
{
|
||||
"icon_id": "44276353",
|
||||
"name": "command_interception (1)",
|
||||
"font_class": "a-command_interception1",
|
||||
"unicode": "ea17",
|
||||
"unicode_decimal": 59927
|
||||
},
|
||||
{
|
||||
"icon_id": "44276352",
|
||||
"name": "quick_commands",
|
||||
"font_class": "quick_commands",
|
||||
"unicode": "ea18",
|
||||
"unicode_decimal": 59928
|
||||
},
|
||||
{
|
||||
"icon_id": "44276351",
|
||||
"name": "terminal_settings",
|
||||
"font_class": "terminal_settings",
|
||||
"unicode": "ea19",
|
||||
"unicode_decimal": 59929
|
||||
},
|
||||
{
|
||||
"icon_id": "44276350",
|
||||
"name": "basic_settings",
|
||||
"font_class": "basic_settings",
|
||||
"unicode": "ea1a",
|
||||
"unicode_decimal": 59930
|
||||
},
|
||||
{
|
||||
"icon_id": "44276278",
|
||||
"name": "asset_management",
|
||||
"font_class": "ops-oneterm-asset-management",
|
||||
"unicode": "ea16",
|
||||
"unicode_decimal": 59926
|
||||
},
|
||||
{
|
||||
"icon_id": "43267802",
|
||||
"name": "ai-seek",
|
||||
"font_class": "ai-seek",
|
||||
"unicode": "ea15",
|
||||
"unicode_decimal": 59925
|
||||
},
|
||||
{
|
||||
"icon_id": "43213714",
|
||||
"name": "ai-hate1",
|
||||
"font_class": "ai-hate1",
|
||||
"unicode": "ea13",
|
||||
"unicode_decimal": 59923
|
||||
},
|
||||
{
|
||||
"icon_id": "43213712",
|
||||
"name": "ai-like1",
|
||||
"font_class": "ai-like1",
|
||||
"unicode": "ea14",
|
||||
"unicode_decimal": 59924
|
||||
},
|
||||
{
|
||||
"icon_id": "43213717",
|
||||
"name": "ai-like2",
|
||||
"font_class": "ai-like2",
|
||||
"unicode": "ea11",
|
||||
"unicode_decimal": 59921
|
||||
},
|
||||
{
|
||||
"icon_id": "43213716",
|
||||
"name": "ai-hate2",
|
||||
"font_class": "ai-hate2",
|
||||
"unicode": "ea12",
|
||||
"unicode_decimal": 59922
|
||||
},
|
||||
{
|
||||
"icon_id": "43139007",
|
||||
"name": "ai-top_up",
|
||||
"font_class": "ai-top_up",
|
||||
"unicode": "ea10",
|
||||
"unicode_decimal": 59920
|
||||
},
|
||||
{
|
||||
"icon_id": "43139017",
|
||||
"name": "ai-top_down",
|
||||
"font_class": "ai-top_down",
|
||||
"unicode": "ea0f",
|
||||
"unicode_decimal": 59919
|
||||
},
|
||||
{
|
||||
"icon_id": "43029539",
|
||||
"name": "autoflow-script",
|
||||
"font_class": "autoflow-script",
|
||||
"unicode": "ea0d",
|
||||
"unicode_decimal": 59917
|
||||
},
|
||||
{
|
||||
"icon_id": "43029538",
|
||||
"name": "autoflow-dag",
|
||||
"font_class": "autoflow-dag",
|
||||
"unicode": "ea0e",
|
||||
"unicode_decimal": 59918
|
||||
},
|
||||
{
|
||||
"icon_id": "42960865",
|
||||
"name": "itsm-default_line",
|
||||
"font_class": "itsm-default_line",
|
||||
"unicode": "ea0c",
|
||||
"unicode_decimal": 59916
|
||||
},
|
||||
{
|
||||
"icon_id": "42930714",
|
||||
"name": "veops-servicetree",
|
||||
"font_class": "veops-servicetree",
|
||||
"unicode": "ea0b",
|
||||
"unicode_decimal": 59915
|
||||
},
|
||||
{
|
||||
"icon_id": "42921461",
|
||||
"name": "veops-switch (1)",
|
||||
"font_class": "veops-switch1",
|
||||
"unicode": "ea0a",
|
||||
"unicode_decimal": 59914
|
||||
},
|
||||
{
|
||||
"icon_id": "42857659",
|
||||
"name": "veops-label",
|
||||
"font_class": "veops-label",
|
||||
"unicode": "ea09",
|
||||
"unicode_decimal": 59913
|
||||
},
|
||||
{
|
||||
"icon_id": "42790685",
|
||||
"name": "top_acl",
|
||||
"font_class": "top_acl",
|
||||
"unicode": "ea08",
|
||||
"unicode_decimal": 59912
|
||||
},
|
||||
{
|
||||
"icon_id": "42790687",
|
||||
"name": "top_ticket",
|
||||
"font_class": "top_ticket",
|
||||
"unicode": "ea06",
|
||||
"unicode_decimal": 59910
|
||||
},
|
||||
{
|
||||
"icon_id": "42790686",
|
||||
"name": "top_agent",
|
||||
"font_class": "top_agent",
|
||||
"unicode": "ea07",
|
||||
"unicode_decimal": 59911
|
||||
},
|
||||
{
|
||||
"icon_id": "42732510",
|
||||
"name": "itsm-table_download",
|
||||
"font_class": "itsm-table_download",
|
||||
"unicode": "ea05",
|
||||
"unicode_decimal": 59909
|
||||
},
|
||||
{
|
||||
"icon_id": "42732515",
|
||||
"name": "itsm-image_download",
|
||||
"font_class": "itsm-image_download",
|
||||
"unicode": "ea04",
|
||||
"unicode_decimal": 59908
|
||||
},
|
||||
{
|
||||
"icon_id": "42510712",
|
||||
"name": "veops-rear",
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,6 +12,7 @@ import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
|
||||
import enUS from 'ant-design-vue/lib/locale-provider/en_US'
|
||||
import { AppDeviceEnquire } from '@/utils/mixin'
|
||||
import { debounce } from './utils/util'
|
||||
import { getSystemLanguage } from '@/api/system.js'
|
||||
|
||||
import { h } from 'snabbdom'
|
||||
import { DomEditor, Boot } from '@wangeditor/editor'
|
||||
@@ -45,8 +46,7 @@ export default {
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.SET_LOCALE(localStorage.getItem('ops_locale') || 'zh')
|
||||
this.$i18n.locale = localStorage.getItem('ops_locale') || 'zh'
|
||||
this.initLanguage()
|
||||
this.timer = setInterval(() => {
|
||||
this.setTime(new Date().getTime())
|
||||
}, 1000)
|
||||
@@ -200,6 +200,28 @@ export default {
|
||||
this.alive = true
|
||||
})
|
||||
},
|
||||
async initLanguage() {
|
||||
let saveLocale = localStorage.getItem('ops_locale')
|
||||
if (!saveLocale) {
|
||||
let requestLanguage = ''
|
||||
try {
|
||||
const languageRes = await getSystemLanguage()
|
||||
requestLanguage = languageRes?.language || ''
|
||||
} catch (e) {
|
||||
console.error('getSystemLanguage error:', e)
|
||||
}
|
||||
|
||||
// request language variable || user local system language
|
||||
const userLanguage = requestLanguage || navigator.language || navigator.userLanguage
|
||||
if (userLanguage.includes('zh')) {
|
||||
saveLocale = 'zh'
|
||||
} else {
|
||||
saveLocale = 'en'
|
||||
}
|
||||
}
|
||||
this.SET_LOCALE(saveLocale)
|
||||
this.$i18n.locale = saveLocale
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
8
cmdb-ui/src/api/system.js
Normal file
8
cmdb-ui/src/api/system.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { axios } from '@/utils/request'
|
||||
|
||||
export function getSystemLanguage() {
|
||||
return axios({
|
||||
url: '/common-setting/v1/system/language',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 249 KiB After Width: | Height: | Size: 1.1 MiB |
@@ -106,7 +106,7 @@
|
||||
<CIReferenceAttr
|
||||
v-if="getAttr(item.property).is_reference && (item.exp === 'is' || item.exp === '~is')"
|
||||
:style="{ width: '175px' }"
|
||||
class="select-filter-component"
|
||||
class="select-filter-component ops-select-bg"
|
||||
:referenceTypeId="getAttr(item.property).reference_type_id"
|
||||
:disabled="disabled"
|
||||
v-model="item.value"
|
||||
@@ -114,7 +114,7 @@
|
||||
<a-select
|
||||
v-else-if="getAttr(item.property).is_bool && (item.exp === 'is' || item.exp === '~is')"
|
||||
v-model="item.value"
|
||||
class="select-filter-component"
|
||||
class="select-filter-component ops-select-bg"
|
||||
:style="{ width: '175px' }"
|
||||
:disabled="disabled"
|
||||
:placeholder="$t('placeholder2')"
|
||||
@@ -398,7 +398,6 @@ export default {
|
||||
|
||||
/deep/ .ant-select-selection {
|
||||
height: 24px;
|
||||
background: #f7f8fa;
|
||||
line-height: 24px;
|
||||
border: none;
|
||||
|
||||
|
@@ -1,302 +1,302 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-popover
|
||||
v-if="isDropdown"
|
||||
v-model="visible"
|
||||
trigger="click"
|
||||
:placement="placement"
|
||||
overlayClassName="table-filter"
|
||||
@visibleChange="visibleChange"
|
||||
>
|
||||
<slot name="popover_item">
|
||||
<a-button type="primary" ghost>{{ $t('cmdbFilterComp.conditionFilter') }}<a-icon type="filter"/></a-button>
|
||||
</slot>
|
||||
<template slot="content">
|
||||
<Expression
|
||||
:needAddHere="needAddHere"
|
||||
v-model="ruleList"
|
||||
:canSearchPreferenceAttrList="canSearchPreferenceAttrList.filter((attr) => !attr.is_password)"
|
||||
:disabled="disabled"
|
||||
/>
|
||||
<a-divider :style="{ margin: '10px 0' }" />
|
||||
<div style="width:554px">
|
||||
<a-space :style="{ display: 'flex', justifyContent: 'flex-end' }">
|
||||
<a-button type="primary" size="small" @click="handleSubmit">{{ $t('confirm') }}</a-button>
|
||||
<a-button size="small" @click="handleClear">{{ $t('clear') }}</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
</a-popover>
|
||||
<Expression
|
||||
:needAddHere="needAddHere"
|
||||
v-else
|
||||
v-model="ruleList"
|
||||
:canSearchPreferenceAttrList="canSearchPreferenceAttrList.filter((attr) => !attr.is_password)"
|
||||
:disabled="disabled"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import Expression from './expression.vue'
|
||||
import { advancedExpList, compareTypeList } from './constants'
|
||||
|
||||
export default {
|
||||
name: 'FilterComp',
|
||||
components: { Expression },
|
||||
props: {
|
||||
canSearchPreferenceAttrList: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: () => [],
|
||||
},
|
||||
expression: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
regQ: {
|
||||
type: String,
|
||||
default: '(?<=q=).+(?=&)|(?<=q=).+$',
|
||||
},
|
||||
placement: {
|
||||
type: String,
|
||||
default: 'bottomRight',
|
||||
},
|
||||
isDropdown: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
needAddHere: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
advancedExpList,
|
||||
compareTypeList,
|
||||
visible: false,
|
||||
ruleList: [],
|
||||
filterExp: '',
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
visibleChange(open, isInitOne = true) {
|
||||
// isInitOne 初始化exp为空时,ruleList是否默认给一条
|
||||
// const regQ = /(?<=q=).+(?=&)|(?<=q=).+$/g
|
||||
const exp = this.expression.match(new RegExp(this.regQ, 'g'))
|
||||
? this.expression.match(new RegExp(this.regQ, 'g'))[0]
|
||||
: null
|
||||
if (open && exp) {
|
||||
const expArray = exp.split(',').map((item) => {
|
||||
let has_not = ''
|
||||
const key = item.split(':')[0]
|
||||
const val = item
|
||||
.split(':')
|
||||
.slice(1)
|
||||
.join(':')
|
||||
let type, property, exp, value, min, max, compareType
|
||||
if (key.includes('-')) {
|
||||
type = 'or'
|
||||
if (key.includes('~')) {
|
||||
property = key.substring(2)
|
||||
has_not = '~'
|
||||
} else {
|
||||
property = key.substring(1)
|
||||
}
|
||||
} else {
|
||||
type = 'and'
|
||||
if (key.includes('~')) {
|
||||
property = key.substring(1)
|
||||
has_not = '~'
|
||||
} else {
|
||||
property = key
|
||||
}
|
||||
}
|
||||
|
||||
const in_reg = /(?<=\().+(?=\))/g
|
||||
const range_reg = /(?<=\[).+(?=\])/g
|
||||
const compare_reg = /(?<=>=|<=|>(?!=)|<(?!=)).+/
|
||||
if (val === '*') {
|
||||
exp = has_not + 'value'
|
||||
value = ''
|
||||
} else if (in_reg.test(val)) {
|
||||
exp = has_not + 'in'
|
||||
value = val.match(in_reg)[0]
|
||||
} else if (range_reg.test(val)) {
|
||||
exp = has_not + 'range'
|
||||
value = val.match(range_reg)[0]
|
||||
min = value.split('_TO_')[0]
|
||||
max = value.split('_TO_')[1]
|
||||
} else if (compare_reg.test(val)) {
|
||||
exp = has_not + 'compare'
|
||||
value = val.match(compare_reg)[0]
|
||||
const _compareType = val.substring(0, val.match(compare_reg)['index'])
|
||||
const idx = compareTypeList.findIndex((item) => item.label === _compareType)
|
||||
compareType = compareTypeList[idx].value
|
||||
} else if (!val.includes('*')) {
|
||||
exp = has_not + 'is'
|
||||
value = val
|
||||
} else {
|
||||
const resList = [
|
||||
['contain', /(?<=\*).*(?=\*)/g],
|
||||
['end_with', /(?<=\*).+/g],
|
||||
['start_with', /.+(?=\*)/g],
|
||||
]
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const reg = resList[i]
|
||||
if (reg[1].test(val)) {
|
||||
exp = has_not + reg[0]
|
||||
value = val.match(reg[1])[0]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
id: uuidv4(),
|
||||
type,
|
||||
property,
|
||||
exp,
|
||||
value,
|
||||
min,
|
||||
max,
|
||||
compareType,
|
||||
}
|
||||
})
|
||||
this.ruleList = [...expArray]
|
||||
} else if (open) {
|
||||
const _canSearchPreferenceAttrList = this.canSearchPreferenceAttrList.filter((attr) => !attr.is_password)
|
||||
this.ruleList = isInitOne
|
||||
? [
|
||||
{
|
||||
id: uuidv4(),
|
||||
type: 'and',
|
||||
property:
|
||||
_canSearchPreferenceAttrList && _canSearchPreferenceAttrList.length
|
||||
? _canSearchPreferenceAttrList[0].name
|
||||
: undefined,
|
||||
exp: 'is',
|
||||
value: null,
|
||||
},
|
||||
]
|
||||
: []
|
||||
}
|
||||
},
|
||||
handleClear() {
|
||||
this.ruleList = [
|
||||
{
|
||||
id: uuidv4(),
|
||||
type: 'and',
|
||||
property: this.canSearchPreferenceAttrList[0].name,
|
||||
exp: 'is',
|
||||
value: null,
|
||||
},
|
||||
]
|
||||
this.filterExp = ''
|
||||
this.visible = false
|
||||
this.$emit('setExpFromFilter', this.filterExp)
|
||||
},
|
||||
handleSubmit() {
|
||||
if (this.ruleList && this.ruleList.length) {
|
||||
this.ruleList[0].type = 'and' // 增删后,以防万一第一个不是and
|
||||
this.filterExp = ''
|
||||
const expList = this.ruleList.map((rule) => {
|
||||
let singleRuleExp = ''
|
||||
let _exp = rule.exp
|
||||
if (rule.type === 'or') {
|
||||
singleRuleExp += '-'
|
||||
}
|
||||
if (rule.exp.includes('~')) {
|
||||
singleRuleExp += '~'
|
||||
_exp = rule.exp.split('~')[1]
|
||||
}
|
||||
singleRuleExp += `${rule.property}:`
|
||||
if (_exp === 'is') {
|
||||
singleRuleExp += `${rule.value ?? ''}`
|
||||
}
|
||||
if (_exp === 'contain') {
|
||||
singleRuleExp += `*${rule.value ?? ''}*`
|
||||
}
|
||||
if (_exp === 'start_with') {
|
||||
singleRuleExp += `${rule.value ?? ''}*`
|
||||
}
|
||||
if (_exp === 'end_with') {
|
||||
singleRuleExp += `*${rule.value ?? ''}`
|
||||
}
|
||||
if (_exp === 'value') {
|
||||
singleRuleExp += `*`
|
||||
}
|
||||
if (_exp === 'in') {
|
||||
singleRuleExp += `(${rule.value ?? ''})`
|
||||
}
|
||||
if (_exp === 'range') {
|
||||
singleRuleExp += `[${rule.min}_TO_${rule.max}]`
|
||||
}
|
||||
if (_exp === 'compare') {
|
||||
const idx = compareTypeList.findIndex((item) => item.value === rule.compareType)
|
||||
singleRuleExp += `${compareTypeList[idx].label}${rule.value ?? ''}`
|
||||
}
|
||||
return singleRuleExp
|
||||
})
|
||||
this.filterExp = expList.join(',')
|
||||
this.$emit('setExpFromFilter', this.filterExp)
|
||||
} else {
|
||||
this.$emit('setExpFromFilter', '')
|
||||
}
|
||||
this.visible = false
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.table-filter {
|
||||
.table-filter-add {
|
||||
margin-top: 10px;
|
||||
& > a {
|
||||
padding: 2px 8px;
|
||||
&:hover {
|
||||
background-color: #f0faff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.table-filter-extra-icon {
|
||||
padding: 0px 2px;
|
||||
&:hover {
|
||||
display: inline-block;
|
||||
border-radius: 5px;
|
||||
background-color: #f0faff;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.table-filter-extra-operation {
|
||||
.ant-popover-inner-content {
|
||||
padding: 3px 4px;
|
||||
.operation {
|
||||
cursor: pointer;
|
||||
width: 90px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 3px 4px;
|
||||
border-radius: 5px;
|
||||
transition: all 0.3s;
|
||||
&:hover {
|
||||
background-color: #f0faff;
|
||||
}
|
||||
> .anticon {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div>
|
||||
<a-popover
|
||||
v-if="isDropdown"
|
||||
v-model="visible"
|
||||
trigger="click"
|
||||
:placement="placement"
|
||||
overlayClassName="table-filter"
|
||||
@visibleChange="visibleChange"
|
||||
>
|
||||
<slot name="popover_item">
|
||||
<a-button type="primary" ghost>{{ $t('cmdbFilterComp.conditionFilter') }}<a-icon type="filter"/></a-button>
|
||||
</slot>
|
||||
<template slot="content">
|
||||
<Expression
|
||||
:needAddHere="needAddHere"
|
||||
v-model="ruleList"
|
||||
:canSearchPreferenceAttrList="canSearchPreferenceAttrList.filter((attr) => !attr.is_password)"
|
||||
:disabled="disabled"
|
||||
/>
|
||||
<a-divider :style="{ margin: '10px 0' }" />
|
||||
<div style="width:554px">
|
||||
<a-space :style="{ display: 'flex', justifyContent: 'flex-end' }">
|
||||
<a-button type="primary" size="small" @click="handleSubmit">{{ $t('confirm') }}</a-button>
|
||||
<a-button size="small" @click="handleClear">{{ $t('clear') }}</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
</a-popover>
|
||||
<Expression
|
||||
:needAddHere="needAddHere"
|
||||
v-else
|
||||
v-model="ruleList"
|
||||
:canSearchPreferenceAttrList="canSearchPreferenceAttrList.filter((attr) => !attr.is_password)"
|
||||
:disabled="disabled"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import Expression from './expression.vue'
|
||||
import { advancedExpList, compareTypeList } from './constants'
|
||||
|
||||
export default {
|
||||
name: 'FilterComp',
|
||||
components: { Expression },
|
||||
props: {
|
||||
canSearchPreferenceAttrList: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: () => [],
|
||||
},
|
||||
expression: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
regQ: {
|
||||
type: String,
|
||||
default: '(?<=q=).+(?=&)|(?<=q=).+$',
|
||||
},
|
||||
placement: {
|
||||
type: String,
|
||||
default: 'bottomRight',
|
||||
},
|
||||
isDropdown: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
needAddHere: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
advancedExpList,
|
||||
compareTypeList,
|
||||
visible: false,
|
||||
ruleList: [],
|
||||
filterExp: '',
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
visibleChange(open, isInitOne = true) {
|
||||
// isInitOne 初始化exp为空时,ruleList是否默认给一条
|
||||
// const regQ = /(?<=q=).+(?=&)|(?<=q=).+$/g
|
||||
const exp = this.expression.match(new RegExp(this.regQ, 'g'))
|
||||
? this.expression.match(new RegExp(this.regQ, 'g'))[0]
|
||||
: null
|
||||
if (open && exp) {
|
||||
const expArray = exp.split(',').map((item) => {
|
||||
let has_not = ''
|
||||
const key = item.split(':')[0]
|
||||
const val = item
|
||||
.split(':')
|
||||
.slice(1)
|
||||
.join(':')
|
||||
let type, property, exp, value, min, max, compareType
|
||||
if (key.includes('-')) {
|
||||
type = 'or'
|
||||
if (key.includes('~')) {
|
||||
property = key.substring(2)
|
||||
has_not = '~'
|
||||
} else {
|
||||
property = key.substring(1)
|
||||
}
|
||||
} else {
|
||||
type = 'and'
|
||||
if (key.includes('~')) {
|
||||
property = key.substring(1)
|
||||
has_not = '~'
|
||||
} else {
|
||||
property = key
|
||||
}
|
||||
}
|
||||
|
||||
const in_reg = /(?<=\().+(?=\))/g
|
||||
const range_reg = /(?<=\[).+(?=\])/g
|
||||
const compare_reg = /(?<=>=|<=|>(?!=)|<(?!=)).+/
|
||||
if (val === '*') {
|
||||
exp = has_not + 'value'
|
||||
value = ''
|
||||
} else if (in_reg.test(val)) {
|
||||
exp = has_not + 'in'
|
||||
value = val.match(in_reg)[0]
|
||||
} else if (range_reg.test(val)) {
|
||||
exp = has_not + 'range'
|
||||
value = val.match(range_reg)[0]
|
||||
min = value.split('_TO_')[0]
|
||||
max = value.split('_TO_')[1]
|
||||
} else if (compare_reg.test(val)) {
|
||||
exp = has_not + 'compare'
|
||||
value = val.match(compare_reg)[0]
|
||||
const _compareType = val.substring(0, val.match(compare_reg)['index'])
|
||||
const idx = compareTypeList.findIndex((item) => item.label === _compareType)
|
||||
compareType = compareTypeList[idx].value
|
||||
} else if (!val.includes('*')) {
|
||||
exp = has_not + 'is'
|
||||
value = val
|
||||
} else {
|
||||
const resList = [
|
||||
['contain', /(?<=\*).*(?=\*)/g],
|
||||
['end_with', /(?<=\*).+/g],
|
||||
['start_with', /.+(?=\*)/g],
|
||||
]
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const reg = resList[i]
|
||||
if (reg[1].test(val)) {
|
||||
exp = has_not + reg[0]
|
||||
value = val.match(reg[1])[0]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
id: uuidv4(),
|
||||
type,
|
||||
property,
|
||||
exp,
|
||||
value,
|
||||
min,
|
||||
max,
|
||||
compareType,
|
||||
}
|
||||
})
|
||||
this.ruleList = [...expArray]
|
||||
} else if (open) {
|
||||
const _canSearchPreferenceAttrList = this.canSearchPreferenceAttrList.filter((attr) => !attr.is_password)
|
||||
this.ruleList = isInitOne
|
||||
? [
|
||||
{
|
||||
id: uuidv4(),
|
||||
type: 'and',
|
||||
property:
|
||||
_canSearchPreferenceAttrList && _canSearchPreferenceAttrList.length
|
||||
? _canSearchPreferenceAttrList[0].name
|
||||
: undefined,
|
||||
exp: 'is',
|
||||
value: null,
|
||||
},
|
||||
]
|
||||
: []
|
||||
}
|
||||
},
|
||||
handleClear() {
|
||||
this.ruleList = [
|
||||
{
|
||||
id: uuidv4(),
|
||||
type: 'and',
|
||||
property: this.canSearchPreferenceAttrList[0].name,
|
||||
exp: 'is',
|
||||
value: null,
|
||||
},
|
||||
]
|
||||
this.filterExp = ''
|
||||
this.visible = false
|
||||
this.$emit('setExpFromFilter', this.filterExp)
|
||||
},
|
||||
handleSubmit() {
|
||||
if (this.ruleList && this.ruleList.length) {
|
||||
this.ruleList[0].type = 'and' // 增删后,以防万一第一个不是and
|
||||
this.filterExp = ''
|
||||
const expList = this.ruleList.map((rule) => {
|
||||
let singleRuleExp = ''
|
||||
let _exp = rule.exp
|
||||
if (rule.type === 'or') {
|
||||
singleRuleExp += '-'
|
||||
}
|
||||
if (rule.exp.includes('~')) {
|
||||
singleRuleExp += '~'
|
||||
_exp = rule.exp.split('~')[1]
|
||||
}
|
||||
singleRuleExp += `${rule.property}:`
|
||||
if (_exp === 'is') {
|
||||
singleRuleExp += `${rule.value ?? ''}`
|
||||
}
|
||||
if (_exp === 'contain') {
|
||||
singleRuleExp += `*${rule.value ?? ''}*`
|
||||
}
|
||||
if (_exp === 'start_with') {
|
||||
singleRuleExp += `${rule.value ?? ''}*`
|
||||
}
|
||||
if (_exp === 'end_with') {
|
||||
singleRuleExp += `*${rule.value ?? ''}`
|
||||
}
|
||||
if (_exp === 'value') {
|
||||
singleRuleExp += `*`
|
||||
}
|
||||
if (_exp === 'in') {
|
||||
singleRuleExp += `(${rule.value ?? ''})`
|
||||
}
|
||||
if (_exp === 'range') {
|
||||
singleRuleExp += `[${rule.min}_TO_${rule.max}]`
|
||||
}
|
||||
if (_exp === 'compare') {
|
||||
const idx = compareTypeList.findIndex((item) => item.value === rule.compareType)
|
||||
singleRuleExp += `${compareTypeList[idx].label}${rule.value ?? ''}`
|
||||
}
|
||||
return singleRuleExp
|
||||
})
|
||||
this.filterExp = expList.join(',')
|
||||
this.$emit('setExpFromFilter', this.filterExp)
|
||||
} else {
|
||||
this.$emit('setExpFromFilter', '')
|
||||
}
|
||||
this.visible = false
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.table-filter {
|
||||
.table-filter-add {
|
||||
margin-top: 10px;
|
||||
& > a {
|
||||
padding: 2px 8px;
|
||||
&:hover {
|
||||
background-color: @primary-color_5;
|
||||
border-radius: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.table-filter-extra-icon {
|
||||
padding: 0px 2px;
|
||||
&:hover {
|
||||
display: inline-block;
|
||||
border-radius: 5px;
|
||||
background-color: #f0faff;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.table-filter-extra-operation {
|
||||
.ant-popover-inner-content {
|
||||
padding: 3px 4px;
|
||||
.operation {
|
||||
cursor: pointer;
|
||||
width: 90px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 3px 4px;
|
||||
border-radius: 5px;
|
||||
transition: all 0.3s;
|
||||
&:hover {
|
||||
background-color: #f0faff;
|
||||
}
|
||||
> .anticon {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -341,7 +341,7 @@ export default {
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
<style lang="less" scoped>
|
||||
.pop_btn {
|
||||
text-align: right;
|
||||
margin-top: 24px;
|
||||
|
@@ -47,7 +47,7 @@ export const commonIconList = ['changyong-ubuntu',
|
||||
export const linearIconList = [
|
||||
{
|
||||
value: 'database',
|
||||
label: '数据库',
|
||||
label: 'components.database',
|
||||
list: [{
|
||||
value: 'icon-xianxing-DB2',
|
||||
label: 'DB2'
|
||||
@@ -81,7 +81,7 @@ export const linearIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'system',
|
||||
label: '操作系统',
|
||||
label: 'components.system',
|
||||
list: [{
|
||||
value: 'icon-xianxing-Windows',
|
||||
label: 'Windows'
|
||||
@@ -106,7 +106,7 @@ export const linearIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'language',
|
||||
label: '语言',
|
||||
label: 'components.language',
|
||||
list: [{
|
||||
value: 'icon-xianxing-python',
|
||||
label: 'python'
|
||||
@@ -137,7 +137,7 @@ export const linearIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'status',
|
||||
label: '状态',
|
||||
label: 'components.status',
|
||||
list: [{
|
||||
value: 'icon-xianxing-yiwen',
|
||||
label: '疑问'
|
||||
@@ -177,7 +177,7 @@ export const linearIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'icon-xianxing-application',
|
||||
label: '常用组件',
|
||||
label: 'components.commonComponent',
|
||||
list: [{
|
||||
value: 'icon-xianxing-yilianjie',
|
||||
label: '已连接'
|
||||
@@ -310,7 +310,7 @@ export const linearIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'data',
|
||||
label: '数据',
|
||||
label: 'components.data',
|
||||
list: [{
|
||||
value: 'icon-xianxing-bingzhuangtu',
|
||||
label: '饼状图'
|
||||
@@ -387,7 +387,7 @@ export const linearIconList = [
|
||||
export const fillIconList = [
|
||||
{
|
||||
value: 'database',
|
||||
label: '数据库',
|
||||
label: 'components.database',
|
||||
list: [{
|
||||
value: 'icon-shidi-DB2',
|
||||
label: 'DB2'
|
||||
@@ -421,7 +421,7 @@ export const fillIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'system',
|
||||
label: '操作系统',
|
||||
label: 'components.system',
|
||||
list: [{
|
||||
value: 'icon-shidi-Windows',
|
||||
label: 'Windows'
|
||||
@@ -446,7 +446,7 @@ export const fillIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'language',
|
||||
label: '语言',
|
||||
label: 'components.language',
|
||||
list: [{
|
||||
value: 'icon-shidi-python',
|
||||
label: 'python'
|
||||
@@ -477,7 +477,7 @@ export const fillIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'status',
|
||||
label: '状态',
|
||||
label: 'components.status',
|
||||
list: [{
|
||||
value: 'icon-shidi-yiwen',
|
||||
label: '疑问'
|
||||
@@ -517,7 +517,7 @@ export const fillIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'icon-shidi-application',
|
||||
label: '常用组件',
|
||||
label: 'components.commonComponent',
|
||||
list: [{
|
||||
value: 'icon-shidi-yilianjie',
|
||||
label: '已连接'
|
||||
@@ -650,7 +650,7 @@ export const fillIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'data',
|
||||
label: '数据',
|
||||
label: 'components.data',
|
||||
list: [{
|
||||
value: 'icon-shidi-bingzhuangtu',
|
||||
label: '饼状图'
|
||||
@@ -727,7 +727,7 @@ export const fillIconList = [
|
||||
export const multicolorIconList = [
|
||||
{
|
||||
value: 'database',
|
||||
label: '数据库',
|
||||
label: 'components.database',
|
||||
list: [{
|
||||
value: 'caise-TIDB',
|
||||
label: 'TIDB'
|
||||
@@ -773,7 +773,7 @@ export const multicolorIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'cloud',
|
||||
label: '云',
|
||||
label: 'components.cloud',
|
||||
list: [{
|
||||
value: 'AWS',
|
||||
label: 'AWS'
|
||||
@@ -819,7 +819,7 @@ export const multicolorIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'system',
|
||||
label: '操作系统',
|
||||
label: 'components.system',
|
||||
list: [{
|
||||
value: 'ciase-aix',
|
||||
label: 'aix'
|
||||
@@ -847,7 +847,7 @@ export const multicolorIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'language',
|
||||
label: '语言',
|
||||
label: 'components.language',
|
||||
list: [{
|
||||
value: 'caise-python',
|
||||
label: 'python'
|
||||
@@ -878,7 +878,7 @@ export const multicolorIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'status',
|
||||
label: '状态',
|
||||
label: 'components.status',
|
||||
list: [{
|
||||
value: 'caise-yiwen',
|
||||
label: '疑问'
|
||||
@@ -918,7 +918,7 @@ export const multicolorIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'caise-application',
|
||||
label: '常用组件',
|
||||
label: 'components.commonComponent',
|
||||
list: [{
|
||||
value: 'caise-websphere',
|
||||
label: 'WebSphere'
|
||||
@@ -1180,7 +1180,7 @@ export const multicolorIconList = [
|
||||
}]
|
||||
}, {
|
||||
value: 'data',
|
||||
label: '数据',
|
||||
label: 'components.data',
|
||||
list: [{
|
||||
value: 'caise-bingzhuangtu',
|
||||
label: '饼状图'
|
||||
|
@@ -33,7 +33,7 @@
|
||||
<template v-if="iconList && iconList.length">
|
||||
<template v-if="currentIconType !== '4'">
|
||||
<div v-for="category in iconList" :key="category.value">
|
||||
<h4 class="category">{{ category.label }}</h4>
|
||||
<h4 class="category">{{ $t(category.label) }}</h4>
|
||||
<div class="custom-icon-select-popover-content-wrapper">
|
||||
<div
|
||||
v-for="name in category.list"
|
||||
|
@@ -6,9 +6,9 @@
|
||||
</div>
|
||||
<div class="content">
|
||||
<h1>{{ config[type].title }}</h1>
|
||||
<div class="desc">{{ config[type].desc }}</div>
|
||||
<div class="desc">{{ $t(config[type].desc) }}</div>
|
||||
<div class="actions">
|
||||
<a-button type="primary" @click="handleToHome">返回首页</a-button>
|
||||
<a-button type="primary" @click="handleToHome">{{ $t('exception.backToHome') }}</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -2,17 +2,17 @@ const types = {
|
||||
403: {
|
||||
img: 'https://gw.alipayobjects.com/zos/rmsportal/wZcnGqRDyhPOEYFcZDnb.svg',
|
||||
title: '403',
|
||||
desc: '抱歉,你无权访问该页面'
|
||||
desc: 'exception.desc1'
|
||||
},
|
||||
404: {
|
||||
img: 'https://gw.alipayobjects.com/zos/rmsportal/KpnpchXsobRgLElEozzI.svg',
|
||||
title: '404',
|
||||
desc: '抱歉,你访问的页面不存在或仍在开发中'
|
||||
desc: 'exception.desc2'
|
||||
},
|
||||
500: {
|
||||
img: 'https://gw.alipayobjects.com/zos/rmsportal/RVRUAYdCGeYNBWoKiIwB.svg',
|
||||
title: '500',
|
||||
desc: '抱歉,服务器出错了'
|
||||
desc: 'exception.desc3'
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -171,7 +171,6 @@ export default {
|
||||
},
|
||||
renderMenuItem(menu) {
|
||||
const isShowDot = menu.path.substr(0, 22) === '/cmdb/instances/types/'
|
||||
const isShowGrant = menu.path.substr(0, 20) === '/cmdb/relationviews/'
|
||||
const target = menu.meta.target || null
|
||||
const tag = target && 'a' || 'router-link'
|
||||
const props = { to: { name: menu.name } }
|
||||
@@ -205,11 +204,9 @@ export default {
|
||||
<a-icon type="menu" ref="extraEllipsis" class="custom-menu-extra-ellipsis"></a-icon>
|
||||
</a-popover>
|
||||
}
|
||||
{isShowGrant && <a-icon class="custom-menu-extra-ellipsis" onClick={e => this.handlePerm(e, menu, 'RelationView')} type="user-add" />}
|
||||
</span>
|
||||
</tag>
|
||||
{isShowDot && <CMDBGrant ref="cmdbGrantCIType" resourceType="CIType" app_id="cmdb" />}
|
||||
{isShowGrant && <CMDBGrant ref="cmdbGrantRelationView" resourceType="RelationView" app_id="cmdb" />}
|
||||
</Item>
|
||||
)
|
||||
},
|
||||
|
@@ -109,9 +109,25 @@ export default {
|
||||
default: 'default',
|
||||
tip: 'Tip',
|
||||
cmdbSearch: 'Search',
|
||||
exception: {
|
||||
backToHome: 'Back to home page',
|
||||
desc1: 'Sorry, you are not authorized to access this page',
|
||||
desc2: 'Sorry, the page you are visiting does not exist or is still under development',
|
||||
desc3: 'Sorry, server error'
|
||||
},
|
||||
pagination: {
|
||||
total: '{range0}-{range1} of {total} items'
|
||||
},
|
||||
components: {
|
||||
colorTagSelectTip: 'Enter or select tags',
|
||||
database: 'Database',
|
||||
system: 'System',
|
||||
language: 'Language',
|
||||
status: 'Status',
|
||||
commonComponent: 'Common Component',
|
||||
data: 'Data',
|
||||
cloud: 'Cloud'
|
||||
},
|
||||
topMenu: {
|
||||
personalCenter: 'My Profile',
|
||||
logout: 'Logout',
|
||||
|
@@ -109,9 +109,25 @@ export default {
|
||||
default: '默认',
|
||||
tip: '提示',
|
||||
cmdbSearch: '搜索一下',
|
||||
exception: {
|
||||
backToHome: '返回首页',
|
||||
desc1: '抱歉,你无权访问该页面',
|
||||
desc2: '抱歉,你访问的页面不存在或仍在开发中',
|
||||
desc3: '抱歉,服务器出错了'
|
||||
},
|
||||
pagination: {
|
||||
total: '当前展示 {range0}-{range1} 条数据, 共 {total} 条'
|
||||
},
|
||||
components: {
|
||||
colorTagSelectTip: '选择或输入(回车确定)标签',
|
||||
database: '数据库',
|
||||
system: '操作系统',
|
||||
language: '语言',
|
||||
status: '状态',
|
||||
commonComponent: '常用组件',
|
||||
data: '数据',
|
||||
cloud: '云'
|
||||
},
|
||||
topMenu: {
|
||||
personalCenter: '个人中心',
|
||||
logout: '退出登录',
|
||||
|
@@ -226,16 +226,16 @@ export default {
|
||||
right: 4px;
|
||||
display: none;
|
||||
&:hover {
|
||||
color: #1f78d1;
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
&:hover .ant-transfer-list-icon {
|
||||
display: inline;
|
||||
background-color: #c0eaff;
|
||||
background-color: @primary-color_4;
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
.ant-transfer-list-content-item-selected {
|
||||
background-color: #f0faff;
|
||||
background-color: ~'@{primary-color_8}35';
|
||||
}
|
||||
</style>
|
||||
|
@@ -58,10 +58,7 @@
|
||||
:title="$t('acl.visualRole')"
|
||||
:width="120"
|
||||
align="center"
|
||||
:filters="[
|
||||
{ label: $t('yes'), value: 1 },
|
||||
{ label: $t('no'), value: 0 },
|
||||
]"
|
||||
:filters="visualRoleFilters"
|
||||
:filterMultiple="false"
|
||||
:filter-method="
|
||||
({ value, row }) => {
|
||||
@@ -155,6 +152,10 @@ export default {
|
||||
pageSizeOptions: ['20', '50', '100', '200'],
|
||||
searchName: '',
|
||||
filterTableValue: { user_role: 1, user_only: 0 },
|
||||
visualRoleFilters: [
|
||||
{ label: this.$t('yes'), value: 1 },
|
||||
{ label: this.$t('no'), value: 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@@ -132,6 +132,7 @@ export default {
|
||||
/deep/ .ant-select-selection {
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
border: none;
|
||||
|
||||
.ant-select-selection__rendered {
|
||||
height: 28px;
|
||||
@@ -187,7 +188,7 @@ export default {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background-color: @primary-color;
|
||||
border: solid 3px #E2E7FC;
|
||||
border: solid 3px @primary-color_4;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@
|
||||
</template>
|
||||
<span
|
||||
class="ci-icon-letter"
|
||||
v-else
|
||||
v-else-if="title"
|
||||
>
|
||||
<span>
|
||||
{{ title[0].toUpperCase() }}
|
||||
|
@@ -1,150 +1,156 @@
|
||||
<template>
|
||||
<div class="ci-type-grant">
|
||||
<vxe-table
|
||||
ref="xTable"
|
||||
size="mini"
|
||||
stripe
|
||||
class="ops-stripe-table"
|
||||
:data="filterTableData"
|
||||
:max-height="`${tableHeight}px`"
|
||||
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
|
||||
>
|
||||
<vxe-column field="name"></vxe-column>
|
||||
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
|
||||
<template #default="{row}">
|
||||
<ReadCheckbox
|
||||
v-if="['read'].includes(col.split('_')[0])"
|
||||
:value="row[col.split('_')[0]]"
|
||||
:valueKey="col"
|
||||
:rid="row.rid"
|
||||
@openReadGrantModal="() => openReadGrantModal(col, row)"
|
||||
/>
|
||||
<a-checkbox v-else-if="col === 'grant'" :checked="row[col]" @click="clickGrant(col, row)"></a-checkbox>
|
||||
<a-checkbox @change="(e) => handleChange(e, col, row)" v-else v-model="row[col]"></a-checkbox>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<template #empty>
|
||||
<div v-if="loading()" style="height: 200px; line-height: 200px;color:#2F54EB">
|
||||
<a-icon type="loading" /> {{ $t('loading') }}
|
||||
</div>
|
||||
<div v-else>
|
||||
<img :style="{ width: '100px' }" :src="require('@/assets/data_empty.png')" />
|
||||
<div>{{ $t('noData') }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</vxe-table>
|
||||
<a-space>
|
||||
<span class="grant-button" @click="grantDepart">{{ $t('cmdb.components.grantUser') }}</span>
|
||||
<span class="grant-button" @click="grantRole">{{ $t('cmdb.components.grantRole') }}</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
import { permMap } from './constants.js'
|
||||
import { grantCiType, revokeCiType } from '../../api/CIType'
|
||||
import ReadCheckbox from './readCheckbox.vue'
|
||||
import { getCurrentRowStyle } from './utils'
|
||||
|
||||
export default {
|
||||
name: 'CiTypeGrant',
|
||||
components: { ReadCheckbox },
|
||||
inject: ['loading', 'isModal'],
|
||||
props: {
|
||||
CITypeId: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
tableData: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
grantType: {
|
||||
type: String,
|
||||
default: 'ci_type',
|
||||
},
|
||||
addedRids: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
filterTableData() {
|
||||
const _tableData = this.tableData.filter((data) => {
|
||||
const _intersection = _.intersection(
|
||||
Object.keys(data),
|
||||
this.columns.map((col) => col.split('_')[0])
|
||||
)
|
||||
return _intersection && _intersection.length
|
||||
})
|
||||
return _.uniqBy(_tableData, (item) => item.rid)
|
||||
},
|
||||
columns() {
|
||||
if (this.grantType === 'ci_type') {
|
||||
return ['config', 'grant']
|
||||
}
|
||||
return ['read_attr', 'read_ci', 'create', 'update', 'delete']
|
||||
},
|
||||
windowHeight() {
|
||||
return this.$store.state.windowHeight
|
||||
},
|
||||
tableHeight() {
|
||||
if (this.isModal) {
|
||||
return (this.windowHeight - 104) / 2
|
||||
}
|
||||
return (this.windowHeight - 104) / 2 - 116
|
||||
},
|
||||
permMap() {
|
||||
return permMap()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCurrentRowStyle,
|
||||
async handleChange(e, col, row) {
|
||||
if (e.target.checked) {
|
||||
await grantCiType(this.CITypeId, row.rid, { perms: [col] }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
} else {
|
||||
await revokeCiType(this.CITypeId, row.rid, { perms: [col] }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
}
|
||||
},
|
||||
grantDepart() {
|
||||
this.$emit('grantDepart', this.grantType)
|
||||
},
|
||||
grantRole() {
|
||||
this.$emit('grantRole', this.grantType)
|
||||
},
|
||||
openReadGrantModal(col, row) {
|
||||
this.$emit('openReadGrantModal', col, row)
|
||||
},
|
||||
clickGrant(col, row, rowIndex) {
|
||||
if (!row[col]) {
|
||||
this.handleChange({ target: { checked: true } }, col, row)
|
||||
const _idx = this.tableData.findIndex((item) => item.rid === row.rid)
|
||||
this.$set(this.tableData, _idx, { ...this.tableData[_idx], grant: true })
|
||||
} else {
|
||||
const that = this
|
||||
this.$confirm({
|
||||
title: that.$t('warning'),
|
||||
content: that.$t('cmdb.components.confirmRevoke', { name: `${row.name}` }),
|
||||
onOk() {
|
||||
that.handleChange({ target: { checked: false } }, col, row)
|
||||
const _idx = that.tableData.findIndex((item) => item.rid === row.rid)
|
||||
that.$set(that.tableData, _idx, { ...that.tableData[_idx], grant: false })
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ci-type-grant {
|
||||
padding: 10px 0;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div class="ci-type-grant">
|
||||
<vxe-table
|
||||
ref="xTable"
|
||||
size="mini"
|
||||
stripe
|
||||
class="ops-stripe-table"
|
||||
:data="filterTableData"
|
||||
:max-height="`${tableHeight}px`"
|
||||
:row-class-name="(params) => getCurrentRowClass(params, addedRids)"
|
||||
>
|
||||
<vxe-column field="name"></vxe-column>
|
||||
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
|
||||
<template #default="{row}">
|
||||
<ReadCheckbox
|
||||
v-if="['read'].includes(col.split('_')[0])"
|
||||
:value="row[col.split('_')[0]]"
|
||||
:valueKey="col"
|
||||
:rid="row.rid"
|
||||
@openReadGrantModal="() => openReadGrantModal(col, row)"
|
||||
/>
|
||||
<a-checkbox v-else-if="col === 'grant'" :checked="row[col]" @click="clickGrant(col, row)"></a-checkbox>
|
||||
<a-checkbox @change="(e) => handleChange(e, col, row)" v-else v-model="row[col]"></a-checkbox>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<template #empty>
|
||||
<div v-if="loading()" class="ci-type-grant-loading">
|
||||
<a-icon type="loading" /> {{ $t('loading') }}
|
||||
</div>
|
||||
<div v-else>
|
||||
<img :style="{ width: '100px' }" :src="require('@/assets/data_empty.png')" />
|
||||
<div>{{ $t('noData') }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</vxe-table>
|
||||
<a-space>
|
||||
<span class="grant-button" @click="grantDepart">{{ $t('cmdb.components.grantUser') }}</span>
|
||||
<span class="grant-button" @click="grantRole">{{ $t('cmdb.components.grantRole') }}</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
import { permMap } from './constants.js'
|
||||
import { grantCiType, revokeCiType } from '../../api/CIType'
|
||||
import ReadCheckbox from './readCheckbox.vue'
|
||||
import { getCurrentRowClass } from './utils'
|
||||
|
||||
export default {
|
||||
name: 'CiTypeGrant',
|
||||
components: { ReadCheckbox },
|
||||
inject: ['loading', 'isModal'],
|
||||
props: {
|
||||
CITypeId: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
tableData: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
grantType: {
|
||||
type: String,
|
||||
default: 'ci_type',
|
||||
},
|
||||
addedRids: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
filterTableData() {
|
||||
const _tableData = this.tableData.filter((data) => {
|
||||
const _intersection = _.intersection(
|
||||
Object.keys(data),
|
||||
this.columns.map((col) => col.split('_')[0])
|
||||
)
|
||||
return _intersection && _intersection.length
|
||||
})
|
||||
return _.uniqBy(_tableData, (item) => item.rid)
|
||||
},
|
||||
columns() {
|
||||
if (this.grantType === 'ci_type') {
|
||||
return ['config', 'grant']
|
||||
}
|
||||
return ['read_attr', 'read_ci', 'create', 'update', 'delete']
|
||||
},
|
||||
windowHeight() {
|
||||
return this.$store.state.windowHeight
|
||||
},
|
||||
tableHeight() {
|
||||
if (this.isModal) {
|
||||
return (this.windowHeight - 104) / 2
|
||||
}
|
||||
return (this.windowHeight - 104) / 2 - 116
|
||||
},
|
||||
permMap() {
|
||||
return permMap()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCurrentRowClass,
|
||||
async handleChange(e, col, row) {
|
||||
if (e.target.checked) {
|
||||
await grantCiType(this.CITypeId, row.rid, { perms: [col] }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
} else {
|
||||
await revokeCiType(this.CITypeId, row.rid, { perms: [col] }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
}
|
||||
},
|
||||
grantDepart() {
|
||||
this.$emit('grantDepart', this.grantType)
|
||||
},
|
||||
grantRole() {
|
||||
this.$emit('grantRole', this.grantType)
|
||||
},
|
||||
openReadGrantModal(col, row) {
|
||||
this.$emit('openReadGrantModal', col, row)
|
||||
},
|
||||
clickGrant(col, row, rowIndex) {
|
||||
if (!row[col]) {
|
||||
this.handleChange({ target: { checked: true } }, col, row)
|
||||
const _idx = this.tableData.findIndex((item) => item.rid === row.rid)
|
||||
this.$set(this.tableData, _idx, { ...this.tableData[_idx], grant: true })
|
||||
} else {
|
||||
const that = this
|
||||
this.$confirm({
|
||||
title: that.$t('warning'),
|
||||
content: that.$t('cmdb.components.confirmRevoke', { name: `${row.name}` }),
|
||||
onOk() {
|
||||
that.handleChange({ target: { checked: false } }, col, row)
|
||||
const _idx = that.tableData.findIndex((item) => item.rid === row.rid)
|
||||
that.$set(that.tableData, _idx, { ...that.tableData[_idx], grant: false })
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ci-type-grant {
|
||||
padding: 10px 0;
|
||||
|
||||
&-loading {
|
||||
height: 200px;
|
||||
line-height: 200px;
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -88,6 +88,7 @@ import ReadGrantModal from './readGrantModal'
|
||||
import RelationViewGrant from './relationViewGrant.vue'
|
||||
import TopologyViewGrant from './topologyViewGrant.vue'
|
||||
import { getCITypeGroupById, ciTypeFilterPermissions } from '../../api/CIType'
|
||||
import { CI_DEFAULT_ATTR } from '@/modules/cmdb/utils/const.js'
|
||||
|
||||
export default {
|
||||
name: 'GrantComp',
|
||||
@@ -186,6 +187,13 @@ export default {
|
||||
},
|
||||
getFilterPermissions() {
|
||||
ciTypeFilterPermissions(this.CITypeId).then((res) => {
|
||||
Object.keys(res).forEach((key) => {
|
||||
const attr_filter = res?.[key]?.attr_filter
|
||||
if (attr_filter?.length) {
|
||||
res[key].attr_filter = attr_filter.filter((item) => ![CI_DEFAULT_ATTR.UPDATE_USER, CI_DEFAULT_ATTR.UPDATE_TIME].includes(item))
|
||||
}
|
||||
})
|
||||
|
||||
this.filerPerimissions = res
|
||||
})
|
||||
},
|
||||
@@ -366,5 +374,9 @@ export default {
|
||||
|
||||
.btn-wave-hover(@primary-color_4, -1);
|
||||
}
|
||||
|
||||
.grant-table-row-focus {
|
||||
background-color: @primary-color_8;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,98 +1,98 @@
|
||||
<template>
|
||||
<div class="ci-relation-grant">
|
||||
<vxe-table
|
||||
ref="xTable"
|
||||
size="mini"
|
||||
stripe
|
||||
class="ops-stripe-table"
|
||||
:data="tableData"
|
||||
:max-height="`${tableHeight}px`"
|
||||
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
|
||||
>
|
||||
<vxe-column field="name"></vxe-column>
|
||||
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
|
||||
<template #default="{row}">
|
||||
<a-checkbox @change="(e) => handleChange(e, col, row)" v-model="row[col]"></a-checkbox>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
<a-space>
|
||||
<span class="grant-button" @click="grantDepart">{{ $t('cmdb.components.grantUser') }}</span>
|
||||
<span class="grant-button" @click="grantRole">{{ $t('cmdb.components.grantRole') }}</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { permMap } from './constants.js'
|
||||
import { grantRelationView, revokeRelationView } from '../../api/preference.js'
|
||||
import { getCurrentRowStyle } from './utils'
|
||||
|
||||
export default {
|
||||
name: 'RelationViewGrant',
|
||||
inject: ['loading', 'isModal'],
|
||||
props: {
|
||||
resourceTypeName: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
tableData: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
grantType: {
|
||||
type: String,
|
||||
default: 'relation_view',
|
||||
},
|
||||
addedRids: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
columns: ['read', 'grant'],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
windowHeight() {
|
||||
return this.$store.state.windowHeight
|
||||
},
|
||||
tableHeight() {
|
||||
if (this.isModal) {
|
||||
return (this.windowHeight - 104) / 2
|
||||
}
|
||||
return (this.windowHeight - 104) / 2 - 116
|
||||
},
|
||||
permMap() {
|
||||
return permMap()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCurrentRowStyle,
|
||||
grantDepart() {
|
||||
this.$emit('grantDepart', this.grantType)
|
||||
},
|
||||
grantRole() {
|
||||
this.$emit('grantRole', this.grantType)
|
||||
},
|
||||
handleChange(e, col, row) {
|
||||
if (e.target.checked) {
|
||||
grantRelationView(row.rid, { perms: [col], name: this.resourceTypeName }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
} else {
|
||||
revokeRelationView(row.rid, { perms: [col], name: this.resourceTypeName }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ci-relation-grant {
|
||||
padding: 10px 0;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div class="ci-relation-grant">
|
||||
<vxe-table
|
||||
ref="xTable"
|
||||
size="mini"
|
||||
stripe
|
||||
class="ops-stripe-table"
|
||||
:data="tableData"
|
||||
:max-height="`${tableHeight}px`"
|
||||
:row-class-name="(params) => getCurrentRowClass(params, addedRids)"
|
||||
>
|
||||
<vxe-column field="name"></vxe-column>
|
||||
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
|
||||
<template #default="{row}">
|
||||
<a-checkbox @change="(e) => handleChange(e, col, row)" v-model="row[col]"></a-checkbox>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
<a-space>
|
||||
<span class="grant-button" @click="grantDepart">{{ $t('cmdb.components.grantUser') }}</span>
|
||||
<span class="grant-button" @click="grantRole">{{ $t('cmdb.components.grantRole') }}</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { permMap } from './constants.js'
|
||||
import { grantRelationView, revokeRelationView } from '../../api/preference.js'
|
||||
import { getCurrentRowClass } from './utils'
|
||||
|
||||
export default {
|
||||
name: 'RelationViewGrant',
|
||||
inject: ['loading', 'isModal'],
|
||||
props: {
|
||||
resourceTypeName: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
tableData: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
grantType: {
|
||||
type: String,
|
||||
default: 'relation_view',
|
||||
},
|
||||
addedRids: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
columns: ['read', 'grant'],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
windowHeight() {
|
||||
return this.$store.state.windowHeight
|
||||
},
|
||||
tableHeight() {
|
||||
if (this.isModal) {
|
||||
return (this.windowHeight - 104) / 2
|
||||
}
|
||||
return (this.windowHeight - 104) / 2 - 116
|
||||
},
|
||||
permMap() {
|
||||
return permMap()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCurrentRowClass,
|
||||
grantDepart() {
|
||||
this.$emit('grantDepart', this.grantType)
|
||||
},
|
||||
grantRole() {
|
||||
this.$emit('grantRole', this.grantType)
|
||||
},
|
||||
handleChange(e, col, row) {
|
||||
if (e.target.checked) {
|
||||
grantRelationView(row.rid, { perms: [col], name: this.resourceTypeName }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
} else {
|
||||
revokeRelationView(row.rid, { perms: [col], name: this.resourceTypeName }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ci-relation-grant {
|
||||
padding: 10px 0;
|
||||
}
|
||||
</style>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
:data="tableData"
|
||||
:max-height="`${tableHeight}px`"
|
||||
:scroll-y="{enabled: true}"
|
||||
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
|
||||
:row-class-name="(params) => getCurrentRowClass(params, addedRids)"
|
||||
>
|
||||
<vxe-column field="name"></vxe-column>
|
||||
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
|
||||
@@ -27,7 +27,7 @@
|
||||
<script>
|
||||
import { permMap } from './constants.js'
|
||||
import { grantTopologyView, revokeTopologyView } from '@/modules/cmdb/api/topology.js'
|
||||
import { getCurrentRowStyle } from './utils'
|
||||
import { getCurrentRowClass } from './utils'
|
||||
export default {
|
||||
name: 'TopologyViewGrant',
|
||||
inject: ['loading', 'isModal'],
|
||||
@@ -73,7 +73,7 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCurrentRowStyle,
|
||||
getCurrentRowClass,
|
||||
grantDepart() {
|
||||
this.$emit('grantDepart', this.grantType)
|
||||
},
|
||||
|
@@ -1,100 +1,100 @@
|
||||
<template>
|
||||
<div class="ci-relation-grant">
|
||||
<vxe-table
|
||||
ref="xTable"
|
||||
size="mini"
|
||||
stripe
|
||||
class="ops-stripe-table"
|
||||
:data="tableData"
|
||||
:max-height="`${tableHeight}px`"
|
||||
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
|
||||
>
|
||||
<vxe-column field="name"></vxe-column>
|
||||
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
|
||||
<template #default="{row}">
|
||||
<a-checkbox @change="(e) => handleChange(e, col, row)" v-model="row[col]"></a-checkbox>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
<a-space>
|
||||
<span class="grant-button" @click="grantDepart">{{ $t('cmdb.components.grantUser') }}</span>
|
||||
<span class="grant-button" @click="grantRole">{{ $t('cmdb.components.grantRole') }}</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { permMap } from './constants.js'
|
||||
import { grantTypeRelation, revokeTypeRelation } from '../../api/CITypeRelation.js'
|
||||
import { getCurrentRowStyle } from './utils'
|
||||
|
||||
export default {
|
||||
name: 'TypeRelationGrant',
|
||||
inject: ['loading', 'isModal'],
|
||||
props: {
|
||||
tableData: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
grantType: {
|
||||
type: String,
|
||||
default: 'type_relation',
|
||||
},
|
||||
typeRelationIds: {
|
||||
type: Array,
|
||||
default: null,
|
||||
},
|
||||
addedRids: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
columns: ['create', 'grant', 'delete'],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
windowHeight() {
|
||||
return this.$store.state.windowHeight
|
||||
},
|
||||
tableHeight() {
|
||||
if (this.isModal) {
|
||||
return (this.windowHeight - 104) / 2
|
||||
}
|
||||
return (this.windowHeight - 104) / 2 - 116
|
||||
},
|
||||
permMap() {
|
||||
return permMap()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCurrentRowStyle,
|
||||
grantDepart() {
|
||||
this.$emit('grantDepart', this.grantType)
|
||||
},
|
||||
grantRole() {
|
||||
this.$emit('grantRole', this.grantType)
|
||||
},
|
||||
handleChange(e, col, row) {
|
||||
const first = this.typeRelationIds[0]
|
||||
const second = this.typeRelationIds[1]
|
||||
if (e.target.checked) {
|
||||
grantTypeRelation(first, second, row.rid, { perms: [col] }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
} else {
|
||||
revokeTypeRelation(first, second, row.rid, { perms: [col] }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ci-relation-grant {
|
||||
padding: 10px 0;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div class="ci-relation-grant">
|
||||
<vxe-table
|
||||
ref="xTable"
|
||||
size="mini"
|
||||
stripe
|
||||
class="ops-stripe-table"
|
||||
:data="tableData"
|
||||
:max-height="`${tableHeight}px`"
|
||||
:row-class-name="(params) => getCurrentRowClass(params, addedRids)"
|
||||
>
|
||||
<vxe-column field="name"></vxe-column>
|
||||
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
|
||||
<template #default="{row}">
|
||||
<a-checkbox @change="(e) => handleChange(e, col, row)" v-model="row[col]"></a-checkbox>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
<a-space>
|
||||
<span class="grant-button" @click="grantDepart">{{ $t('cmdb.components.grantUser') }}</span>
|
||||
<span class="grant-button" @click="grantRole">{{ $t('cmdb.components.grantRole') }}</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { permMap } from './constants.js'
|
||||
import { grantTypeRelation, revokeTypeRelation } from '../../api/CITypeRelation.js'
|
||||
import { getCurrentRowClass } from './utils'
|
||||
|
||||
export default {
|
||||
name: 'TypeRelationGrant',
|
||||
inject: ['loading', 'isModal'],
|
||||
props: {
|
||||
tableData: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
grantType: {
|
||||
type: String,
|
||||
default: 'type_relation',
|
||||
},
|
||||
typeRelationIds: {
|
||||
type: Array,
|
||||
default: null,
|
||||
},
|
||||
addedRids: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
columns: ['create', 'grant', 'delete'],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
windowHeight() {
|
||||
return this.$store.state.windowHeight
|
||||
},
|
||||
tableHeight() {
|
||||
if (this.isModal) {
|
||||
return (this.windowHeight - 104) / 2
|
||||
}
|
||||
return (this.windowHeight - 104) / 2 - 116
|
||||
},
|
||||
permMap() {
|
||||
return permMap()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCurrentRowClass,
|
||||
grantDepart() {
|
||||
this.$emit('grantDepart', this.grantType)
|
||||
},
|
||||
grantRole() {
|
||||
this.$emit('grantRole', this.grantType)
|
||||
},
|
||||
handleChange(e, col, row) {
|
||||
const first = this.typeRelationIds[0]
|
||||
const second = this.typeRelationIds[1]
|
||||
if (e.target.checked) {
|
||||
grantTypeRelation(first, second, row.rid, { perms: [col] }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
} else {
|
||||
revokeTypeRelation(first, second, row.rid, { perms: [col] }).catch(() => {
|
||||
this.$emit('getTableData')
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ci-relation-grant {
|
||||
padding: 10px 0;
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,147 +0,0 @@
|
||||
<template>
|
||||
<div class="node-setting-wrap">
|
||||
<ops-table
|
||||
:data="nodes"
|
||||
size="mini"
|
||||
show-header-overflow
|
||||
:row-config="{ height: 42 }"
|
||||
border
|
||||
:min-height="78"
|
||||
>
|
||||
<vxe-column width="170" :title="$t('cmdb.ciType.nodeSettingIp')">
|
||||
<template #default="{ row }">
|
||||
<a-input v-model="row.ip"></a-input>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column width="170" :title="$t('cmdb.ciType.nodeSettingCommunity')">
|
||||
<template #default="{ row }">
|
||||
<a-input v-model="row.community"></a-input>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column width="170" :title="$t('cmdb.ciType.nodeSettingVersion')">
|
||||
<template #default="{ row }">
|
||||
<a-select
|
||||
v-model="row.version"
|
||||
:placeholder="$t('cmdb.ciType.nodeSettingVersionTip')"
|
||||
allowClear
|
||||
class="node-setting-select"
|
||||
>
|
||||
<a-select-option value="1">
|
||||
v1
|
||||
</a-select-option>
|
||||
<a-select-option value="2c">
|
||||
v2c
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column wdith="170">
|
||||
<template #default="{ row }">
|
||||
<div class="action">
|
||||
<a @click="() => copyNode(row.id)">
|
||||
<a-icon type="copy" />
|
||||
</a>
|
||||
<a @click="() => removeNode(row.id, 1)">
|
||||
<a-icon type="minus-circle" />
|
||||
</a>
|
||||
<a @click="addNode">
|
||||
<a-icon type="plus-circle" />
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</ops-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
export default {
|
||||
name: 'MonitorNodeSetting',
|
||||
props: {
|
||||
initNodes: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
form: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
nodes: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initNodesFunc() {
|
||||
this.nodes = _.cloneDeep(this.initNodes)
|
||||
},
|
||||
addNode() {
|
||||
const newNode = {
|
||||
id: uuidv4(),
|
||||
ip: '',
|
||||
community: 'public',
|
||||
version: '',
|
||||
}
|
||||
this.nodes.push(newNode)
|
||||
},
|
||||
removeNode(removeId, minLength) {
|
||||
if (this.nodes.length <= minLength) {
|
||||
this.$message.error('不可再删除!')
|
||||
return
|
||||
}
|
||||
const _idx = this.nodes.findIndex((item) => item.id === removeId)
|
||||
if (_idx > -1) {
|
||||
this.nodes.splice(_idx, 1)
|
||||
}
|
||||
},
|
||||
copyNode(id) {
|
||||
const copyNode = this.nodes.find((item) => item.id === id)
|
||||
if (copyNode) {
|
||||
const newNode = {
|
||||
...copyNode,
|
||||
id: uuidv4(),
|
||||
}
|
||||
this.nodes.push(newNode)
|
||||
}
|
||||
},
|
||||
getNodeValue() {
|
||||
const nodes = this.nodes.map((node) => {
|
||||
return _.pick(node, ['ip', 'community', 'version'])
|
||||
})
|
||||
return nodes
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.node-setting-wrap {
|
||||
margin-left: 17px;
|
||||
width: 600px;
|
||||
|
||||
.ant-row {
|
||||
/deep/ .ant-input-clear-icon {
|
||||
color: rgba(0,0,0,.25);
|
||||
|
||||
&:hover {
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.node-setting-select {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
|
||||
.action {
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
</style>
|
@@ -16,12 +16,8 @@
|
||||
<template v-for="(item, index) in preferenceSearchList.slice(0, 3)">
|
||||
<span
|
||||
v-if="item.name.length > 6"
|
||||
class="preference-search-tag"
|
||||
:class="['preference-search-tag', item.id === currentPreferenceSearch ? 'preference-search-tag-focus' : '']"
|
||||
:key="`${item.id}_${index}`"
|
||||
:style="{
|
||||
backgroundColor: item.id === currentPreferenceSearch ? '#2f54eb' : '',
|
||||
color: item.id === currentPreferenceSearch ? '#fff' : '',
|
||||
}"
|
||||
>
|
||||
<a-tooltip :title="item.name">
|
||||
<span @click="clickPreferenceSearch(item)">{{ `${item.name.slice(0, 6)}...` }}</span>
|
||||
@@ -33,11 +29,7 @@
|
||||
<span
|
||||
v-else
|
||||
:key="`${item.id}_${index}`"
|
||||
class="preference-search-tag"
|
||||
:style="{
|
||||
backgroundColor: item.id === currentPreferenceSearch ? '#2f54eb' : '',
|
||||
color: item.id === currentPreferenceSearch ? '#fff' : '',
|
||||
}"
|
||||
:class="['preference-search-tag', item.id === currentPreferenceSearch ? 'preference-search-tag-focus' : '']"
|
||||
>
|
||||
<span @click="clickPreferenceSearch(item)">{{ item.name }}</span>
|
||||
<a-popconfirm :title="$t('cmdb.ciType.confirmDelete2')" @confirm="deletePreferenceSearch(item)">
|
||||
@@ -193,6 +185,11 @@ export default {
|
||||
&:hover {
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
&-focus {
|
||||
background-color: @primary-color;
|
||||
color: #FFFFFF !important;
|
||||
}
|
||||
}
|
||||
.preference-search-delete {
|
||||
color: #a9a9a9;
|
||||
|
@@ -53,7 +53,7 @@
|
||||
<a-icon
|
||||
type="search"
|
||||
slot="suffix"
|
||||
:style="{ color: fuzzySearch ? '#2f54eb' : '#d9d9d9', cursor: 'pointer' }"
|
||||
:class="['search-form-bar-input-icon', fuzzySearch ? 'search-form-bar-input-icon-focus' : '']"
|
||||
@click="emitRefresh"
|
||||
/>
|
||||
<a-tooltip slot="prefix" placement="bottom" :overlayStyle="{ maxWidth: '550px', whiteSpace: 'pre-line' }">
|
||||
@@ -308,6 +308,16 @@ export default {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 32px;
|
||||
|
||||
&-input-icon {
|
||||
cursor: pointer;
|
||||
color: #d9d9d9;
|
||||
|
||||
&-focus {
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
.search-form-bar-filter {
|
||||
.ops_display_wrapper(transparent);
|
||||
|
||||
|
@@ -26,7 +26,8 @@ const cmdb_en = {
|
||||
ad: 'AutoDiscovery',
|
||||
cidetail: 'CI Detail',
|
||||
scene: 'Scene',
|
||||
dcim: 'DCIM'
|
||||
dcim: 'DCIM',
|
||||
serviceTree: 'Service Tree'
|
||||
},
|
||||
ciType: {
|
||||
ciType: 'CIType',
|
||||
@@ -76,6 +77,7 @@ const cmdb_en = {
|
||||
confirmDeleteADT: 'Do you confirm to delete [{pluginName}]',
|
||||
attributeMap: 'Attribute mapping',
|
||||
nodeConfig: 'Node Configuration',
|
||||
scanningParameter: 'Scanning Parameter',
|
||||
autoDiscovery: 'AutoDiscovery',
|
||||
node: 'Node',
|
||||
adExecConfig: 'Execute configuration',
|
||||
@@ -252,6 +254,25 @@ const cmdb_en = {
|
||||
checkModalColumn4: 'Last checkup time',
|
||||
testModalTitle: 'Automated discovery testing',
|
||||
attrMapTableAttrPlaceholder: 'Please edit the name',
|
||||
SNMPConfiguration: 'SNMP Configuration',
|
||||
nodeList: 'Node List',
|
||||
defaultVersion: 'Default Version',
|
||||
defaultCommunity: 'Default Community',
|
||||
timeout: 'Timeout',
|
||||
retryCount: 'Retry Count',
|
||||
scanningConfiguration: 'Scanning Configuration',
|
||||
initialNode: 'Initial Node',
|
||||
defaultGateway: 'Default Gateway',
|
||||
recursiveOrNot: 'Recursive Or Not',
|
||||
recursiveTip: 'Scanning Configuration: When disabling recursion, the node list must be configured.',
|
||||
maximumDepth: 'Maximum Depth',
|
||||
snmpFormTip1: 'If SNMP is not the default, Community and version need to be configured separately',
|
||||
snmpFormTip2: 'Timeout for establishing SNMP connection',
|
||||
snmpFormTip3: 'Number of retries to establish an SNMP connection',
|
||||
snmpFormTip4: 'The first node to start scanning, or recursively from the default gateway if unconfigured',
|
||||
snmpFormTip5: 'Enabled by default to discover all network devices and topology relationships as much as possible, and disabled to scan only the devices in the node list',
|
||||
snmpFormTip6: 'Depth of network device topology',
|
||||
snmpFormTip7: 'The results of the scan are filtered with CIDR, not filtered if not configured. Format: 192.168.1.0/24',
|
||||
nodeSettingIp: 'Network device IP address',
|
||||
nodeSettingIpTip: 'Please enter the ip address',
|
||||
nodeSettingIpTip1: 'ip address format error',
|
||||
@@ -314,6 +335,10 @@ const cmdb_en = {
|
||||
enum: 'Enum',
|
||||
ciGrantTip: `Filter conditions can be changed dynamically using {{}} referenced variables, currently user variables are supported, such as {{user.uid}},{{user.username}},{{user.email}},{{user.nickname}}`,
|
||||
searchInputTip: 'Please search for resource keywords',
|
||||
columnSearchInputTip: '192.168.1.1\n192.168.1.2\n192.168.1.3',
|
||||
rowSearchMode: 'Single Row',
|
||||
columnSearchMode: 'Multi Row',
|
||||
columnSearchTip: 'Supports retrieval of short texts only',
|
||||
resourceSearch: 'Resource Search',
|
||||
recentSearch: 'Recent Search',
|
||||
myCollection: 'My Collection',
|
||||
@@ -696,6 +721,9 @@ if __name__ == "__main__":
|
||||
batchRollbacking: 'Deleting {total} items in total, {successNum} items successful, {errorNum} items failed',
|
||||
baselineTips: 'Changes at this point in time will also be rollbacked, Unique ID, password and dynamic attributes do not support',
|
||||
cover: 'Cover',
|
||||
detail: 'Detail',
|
||||
upstream: 'Upstream',
|
||||
downstream: 'Downstream'
|
||||
},
|
||||
serviceTree: {
|
||||
remove: 'Remove',
|
||||
|
@@ -26,7 +26,8 @@ const cmdb_zh = {
|
||||
ad: '自动发现',
|
||||
cidetail: 'CI 详情',
|
||||
scene: '场景',
|
||||
dcim: '数据中心'
|
||||
dcim: '数据中心',
|
||||
serviceTree: '服务树'
|
||||
},
|
||||
ciType: {
|
||||
ciType: '模型',
|
||||
@@ -76,6 +77,7 @@ const cmdb_zh = {
|
||||
confirmDeleteADT: '确认删除 【{pluginName}】',
|
||||
attributeMap: '字段映射',
|
||||
nodeConfig: '节点配置',
|
||||
scanningParameter: '扫描参数',
|
||||
autoDiscovery: '自动发现属性',
|
||||
node: '节点',
|
||||
adExecConfig: '执行配置',
|
||||
@@ -252,6 +254,25 @@ const cmdb_zh = {
|
||||
checkModalColumn4: '最近检查时间',
|
||||
testModalTitle: '自动发现测试',
|
||||
attrMapTableAttrPlaceholder: '请编辑名称',
|
||||
SNMPConfiguration: 'SNMP配置',
|
||||
nodeList: '节点列表',
|
||||
defaultVersion: '默认版本',
|
||||
defaultCommunity: '默认 Community',
|
||||
timeout: '超时时间',
|
||||
retryCount: '重试次数',
|
||||
scanningConfiguration: '扫描配置',
|
||||
initialNode: '初始节点',
|
||||
defaultGateway: '默认网关',
|
||||
recursiveOrNot: '是否递归',
|
||||
recursiveTip: '扫描配置关闭递归时, 必须配置节点列表',
|
||||
maximumDepth: '最大深度',
|
||||
snmpFormTip1: '如果不是默认的SNMP, Community和版本需要单独配置',
|
||||
snmpFormTip2: '建立SNMP连接的超时时间',
|
||||
snmpFormTip3: '建立SNMP连接的重试次数',
|
||||
snmpFormTip4: '开始扫描的第一个节点,如果不配置则是从默认网关开始递归扫描',
|
||||
snmpFormTip5: '默认开启,表示尽可能发现所有网络设备和拓扑关系, 如果关闭,则仅扫描节点列表里的设备',
|
||||
snmpFormTip6: '网络设备拓扑的深度',
|
||||
snmpFormTip7: '扫描的结果用CIDR进行过滤,不配置则不会过滤。格式: 192.168.1.0/24',
|
||||
nodeSettingIp: '网络设备IP地址',
|
||||
nodeSettingIpTip: '请输入 ip 地址',
|
||||
nodeSettingIpTip1: 'ip地址格式错误',
|
||||
@@ -314,6 +335,10 @@ const cmdb_zh = {
|
||||
enum: '枚举',
|
||||
ciGrantTip: `筛选条件可使用{{}}引用变量实现动态变化,目前支持用户变量,如{{user.uid}},{{user.username}},{{user.email}},{{user.nickname}}`,
|
||||
searchInputTip: '请搜索资源关键字',
|
||||
columnSearchInputTip: '192.168.1.1\n192.168.1.2\n192.168.1.3',
|
||||
rowSearchMode: '单行',
|
||||
columnSearchMode: '多行',
|
||||
columnSearchTip: '仅支持检索短文本',
|
||||
resourceSearch: '资源搜索',
|
||||
recentSearch: '最近搜索',
|
||||
myCollection: '我的收藏',
|
||||
@@ -695,6 +720,9 @@ if __name__ == "__main__":
|
||||
batchRollbacking: '正在回滚,共{total}个,成功{successNum}个,失败{errorNum}个',
|
||||
baselineTips: '该时间点的变更也会被回滚, 唯一标识、密码属性、动态属性不支持回滚',
|
||||
cover: '覆盖',
|
||||
detail: '详情',
|
||||
upstream: '上游',
|
||||
downstream: '下游'
|
||||
},
|
||||
serviceTree: {
|
||||
remove: '移除',
|
||||
|
@@ -27,6 +27,17 @@ const genCmdbRoutes = async () => {
|
||||
name: 'cmdb_disabled1',
|
||||
meta: { title: 'cmdb.menu.resources', disabled: true },
|
||||
},
|
||||
{
|
||||
path: '/cmdb/relationviews/:viewId?',
|
||||
name: 'cmdb_relation_views',
|
||||
component: () => import('../views/relation_views/index'),
|
||||
meta: {
|
||||
title: 'cmdb.menu.serviceTree',
|
||||
appName: 'cmdb',
|
||||
icon: 'veops-servicetree',
|
||||
keepAlive: false
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/cmdb/resourceviews',
|
||||
name: 'cmdb_resource_views',
|
||||
@@ -60,7 +71,7 @@ const genCmdbRoutes = async () => {
|
||||
{
|
||||
path: '/cmdb/adc',
|
||||
name: 'cmdb_auto_discovery_ci',
|
||||
meta: { title: 'cmdb.menu.adCIs', icon: 'ops-cmdb-adc', selectedIcon: 'ops-cmdb-adc', keepAlive: false },
|
||||
meta: { title: 'cmdb.menu.adCIs', icon: 'ops-cmdb-adc', selectedIcon: 'ops-cmdb-adc', keepAlive: false, permission: ['admin', 'cmdb_admin'] },
|
||||
component: () => import('../views/discoveryCI/index.vue')
|
||||
},
|
||||
{
|
||||
@@ -194,15 +205,14 @@ const genCmdbRoutes = async () => {
|
||||
} else {
|
||||
routes.redirect = '/cmdb/dashboard'
|
||||
}
|
||||
const relationViews = relation.name2id.map(item => {
|
||||
return {
|
||||
path: `/cmdb/relationviews/${item[1]}`,
|
||||
name: `cmdb_relation_views_${item[1]}`,
|
||||
component: () => import('../views/relation_views/index'),
|
||||
meta: { title: item[0], icon: 'ops-cmdb-relation', selectedIcon: 'ops-cmdb-relation', keepAlive: false, name: item[0] },
|
||||
|
||||
if (relation?.name2id?.length === 0) {
|
||||
const relationViewRouteIndex = routes.children?.findIndex?.((route) => route.name === 'cmdb_relation_views')
|
||||
if (relationViewRouteIndex >= 0) {
|
||||
routes.children.splice(relationViewRouteIndex, 1)
|
||||
}
|
||||
})
|
||||
routes.children.splice(resourceViewsIndex, 0, ...relationViews)
|
||||
}
|
||||
|
||||
return routes
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
<p v-html="$t('cmdb.batch.drawTips1')"></p>
|
||||
<p v-html="$t('cmdb.batch.drawTips2')"></p>
|
||||
<div v-for="item in fileList" :key="item.name" class="cmdb-batch-upload-dragger-file">
|
||||
<span><a-icon type="file" :style="{ color: '#2F54EB', marginRight: '5px' }" />{{ item.name }}</span>
|
||||
<span><a-icon type="file" class="cmdb-batch-upload-dragger-file-icon"/>{{ item.name }}</span>
|
||||
<a-progress :status="progressStatus" :percent="percent" />
|
||||
</div>
|
||||
</a-upload-dragger>
|
||||
@@ -92,12 +92,7 @@ export default {
|
||||
}
|
||||
.ant-upload.ant-upload-drag {
|
||||
border: none;
|
||||
background: linear-gradient(90deg, @text-color_5 50%, transparent 0) repeat-x,
|
||||
linear-gradient(90deg, @text-color_5 50%, transparent 0) repeat-x,
|
||||
linear-gradient(0deg, @text-color_5 50%, transparent 0) repeat-y,
|
||||
linear-gradient(0deg, @text-color_5 50%, transparent 0) repeat-y;
|
||||
background-size: 15px 1px, 15px 1px, 1px 15px, 1px 15px;
|
||||
background-position: 0 0, 0 100%, 0 0, 100% 0;
|
||||
background: ~'linear-gradient(90deg, @{text-color_5} 50%, transparent 0) repeat-x 0 0 / 15px 1px, linear-gradient(90deg, @{text-color_5} 50%, transparent 0) repeat-x 0 100% / 15px 1px, linear-gradient(0deg, @{text-color_5} 50%, transparent 0) repeat-y 0 0 / 1px 15px, linear-gradient(0deg, @{text-color_5} 50%, transparent 0) repeat-y 100% 0 / 1px 15px';
|
||||
.ant-upload-drag-container > i {
|
||||
font-size: 60px;
|
||||
}
|
||||
@@ -106,13 +101,7 @@ export default {
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(90deg, @primary-color_2 50%, transparent 0) repeat-x,
|
||||
linear-gradient(90deg, @primary-color_2 50%, transparent 0) repeat-x,
|
||||
linear-gradient(0deg, @primary-color_2 50%, transparent 0) repeat-y,
|
||||
linear-gradient(0deg, @primary-color_2 50%, transparent 0) repeat-y;
|
||||
background-size: 15px 1px, 15px 1px, 1px 15px, 1px 15px;
|
||||
background-position: 0 0, 0 100%, 0 0, 100% 0;
|
||||
background-color: @primary-color_7;
|
||||
background: ~'linear-gradient(90deg, @{primary-color_2} 50%, transparent 0) repeat-x 0 0 / 15px 1px, linear-gradient(90deg, @{primary-color_2} 50%, transparent 0) repeat-x 0 100% / 15px 1px, linear-gradient(0deg, @{primary-color_2} 50%, transparent 0) repeat-y 0 0 / 1px 15px, linear-gradient(0deg, @{primary-color_2} 50%, transparent 0) repeat-y 100% 0 / 1px 15px, @{primary-color_7}';
|
||||
}
|
||||
}
|
||||
.ant-upload.ant-upload-drag .ant-upload-drag-container {
|
||||
@@ -139,6 +128,11 @@ export default {
|
||||
white-space: nowrap;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
&-icon {
|
||||
color: @primary-color;
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
.cmdb-batch-upload-tips {
|
||||
width: 50%;
|
||||
|
@@ -17,7 +17,15 @@
|
||||
:ci_id="ci._id"
|
||||
:attr_id="attr.id"
|
||||
></PasswordField>
|
||||
<template v-else-if="attr.value_type === '6'">{{ JSON.stringify(ci[attr.name] || {}) }}</template>
|
||||
<a-tooltip
|
||||
v-else-if="attr.value_type === '6'"
|
||||
:title="JSON.stringify(ci[attr.name] || {})"
|
||||
overlayClassName="ci-detail-attr-json-tooltip"
|
||||
>
|
||||
<span class="ci-detail-attr-json">
|
||||
{{ JSON.stringify(ci[attr.name] || {}) }}
|
||||
</span>
|
||||
</a-tooltip>
|
||||
<template v-else-if="attr.is_choice">
|
||||
<template v-if="attr.is_list">
|
||||
<span
|
||||
@@ -348,4 +356,22 @@ export default {
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
<style lang="less" scoped>
|
||||
.ci-detail-attr-json {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.ci-detail-attr-json-tooltip {
|
||||
|
||||
.ant-tooltip-content {
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<div class="ci-detail-table-title">
|
||||
{{ title }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'CIDetailTableTitle',
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ci-detail-table-title {
|
||||
height: 42px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: @text-color_1;
|
||||
padding: 0px 20px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: #EBF0F9;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
height: 44px;
|
||||
width: 300px;
|
||||
background: #F8F9FD60;
|
||||
transform: rotate(40deg);
|
||||
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 25%;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
height: 44px;
|
||||
width: 300px;
|
||||
background: #F8F9FD60;
|
||||
transform: rotate(40deg);
|
||||
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: calc(25% + 100px);
|
||||
}
|
||||
}
|
||||
</style>
|
@@ -0,0 +1,64 @@
|
||||
<template>
|
||||
<div class="ci-detail-title">
|
||||
<CIIcon :icon="icon" size="20" />
|
||||
<span class="ci-detail-title-text">{{ title }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CIIcon from '@/modules/cmdb/components/ciIcon'
|
||||
|
||||
export default {
|
||||
name: 'CIDetailTitle',
|
||||
components: {
|
||||
CIIcon
|
||||
},
|
||||
props: {
|
||||
ci: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
ci_types: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
icon: '',
|
||||
title: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
findCIType() {
|
||||
return this.ci_types?.find?.((item) => item?.id === this.ci?._type) || {}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
findCIType: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(val) {
|
||||
this.icon = val?.icon || ''
|
||||
this.title = this?.ci?.[val?.show_name] || this?.ci?.[val?.unique_key] || ''
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ci-detail-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
column-gap: 9px;
|
||||
|
||||
&-text {
|
||||
width: 100%;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: @text-color_1;
|
||||
}
|
||||
}
|
||||
</style>
|
@@ -0,0 +1,673 @@
|
||||
<template>
|
||||
<div v-if="allCITypes.length" class="ci-relation-table">
|
||||
<CIDetailTableTitle :title="$t('cmdb.relation')" />
|
||||
|
||||
<div class="ci-relation-table-wrap">
|
||||
<div class="ci-relation-table-tab">
|
||||
<div
|
||||
v-for="(group) in tabList"
|
||||
:key="group.key"
|
||||
class="tab-group"
|
||||
>
|
||||
<div
|
||||
v-if="group.name"
|
||||
class="tab-group-name"
|
||||
>
|
||||
{{ group.name }}
|
||||
</div>
|
||||
<div
|
||||
v-for="(item) in group.list"
|
||||
:key="item.key"
|
||||
:class="`tab-item ${item.key === currentTab ? 'tab-item-active' : ''}`"
|
||||
:style="{
|
||||
paddingLeft: item.key === 'all' ? '8px' : '16px'
|
||||
}"
|
||||
@click="clickTab(item.key)"
|
||||
>
|
||||
<span class="tab-item-name">
|
||||
<a-tooltip :title="item.name">
|
||||
<span class="tab-item-name-text">{{ item.name }}</span>
|
||||
</a-tooltip>
|
||||
<span
|
||||
v-if="item.count"
|
||||
class="tab-item-name-count"
|
||||
>
|
||||
({{ item.count }})
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
v-if="item.key === currentTab && item.showAdd"
|
||||
class="tab-item-add"
|
||||
@click="openAddModal(item)"
|
||||
>
|
||||
<a-icon type="plus" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="ci-relation-table-container"
|
||||
v-if="tableIDList.length"
|
||||
>
|
||||
<div
|
||||
v-for="(item) in tableIDList"
|
||||
:key="item.key"
|
||||
class="ci-relation-table-item"
|
||||
>
|
||||
<div
|
||||
v-if="currentTab === 'all'"
|
||||
class="ci-relation-table-item-name"
|
||||
>
|
||||
<span class="ci-relation-table-item-name-text">{{ item.name }}</span>
|
||||
<span class="ci-relation-table-item-name-count">({{ item.count }})</span>
|
||||
</div>
|
||||
|
||||
<vxe-grid
|
||||
bordered
|
||||
size="mini"
|
||||
:columns="allColumns[item.value]"
|
||||
:data="allCIList[item.key]"
|
||||
overflow
|
||||
showOverflow="tooltip"
|
||||
showHeaderOverflow="tooltip"
|
||||
resizable
|
||||
class="ops-stripe-table"
|
||||
max-height="300px"
|
||||
>
|
||||
<template #reference_default="{ row, column }">
|
||||
<a
|
||||
v-for="(id) in (column.params.attr.is_list ? row[column.field] : [row[column.field]])"
|
||||
:key="id"
|
||||
:href="`/cmdb/cidetail/${column.params.attr.reference_type_id}/${id}`"
|
||||
target="_blank"
|
||||
>
|
||||
{{ getReferenceName(id, column) }}
|
||||
</a>
|
||||
</template>
|
||||
<template #operation_default="{ row }">
|
||||
<a-popconfirm
|
||||
arrowPointAtCenter
|
||||
:title="$t('cmdb.ci.confirmDeleteRelation')"
|
||||
@confirm="deleteRelation(row)"
|
||||
>
|
||||
<a
|
||||
:disabled="!allCanEdit[item.value]"
|
||||
:style="{
|
||||
color: !allCanEdit[item.value] ? 'rgba(0, 0, 0, 0.25)' : 'red',
|
||||
}"
|
||||
>
|
||||
<a-icon type="delete" />
|
||||
</a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</vxe-grid>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AddTableModal ref="addTableModal" @reload="refreshTableData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
import { getCanEditByParentIdChildId } from '@/modules/cmdb/api/CITypeRelation'
|
||||
import { deleteCIRelationView } from '@/modules/cmdb/api/CIRelation'
|
||||
import { searchCI } from '@/modules/cmdb/api/ci'
|
||||
import { getSubscribeAttributes } from '@/modules/cmdb/api/preference'
|
||||
|
||||
import CIDetailTableTitle from './ciDetailTableTitle.vue'
|
||||
import AddTableModal from '@/modules/cmdb/views/relation_views/modules/AddTableModal.vue'
|
||||
|
||||
const PARENT_KEY = 'parents'
|
||||
const CHILDREN_KEY = 'children'
|
||||
|
||||
export default {
|
||||
name: 'CIRelationTable',
|
||||
components: {
|
||||
CIDetailTableTitle,
|
||||
AddTableModal
|
||||
},
|
||||
inject: {
|
||||
ci_types: { from: 'ci_types' },
|
||||
relationViewRefreshNumber: {
|
||||
from: 'relationViewRefreshNumber',
|
||||
default: () => null,
|
||||
},
|
||||
},
|
||||
props: {
|
||||
ciId: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
typeId: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
ci: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
relationData: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
tabList: [],
|
||||
currentTab: 'all',
|
||||
allCITypes: [],
|
||||
allColumns: {},
|
||||
allJSONAttr: {},
|
||||
allCIList: {},
|
||||
allCanEdit: {},
|
||||
referenceCINameMap: {}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
tabListFlat() {
|
||||
return this.tabList.reduce((list, group) => list.concat(group.list), [])
|
||||
},
|
||||
tableIDList() {
|
||||
const baseKeys = this.currentTab === 'all'
|
||||
? this.tabListFlat.filter(item => item.value !== 'all').map(item => item.key)
|
||||
: [this.currentTab]
|
||||
|
||||
return baseKeys.filter((key) => this.allCIList?.[key]?.length).map((key) => {
|
||||
const findTab = this.tabListFlat.find((item) => item.key === key) || {}
|
||||
|
||||
let name = findTab?.name || ''
|
||||
if (name && findTab?.value === this.ci._type) {
|
||||
name = `${findTab?.isParent ? this.$t('cmdb.ci.upstream') : this.$t('cmdb.ci.downstream')} - ${name}`
|
||||
}
|
||||
|
||||
return {
|
||||
key,
|
||||
value: findTab?.value || '',
|
||||
name,
|
||||
count: findTab?.count || ''
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
relationData: {
|
||||
immediate: true,
|
||||
deep: true,
|
||||
handler(val) {
|
||||
this.init(val)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async init(relationData) {
|
||||
const ci_types_list = this.ci_types()
|
||||
const _findCiType = ci_types_list.find((item) => item.id === this.typeId)
|
||||
if (!_findCiType) {
|
||||
return
|
||||
}
|
||||
|
||||
const cloneRelationData = _.cloneDeep(relationData)
|
||||
|
||||
const allCITypes = _.uniqBy(
|
||||
[
|
||||
...cloneRelationData.parentCITypeList,
|
||||
...cloneRelationData.childCITypeList
|
||||
],
|
||||
'id'
|
||||
)
|
||||
await this.handleSubscribeAttributes(allCITypes)
|
||||
|
||||
const {
|
||||
columns: parentColumns,
|
||||
jsonAttr: parentJSONAttr,
|
||||
} = this.handleCITypeList(cloneRelationData.parentCITypeList, true)
|
||||
const {
|
||||
columns: childColumns,
|
||||
jsonAttr: childJSONAttr,
|
||||
} = this.handleCITypeList(cloneRelationData.childCITypeList, false)
|
||||
|
||||
this.allCITypes = allCITypes
|
||||
this.allColumns = {
|
||||
...parentColumns,
|
||||
...childColumns
|
||||
}
|
||||
this.allJSONAttr = {
|
||||
...parentJSONAttr,
|
||||
...childJSONAttr
|
||||
}
|
||||
|
||||
await this.getCanEditList(this.allCITypes)
|
||||
|
||||
const [parentCIs, childCIs] = await Promise.all([
|
||||
this.handleCIList(cloneRelationData.parentCIList, true),
|
||||
this.handleCIList(cloneRelationData.childCIList, false)
|
||||
])
|
||||
this.allCIList = {
|
||||
...parentCIs,
|
||||
...childCIs
|
||||
}
|
||||
|
||||
const tabList = []
|
||||
|
||||
tabList[0] = {
|
||||
name: '',
|
||||
key: 'all',
|
||||
list: [{
|
||||
name: this.$t('all'),
|
||||
key: 'all',
|
||||
value: 'all',
|
||||
count: Object.values(this.allCIList).reduce((acc, cur) => acc + (cur?.length || 0), 0),
|
||||
showAdd: false
|
||||
}]
|
||||
}
|
||||
tabList[1] = {
|
||||
name: this.$t('cmdb.ci.upstream'),
|
||||
key: PARENT_KEY,
|
||||
list: this.buildTabList(cloneRelationData.parentCITypeList, PARENT_KEY, true)
|
||||
}
|
||||
tabList[2] = {
|
||||
name: this.$t('cmdb.ci.downstream'),
|
||||
key: CHILDREN_KEY,
|
||||
list: this.buildTabList(cloneRelationData.childCITypeList, CHILDREN_KEY, false)
|
||||
}
|
||||
this.tabList = tabList
|
||||
|
||||
this.handleReferenceCINameMap()
|
||||
},
|
||||
|
||||
buildTabList(list, keyPrefix, isParent) {
|
||||
return list.map((item) => {
|
||||
const key = `${keyPrefix}-${item.id}`
|
||||
return {
|
||||
name: item?.alias ?? item?.name ?? '',
|
||||
key,
|
||||
isParent,
|
||||
value: item.id,
|
||||
count: this.allCIList?.[key]?.length || 0,
|
||||
showAdd: this.allCanEdit?.[item.id] ?? false
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
handleCITypeList(list, isParent) {
|
||||
const CIColumns = {}
|
||||
const CIJSONAttr = {}
|
||||
|
||||
list.forEach((item) => {
|
||||
const columns = []
|
||||
const jsonAttr = []
|
||||
|
||||
item.isParent = isParent
|
||||
item.attributes.forEach((attr) => {
|
||||
const column = {
|
||||
key: 'p_' + attr.id,
|
||||
field: attr.name,
|
||||
title: attr.alias,
|
||||
minWidth: '100px',
|
||||
params: {
|
||||
attr
|
||||
},
|
||||
}
|
||||
if (attr.is_reference) {
|
||||
column.slots = {
|
||||
default: 'reference_default'
|
||||
}
|
||||
}
|
||||
columns.push(column)
|
||||
|
||||
if (attr.value_type === '6') {
|
||||
jsonAttr.push(attr.name)
|
||||
}
|
||||
})
|
||||
CIJSONAttr[item.id] = jsonAttr
|
||||
CIColumns[item.id] = columns
|
||||
CIColumns[item.id].push({
|
||||
key: 'p_operation',
|
||||
field: 'operation',
|
||||
title: this.$t('operation'),
|
||||
width: '60px',
|
||||
fixed: 'right',
|
||||
slots: {
|
||||
default: 'operation_default',
|
||||
},
|
||||
align: 'center',
|
||||
})
|
||||
})
|
||||
|
||||
return {
|
||||
columns: CIColumns,
|
||||
jsonAttr: CIJSONAttr
|
||||
}
|
||||
},
|
||||
|
||||
async getCanEditList(allCITypes) {
|
||||
const promises = allCITypes.map((ciType) => {
|
||||
let parentId = ciType.id
|
||||
let childId = this.typeId
|
||||
|
||||
if (!ciType.isParent) {
|
||||
parentId = this.typeId
|
||||
childId = ciType.id
|
||||
}
|
||||
|
||||
return getCanEditByParentIdChildId(parentId, childId).then((res) => {
|
||||
return { id: ciType.id, canEdit: res.result }
|
||||
})
|
||||
})
|
||||
|
||||
const allCanEdit = {}
|
||||
|
||||
const res = await Promise.all(promises)
|
||||
if (res?.length) {
|
||||
res.map((item) => {
|
||||
allCanEdit[item.id] = item.canEdit
|
||||
})
|
||||
}
|
||||
|
||||
this.allCanEdit = allCanEdit
|
||||
},
|
||||
|
||||
async handleSubscribeAttributes(allCITypes) {
|
||||
const promises = allCITypes.map((ciType, index) => {
|
||||
return getSubscribeAttributes(ciType.id).then((res) => {
|
||||
return {
|
||||
...(res || {}),
|
||||
id: ciType.id,
|
||||
indexInAll: index
|
||||
}
|
||||
})
|
||||
})
|
||||
const res = await Promise.all(promises)
|
||||
|
||||
if (res?.length) {
|
||||
res.forEach((item) => {
|
||||
if (
|
||||
allCITypes?.[item.indexInAll]?.attributes &&
|
||||
item?.is_subscribed
|
||||
) {
|
||||
allCITypes[item.indexInAll].attributes = item.attributes
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return allCITypes
|
||||
},
|
||||
|
||||
async handleCIList(ciList, isParent) {
|
||||
const cis = {}
|
||||
ciList.forEach((item) => {
|
||||
this.allJSONAttr[item._type].forEach((attr) => {
|
||||
item[`${attr}`] = item[`${attr}`] ? JSON.stringify(item[`${attr}`]) : ''
|
||||
})
|
||||
this.formatCI(item)
|
||||
item.isParent = isParent
|
||||
const CIKey = `${isParent ? PARENT_KEY : CHILDREN_KEY}-${item._type}`
|
||||
|
||||
if (CIKey in cis) {
|
||||
cis[CIKey].push(item)
|
||||
} else {
|
||||
cis[CIKey] = [item]
|
||||
}
|
||||
})
|
||||
|
||||
return cis
|
||||
},
|
||||
|
||||
formatCI(ci) {
|
||||
Object.keys(ci).forEach((key) => {
|
||||
const attr = this.allColumns?.[ci?._type]?.find((item) => item?.params?.attr?.name === key)?.params?.attr
|
||||
if (attr?.is_choice && attr?.choice_value?.length) {
|
||||
if (attr?.is_list) {
|
||||
ci[key] = ci[key].map((value) => {
|
||||
const label = attr?.choice_value?.find((choice) => choice?.[0] === value)?.[1]?.label
|
||||
return label || ci[key]
|
||||
})
|
||||
} else {
|
||||
const label = attr?.choice_value?.find((choice) => choice?.[0] === ci[key])?.[1]?.label
|
||||
ci[key] = label || ci[key]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return ci
|
||||
},
|
||||
|
||||
async handleReferenceCINameMap() {
|
||||
const referenceCINameMap = {}
|
||||
this.allCITypes.forEach((CIType) => {
|
||||
const CIKey = `${CIType.isParent ? PARENT_KEY : CHILDREN_KEY}-${CIType.id}`
|
||||
|
||||
CIType.attributes.forEach((attr) => {
|
||||
if (attr?.is_reference && attr?.reference_type_id) {
|
||||
const currentCIList = this.allCIList[CIKey]
|
||||
if (currentCIList?.length) {
|
||||
currentCIList.forEach((ci) => {
|
||||
const ids = Array.isArray(ci[attr.name]) ? ci[attr.name] : ci[attr.name] ? [ci[attr.name]] : []
|
||||
|
||||
if (ids.length) {
|
||||
if (!referenceCINameMap?.[attr.reference_type_id]) {
|
||||
referenceCINameMap[attr.reference_type_id] = {}
|
||||
}
|
||||
ids.forEach((id) => {
|
||||
referenceCINameMap[attr.reference_type_id][id] = ''
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
if (!Object.keys(referenceCINameMap).length) {
|
||||
return
|
||||
}
|
||||
|
||||
const allRes = await Promise.all(
|
||||
Object.keys(referenceCINameMap).map((key) => {
|
||||
return searchCI({
|
||||
q: `_type:${key},_id:(${Object.keys(referenceCINameMap[key]).join(';')})`,
|
||||
count: 9999
|
||||
})
|
||||
})
|
||||
)
|
||||
const CITypeList = this.ci_types()
|
||||
const showNameMap = {}
|
||||
|
||||
Object.keys(referenceCINameMap).forEach((id) => {
|
||||
const CIType = CITypeList.find((CIType) => Number(CIType.id) === Number(id))
|
||||
|
||||
showNameMap[id] = {
|
||||
show_name: CIType?.show_name,
|
||||
unique_key: CIType?.unique_key
|
||||
}
|
||||
})
|
||||
|
||||
allRes.forEach((res) => {
|
||||
res.result.forEach((item) => {
|
||||
if (referenceCINameMap?.[item._type]?.[item._id] === '') {
|
||||
const showName = showNameMap?.[item._type]
|
||||
|
||||
referenceCINameMap[item._type][item._id] = item?.[showName?.show_name] ?? item?.[showName?.unique_key] ?? ''
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
this.referenceCINameMap = referenceCINameMap
|
||||
},
|
||||
|
||||
getReferenceName(id, column) {
|
||||
const typeId = column?.params?.attr?.reference_type_id
|
||||
return this.referenceCINameMap?.[typeId]?.[id] || id
|
||||
},
|
||||
|
||||
clickTab(key) {
|
||||
this.currentTab = key
|
||||
},
|
||||
|
||||
deleteRelation(row) {
|
||||
const first_ci_id = row?.isParent ? row?._id : this.ciId
|
||||
const second_ci_id = row?.isParent ? this.ciId : row?._id
|
||||
|
||||
deleteCIRelationView(first_ci_id, second_ci_id).then(() => {
|
||||
this.refreshTableData()
|
||||
if (this.relationViewRefreshNumber) {
|
||||
this.relationViewRefreshNumber()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
openAddModal(tabData) {
|
||||
const ciType = this.allCITypes.find((item) => item.id === tabData.value)
|
||||
|
||||
this.$refs.addTableModal.openModal(
|
||||
{
|
||||
[`${this.ci.unique}`]: this.ci?.[this.ci.unique]
|
||||
},
|
||||
this.ciId,
|
||||
ciType,
|
||||
tabData?.isParent ? 'parents' : 'children'
|
||||
)
|
||||
},
|
||||
|
||||
async refreshTableData() {
|
||||
this.$emit('refreshRelationCI')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ci-relation-table {
|
||||
width: 100%;
|
||||
margin-top: 32px;
|
||||
|
||||
&-wrap {
|
||||
border: solid 1px #E4E7ED;
|
||||
border-top: none;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&-tab {
|
||||
flex-shrink: 0;
|
||||
width: 160px;
|
||||
min-height: 300px;
|
||||
max-height: 600px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 6px 0px;
|
||||
border-right: solid 1px #E4E7ED;
|
||||
|
||||
.tab-group {
|
||||
width: 100%;
|
||||
|
||||
&-name {
|
||||
padding-left: 8px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
width: 100%;
|
||||
font-weight: 600;
|
||||
color: rgba(0, 0, 0, .45);
|
||||
}
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
height: 32px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-left: 16px;
|
||||
padding-right: 10px;
|
||||
background-color: #FFFFFF;
|
||||
cursor: pointer;
|
||||
|
||||
&-name {
|
||||
font-size: 14px;
|
||||
color: @text-color_1;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
max-width: calc(100% - 16px);
|
||||
|
||||
&-text {
|
||||
text-overflow: ellipsis;
|
||||
text-wrap: nowrap;
|
||||
overflow: hidden;
|
||||
color: @text-color_2;
|
||||
}
|
||||
|
||||
&-count {
|
||||
color: @text-color_3;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
&-add {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 14px;
|
||||
background-color: #FFFFFF;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: @primary-color;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
&-active {
|
||||
background-color: #F0F5FF;
|
||||
|
||||
.tab-item-name-text {
|
||||
color: @text-color_1;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.tab-item-name-text {
|
||||
color: @text-color_1;
|
||||
}
|
||||
|
||||
.tab-item-add {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-container {
|
||||
width: 100%;
|
||||
padding: 15px 17px;
|
||||
overflow: hidden;
|
||||
min-height: 300px;
|
||||
max-height: 600px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
&-item {
|
||||
margin-bottom: 16px;
|
||||
|
||||
&-name {
|
||||
margin-bottom: 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: @text-color_1;
|
||||
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
|
||||
&-count {
|
||||
font-size: 12px;
|
||||
color: @text-color_3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@@ -0,0 +1,95 @@
|
||||
import { getCITypeChildren, getCITypeParent } from '@/modules/cmdb/api/CITypeRelation'
|
||||
import { searchCIRelation } from '@/modules/cmdb/api/CIRelation'
|
||||
|
||||
const RelationMixin = {
|
||||
data() {
|
||||
return {
|
||||
relationData: {
|
||||
parentCITypeList: [],
|
||||
childCITypeList: [],
|
||||
parentCIList: [],
|
||||
childCIList: []
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async initRelationData(typeId, ciId) {
|
||||
const {
|
||||
parentCITypeList,
|
||||
childCITypeList
|
||||
} = await this.getRelationCITypeList(typeId)
|
||||
const {
|
||||
parentCIList,
|
||||
childCIList
|
||||
} = await this.getRelationCIList(ciId)
|
||||
this.relationData = {
|
||||
parentCITypeList,
|
||||
childCITypeList,
|
||||
parentCIList,
|
||||
childCIList
|
||||
}
|
||||
},
|
||||
|
||||
async getRelationCITypeList(typeId) {
|
||||
let parentCITypeList = []
|
||||
let childCITypeList = []
|
||||
|
||||
if (typeId) {
|
||||
parentCITypeList = await this.getParentCITypeList(typeId)
|
||||
childCITypeList = await this.getChildCITypeList(typeId)
|
||||
}
|
||||
|
||||
return {
|
||||
parentCITypeList,
|
||||
childCITypeList
|
||||
}
|
||||
},
|
||||
|
||||
async getRelationCIList(ciId) {
|
||||
let parentCIList = []
|
||||
let childCIList = []
|
||||
|
||||
if (ciId) {
|
||||
parentCIList = await this.getParentCIList(ciId)
|
||||
childCIList = await this.getChildCIList(ciId)
|
||||
}
|
||||
|
||||
return {
|
||||
parentCIList,
|
||||
childCIList
|
||||
}
|
||||
},
|
||||
|
||||
async refreshRelationCI(ciId) {
|
||||
const {
|
||||
parentCIList,
|
||||
childCIList
|
||||
} = await this.getRelationCIList(ciId)
|
||||
this.relationData.parentCIList = parentCIList
|
||||
this.relationData.childCIList = childCIList
|
||||
},
|
||||
|
||||
async getParentCITypeList(typeId) {
|
||||
const res = await getCITypeParent(typeId)
|
||||
return res?.parents || []
|
||||
},
|
||||
|
||||
async getChildCITypeList(typeId) {
|
||||
const res = await getCITypeChildren(typeId)
|
||||
return res.children || []
|
||||
},
|
||||
|
||||
async getParentCIList(ciId) {
|
||||
const res = await searchCIRelation(`root_id=${ciId}&level=1&reverse=1&count=10000`)
|
||||
return res?.result || []
|
||||
},
|
||||
|
||||
async getChildCIList(ciId) {
|
||||
const res = await searchCIRelation(`root_id=${ciId}&level=1&reverse=0&count=10000`)
|
||||
return res?.result || []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default RelationMixin
|
@@ -1,146 +1,16 @@
|
||||
<template>
|
||||
<div class="ci-detail-relation">
|
||||
<a-radio-group v-model="activeKey" size="small" @change="handleChangeActiveKey">
|
||||
<a-radio-button value="1">
|
||||
{{ $t('cmdb.ci.topo') }}
|
||||
</a-radio-button>
|
||||
<a-radio-button value="2">
|
||||
{{ $t('cmdb.ci.table') }}
|
||||
</a-radio-button>
|
||||
</a-radio-group>
|
||||
<CiDetailRelationTopo ref="ciDetailRelationTopo" v-if="activeKey === '1'" />
|
||||
<template v-if="activeKey === '2'">
|
||||
<template v-for="parent in parentCITypes">
|
||||
<div :key="'ctr_' + parent.ctr_id">
|
||||
<div class="ci-detail-relation-table-title">
|
||||
{{ parent.alias || parent.name }}
|
||||
<a
|
||||
:disabled="!canEdit[parent.id]"
|
||||
@click="
|
||||
() => {
|
||||
$refs.addTableModal.openModal({ [`${ci.unique}`]: ci[ci.unique] }, ci._id, parent, 'parents')
|
||||
}
|
||||
"
|
||||
><a-icon
|
||||
type="plus-square"
|
||||
/></a>
|
||||
<span v-if="!canEdit[parent.id]">({{ $t('cmdb.ci.m2mTips') }})</span>
|
||||
</div>
|
||||
<vxe-grid
|
||||
v-if="firstCIs[parent.name]"
|
||||
bordered
|
||||
size="mini"
|
||||
:columns="firstCIColumns[parent.id]"
|
||||
:data="firstCIs[parent.name]"
|
||||
overflow
|
||||
showOverflow="tooltip"
|
||||
showHeaderOverflow="tooltip"
|
||||
resizable
|
||||
class="ops-stripe-table"
|
||||
>
|
||||
<template #reference_default="{ row, column }">
|
||||
<a
|
||||
v-for="(id) in (column.params.attr.is_list ? row[column.field] : [row[column.field]])"
|
||||
:key="id"
|
||||
:href="`/cmdb/cidetail/${column.params.attr.reference_type_id}/${id}`"
|
||||
target="_blank"
|
||||
>
|
||||
{{ getReferenceName(id, column) }}
|
||||
</a>
|
||||
</template>
|
||||
<template #operation_default="{ row }">
|
||||
<a-popconfirm
|
||||
arrowPointAtCenter
|
||||
:title="$t('cmdb.ci.confirmDeleteRelation')"
|
||||
@confirm="deleteRelation(row._id, ciId)"
|
||||
>
|
||||
<a
|
||||
:disabled="!canEdit[parent.id]"
|
||||
:style="{
|
||||
color: !canEdit[parent.id] ? 'rgba(0, 0, 0, 0.25)' : 'red',
|
||||
}"
|
||||
><a-icon
|
||||
type="delete"
|
||||
/></a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</vxe-grid>
|
||||
</div>
|
||||
</template>
|
||||
<a-divider />
|
||||
<template v-for="child in childCITypes">
|
||||
<div :key="'ctr_' + child.ctr_id">
|
||||
<div class="ci-detail-relation-table-title">
|
||||
{{ child.alias || child.name }}
|
||||
<a
|
||||
:disabled="!canEdit[child.id]"
|
||||
@click="
|
||||
() => {
|
||||
$refs.addTableModal.openModal({ [`${ci.unique}`]: ci[ci.unique] }, ci._id, child, 'children')
|
||||
}
|
||||
"
|
||||
><a-icon
|
||||
type="plus-square"
|
||||
/></a>
|
||||
<span v-if="!canEdit[child.id]">({{ $t('cmdb.ci.m2mTips') }})</span>
|
||||
</div>
|
||||
<vxe-grid
|
||||
v-if="secondCIs[child.name]"
|
||||
bordered
|
||||
size="mini"
|
||||
:columns="secondCIColumns[child.id]"
|
||||
:data="secondCIs[child.name]"
|
||||
showOverflow="tooltip"
|
||||
showHeaderOverflow="tooltip"
|
||||
resizable
|
||||
class="ops-stripe-table"
|
||||
>
|
||||
<template #reference_default="{ row, column }">
|
||||
<a
|
||||
v-for="(id) in (column.params.attr.is_list ? row[column.field] : [row[column.field]])"
|
||||
:key="id"
|
||||
:href="`/cmdb/cidetail/${column.params.attr.reference_type_id}/${id}`"
|
||||
target="_blank"
|
||||
>
|
||||
{{ getReferenceName(id, column) }}
|
||||
</a>
|
||||
</template>
|
||||
<template #operation_default="{ row }">
|
||||
<a-popconfirm
|
||||
arrowPointAtCenter
|
||||
:title="$t('cmdb.ci.confirmDeleteRelation')"
|
||||
@confirm="deleteRelation(ciId, row._id)"
|
||||
>
|
||||
<a
|
||||
:disabled="!canEdit[child.id]"
|
||||
:style="{
|
||||
color: !canEdit[child.id] ? 'rgba(0, 0, 0, 0.25)' : 'red',
|
||||
}"
|
||||
><a-icon
|
||||
type="delete"
|
||||
/></a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</vxe-grid>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<AddTableModal ref="addTableModal" @reload="reload" />
|
||||
<CiDetailRelationTopo ref="ciDetailRelationTopo"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
import { getCITypeChildren, getCITypeParent, getCanEditByParentIdChildId } from '@/modules/cmdb/api/CITypeRelation'
|
||||
import { searchCIRelation, deleteCIRelationView } from '@/modules/cmdb/api/CIRelation'
|
||||
import { searchCI } from '@/modules/cmdb/api/ci'
|
||||
import CiDetailRelationTopo from './ciDetailRelationTopo/index.vue'
|
||||
import Node from './ciDetailRelationTopo/node.js'
|
||||
import AddTableModal from '../../relation_views/modules/AddTableModal.vue'
|
||||
|
||||
export default {
|
||||
name: 'CiDetailRelation',
|
||||
components: { CiDetailRelationTopo, AddTableModal },
|
||||
name: 'CIDetailRelation',
|
||||
components: { CiDetailRelationTopo },
|
||||
props: {
|
||||
ciId: {
|
||||
type: Number,
|
||||
@@ -154,41 +24,32 @@ export default {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
initQueryLoading: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
relationData: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
activeKey: '1',
|
||||
parentCITypes: [],
|
||||
childCITypes: [],
|
||||
firstCIs: {},
|
||||
firstCIColumns: {},
|
||||
secondCIs: {},
|
||||
secondCIColumns: {},
|
||||
firstCIJsonAttr: {},
|
||||
secondCIJsonAttr: {},
|
||||
canEdit: {},
|
||||
topoData: {
|
||||
nodes: {},
|
||||
edges: []
|
||||
},
|
||||
referenceCINameMap: {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
exsited_ci() {
|
||||
const _exsited_ci = [this.ciId]
|
||||
this.parentCITypes.forEach((parent) => {
|
||||
this.relationData.parentCITypeList.forEach((parent) => {
|
||||
if (this.firstCIs[parent.name]) {
|
||||
this.firstCIs[parent.name].forEach((parentCi) => {
|
||||
_exsited_ci.push(parentCi._id)
|
||||
})
|
||||
}
|
||||
})
|
||||
this.childCITypes.forEach((child) => {
|
||||
this.relationData.childCITypeList.forEach((child) => {
|
||||
if (this.secondCIs[child.name]) {
|
||||
this.secondCIs[child.name].forEach((childCi) => {
|
||||
_exsited_ci.push(childCi._id)
|
||||
@@ -207,314 +68,59 @@ export default {
|
||||
default: () => null,
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
if (!this.initQueryLoading) {
|
||||
this.init(true)
|
||||
|
||||
watch: {
|
||||
relationData: {
|
||||
immediate: true,
|
||||
deep: true,
|
||||
handler(val) {
|
||||
this.init(val)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async init(isFirst) {
|
||||
async init(relationData) {
|
||||
const ci_types_list = this.ci_types()
|
||||
const _findCiType = ci_types_list.find((item) => item.id === this.typeId)
|
||||
if (!_findCiType) {
|
||||
return
|
||||
}
|
||||
|
||||
await Promise.all([this.getParentCITypes(), this.getChildCITypes()])
|
||||
Promise.all([this.getFirstCIs(), this.getSecondCIs()]).then(() => {
|
||||
this.handleTopoData()
|
||||
if (
|
||||
isFirst &&
|
||||
this.$refs.ciDetailRelationTopo &&
|
||||
ci_types_list.length
|
||||
) {
|
||||
this.getFirstCIs(relationData.parentCIList)
|
||||
this.getSecondCIs(relationData.childCIList)
|
||||
|
||||
this.handleTopoData()
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.ciDetailRelationTopo) {
|
||||
this.$refs.ciDetailRelationTopo.exsited_ci = this.exsited_ci
|
||||
this.$refs.ciDetailRelationTopo.setTopoData(this.topoData)
|
||||
}
|
||||
|
||||
this.handleReferenceCINameMap()
|
||||
})
|
||||
},
|
||||
async getFirstCIs() {
|
||||
await searchCIRelation(`root_id=${Number(this.ciId)}&level=1&reverse=1&count=10000`)
|
||||
.then((res) => {
|
||||
const firstCIs = {}
|
||||
res.result.forEach((item) => {
|
||||
this.firstCIJsonAttr[item._type].forEach((attr) => {
|
||||
item[`${attr}`] = item[`${attr}`] ? JSON.stringify(item[`${attr}`]) : ''
|
||||
})
|
||||
this.formatCI(item, this.firstCIColumns)
|
||||
if (item.ci_type in firstCIs) {
|
||||
firstCIs[item.ci_type].push(item)
|
||||
} else {
|
||||
firstCIs[item.ci_type] = [item]
|
||||
}
|
||||
})
|
||||
this.firstCIs = firstCIs
|
||||
})
|
||||
.catch((e) => {})
|
||||
},
|
||||
async getSecondCIs() {
|
||||
await searchCIRelation(`root_id=${Number(this.ciId)}&level=1&reverse=0&count=10000`)
|
||||
.then((res) => {
|
||||
const secondCIs = {}
|
||||
res.result.forEach((item) => {
|
||||
this.secondCIJsonAttr[item._type].forEach((attr) => {
|
||||
item[`${attr}`] = item[`${attr}`] ? JSON.stringify(item[`${attr}`]) : ''
|
||||
})
|
||||
this.formatCI(item, this.secondCIColumns)
|
||||
if (item.ci_type in secondCIs) {
|
||||
secondCIs[item.ci_type].push(item)
|
||||
} else {
|
||||
secondCIs[item.ci_type] = [item]
|
||||
}
|
||||
})
|
||||
this.secondCIs = secondCIs
|
||||
})
|
||||
.catch((e) => {})
|
||||
},
|
||||
|
||||
formatCI(ci, columns) {
|
||||
Object.keys(ci).forEach((key) => {
|
||||
const attr = columns?.[ci?._type]?.find((item) => item?.params?.attr?.name === key)?.params?.attr
|
||||
if (attr?.is_choice && attr?.choice_value?.length) {
|
||||
if (attr?.is_list) {
|
||||
ci[key] = ci[key].map((value) => {
|
||||
const label = attr?.choice_value?.find((choice) => choice?.[0] === value)?.[1]?.label
|
||||
return label || ci[key]
|
||||
})
|
||||
} else {
|
||||
const label = attr?.choice_value?.find((choice) => choice?.[0] === ci[key])?.[1]?.label
|
||||
ci[key] = label || ci[key]
|
||||
}
|
||||
async getFirstCIs(parentCIList) {
|
||||
const firstCIs = {}
|
||||
parentCIList.forEach((item) => {
|
||||
if (item.ci_type in firstCIs) {
|
||||
firstCIs[item.ci_type].push(item)
|
||||
} else {
|
||||
firstCIs[item.ci_type] = [item]
|
||||
}
|
||||
})
|
||||
|
||||
return ci
|
||||
this.firstCIs = firstCIs
|
||||
},
|
||||
|
||||
async getParentCITypes() {
|
||||
const res = await getCITypeParent(this.typeId)
|
||||
this.parentCITypes = res.parents
|
||||
for (let i = 0; i < res.parents.length; i++) {
|
||||
await getCanEditByParentIdChildId(res.parents[i].id, this.typeId).then((p_res) => {
|
||||
this.canEdit = {
|
||||
..._.cloneDeep(this.canEdit),
|
||||
[res.parents[i].id]: p_res.result,
|
||||
}
|
||||
})
|
||||
}
|
||||
const firstCIColumns = {}
|
||||
const firstCIJsonAttr = {}
|
||||
res.parents.forEach((item) => {
|
||||
const columns = []
|
||||
const jsonAttr = []
|
||||
item.attributes.forEach((attr) => {
|
||||
const column = {
|
||||
key: 'p_' + attr.id,
|
||||
field: attr.name,
|
||||
title: attr.alias,
|
||||
minWidth: '100px',
|
||||
params: {
|
||||
attr
|
||||
},
|
||||
}
|
||||
if (attr.is_reference) {
|
||||
column.slots = {
|
||||
default: 'reference_default'
|
||||
}
|
||||
}
|
||||
columns.push(column)
|
||||
|
||||
if (attr.value_type === '6') {
|
||||
jsonAttr.push(attr.name)
|
||||
}
|
||||
})
|
||||
firstCIJsonAttr[item.id] = jsonAttr
|
||||
firstCIColumns[item.id] = columns
|
||||
firstCIColumns[item.id].push({
|
||||
key: 'p_operation',
|
||||
field: 'operation',
|
||||
title: this.$t('operation'),
|
||||
width: '60px',
|
||||
fixed: 'right',
|
||||
slots: {
|
||||
default: 'operation_default',
|
||||
},
|
||||
align: 'center',
|
||||
})
|
||||
})
|
||||
|
||||
this.firstCIColumns = firstCIColumns
|
||||
this.firstCIJsonAttr = firstCIJsonAttr
|
||||
},
|
||||
async getChildCITypes() {
|
||||
const res = await getCITypeChildren(this.typeId)
|
||||
|
||||
this.childCITypes = res.children
|
||||
for (let i = 0; i < res.children.length; i++) {
|
||||
await getCanEditByParentIdChildId(this.typeId, res.children[i].id).then((c_res) => {
|
||||
this.canEdit = {
|
||||
..._.cloneDeep(this.canEdit),
|
||||
[res.children[i].id]: c_res.result,
|
||||
}
|
||||
})
|
||||
}
|
||||
const secondCIColumns = {}
|
||||
const secondCIJsonAttr = {}
|
||||
res.children.forEach((item) => {
|
||||
const columns = []
|
||||
const jsonAttr = []
|
||||
item.attributes.forEach((attr) => {
|
||||
const column = {
|
||||
key: 'c_' + attr.id,
|
||||
field: attr.name,
|
||||
title: attr.alias,
|
||||
minWidth: '100px',
|
||||
params: {
|
||||
attr
|
||||
},
|
||||
}
|
||||
if (attr.is_reference) {
|
||||
column.slots = {
|
||||
default: 'reference_default'
|
||||
}
|
||||
}
|
||||
columns.push(column)
|
||||
|
||||
if (attr.value_type === '6') {
|
||||
jsonAttr.push(attr.name)
|
||||
}
|
||||
})
|
||||
secondCIJsonAttr[item.id] = jsonAttr
|
||||
secondCIColumns[item.id] = columns
|
||||
secondCIColumns[item.id].push({
|
||||
key: 'c_operation',
|
||||
field: 'operation',
|
||||
title: this.$t('operation'),
|
||||
width: '60px',
|
||||
fixed: 'right',
|
||||
slots: {
|
||||
default: 'operation_default',
|
||||
},
|
||||
align: 'center',
|
||||
})
|
||||
})
|
||||
|
||||
this.secondCIColumns = secondCIColumns
|
||||
this.secondCIJsonAttr = secondCIJsonAttr
|
||||
},
|
||||
|
||||
async handleReferenceCINameMap() {
|
||||
const CITypes = _.unionBy(
|
||||
[
|
||||
...this.parentCITypes,
|
||||
...this.childCITypes
|
||||
],
|
||||
'id'
|
||||
)
|
||||
const CIList = _.unionBy(
|
||||
_.flatten(
|
||||
[
|
||||
...Object.values(this.firstCIs),
|
||||
...Object.values(this.secondCIs)
|
||||
]
|
||||
),
|
||||
'_id'
|
||||
)
|
||||
|
||||
const CIMap = {}
|
||||
CIList.forEach((ci) => {
|
||||
if (!CIMap[ci._type]) {
|
||||
CIMap[ci._type] = []
|
||||
}
|
||||
CIMap[ci._type].push(ci)
|
||||
})
|
||||
|
||||
const referenceCINameMap = {}
|
||||
CITypes.forEach((CIType) => {
|
||||
CIType.attributes.forEach((attr) => {
|
||||
if (attr?.is_reference && attr?.reference_type_id) {
|
||||
const currentCIList = CIMap[CIType.id]
|
||||
if (currentCIList?.length) {
|
||||
currentCIList.forEach((ci) => {
|
||||
const ids = Array.isArray(ci[attr.name]) ? ci[attr.name] : ci[attr.name] ? [ci[attr.name]] : []
|
||||
|
||||
if (ids.length) {
|
||||
if (!referenceCINameMap?.[attr.reference_type_id]) {
|
||||
referenceCINameMap[attr.reference_type_id] = {}
|
||||
}
|
||||
ids.forEach((id) => {
|
||||
referenceCINameMap[attr.reference_type_id][id] = ''
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
if (!Object.keys(referenceCINameMap).length) {
|
||||
return
|
||||
}
|
||||
|
||||
const allRes = await Promise.all(
|
||||
Object.keys(referenceCINameMap).map((key) => {
|
||||
return searchCI({
|
||||
q: `_type:${key},_id:(${Object.keys(referenceCINameMap[key]).join(';')})`,
|
||||
count: 9999
|
||||
})
|
||||
})
|
||||
)
|
||||
const CITypeList = this.ci_types()
|
||||
const showNameMap = {}
|
||||
|
||||
Object.keys(referenceCINameMap).forEach((id) => {
|
||||
const CIType = CITypeList.find((CIType) => Number(CIType.id) === Number(id))
|
||||
|
||||
showNameMap[id] = {
|
||||
show_name: CIType?.show_name,
|
||||
unique_key: CIType?.unique_key
|
||||
async getSecondCIs(childCIList) {
|
||||
const secondCIs = {}
|
||||
childCIList.forEach((item) => {
|
||||
if (item.ci_type in secondCIs) {
|
||||
secondCIs[item.ci_type].push(item)
|
||||
} else {
|
||||
secondCIs[item.ci_type] = [item]
|
||||
}
|
||||
})
|
||||
|
||||
allRes.forEach((res) => {
|
||||
res.result.forEach((item) => {
|
||||
if (referenceCINameMap?.[item._type]?.[item._id] === '') {
|
||||
const showName = showNameMap?.[item._type]
|
||||
|
||||
referenceCINameMap[item._type][item._id] = item?.[showName?.show_name] ?? item?.[showName?.unique_key] ?? ''
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
this.referenceCINameMap = referenceCINameMap
|
||||
this.secondCIs = secondCIs
|
||||
},
|
||||
|
||||
getReferenceName(id, column) {
|
||||
const typeId = column?.params?.attr?.reference_type_id
|
||||
return this.referenceCINameMap?.[typeId]?.[id] || id
|
||||
},
|
||||
|
||||
reload() {
|
||||
this.init()
|
||||
},
|
||||
deleteRelation(first_ci_id, second_ci_id) {
|
||||
deleteCIRelationView(first_ci_id, second_ci_id).then((res) => {
|
||||
this.init()
|
||||
if (this.relationViewRefreshNumber) {
|
||||
this.relationViewRefreshNumber()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleChangeActiveKey(e) {
|
||||
if (e.target.value === '1') {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.ciDetailRelationTopo.exsited_ci = this.exsited_ci
|
||||
this.$refs.ciDetailRelationTopo.setTopoData(this.topoData)
|
||||
})
|
||||
}
|
||||
},
|
||||
handleTopoData() {
|
||||
const ci_types_list = this.ci_types()
|
||||
if (!ci_types_list?.length) {
|
||||
@@ -526,10 +132,11 @@ export default {
|
||||
}
|
||||
|
||||
const _findCiType = ci_types_list.find((item) => item.id === this.typeId)
|
||||
const unique_id = _findCiType.show_id || this.attributes().unique_id
|
||||
const unique_name = _findCiType.show_name || this.attributes().unique
|
||||
const unique_id = _findCiType.show_id || _findCiType.unique_id
|
||||
const _findUnique = this.attrList().find((attr) => attr.id === unique_id)
|
||||
const unique_name = _findUnique?.name
|
||||
const unique_alias = _findUnique?.alias || _findUnique?.name || ''
|
||||
|
||||
const nodes = {
|
||||
isRoot: true,
|
||||
id: `Root_${this.typeId}`,
|
||||
@@ -555,7 +162,7 @@ export default {
|
||||
children: [],
|
||||
}
|
||||
const edges = []
|
||||
this.parentCITypes.forEach((parent) => {
|
||||
this.relationData.parentCITypeList.forEach((parent) => {
|
||||
const _findCiType = ci_types_list.find((item) => item.id === parent.id)
|
||||
if (this.firstCIs[parent.name] && _findCiType) {
|
||||
const unique_id = _findCiType.show_id || _findCiType.unique_id
|
||||
@@ -598,7 +205,7 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
this.childCITypes.forEach((child) => {
|
||||
this.relationData.childCITypeList.forEach((child) => {
|
||||
const _findCiType = ci_types_list.find((item) => item.id === child.id)
|
||||
if (this.secondCIs[child.name] && _findCiType) {
|
||||
const unique_id = _findCiType.show_id || _findCiType.unique_id
|
||||
@@ -653,12 +260,5 @@ export default {
|
||||
<style lang="less" scoped>
|
||||
.ci-detail-relation {
|
||||
height: 100%;
|
||||
.ci-detail-relation-table-title {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 5px;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<div
|
||||
id="ci-detail-relation-topo"
|
||||
class="ci-detail-relation-topo"
|
||||
:style="{ width: '100%', marginTop: '20px', height: 'calc(100% - 44px)' }"
|
||||
:style="{ width: '100%', height: '100%' }"
|
||||
></div>
|
||||
</template>
|
||||
|
||||
@@ -25,7 +25,6 @@ export default {
|
||||
}
|
||||
},
|
||||
inject: ['ci_types'],
|
||||
mounted() {},
|
||||
methods: {
|
||||
init() {
|
||||
const root = document.getElementById('ci-detail-relation-topo')
|
||||
|
@@ -6,29 +6,79 @@
|
||||
{{ $t('cmdb.ci.share') }}
|
||||
</a>
|
||||
<a-tab-pane key="tab_1">
|
||||
<span slot="tab"><a-icon type="book" />{{ $t('cmdb.attribute') }}</span>
|
||||
<div class="ci-detail-attr">
|
||||
<el-descriptions
|
||||
:title="group.name || $t('other')"
|
||||
:key="group.name"
|
||||
v-for="group in attributeGroups"
|
||||
border
|
||||
:column="3"
|
||||
>
|
||||
<el-descriptions-item
|
||||
:label="`${attr.alias || attr.name}`"
|
||||
:key="attr.name"
|
||||
v-for="attr in group.attributes"
|
||||
>
|
||||
<ci-detail-attr-content :ci="ci" :attr="attr" @refresh="refresh" @updateCIByself="updateCIByself" @refreshReferenceAttr="handleReferenceAttr" />
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<span slot="tab"><a-icon type="book" />{{ $t('cmdb.ci.detail') }}</span>
|
||||
|
||||
<div class="ci-detail-table">
|
||||
<CIDetailTitle :ci="ci" :ci_types="ci_types" />
|
||||
|
||||
<div class="ci-detail-table-attr">
|
||||
<CIDetailTableTitle :title="$t('cmdb.attribute')" />
|
||||
|
||||
<div class="ci-detail-table-attr-wrap">
|
||||
<div
|
||||
v-for="group in attributeGroups"
|
||||
:key="group.name"
|
||||
class="ci-detail-table-attr-group"
|
||||
>
|
||||
<div class="ci-detail-table-attr-group-name">
|
||||
{{ group.name || $t('other') }}
|
||||
</div>
|
||||
|
||||
<a-row :gutter="[18, 14]">
|
||||
<a-col
|
||||
v-for="attr in group.attributes"
|
||||
:key="attr.name"
|
||||
:span="8"
|
||||
>
|
||||
<a-row :gutter="[8, 0]">
|
||||
<a-col :span="8">
|
||||
<span class="ci-detail-table-attr-label">
|
||||
<a-tooltip :title="attr.alias || attr.name">
|
||||
<span class="ci-detail-table-attr-label-text">{{ attr.alias || attr.name }}</span>
|
||||
</a-tooltip>
|
||||
<span class="ci-detail-table-attr-label-colon">:</span>
|
||||
</span>
|
||||
</a-col>
|
||||
|
||||
<a-col
|
||||
:span="16"
|
||||
class="ci-detail-table-attr-content"
|
||||
>
|
||||
<CIDetailAttrContent
|
||||
:ci="ci"
|
||||
:attr="attr"
|
||||
:attributeGroups="attributeGroups"
|
||||
@updateChoiceValue="updateChoiceValue"
|
||||
@refresh="refresh"
|
||||
@updateCIByself="updateCIByself"
|
||||
@refreshReferenceAttr="handleReferenceAttr"
|
||||
/>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CIRelationTable
|
||||
:ciId="ciId"
|
||||
:typeId="typeId"
|
||||
:ci="ci"
|
||||
:relationData="relationData"
|
||||
@refreshRelationCI="refreshRelationCI(ciId)"
|
||||
/>
|
||||
</div>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="tab_2">
|
||||
<span slot="tab"><a-icon type="branches" />{{ $t('cmdb.relation') }}</span>
|
||||
<span slot="tab"><a-icon type="branches" />{{ $t('cmdb.ci.topo') }}</span>
|
||||
<div :style="{ height: '100%', padding: '24px', overflow: 'auto' }">
|
||||
<ci-detail-relation ref="ciDetailRelation" :ciId="ciId" :typeId="typeId" :ci="ci" :initQueryLoading="initQueryLoading" />
|
||||
<CIDetailRelation
|
||||
:ciId="ciId"
|
||||
:typeId="typeId"
|
||||
:ci="ci"
|
||||
:relationData="relationData"
|
||||
/>
|
||||
</div>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="tab_3">
|
||||
@@ -42,7 +92,7 @@
|
||||
<ops-icon type="veops-export" />{{ $t('export') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
<ci-rollback-form ref="ciRollbackForm" :ciIds="[ciId]" @getCIHistory="getCIHistory" />
|
||||
<CIRollbackForm ref="ciRollbackForm" :ciIds="[ciId]" @getCIHistory="getCIHistory" />
|
||||
<vxe-table
|
||||
ref="xTable"
|
||||
show-overflow
|
||||
@@ -134,25 +184,33 @@
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
import { Descriptions, DescriptionsItem } from 'element-ui'
|
||||
import { getCITypeGroupById, getCITypes } from '@/modules/cmdb/api/CIType'
|
||||
import { getCIHistory, judgeItsmInstalled } from '@/modules/cmdb/api/history'
|
||||
import { getCIById, searchCI } from '@/modules/cmdb/api/ci'
|
||||
import CiDetailAttrContent from './ciDetailAttrContent.vue'
|
||||
import CiDetailRelation from './ciDetailRelation.vue'
|
||||
|
||||
import RelationMixin from './ciDetailMixin/relationMixin.js'
|
||||
|
||||
import CIDetailTitle from './ciDetailComponent/ciDetailTitle.vue'
|
||||
import CIDetailTableTitle from './ciDetailComponent/ciDetailTableTitle.vue'
|
||||
import CIDetailAttrContent from './ciDetailAttrContent.vue'
|
||||
import CIRelationTable from './ciDetailComponent/ciRelationTable.vue'
|
||||
import CIDetailRelation from './ciDetailRelation.vue'
|
||||
import TriggerTable from '../../operation_history/modules/triggerTable.vue'
|
||||
import RelatedItsmTable from './ciDetailRelatedItsmTable.vue'
|
||||
import CiRollbackForm from './ciRollbackForm.vue'
|
||||
import CIRollbackForm from './ciRollbackForm.vue'
|
||||
|
||||
export default {
|
||||
name: 'CiDetailTab',
|
||||
mixins: [RelationMixin],
|
||||
components: {
|
||||
ElDescriptions: Descriptions,
|
||||
ElDescriptionsItem: DescriptionsItem,
|
||||
CiDetailAttrContent,
|
||||
CiDetailRelation,
|
||||
CIDetailAttrContent,
|
||||
CIDetailRelation,
|
||||
TriggerTable,
|
||||
RelatedItsmTable,
|
||||
CiRollbackForm,
|
||||
CIRollbackForm,
|
||||
CIDetailTitle,
|
||||
CIDetailTableTitle,
|
||||
CIRelationTable
|
||||
},
|
||||
props: {
|
||||
typeId: {
|
||||
@@ -218,15 +276,11 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async create(ciId, activeTabKey = 'tab_1', ciDetailRelationKey = '1') {
|
||||
async create(ciId, activeTabKey = 'tab_1') {
|
||||
this.initQueryLoading = true
|
||||
this.activeTabKey = activeTabKey
|
||||
if (activeTabKey === 'tab_2') {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.ciDetailRelation.activeKey = ciDetailRelationKey
|
||||
})
|
||||
}
|
||||
this.ciId = ciId
|
||||
|
||||
await this.getCI()
|
||||
await this.judgeItsmInstalled()
|
||||
if (this.hasPermission) {
|
||||
@@ -234,16 +288,15 @@ export default {
|
||||
this.getCIHistory()
|
||||
const ciTypeRes = await getCITypes()
|
||||
this.ci_types = ciTypeRes.ci_types
|
||||
if (this.activeTabKey === 'tab_2') {
|
||||
this.$refs.ciDetailRelation.init(true)
|
||||
}
|
||||
|
||||
this.initRelationData(this.typeId, this.ciId)
|
||||
}
|
||||
this.initQueryLoading = false
|
||||
},
|
||||
getAttributes() {
|
||||
getCITypeGroupById(this.typeId, { need_other: 1 })
|
||||
.then((res) => {
|
||||
this.attributeGroups = res
|
||||
this.attributeGroups = (res || []).filter((group) => group?.attributes?.length)
|
||||
|
||||
this.handleReferenceAttr()
|
||||
})
|
||||
@@ -509,23 +562,68 @@ export default {
|
||||
.ant-tabs-extra-content {
|
||||
line-height: 44px;
|
||||
}
|
||||
.ci-detail-attr {
|
||||
.ci-detail-table {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
padding: 24px;
|
||||
.el-descriptions-item__content {
|
||||
cursor: default;
|
||||
&:hover a {
|
||||
opacity: 1 !important;
|
||||
|
||||
&-attr {
|
||||
width: 100%;
|
||||
margin-top: 14px;
|
||||
|
||||
&-wrap {
|
||||
padding: 13px;
|
||||
width: 100%;
|
||||
border: solid 1px #E4E7ED;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
&-group {
|
||||
&:not(:last-child) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
&-name {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: @text-color_1;
|
||||
margin-bottom: 7.5px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
&-label {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
color: @text-color_3;
|
||||
display: inline-flex;
|
||||
max-width: 100%;
|
||||
|
||||
&-text {
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-wrap: nowrap;
|
||||
}
|
||||
|
||||
&-colon {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&-content {
|
||||
overflow-wrap: break-word;
|
||||
|
||||
&:hover a {
|
||||
opacity: 1 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
.el-descriptions:first-child > .el-descriptions__header {
|
||||
margin-top: 0;
|
||||
}
|
||||
.el-descriptions__header {
|
||||
margin-bottom: 5px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.ant-form-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<a-form-model
|
||||
:model="formData"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="{ span: 6 }"
|
||||
class="attr-ad-form"
|
||||
>
|
||||
<a-form-model-item
|
||||
:label="$t('cmdb.ciType.defaultVersion')"
|
||||
>
|
||||
<a-select
|
||||
v-model="formData.version"
|
||||
allowClear
|
||||
>
|
||||
<a-select-option value="1">
|
||||
v1
|
||||
</a-select-option>
|
||||
<a-select-option value="2c">
|
||||
v2c
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
:label="$t('cmdb.ciType.defaultCommunity')"
|
||||
>
|
||||
<a-input v-model="formData.community" />
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
:label="$t('cmdb.ciType.timeout')"
|
||||
:extra="$t('cmdb.ciType.snmpFormTip2')"
|
||||
>
|
||||
<a-input-number
|
||||
v-model="formData.timeout"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
:label="$t('cmdb.ciType.retryCount')"
|
||||
:extra="$t('cmdb.ciType.snmpFormTip3')"
|
||||
>
|
||||
<a-input-number
|
||||
v-model="formData.retries"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
</a-form-model>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SNMPConfig',
|
||||
model: {
|
||||
prop: 'value',
|
||||
event: 'change',
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
inject: ['provide_labelCol'],
|
||||
computed: {
|
||||
formData: {
|
||||
get() {
|
||||
return this.value
|
||||
},
|
||||
set(newValue) {
|
||||
this.$emit('change', newValue)
|
||||
}
|
||||
},
|
||||
labelCol() {
|
||||
return this.provide_labelCol()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
</style>
|
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<a-form-model
|
||||
:model="formData"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="{ span: 6 }"
|
||||
class="attr-ad-form"
|
||||
>
|
||||
<a-form-model-item
|
||||
:label="$t('cmdb.ciType.initialNode')"
|
||||
:extra="$t('cmdb.ciType.snmpFormTip4')"
|
||||
>
|
||||
<a-input
|
||||
v-model="formData.initial_node"
|
||||
:placeholder="$t('cmdb.ciType.defaultGateway')"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
:label="$t('cmdb.ciType.recursiveOrNot')"
|
||||
:extra="$t('cmdb.ciType.snmpFormTip5')"
|
||||
>
|
||||
<a-switch v-model="formData.recursive_scan" />
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
:label="$t('cmdb.ciType.maximumDepth')"
|
||||
:extra="$t('cmdb.ciType.snmpFormTip6')"
|
||||
>
|
||||
<a-input-number
|
||||
v-model="formData.max_depth"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
</a-form-model>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SNMPScanningConfig',
|
||||
model: {
|
||||
prop: 'value',
|
||||
event: 'change',
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
inject: ['provide_labelCol'],
|
||||
computed: {
|
||||
formData: {
|
||||
get() {
|
||||
return this.value
|
||||
},
|
||||
set(newValue) {
|
||||
this.$emit('change', newValue)
|
||||
}
|
||||
},
|
||||
labelCol() {
|
||||
return this.provide_labelCol()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
@@ -1,40 +1,35 @@
|
||||
<template>
|
||||
<a-row class="attr-ad-form">
|
||||
<a-col :span="24">
|
||||
<a-form-item
|
||||
label="CIDR"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="{ span: 18 }"
|
||||
labelAlign="right"
|
||||
style="width: 100%; margin-top: 20px"
|
||||
<a-form-item
|
||||
label="CIDR"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="{ span: 6 }"
|
||||
:extra="$t('cmdb.ciType.snmpFormTip7')"
|
||||
>
|
||||
<div class="cidr-tag">
|
||||
<div
|
||||
v-for="(item) in list"
|
||||
:key="item.id"
|
||||
class="cidr-tag-item"
|
||||
>
|
||||
<div class="cidr-tag">
|
||||
<div
|
||||
v-for="(item) in list"
|
||||
:key="item.id"
|
||||
class="cidr-tag-item"
|
||||
>
|
||||
<a-tooltip :title="item.value">
|
||||
<span class="cidr-tag-text">{{ item.value }}</span>
|
||||
</a-tooltip>
|
||||
<a-icon
|
||||
class="cidrv-tag-close"
|
||||
type="close"
|
||||
@click.stop="clickClose(item.id)"
|
||||
/>
|
||||
</div>
|
||||
<a-input
|
||||
v-if="showAddInput"
|
||||
class="cidr-tag-input"
|
||||
autofocus
|
||||
@blur="addPreValue"
|
||||
@pressEnter="showAddInput = false"
|
||||
></a-input>
|
||||
<a v-else class="cidr-tag-add" @click="showAddInput = true">+ {{ $t('new') }}</a>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-tooltip :title="item.value">
|
||||
<span class="cidr-tag-text">{{ item.value }}</span>
|
||||
</a-tooltip>
|
||||
<a-icon
|
||||
class="cidrv-tag-close"
|
||||
type="close"
|
||||
@click.stop="clickClose(item.id)"
|
||||
/>
|
||||
</div>
|
||||
<a-input
|
||||
v-if="showAddInput"
|
||||
class="cidr-tag-input"
|
||||
autofocus
|
||||
@blur="addPreValue"
|
||||
@pressEnter="showAddInput = false"
|
||||
></a-input>
|
||||
<a v-else class="cidr-tag-add" @click="showAddInput = true">+ {{ $t('new') }}</a>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="{ span: 18 }"
|
||||
>
|
||||
<span slot="label">
|
||||
{{ $t('cmdb.ciType.nodeList') }}
|
||||
<a-tooltip :title="$t('cmdb.ciType.snmpFormTip1')">
|
||||
<a-icon type="question-circle" />
|
||||
</a-tooltip>
|
||||
</span>
|
||||
<div class="node-setting-wrap">
|
||||
<ops-table
|
||||
:data="nodes"
|
||||
size="mini"
|
||||
show-header-overflow
|
||||
:row-config="{ height: 42 }"
|
||||
border
|
||||
:min-height="78"
|
||||
>
|
||||
<vxe-column width="170" :title="$t('cmdb.ciType.nodeSettingIp')">
|
||||
<template #default="{ row }">
|
||||
<a-input v-model="row.ip"></a-input>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column width="170" :title="$t('cmdb.ciType.nodeSettingCommunity')">
|
||||
<template #default="{ row }">
|
||||
<a-input v-model="row.community"></a-input>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column width="170" :title="$t('cmdb.ciType.nodeSettingVersion')">
|
||||
<template #default="{ row }">
|
||||
<a-select
|
||||
v-model="row.version"
|
||||
:placeholder="$t('cmdb.ciType.nodeSettingVersionTip')"
|
||||
allowClear
|
||||
class="node-setting-select"
|
||||
>
|
||||
<a-select-option value="1">
|
||||
v1
|
||||
</a-select-option>
|
||||
<a-select-option value="2c">
|
||||
v2c
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column min-wdith="90">
|
||||
<template #default="{ row }">
|
||||
<div class="action">
|
||||
<a @click="() => copyNode(row.id)">
|
||||
<a-icon type="copy" />
|
||||
</a>
|
||||
<a @click="() => removeNode(row.id, 1)">
|
||||
<a-icon type="minus-circle" />
|
||||
</a>
|
||||
<a @click="addNode">
|
||||
<a-icon type="plus-circle" />
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</ops-table>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
export default {
|
||||
name: 'MonitorNodeSetting',
|
||||
inject: ['provide_labelCol'],
|
||||
props: {
|
||||
form: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
nodes: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
labelCol() {
|
||||
return this.provide_labelCol()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initNodesFunc(nodes) {
|
||||
this.nodes = _.cloneDeep(nodes)
|
||||
},
|
||||
addNode() {
|
||||
const newNode = {
|
||||
id: uuidv4(),
|
||||
ip: '',
|
||||
community: 'public',
|
||||
version: '',
|
||||
}
|
||||
this.nodes.push(newNode)
|
||||
},
|
||||
removeNode(removeId, minLength) {
|
||||
if (this.nodes.length <= minLength) {
|
||||
this.$message.error('不可再删除!')
|
||||
return
|
||||
}
|
||||
const _idx = this.nodes.findIndex((item) => item.id === removeId)
|
||||
if (_idx > -1) {
|
||||
this.nodes.splice(_idx, 1)
|
||||
}
|
||||
},
|
||||
copyNode(id) {
|
||||
const copyNode = this.nodes.find((item) => item.id === id)
|
||||
if (copyNode) {
|
||||
const newNode = {
|
||||
...copyNode,
|
||||
id: uuidv4(),
|
||||
}
|
||||
this.nodes.push(newNode)
|
||||
}
|
||||
},
|
||||
|
||||
getNodeValue() {
|
||||
const nodes = this.nodes.map((node) => {
|
||||
return _.pick(node, ['ip', 'community', 'version'])
|
||||
})
|
||||
return nodes
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.node-setting-wrap {
|
||||
max-width: 600px;
|
||||
|
||||
.ant-row {
|
||||
/deep/ .ant-input-clear-icon {
|
||||
color: rgba(0,0,0,.25);
|
||||
|
||||
&:hover {
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.node-setting-select {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
|
||||
.action {
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
</style>
|
@@ -54,11 +54,20 @@
|
||||
/>
|
||||
</div>
|
||||
<template v-if="adrType === DISCOVERY_CATEGORY_TYPE.SNMP">
|
||||
<div class="attr-ad-header">{{ $t('cmdb.ciType.nodeConfig') }}</div>
|
||||
<a-form :form="nodeSettingForm" layout="inline" class="attr-ad-snmp-form">
|
||||
<NodeSetting ref="nodeSetting" :initNodes="nodes" />
|
||||
<CIDRTags v-model="cidrList" />
|
||||
</a-form>
|
||||
<div class="attr-ad-header">{{ $t('cmdb.ciType.scanningParameter') }}</div>
|
||||
<div class="attr-ad-form attr-ad-snmp-form">
|
||||
<div class="attr-ad-snmp-form-title">
|
||||
{{ $t('cmdb.ciType.SNMPConfiguration') }}
|
||||
</div>
|
||||
<NodeSetting ref="nodeSetting" />
|
||||
<SNMPConfig v-model="SNMPScanningConfigForm" />
|
||||
|
||||
<div class="attr-ad-snmp-form-title">
|
||||
{{ $t('cmdb.ciType.scanningConfiguration') }}
|
||||
</div>
|
||||
<SNMPScanningConfig v-model="SNMPScanningConfigForm" />
|
||||
<CIDRTags v-model="SNMPScanningConfigForm.cidr" />
|
||||
</div>
|
||||
</template>
|
||||
<div class="attr-ad-header">{{ $t('cmdb.ciType.adExecConfig') }}</div>
|
||||
<a-form-model
|
||||
@@ -177,13 +186,15 @@ import { TAB_KEY } from './attrAD/constants.js'
|
||||
import HttpSnmpAD from '../../components/httpSnmpAD'
|
||||
import AttrMapTable from '@/modules/cmdb/components/attrMapTable/index.vue'
|
||||
import CMDBExprDrawer from '@/components/CMDBExprDrawer'
|
||||
import NodeSetting from '@/modules/cmdb/components/nodeSetting/index.vue'
|
||||
import NodeSetting from './attrAD/nodeSetting/index.vue'
|
||||
import AttrADTest from './attrADTest.vue'
|
||||
import { Popover } from 'element-ui'
|
||||
import VcenterForm from './attrAD/privateCloud/vcenterForm.vue'
|
||||
import PublicCloud from './attrAD/publicCloud/index.vue'
|
||||
import PortScanConfig from './attrAD/portScanConfig/index.vue'
|
||||
import CIDRTags from './attrAD/cidrTags/index.vue'
|
||||
import SNMPScanningConfig from './attrAD/SNMPScanningConfig/index.vue'
|
||||
import SNMPConfig from './attrAD/SNMPConfig/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'AttrADTabpane',
|
||||
@@ -198,7 +209,9 @@ export default {
|
||||
VcenterForm,
|
||||
PublicCloud,
|
||||
PortScanConfig,
|
||||
CIDRTags
|
||||
CIDRTags,
|
||||
SNMPScanningConfig,
|
||||
SNMPConfig
|
||||
},
|
||||
props: {
|
||||
adr_id: {
|
||||
@@ -263,14 +276,6 @@ export default {
|
||||
cronVisible: false,
|
||||
intervalValue: 3,
|
||||
agent_type: 'agent_id',
|
||||
nodes: [
|
||||
{
|
||||
id: uuidv4(),
|
||||
ip: '',
|
||||
community: 'public',
|
||||
version: '',
|
||||
},
|
||||
],
|
||||
nodeSettingForm: this.$form.createForm(this, { name: 'snmp_form' }),
|
||||
uniqueKey: '',
|
||||
isPrivateCloud: false,
|
||||
@@ -278,7 +283,16 @@ export default {
|
||||
PRIVATE_CLOUD_NAME,
|
||||
DISCOVERY_CATEGORY_TYPE,
|
||||
isClient: false, // 是否前端新增临时数据
|
||||
cidrList: [],
|
||||
SNMPScanningConfigForm: {
|
||||
version: '2c',
|
||||
community: 'public',
|
||||
timeout: 5,
|
||||
retries: 3,
|
||||
initial_node: '',
|
||||
recursive_scan: true,
|
||||
max_depth: 5,
|
||||
cidr: []
|
||||
}, // snmp scanning config form data
|
||||
}
|
||||
},
|
||||
provide() {
|
||||
@@ -323,13 +337,13 @@ export default {
|
||||
const isEn = this.$i18n.locale === 'en'
|
||||
return {
|
||||
xl: {
|
||||
span: isEn ? 4 : 2
|
||||
span: isEn ? 4 : 3
|
||||
},
|
||||
lg: {
|
||||
span: isEn ? 5 : 3
|
||||
span: isEn ? 5 : 4
|
||||
},
|
||||
sm: {
|
||||
span: isEn ? 6 : 4
|
||||
span: isEn ? 6 : 5
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,7 +418,13 @@ export default {
|
||||
}
|
||||
|
||||
if (this.adrType === DISCOVERY_CATEGORY_TYPE.SNMP) {
|
||||
const nodes = _findADT?.extra_option?.nodes?.length ? _findADT?.extra_option?.nodes : [
|
||||
const extra_option = _findADT?.extra_option ?? {}
|
||||
const {
|
||||
nodes,
|
||||
cidr = []
|
||||
} = extra_option
|
||||
|
||||
const initializeNodes = nodes?.length ? nodes : [
|
||||
{
|
||||
id: uuidv4(),
|
||||
ip: '',
|
||||
@@ -412,13 +432,11 @@ export default {
|
||||
version: '',
|
||||
},
|
||||
]
|
||||
this.nodes = nodes
|
||||
this.$nextTick(() => {
|
||||
this.$refs.nodeSetting.initNodesFunc()
|
||||
this.$refs.nodeSetting.initNodesFunc(initializeNodes)
|
||||
})
|
||||
|
||||
let cidrList = []
|
||||
const cidr = _findADT?.extra_option?.cidr
|
||||
if (Array.isArray(cidr) && cidr?.length) {
|
||||
cidrList = cidr.map((v) => {
|
||||
return {
|
||||
@@ -427,7 +445,16 @@ export default {
|
||||
}
|
||||
})
|
||||
}
|
||||
this.cidrList = cidrList
|
||||
this.SNMPScanningConfigForm = {
|
||||
version: extra_option?.version ?? '2c',
|
||||
community: extra_option?.community ?? 'public',
|
||||
timeout: extra_option?.timeout ?? 5,
|
||||
retries: extra_option?.retries ?? 3,
|
||||
initial_node: extra_option?.initial_node ?? '',
|
||||
recursive_scan: extra_option?.recursive_scan ?? true,
|
||||
max_depth: extra_option?.max_depth ?? 5,
|
||||
cidr: cidrList
|
||||
}
|
||||
}
|
||||
if (this.adrType === DISCOVERY_CATEGORY_TYPE.AGENT) {
|
||||
this.tableData = (_find?.attributes || []).map((item) => {
|
||||
@@ -501,12 +528,27 @@ export default {
|
||||
}
|
||||
|
||||
if (this.adrType === DISCOVERY_CATEGORY_TYPE.SNMP) {
|
||||
const {
|
||||
cidr,
|
||||
...otherConfigForm
|
||||
} = this.SNMPScanningConfigForm
|
||||
const nodes = this.$refs.nodeSetting?.getNodeValue() ?? []
|
||||
|
||||
params = {
|
||||
extra_option: {
|
||||
nodes: this.$refs.nodeSetting?.getNodeValue() ?? [],
|
||||
cidr: this?.cidrList?.map((item) => item.value) || []
|
||||
...otherConfigForm,
|
||||
nodes,
|
||||
cidr: cidr?.map((item) => item.value) || []
|
||||
},
|
||||
}
|
||||
|
||||
if (
|
||||
!otherConfigForm?.recursive_scan &&
|
||||
nodes?.some((item) => !item?.ip)
|
||||
) {
|
||||
this.$message.error(this.$t('cmdb.ciType.recursiveTip'))
|
||||
return
|
||||
}
|
||||
}
|
||||
if (this.adrType === DISCOVERY_CATEGORY_TYPE.AGENT) {
|
||||
const $table = this.$refs.attrMapTable
|
||||
@@ -761,8 +803,18 @@ export default {
|
||||
}
|
||||
}
|
||||
.attr-ad-snmp-form {
|
||||
.ant-form-item {
|
||||
margin-bottom: 0;
|
||||
&-title {
|
||||
font-size: 16px;
|
||||
color: #000000;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
/deep/ .ant-input-number {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/deep/ .ant-form-extra {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -47,8 +47,8 @@
|
||||
<a-descriptions layout="horizontal" bordered size="small" :column="2">
|
||||
<a-descriptions-item v-for="item in propertyList" :key="item.property" :label="item.label">
|
||||
<ops-icon
|
||||
:style="{ color: property[item.property] ? '#7f97fa' : '', fontSize: '10px' }"
|
||||
:type="`ops-${item.property}-disabled`"
|
||||
:class="['attribute-card-footer-icon', property[item.property] ? 'attribute-card-footer-icon-mark' : '']"
|
||||
/>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label></a-descriptions-item>
|
||||
@@ -58,7 +58,7 @@
|
||||
<ops-icon
|
||||
v-for="item in propertyList.filter((p) => property[p.property])"
|
||||
:key="item.property"
|
||||
:style="{ color: '#7f97fa', fontSize: '10px' }"
|
||||
class="attribute-card-footer-icon attribute-card-footer-icon-mark"
|
||||
:type="`ops-${item.property}-disabled`"
|
||||
/>
|
||||
</a-space>
|
||||
@@ -247,13 +247,13 @@ export default {
|
||||
.attribute-card {
|
||||
width: 172px;
|
||||
height: 75px;
|
||||
background: @primary-color_6;
|
||||
background-color: @primary-color_6;
|
||||
border-radius: 2px;
|
||||
position: relative;
|
||||
margin-bottom: 16px;
|
||||
transition: all 0.3s;
|
||||
&:hover {
|
||||
box-shadow: 0 4px 12px #4e5ea066;
|
||||
box-shadow: 0 4px 12px @primary-color_8;
|
||||
.attribute-card-operation {
|
||||
visibility: visible !important;
|
||||
}
|
||||
@@ -342,6 +342,15 @@ export default {
|
||||
padding: 2px 0 2px 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.attribute-card-footer-icon {
|
||||
font-size: 10px;
|
||||
|
||||
&-mark {
|
||||
color: @primary-color_2;
|
||||
}
|
||||
}
|
||||
|
||||
.attribute-card-inherited {
|
||||
background: @primary-color_7;
|
||||
.attribute-card-footer {
|
||||
@@ -356,10 +365,10 @@ export default {
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
background-color: inherit;
|
||||
background-color: inherit !important;
|
||||
&:hover {
|
||||
box-shadow: none;
|
||||
background-color: @primary-color_6;
|
||||
box-shadow: none !important;
|
||||
background-color: @primary-color_6 !important;
|
||||
}
|
||||
&:after {
|
||||
content: '';
|
||||
|
@@ -140,7 +140,7 @@
|
||||
:type="ci.icon.split('$$')[0]"
|
||||
/>
|
||||
</template>
|
||||
<span :style="{ color: '#2f54eb' }" v-else>{{ ci.name[0].toUpperCase() }}</span>
|
||||
<span class="primary-color" v-else>{{ ci.name[0].toUpperCase() }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<span class="ci-types-left-detail-title">{{ ci.alias || ci.name }}</span>
|
||||
|
@@ -35,7 +35,7 @@
|
||||
:title="$t('cmdb.ciType.choiceWebhookTips')"
|
||||
>
|
||||
<a-icon
|
||||
style="position:absolute;top:3px;left:-17px;color:#2f54eb;"
|
||||
class="tab-webhook-filter-icon"
|
||||
type="question-circle"
|
||||
theme="filled"
|
||||
/>
|
||||
@@ -553,7 +553,7 @@ export default {
|
||||
|
||||
&-tag {
|
||||
background-color: #E1EFFF;
|
||||
color: #2F54EB;
|
||||
color: @primary-color;
|
||||
font-size: 10px;
|
||||
font-weight: 400;
|
||||
padding: 0 3px;
|
||||
@@ -575,6 +575,13 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
.tab-webhook-filter-icon {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
left: -17px;
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
.script-tip {
|
||||
font-size: 12px;
|
||||
line-height: 22px;
|
||||
|
@@ -363,7 +363,7 @@ export default {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background-color: @primary-color;
|
||||
border: solid 3px #E2E7FC;
|
||||
border: solid 3px @primary-color_4;
|
||||
border-radius: 50%
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@
|
||||
<vxe-column field="source_ci_type_name" :title="$t('cmdb.ciType.sourceCIType')"></vxe-column>
|
||||
<vxe-column field="relation_type" :title="$t('cmdb.ciType.relationType')">
|
||||
<template #default="{row}">
|
||||
<span style="color:#2f54eb" v-if="row.isParent">{{ $t('cmdb.ciType.isParent') }}</span>
|
||||
<span class="primary-color" v-if="row.isParent">{{ $t('cmdb.ciType.isParent') }}</span>
|
||||
{{ row.relation_type }}
|
||||
</template>
|
||||
</vxe-column>
|
||||
@@ -179,7 +179,11 @@
|
||||
:filterOption="filterOption"
|
||||
@change="changeChild"
|
||||
>
|
||||
<a-select-option :value="CIType.id" :key="CIType.id" v-for="CIType in CITypes">
|
||||
<a-select-option
|
||||
:value="CIType.id"
|
||||
:key="CIType.id"
|
||||
v-for="CIType in CITypes"
|
||||
>
|
||||
{{ CIType.alias || CIType.name }}
|
||||
<span class="model-select-name">({{ CIType.name }})</span>
|
||||
</a-select-option>
|
||||
@@ -510,7 +514,11 @@ export default {
|
||||
})
|
||||
},
|
||||
filterOption(input, option) {
|
||||
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||
const inputValue = input.toLowerCase()
|
||||
const alias = option.componentOptions.children[0].text.toLowerCase()
|
||||
const name = option.componentOptions.children[1]?.elm?.innerHTML?.toLowerCase?.() ?? ''
|
||||
|
||||
return alias.indexOf(inputValue) >= 0 || name.indexOf(inputValue) >= 0
|
||||
},
|
||||
rowClass({ row }) {
|
||||
if (row.isDivider) return 'relation-table-divider'
|
||||
@@ -700,7 +708,7 @@ export default {
|
||||
}
|
||||
|
||||
/deep/ .relation-table-parent {
|
||||
background-color: #f5f8ff !important;
|
||||
background-color: @primary-color_5 !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -24,7 +24,7 @@
|
||||
<vxe-column field="attr_ids" :title="$t('cmdb.ciType.attributes')" :edit-render="{}">
|
||||
<template #default="{ row }">
|
||||
<template v-for="(attr, index) in row.attr_ids">
|
||||
<span :key="attr" :style="{ color: '#2f54eb' }">{{ getDisplayName(attr) }}</span>
|
||||
<span :key="attr" class="primary-color">{{ getDisplayName(attr) }}</span>
|
||||
<span :key="`_${attr}`" v-if="index !== row.attr_ids.length - 1"> + </span>
|
||||
</template>
|
||||
</template>
|
||||
|
@@ -19,7 +19,7 @@
|
||||
:type="ciType.icon.split('$$')[0]"
|
||||
/>
|
||||
</template>
|
||||
<span :style="{ color: '#2f54eb' }" v-else>{{ ciType.name[0].toUpperCase() }}</span>
|
||||
<span class="primary-color" v-else>{{ ciType.name[0].toUpperCase() }}</span>
|
||||
</div>
|
||||
<span :style="{ ...options.fontConfig }">{{ toThousands(data) }}</span>
|
||||
</div>
|
||||
|
@@ -148,7 +148,7 @@
|
||||
:type="ciType.icon.split('$$')[0]"
|
||||
/>
|
||||
</template>
|
||||
<span :style="{ color: '#2f54eb' }" v-else>{{ ciType.name[0].toUpperCase() }}</span>
|
||||
<span class="primary-color" v-else>{{ ciType.name[0].toUpperCase() }}</span>
|
||||
</template>
|
||||
<span :style="{ color: '#000' }"> {{ form.name }}</span>
|
||||
</div>
|
||||
@@ -800,7 +800,7 @@ export default {
|
||||
}
|
||||
}
|
||||
.chart-right-type-box-selected {
|
||||
background-color: #e5f1ff;
|
||||
background-color: @primary-color_3;
|
||||
}
|
||||
}
|
||||
.chart-width {
|
||||
|
@@ -63,7 +63,7 @@
|
||||
:type="getCiType(item).icon.split('$$')[0]"
|
||||
/>
|
||||
</template>
|
||||
<span :style="{ color: '#2f54eb' }" v-else>{{ getCiType(item).name[0].toUpperCase() }}</span>
|
||||
<span class="primary-color" v-else>{{ getCiType(item).name[0].toUpperCase() }}</span>
|
||||
</template>
|
||||
<span :style="{ color: item.options.chartType === 'count' ? item.options.fontColor : '#000' }">{{
|
||||
item.options.name
|
||||
|
@@ -268,18 +268,18 @@ export default {
|
||||
margin-right: 2px;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: #3F75FF;
|
||||
color: #2F54EB;
|
||||
}
|
||||
|
||||
&-icon {
|
||||
font-size: 12px;
|
||||
color: #3F75FF;
|
||||
color: #2F54EB;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: #FFFFFF;
|
||||
box-shadow: 0px 22px 33px 0px rgba(41, 65, 126, 0.25);
|
||||
box-shadow: ~'0px 22px 33px 0px @{primary-color}15';
|
||||
z-index: 2;
|
||||
|
||||
.rack-grid-item-name {
|
||||
|
@@ -58,15 +58,11 @@
|
||||
>
|
||||
<ops-icon
|
||||
:type="treeNodeData.icon"
|
||||
class="dcim-tree-node-icon"
|
||||
:style="{ color: treeNodeData.iconColor }"
|
||||
:class="['dcim-tree-node-icon', treeNodeData.dcimType === DCIM_TYPE.REGION ? 'primary-color' : '']"
|
||||
/>
|
||||
<a-tooltip :title="treeNodeData.title">
|
||||
<span
|
||||
class="dcim-tree-node-title"
|
||||
:style="{
|
||||
color: treeKey === treeNodeData.key ? '#2F54EB' : ''
|
||||
}"
|
||||
:class="['dcim-tree-node-title', treeKey === treeNodeData.key ? 'primary-color' : '']"
|
||||
>
|
||||
{{ treeNodeData.title }}
|
||||
</span>
|
||||
@@ -164,6 +160,7 @@ export default {
|
||||
DCIM_TYPE.REGION,
|
||||
DCIM_TYPE.IDC
|
||||
],
|
||||
DCIM_TYPE,
|
||||
|
||||
viewDetailCITypeId: 0,
|
||||
viewDetailAttrObj: {},
|
||||
@@ -365,6 +362,7 @@ export default {
|
||||
&-icon {
|
||||
font-size: 12px;
|
||||
flex-shrink: 0;
|
||||
color: #A5A9BC;
|
||||
}
|
||||
|
||||
&-title {
|
||||
|
@@ -112,11 +112,18 @@ export default {
|
||||
})
|
||||
let CIList = res?.result || []
|
||||
|
||||
const {
|
||||
show_key = '',
|
||||
unique_id = '',
|
||||
attributes = []
|
||||
} = this?.currentCITYpe || {}
|
||||
const unique_key = attributes?.find((attr) => attr?.id === unique_id)?.name || ''
|
||||
|
||||
if (CIList.length) {
|
||||
CIList = CIList.map((item) => {
|
||||
return {
|
||||
value: item?._id,
|
||||
name: item?.[this?.currentCITYpe?.show_key] || item?._id || '',
|
||||
name: item?.[show_key] || item?.[unique_key] || item?._id || '',
|
||||
unitCount: item?.u_count ?? 0
|
||||
}
|
||||
})
|
||||
|
@@ -117,8 +117,8 @@
|
||||
}"
|
||||
@click="addDevice(index)"
|
||||
>
|
||||
<ops-icon
|
||||
type="monitor-add"
|
||||
<a-icon
|
||||
type="plus-circle"
|
||||
class="rack-container-main-list-gap-icon"
|
||||
/>
|
||||
<span
|
||||
@@ -492,12 +492,13 @@ export default {
|
||||
&-icon {
|
||||
font-size: 12px;
|
||||
display: none;
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
&-text {
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: rgba(0, 87, 255, 0.80);
|
||||
color: @primary-color;
|
||||
margin-left: 6px;
|
||||
display: none;
|
||||
}
|
||||
@@ -508,7 +509,7 @@ export default {
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: #D5DDEE;
|
||||
background-color: @primary-color_4;
|
||||
|
||||
.rack-container-main-list-gap-icon {
|
||||
display: inline-block;
|
||||
|
@@ -165,7 +165,7 @@ export default {
|
||||
display: inline-block;
|
||||
width: 180px;
|
||||
height: 105px;
|
||||
box-shadow: 0px 2px 8px rgba(122, 140, 204, 0.25);
|
||||
box-shadow: 0px 2px 8px @primary-color_3;
|
||||
border-radius: 4px;
|
||||
position: relative;
|
||||
margin-bottom: 40px;
|
||||
@@ -297,7 +297,7 @@ export default {
|
||||
|
||||
&, &.discovery-card-small {
|
||||
&:hover {
|
||||
box-shadow: 0px 6px 20px 0px rgba(122, 140, 204, 0.30);
|
||||
box-shadow: 0px 6px 20px 0px @primary-color_3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ export default {
|
||||
}
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0px 6px 28px 0px rgba(122, 140, 204, 0.30);
|
||||
box-shadow: 0px 6px 28px 0px @primary-color_3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -70,7 +70,7 @@
|
||||
class="setting-discovery-add"
|
||||
@click="handleOpenEditDrawer(null, 'add', DISCOVERY_CATEGORY_TYPE.PLUGIN)"
|
||||
>
|
||||
<a-icon type="plus-circle" theme="twoTone" />
|
||||
<a-icon class="setting-discovery-add-icon" type="plus-circle" />
|
||||
<span class="setting-discovery-add-text">
|
||||
{{ $t('cmdb.ad.addPlugin') }}
|
||||
</span>
|
||||
@@ -380,6 +380,10 @@ export default {
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
|
||||
&-icon {
|
||||
color: @primary-color_9;
|
||||
}
|
||||
|
||||
&-text {
|
||||
color: @text-color_3;
|
||||
font-size: 12px;
|
||||
|
@@ -24,7 +24,7 @@
|
||||
:type="ciType.icon.split('$$')[0]"
|
||||
/>
|
||||
</template>
|
||||
<span :style="{ color: '#2f54eb' }" v-else>{{ ciType.name[0].toUpperCase() }}</span>
|
||||
<span class="primary-color" v-else>{{ ciType.name[0].toUpperCase() }}</span>
|
||||
</span>
|
||||
<span :title="ciType.alias || ciType.name" class="cmdb-adc-side-name">{{ ciType.alias || ciType.name }}</span>
|
||||
</div>
|
||||
|
@@ -26,10 +26,7 @@
|
||||
/>
|
||||
<a-tooltip :title="treeNodeData.title">
|
||||
<span
|
||||
class="ipam-tree-node-title"
|
||||
:style="{
|
||||
color: treeKey === treeNodeData.key ? '#2F54EB' : ''
|
||||
}"
|
||||
:class="['ipam-tree-node-title', treeKey === treeNodeData.key ? 'primary-color' : '']"
|
||||
>
|
||||
{{ treeNodeData.title }}
|
||||
</span>
|
||||
|
@@ -1,79 +1,82 @@
|
||||
<template>
|
||||
<div ref="wrapRef">
|
||||
<div class="table-header">
|
||||
<SearchForm
|
||||
ref="search"
|
||||
:preferenceAttrList="preferenceAttrList"
|
||||
:typeId="addressCITypeId"
|
||||
@copyExpression="copyExpression"
|
||||
@refresh="handleSearch"
|
||||
<a-spin :tip="loadTip" :spinning="loading" >
|
||||
<div class="table-header">
|
||||
<SearchForm
|
||||
ref="search"
|
||||
:preferenceAttrList="preferenceAttrList"
|
||||
:typeId="addressCITypeId"
|
||||
:selectedRowKeys="selectedRowKeys"
|
||||
@copyExpression="copyExpression"
|
||||
@refresh="handleSearch"
|
||||
>
|
||||
<div class="ops-list-batch-action" v-show="!!selectedRowKeys.length">
|
||||
<span @click="$refs.create.handleOpen(true, 'update')">{{ $t('update') }}</span>
|
||||
<a-divider type="vertical" />
|
||||
<span @click="openBatchDownload">{{ $t('download') }}</span>
|
||||
<a-divider type="vertical" />
|
||||
<span @click="batchDelete">{{ $t('delete') }}</span>
|
||||
<span>{{ $t('cmdb.ci.selectRows', { rows: selectedRowKeys.length }) }}</span>
|
||||
</div>
|
||||
</SearchForm>
|
||||
|
||||
<div class="table-header-right">
|
||||
<EditAttrsPopover
|
||||
:typeId="addressCITypeId"
|
||||
@refresh="refreshAfterEditAttrs"
|
||||
>
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
class="ops-button-ghost"
|
||||
>
|
||||
<ops-icon type="veops-configuration_table" />
|
||||
{{ $t('cmdb.configTable') }}
|
||||
</a-button>
|
||||
</EditAttrsPopover>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CITable
|
||||
ref="xTable"
|
||||
:loading="loading"
|
||||
:attrList="preferenceAttrList"
|
||||
:columns="columns"
|
||||
:data="instanceList"
|
||||
:height="tableHeight"
|
||||
@sort-change="handleSortCol"
|
||||
@openDetail="openDetail"
|
||||
@deleteCI="deleteCI"
|
||||
@onSelectChange="onSelectChange"
|
||||
/>
|
||||
|
||||
<div class="table-header-right">
|
||||
<EditAttrsPopover
|
||||
:typeId="addressCITypeId"
|
||||
@refresh="refreshAfterEditAttrs"
|
||||
<div class="table-pagination">
|
||||
<a-pagination
|
||||
:showSizeChanger="true"
|
||||
:current="page"
|
||||
size="small"
|
||||
:total="totalNumber"
|
||||
show-quick-jumper
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="
|
||||
(total, range) =>
|
||||
$t('pagination.total', {
|
||||
range0: range[0],
|
||||
range1: range[1],
|
||||
total,
|
||||
})
|
||||
"
|
||||
@change="handleChangePage"
|
||||
@showSizeChange="onShowSizeChange"
|
||||
>
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
class="ops-button-ghost"
|
||||
>
|
||||
<ops-icon type="veops-configuration_table" />
|
||||
{{ $t('cmdb.configTable') }}
|
||||
</a-button>
|
||||
</EditAttrsPopover>
|
||||
<a-button
|
||||
v-if="instanceList && instanceList.length"
|
||||
type="primary"
|
||||
class="ops-button-ghost"
|
||||
ghost
|
||||
@click="handleExport"
|
||||
>
|
||||
<ops-icon type="veops-export" />
|
||||
{{ $t('export') }}
|
||||
</a-button>
|
||||
<template slot="buildOptionText" slot-scope="props">
|
||||
<span v-if="props.value !== '100000'">{{ props.value }}{{ $t('itemsPerPage') }}</span>
|
||||
<span v-if="props.value === '100000'">{{ $t('cmdb.ci.all') }}</span>
|
||||
</template>
|
||||
</a-pagination>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CITable
|
||||
ref="xTable"
|
||||
:loading="loading"
|
||||
:attrList="preferenceAttrList"
|
||||
:columns="columns"
|
||||
:data="instanceList"
|
||||
:height="tableHeight"
|
||||
@sort-change="handleSortCol"
|
||||
@openDetail="openDetail"
|
||||
@deleteCI="deleteCI"
|
||||
/>
|
||||
|
||||
<div class="table-pagination">
|
||||
<a-pagination
|
||||
:showSizeChanger="true"
|
||||
:current="page"
|
||||
size="small"
|
||||
:total="totalNumber"
|
||||
show-quick-jumper
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="
|
||||
(total, range) =>
|
||||
$t('pagination.total', {
|
||||
range0: range[0],
|
||||
range1: range[1],
|
||||
total,
|
||||
})
|
||||
"
|
||||
@change="handleChangePage"
|
||||
@showSizeChange="onShowSizeChange"
|
||||
>
|
||||
<template slot="buildOptionText" slot-scope="props">
|
||||
<span v-if="props.value !== '100000'">{{ props.value }}{{ $t('itemsPerPage') }}</span>
|
||||
<span v-if="props.value === '100000'">{{ $t('cmdb.ci.all') }}</span>
|
||||
</template>
|
||||
</a-pagination>
|
||||
</div>
|
||||
</a-spin>
|
||||
|
||||
<BatchDownload
|
||||
ref="batchDownload"
|
||||
@@ -82,6 +85,12 @@
|
||||
/>
|
||||
|
||||
<CIDetailDrawer ref="detail" :typeId="addressCITypeId" />
|
||||
|
||||
<CreateInstanceForm
|
||||
ref="create"
|
||||
:typeIdFromRelation="addressCITypeId"
|
||||
@submit="batchUpdate"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -90,7 +99,7 @@ import _ from 'lodash'
|
||||
import { mapState } from 'vuex'
|
||||
import ExcelJS from 'exceljs'
|
||||
import FileSaver from 'file-saver'
|
||||
import { searchCI, deleteCI } from '@/modules/cmdb/api/ci'
|
||||
import { searchCI, deleteCI, updateCI } from '@/modules/cmdb/api/ci'
|
||||
import { getSubscribeAttributes } from '@/modules/cmdb/api/preference'
|
||||
import { getCITypeAttributesById } from '@/modules/cmdb/api/CITypeAttr'
|
||||
import { getCITableColumns } from '@/modules/cmdb/utils/helper'
|
||||
@@ -100,6 +109,7 @@ import CITable from '@/modules/cmdb/components/ciTable/index.vue'
|
||||
import BatchDownload from '@/modules/cmdb/components/batchDownload/batchDownload.vue'
|
||||
import CIDetailDrawer from '@/modules/cmdb/views/ci/modules/ciDetailDrawer.vue'
|
||||
import EditAttrsPopover from '@/modules/cmdb/views/ci/modules/editAttrsPopover.vue'
|
||||
import CreateInstanceForm from '@/modules/cmdb/views/ci/modules/CreateInstanceForm'
|
||||
|
||||
export default {
|
||||
name: 'IPSearch',
|
||||
@@ -108,7 +118,8 @@ export default {
|
||||
CITable,
|
||||
BatchDownload,
|
||||
CIDetailDrawer,
|
||||
EditAttrsPopover
|
||||
EditAttrsPopover,
|
||||
CreateInstanceForm
|
||||
},
|
||||
props: {
|
||||
addressCIType: {
|
||||
@@ -122,6 +133,7 @@ export default {
|
||||
pageSize: 50,
|
||||
pageSizeOptions: ['50', '100', '200'],
|
||||
loading: false,
|
||||
loadTip: '',
|
||||
sortByTable: undefined,
|
||||
|
||||
instanceList: [],
|
||||
@@ -130,6 +142,7 @@ export default {
|
||||
preferenceAttrList: [],
|
||||
attrList: [],
|
||||
attributes: {},
|
||||
selectedRowKeys: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -275,7 +288,7 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
handleExport() {
|
||||
openBatchDownload() {
|
||||
this.$refs.batchDownload.open({
|
||||
preferenceAttrList: this.preferenceAttrList,
|
||||
ciTypeName: this.$t('cmdb.ipam.ipSearch') || '',
|
||||
@@ -336,6 +349,7 @@ export default {
|
||||
FileSaver.saveAs(file, `${filename}.xlsx`)
|
||||
})
|
||||
|
||||
this.selectedRowKeys = []
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxRow()
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
|
||||
},
|
||||
@@ -361,6 +375,120 @@ export default {
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
onSelectChange(records) {
|
||||
this.selectedRowKeys = records.map((i) => i.ci_id || i._id)
|
||||
},
|
||||
|
||||
batchDelete() {
|
||||
this.$confirm({
|
||||
title: this.$t('warning'),
|
||||
content: this.$t('confirmDelete'),
|
||||
onOk: () => {
|
||||
this.batchDeleteAsync()
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
async batchDeleteAsync() {
|
||||
let successNum = 0
|
||||
let errorNum = 0
|
||||
this.loading = true
|
||||
this.loadTip = this.$t('cmdb.ci.batchDeleting')
|
||||
|
||||
const floor = Math.ceil(this.selectedRowKeys.length / 6)
|
||||
for (let i = 0; i < floor; i++) {
|
||||
const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6)
|
||||
const promises = itemList.map((x) => deleteCI(x, false))
|
||||
await Promise.allSettled(promises)
|
||||
.then((res) => {
|
||||
res.forEach((r) => {
|
||||
if (r.status === 'fulfilled') {
|
||||
successNum += 1
|
||||
} else {
|
||||
errorNum += 1
|
||||
}
|
||||
})
|
||||
})
|
||||
.finally(() => {
|
||||
this.loadTip = this.$t('cmdb.ci.batchDeleting2', {
|
||||
total: this.selectedRowKeys.length,
|
||||
successNum: successNum,
|
||||
errorNum: errorNum,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
this.loading = false
|
||||
this.loadTip = ''
|
||||
this.selectedRowKeys = []
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxRow()
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
|
||||
this.$nextTick(() => {
|
||||
this.page = 1
|
||||
this.getTableData()
|
||||
})
|
||||
},
|
||||
|
||||
batchUpdate(values) {
|
||||
this.$confirm({
|
||||
title: this.$t('warning'),
|
||||
content: this.$t('cmdb.ci.batchUpdateConfirm'),
|
||||
onOk: () => {
|
||||
this.batchUpdateAsync(values)
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
async batchUpdateAsync(values) {
|
||||
let successNum = 0
|
||||
let errorNum = 0
|
||||
this.loading = true
|
||||
this.loadTip = this.$t('cmdb.ci.batchUpdateInProgress') + '...'
|
||||
|
||||
const payload = {}
|
||||
Object.keys(values).forEach((key) => {
|
||||
if (values[key] === undefined || values[key] === null) {
|
||||
payload[key] = null
|
||||
} else {
|
||||
payload[key] = values[key]
|
||||
}
|
||||
})
|
||||
this.$refs.create.visible = false
|
||||
const key = 'updatable'
|
||||
let errorMsg = ''
|
||||
|
||||
for (let i = 0; i < this.selectedRowKeys.length; i++) {
|
||||
await updateCI(this.selectedRowKeys[i], payload, false)
|
||||
.then(() => {
|
||||
successNum += 1
|
||||
})
|
||||
.catch((error) => {
|
||||
errorMsg = errorMsg + '\n' + `${this.selectedRowKeys[i]}:${error.response?.data?.message ?? ''}`
|
||||
this.$notification.warning({
|
||||
key,
|
||||
message: this.$t('warning'),
|
||||
description: errorMsg,
|
||||
duration: 0,
|
||||
style: { whiteSpace: 'break-spaces', overflow: 'auto', maxHeight: this.windowHeight - 80 + 'px' },
|
||||
})
|
||||
errorNum += 1
|
||||
})
|
||||
.finally(() => {
|
||||
this.loadTip = this.$t('cmdb.ci.batchUpdateInProgress2', {
|
||||
total: this.selectedRowKeys.length,
|
||||
successNum: successNum,
|
||||
errorNum: errorNum,
|
||||
})
|
||||
})
|
||||
}
|
||||
this.loading = false
|
||||
this.loadTip = ''
|
||||
this.selectedRowKeys = []
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxRow()
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
|
||||
this.getTableData()
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@@ -1,79 +1,82 @@
|
||||
<template>
|
||||
<div ref="wrapRef">
|
||||
<div class="table-header">
|
||||
<SearchForm
|
||||
ref="search"
|
||||
:preferenceAttrList="preferenceAttrList"
|
||||
:typeId="subnetCITypeId"
|
||||
@copyExpression="copyExpression"
|
||||
@refresh="handleSearch"
|
||||
<a-spin :tip="loadTip" :spinning="loading" >
|
||||
<div class="table-header">
|
||||
<SearchForm
|
||||
ref="search"
|
||||
:preferenceAttrList="preferenceAttrList"
|
||||
:typeId="subnetCITypeId"
|
||||
:selectedRowKeys="selectedRowKeys"
|
||||
@copyExpression="copyExpression"
|
||||
@refresh="handleSearch"
|
||||
>
|
||||
<div class="ops-list-batch-action" v-show="!!selectedRowKeys.length">
|
||||
<span @click="$refs.create.handleOpen(true, 'update')">{{ $t('update') }}</span>
|
||||
<a-divider type="vertical" />
|
||||
<span @click="openBatchDownload">{{ $t('download') }}</span>
|
||||
<a-divider type="vertical" />
|
||||
<span @click="batchDelete">{{ $t('delete') }}</span>
|
||||
<span>{{ $t('cmdb.ci.selectRows', { rows: selectedRowKeys.length }) }}</span>
|
||||
</div>
|
||||
</SearchForm>
|
||||
|
||||
<div class="table-header-right">
|
||||
<EditAttrsPopover
|
||||
:typeId="subnetCITypeId"
|
||||
@refresh="refreshAfterEditAttrs"
|
||||
>
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
class="ops-button-ghost"
|
||||
>
|
||||
<ops-icon type="veops-configuration_table" />
|
||||
{{ $t('cmdb.configTable') }}
|
||||
</a-button>
|
||||
</EditAttrsPopover>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CITable
|
||||
ref="xTable"
|
||||
:loading="loading"
|
||||
:attrList="preferenceAttrList"
|
||||
:columns="columns"
|
||||
:data="instanceList"
|
||||
:height="tableHeight"
|
||||
@sort-change="handleSortCol"
|
||||
@openDetail="openDetail"
|
||||
@deleteCI="deleteCI"
|
||||
@onSelectChange="onSelectChange"
|
||||
/>
|
||||
|
||||
<div class="table-header-right">
|
||||
<EditAttrsPopover
|
||||
:typeId="subnetCITypeId"
|
||||
@refresh="refreshAfterEditAttrs"
|
||||
<div class="table-pagination">
|
||||
<a-pagination
|
||||
:showSizeChanger="true"
|
||||
:current="page"
|
||||
size="small"
|
||||
:total="totalNumber"
|
||||
show-quick-jumper
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="
|
||||
(total, range) =>
|
||||
$t('pagination.total', {
|
||||
range0: range[0],
|
||||
range1: range[1],
|
||||
total,
|
||||
})
|
||||
"
|
||||
@change="handleChangePage"
|
||||
@showSizeChange="onShowSizeChange"
|
||||
>
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
class="ops-button-ghost"
|
||||
>
|
||||
<ops-icon type="veops-configuration_table" />
|
||||
{{ $t('cmdb.configTable') }}
|
||||
</a-button>
|
||||
</EditAttrsPopover>
|
||||
<a-button
|
||||
v-if="instanceList && instanceList.length"
|
||||
type="primary"
|
||||
class="ops-button-ghost"
|
||||
ghost
|
||||
@click="handleExport"
|
||||
>
|
||||
<ops-icon type="veops-export" />
|
||||
{{ $t('export') }}
|
||||
</a-button>
|
||||
<template slot="buildOptionText" slot-scope="props">
|
||||
<span v-if="props.value !== '100000'">{{ props.value }}{{ $t('itemsPerPage') }}</span>
|
||||
<span v-if="props.value === '100000'">{{ $t('cmdb.ci.all') }}</span>
|
||||
</template>
|
||||
</a-pagination>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CITable
|
||||
ref="xTable"
|
||||
:loading="loading"
|
||||
:attrList="preferenceAttrList"
|
||||
:columns="columns"
|
||||
:data="instanceList"
|
||||
:height="tableHeight"
|
||||
@sort-change="handleSortCol"
|
||||
@openDetail="openDetail"
|
||||
@deleteCI="deleteCI"
|
||||
/>
|
||||
|
||||
<div class="table-pagination">
|
||||
<a-pagination
|
||||
:showSizeChanger="true"
|
||||
:current="page"
|
||||
size="small"
|
||||
:total="totalNumber"
|
||||
show-quick-jumper
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="
|
||||
(total, range) =>
|
||||
$t('pagination.total', {
|
||||
range0: range[0],
|
||||
range1: range[1],
|
||||
total,
|
||||
})
|
||||
"
|
||||
@change="handleChangePage"
|
||||
@showSizeChange="onShowSizeChange"
|
||||
>
|
||||
<template slot="buildOptionText" slot-scope="props">
|
||||
<span v-if="props.value !== '100000'">{{ props.value }}{{ $t('itemsPerPage') }}</span>
|
||||
<span v-if="props.value === '100000'">{{ $t('cmdb.ci.all') }}</span>
|
||||
</template>
|
||||
</a-pagination>
|
||||
</div>
|
||||
</a-spin>
|
||||
|
||||
<BatchDownload
|
||||
ref="batchDownload"
|
||||
@@ -82,6 +85,12 @@
|
||||
/>
|
||||
|
||||
<CIDetailDrawer ref="detail" :typeId="subnetCITypeId" />
|
||||
|
||||
<CreateInstanceForm
|
||||
ref="create"
|
||||
:typeIdFromRelation="subnetCITypeId"
|
||||
@submit="batchUpdate"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -90,7 +99,7 @@ import _ from 'lodash'
|
||||
import { mapState } from 'vuex'
|
||||
import ExcelJS from 'exceljs'
|
||||
import FileSaver from 'file-saver'
|
||||
import { searchCI, deleteCI } from '@/modules/cmdb/api/ci'
|
||||
import { searchCI, deleteCI, updateCI } from '@/modules/cmdb/api/ci'
|
||||
import { getSubscribeAttributes } from '@/modules/cmdb/api/preference'
|
||||
import { getCITypeAttributesById } from '@/modules/cmdb/api/CITypeAttr'
|
||||
import { getCITableColumns } from '@/modules/cmdb/utils/helper'
|
||||
@@ -100,6 +109,7 @@ import CITable from '@/modules/cmdb/components/ciTable/index.vue'
|
||||
import BatchDownload from '@/modules/cmdb/components/batchDownload/batchDownload.vue'
|
||||
import CIDetailDrawer from '@/modules/cmdb/views/ci/modules/ciDetailDrawer.vue'
|
||||
import EditAttrsPopover from '@/modules/cmdb/views/ci/modules/editAttrsPopover.vue'
|
||||
import CreateInstanceForm from '@/modules/cmdb/views/ci/modules/CreateInstanceForm'
|
||||
|
||||
export default {
|
||||
name: 'SubnetList',
|
||||
@@ -108,7 +118,8 @@ export default {
|
||||
CITable,
|
||||
BatchDownload,
|
||||
CIDetailDrawer,
|
||||
EditAttrsPopover
|
||||
EditAttrsPopover,
|
||||
CreateInstanceForm
|
||||
},
|
||||
props: {
|
||||
subnetCIType: {
|
||||
@@ -122,6 +133,7 @@ export default {
|
||||
pageSize: 50,
|
||||
pageSizeOptions: ['50', '100', '200'],
|
||||
loading: false,
|
||||
loadTip: '',
|
||||
sortByTable: undefined,
|
||||
|
||||
instanceList: [],
|
||||
@@ -130,6 +142,7 @@ export default {
|
||||
preferenceAttrList: [],
|
||||
attrList: [],
|
||||
attributes: {},
|
||||
selectedRowKeys: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -275,7 +288,7 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
handleExport() {
|
||||
openBatchDownload() {
|
||||
this.$refs.batchDownload.open({
|
||||
preferenceAttrList: this.preferenceAttrList,
|
||||
ciTypeName: this.$t('cmdb.ipam.subnetList') || '',
|
||||
@@ -336,6 +349,7 @@ export default {
|
||||
FileSaver.saveAs(file, `${filename}.xlsx`)
|
||||
})
|
||||
|
||||
this.selectedRowKeys = []
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxRow()
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
|
||||
},
|
||||
@@ -362,6 +376,120 @@ export default {
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
onSelectChange(records) {
|
||||
this.selectedRowKeys = records.map((i) => i.ci_id || i._id)
|
||||
},
|
||||
|
||||
batchDelete() {
|
||||
this.$confirm({
|
||||
title: this.$t('warning'),
|
||||
content: this.$t('confirmDelete'),
|
||||
onOk: () => {
|
||||
this.batchDeleteAsync()
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
async batchDeleteAsync() {
|
||||
let successNum = 0
|
||||
let errorNum = 0
|
||||
this.loading = true
|
||||
this.loadTip = this.$t('cmdb.ci.batchDeleting')
|
||||
|
||||
const floor = Math.ceil(this.selectedRowKeys.length / 6)
|
||||
for (let i = 0; i < floor; i++) {
|
||||
const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6)
|
||||
const promises = itemList.map((x) => deleteCI(x, false))
|
||||
await Promise.allSettled(promises)
|
||||
.then((res) => {
|
||||
res.forEach((r) => {
|
||||
if (r.status === 'fulfilled') {
|
||||
successNum += 1
|
||||
} else {
|
||||
errorNum += 1
|
||||
}
|
||||
})
|
||||
})
|
||||
.finally(() => {
|
||||
this.loadTip = this.$t('cmdb.ci.batchDeleting2', {
|
||||
total: this.selectedRowKeys.length,
|
||||
successNum: successNum,
|
||||
errorNum: errorNum,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
this.loading = false
|
||||
this.loadTip = ''
|
||||
this.selectedRowKeys = []
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxRow()
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
|
||||
this.$nextTick(() => {
|
||||
this.page = 1
|
||||
this.getTableData()
|
||||
})
|
||||
},
|
||||
|
||||
batchUpdate(values) {
|
||||
this.$confirm({
|
||||
title: this.$t('warning'),
|
||||
content: this.$t('cmdb.ci.batchUpdateConfirm'),
|
||||
onOk: () => {
|
||||
this.batchUpdateAsync(values)
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
async batchUpdateAsync(values) {
|
||||
let successNum = 0
|
||||
let errorNum = 0
|
||||
this.loading = true
|
||||
this.loadTip = this.$t('cmdb.ci.batchUpdateInProgress') + '...'
|
||||
|
||||
const payload = {}
|
||||
Object.keys(values).forEach((key) => {
|
||||
if (values[key] === undefined || values[key] === null) {
|
||||
payload[key] = null
|
||||
} else {
|
||||
payload[key] = values[key]
|
||||
}
|
||||
})
|
||||
this.$refs.create.visible = false
|
||||
const key = 'updatable'
|
||||
let errorMsg = ''
|
||||
|
||||
for (let i = 0; i < this.selectedRowKeys.length; i++) {
|
||||
await updateCI(this.selectedRowKeys[i], payload, false)
|
||||
.then(() => {
|
||||
successNum += 1
|
||||
})
|
||||
.catch((error) => {
|
||||
errorMsg = errorMsg + '\n' + `${this.selectedRowKeys[i]}:${error.response?.data?.message ?? ''}`
|
||||
this.$notification.warning({
|
||||
key,
|
||||
message: this.$t('warning'),
|
||||
description: errorMsg,
|
||||
duration: 0,
|
||||
style: { whiteSpace: 'break-spaces', overflow: 'auto', maxHeight: this.windowHeight - 80 + 'px' },
|
||||
})
|
||||
errorNum += 1
|
||||
})
|
||||
.finally(() => {
|
||||
this.loadTip = this.$t('cmdb.ci.batchUpdateInProgress2', {
|
||||
total: this.selectedRowKeys.length,
|
||||
successNum: successNum,
|
||||
errorNum: errorNum,
|
||||
})
|
||||
})
|
||||
}
|
||||
this.loading = false
|
||||
this.loadTip = ''
|
||||
this.selectedRowKeys = []
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxRow()
|
||||
this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
|
||||
this.getTableData()
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@@ -20,7 +20,7 @@
|
||||
<vxe-column
|
||||
field="relation_type_id"
|
||||
:title="$t('cmdb.custom_dashboard.relation')"
|
||||
:filters="[{ data: '' }]"
|
||||
:filters="relationTypeList"
|
||||
:filter-multiple="false"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
@@ -144,7 +144,7 @@ export default {
|
||||
return {
|
||||
drawerVisible: false,
|
||||
tableData: [],
|
||||
relationTypeList: null,
|
||||
relationTypeList: [],
|
||||
type2attributes: {},
|
||||
tableAttrList: [],
|
||||
}
|
||||
@@ -201,13 +201,6 @@ export default {
|
||||
async getRelationTypes() {
|
||||
const res = await getRelationTypes()
|
||||
this.relationTypeList = res.map((item) => ({ value: item.id, label: item.name }))
|
||||
const $table = this.$refs.xTable
|
||||
if ($table) {
|
||||
const nameColumn = $table.getColumnByField('relation_type_id')
|
||||
if (nameColumn) {
|
||||
$table.setFilter(nameColumn, this.relationTypeList)
|
||||
}
|
||||
}
|
||||
},
|
||||
// 转换关联关系
|
||||
handleConstraint(constraintId) {
|
||||
@@ -359,5 +352,9 @@ export default {
|
||||
&-action {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
/deep/ .ant-select-selection {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -30,7 +30,7 @@
|
||||
<span>{{ column.title }}</span>
|
||||
<a-popover trigger="click" placement="bottom">
|
||||
<a-icon class="filter" type="filter" theme="filled" />
|
||||
<a slot="content">
|
||||
<a class="filter-content" slot="content">
|
||||
<a-input
|
||||
:placeholder="$t('cmdb.history.userTips')"
|
||||
size="small"
|
||||
@@ -453,4 +453,10 @@ export default {
|
||||
color: #606266;
|
||||
}
|
||||
}
|
||||
|
||||
.filter-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
column-gap: 8px;
|
||||
}
|
||||
</style>
|
||||
|
@@ -28,7 +28,7 @@
|
||||
<span>{{ column.title }}</span>
|
||||
<a-popover trigger="click" placement="bottom">
|
||||
<a-icon class="filter" type="filter" theme="filled" />
|
||||
<a slot="content">
|
||||
<a class="filter-content" slot="content">
|
||||
<a-input
|
||||
:placeholder="$t('cmdb.history.userTips')"
|
||||
size="small"
|
||||
@@ -47,7 +47,7 @@
|
||||
<span>{{ column.title }}</span>
|
||||
<a-popover trigger="click" placement="bottom">
|
||||
<a-icon class="filter" type="filter" theme="filled" />
|
||||
<a slot="content">
|
||||
<a class="filter-content" slot="content">
|
||||
<a-select
|
||||
v-model="queryParams.operate_type"
|
||||
:placeholder="$t('cmdb.history.filterOperate')"
|
||||
@@ -445,4 +445,10 @@ export default {
|
||||
color: #606266;
|
||||
}
|
||||
}
|
||||
|
||||
.filter-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
column-gap: 8px;
|
||||
}
|
||||
</style>
|
||||
|
@@ -26,7 +26,7 @@
|
||||
<span>{{ column.title }}</span>
|
||||
<a-popover trigger="click" placement="bottom">
|
||||
<a-icon class="filter" type="filter" theme="filled" />
|
||||
<a slot="content">
|
||||
<a class="filter-content" slot="content">
|
||||
<a-select
|
||||
v-model="queryParams.operate_type"
|
||||
:placeholder="$t('cmdb.history.filterOperate')"
|
||||
@@ -563,4 +563,10 @@ export default {
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.filter-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
column-gap: 8px;
|
||||
}
|
||||
</style>
|
||||
|
@@ -654,11 +654,11 @@ export default {
|
||||
height: 155px;
|
||||
border-radius: @border-radius-box;
|
||||
background-color: #fff;
|
||||
box-shadow: 0px 2px 8px rgba(149, 160, 208, 0.25);
|
||||
box-shadow: ~'0px 2px 8px @{primary-color}15';
|
||||
margin: 0 20px 20px 0;
|
||||
padding: 12px;
|
||||
&:hover {
|
||||
box-shadow: 4px 25px 30px rgba(50, 89, 134, 0.25);
|
||||
box-shadow: ~'4px 25px 30px @{primary-color}15';
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.cmdb-preference-header {
|
||||
@@ -733,10 +733,10 @@ export default {
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
font-size: 12px;
|
||||
color: rgba(0, 0, 0, 0.76);
|
||||
color: @text-color_1;
|
||||
|
||||
&:hover {
|
||||
color: #1890ff;
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,48 @@
|
||||
>
|
||||
<template #one>
|
||||
<div class="relation-views-left" :style="{ height: `${windowHeight - 64}px` }">
|
||||
<div class="relation-views-left-header" :title="$route.meta.name">{{ $route.meta.name }}</div>
|
||||
<div class="relation-views-left-header">
|
||||
<div class="relation-views-left-header-icon">
|
||||
<ops-icon type="ops-cmdb-relation" />
|
||||
</div>
|
||||
|
||||
<div class="relation-views-left-header-name relation-views-text-scroll">
|
||||
<span>
|
||||
{{ viewName }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<a-dropdown
|
||||
overlayClassName="relation-views-left-header-dropdown"
|
||||
>
|
||||
<div class="relation-views-left-header-down">
|
||||
<ops-icon type="veops-switch1" />
|
||||
</div>
|
||||
|
||||
<a-menu
|
||||
slot="overlay"
|
||||
:selectedKeys="[viewId]"
|
||||
class="relation-views-left-header-menu"
|
||||
>
|
||||
<a-menu-item
|
||||
v-for="(item) in relationViewMenu"
|
||||
:key="item.id"
|
||||
@click="clickRelationViewMenu(item.id)"
|
||||
>
|
||||
<a class="relation-views-left-header-menu-item">
|
||||
<div class="relation-views-left-header-menu-name relation-views-text-scroll">
|
||||
<span>{{ item.name }}</span>
|
||||
</div>
|
||||
<a-icon
|
||||
class="relation-views-left-header-menu-grant"
|
||||
type="user-add"
|
||||
@click.stop="handlePerm(item.name)"
|
||||
/>
|
||||
</a>
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</a-dropdown>
|
||||
</div>
|
||||
<a-input
|
||||
:placeholder="$t('cmdb.serviceTree.searchTips')"
|
||||
class="relation-views-left-input"
|
||||
@@ -214,7 +255,7 @@
|
||||
</SplitPane>
|
||||
</div>
|
||||
<a-alert
|
||||
:message="$t('cmdb.serviceTreealert1')"
|
||||
:message="$t('noData')"
|
||||
banner
|
||||
v-else-if="relationViews.name2id && !relationViews.name2id.length"
|
||||
></a-alert>
|
||||
@@ -271,6 +312,8 @@ import ReadPermissionsModal from './modules/ReadPermissionsModal.vue'
|
||||
import RevokeModal from '../../components/cmdbGrant/revokeModal.vue'
|
||||
import CITable from '@/modules/cmdb/components/ciTable/index.vue'
|
||||
|
||||
const relationViewKeyStorage = 'cmdb_relation_view_menu_key'
|
||||
|
||||
export default {
|
||||
name: 'RelationViews',
|
||||
components: {
|
||||
@@ -370,7 +413,7 @@ export default {
|
||||
return !!this.selectedRowKeys.length
|
||||
},
|
||||
topo_flatten() {
|
||||
return this.relationViews?.views[this.$route.meta.name]?.topo_flatten ?? []
|
||||
return this.relationViews?.views[this.viewName]?.topo_flatten ?? []
|
||||
},
|
||||
descendant_ids() {
|
||||
return this.topo_flatten.slice(this.treeKeys.length).join(',')
|
||||
@@ -393,6 +436,15 @@ export default {
|
||||
leaf_tree_sort() {
|
||||
return this.viewOption?.sort ?? 1
|
||||
},
|
||||
relationViewMenu() {
|
||||
const name2id = this?.relationViews?.name2id || []
|
||||
return name2id.map((item) => {
|
||||
return {
|
||||
id: item?.[1] || -1,
|
||||
name: item?.[0] || ''
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
provide() {
|
||||
return {
|
||||
@@ -429,10 +481,6 @@ export default {
|
||||
},
|
||||
inject: ['reload'],
|
||||
watch: {
|
||||
'$route.path': function(newPath, oldPath) {
|
||||
this.viewId = this.$route.params.viewId
|
||||
this.reload()
|
||||
},
|
||||
pageNo: function(newPage, oldPage) {
|
||||
this.loadData({ parameter: { pageNo: newPage }, refreshType: undefined, sortByTable: this.sortByTable })
|
||||
},
|
||||
@@ -869,36 +917,46 @@ export default {
|
||||
this.relationViews = res
|
||||
}
|
||||
if ((Object.keys(this.relationViews.views) || []).length) {
|
||||
this.viewId =
|
||||
parseInt(this.$route.path.split('/')[this.$route.path.split('/').length - 1]) ||
|
||||
this.relationViews.name2id[0][1]
|
||||
this.relationViews.name2id.forEach((item) => {
|
||||
if (item[1] === this.viewId) {
|
||||
this.viewName = item[0]
|
||||
}
|
||||
})
|
||||
this.levels = this.relationViews.views[this.viewName].topo
|
||||
this.origShowTypes = this.relationViews.views[this.viewName].show_types
|
||||
const showTypeIds = []
|
||||
this.origShowTypes.forEach((item) => {
|
||||
showTypeIds.push(item.id)
|
||||
})
|
||||
this.origShowTypeIds = showTypeIds
|
||||
this.leaf2showTypes = this.relationViews.views[this.viewName].leaf2show_types
|
||||
this.node2ShowTypes = this.relationViews.views[this.viewName].node2show_types
|
||||
this.level2constraint = this.relationViews.views[this.viewName].level2constraint
|
||||
this.leaf = this.relationViews.views[this.viewName].leaf
|
||||
this.currentView = `${this.viewId}`
|
||||
this.typeId = this.levels[0][0]
|
||||
this.viewOption = this.relationViews.views[this.viewName].option ?? {}
|
||||
let viewId = parseInt(localStorage.getItem(relationViewKeyStorage)) || parseInt(this.$route.params.viewId) || this.relationViews.name2id[0][1]
|
||||
let viewName = null
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.refreshTable()
|
||||
})
|
||||
const currentView = this.relationViews.name2id.find((item) => item?.[1] === viewId)
|
||||
if (currentView) {
|
||||
viewName = currentView[0]
|
||||
} else {
|
||||
viewId = this.relationViews.name2id[0][1]
|
||||
viewName = this.relationViews.name2id[0][0]
|
||||
}
|
||||
|
||||
localStorage.setItem(relationViewKeyStorage, viewId)
|
||||
this.viewId = viewId
|
||||
this.viewName = viewName
|
||||
this.refreshData()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
refreshData() {
|
||||
this.levels = this.relationViews.views[this.viewName].topo
|
||||
this.origShowTypes = this.relationViews.views[this.viewName].show_types
|
||||
const showTypeIds = []
|
||||
this.origShowTypes.forEach((item) => {
|
||||
showTypeIds.push(item.id)
|
||||
})
|
||||
this.origShowTypeIds = showTypeIds
|
||||
this.leaf2showTypes = this.relationViews.views[this.viewName].leaf2show_types
|
||||
this.node2ShowTypes = this.relationViews.views[this.viewName].node2show_types
|
||||
this.level2constraint = this.relationViews.views[this.viewName].level2constraint
|
||||
this.leaf = this.relationViews.views[this.viewName].leaf
|
||||
this.currentView = `${this.viewId}`
|
||||
this.typeId = this.levels[0][0]
|
||||
this.viewOption = this.relationViews.views[this.viewName].option ?? {}
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.refreshTable()
|
||||
})
|
||||
},
|
||||
|
||||
async loadColumns() {
|
||||
if (this.currentTypeId[0]) {
|
||||
this.getAttributeList()
|
||||
@@ -954,7 +1012,7 @@ export default {
|
||||
const that = this
|
||||
this.$confirm({
|
||||
title: that.$t('warning'),
|
||||
content: (h) => <div>{that.$t('confirmDelete2', { name: Object.values(firstCIObj)[0] })}</div>,
|
||||
content: that.$t('confirmDelete2', { name: Object.values(firstCIObj)[0] }),
|
||||
onOk() {
|
||||
deleteCIRelationView(_tempTreeParent[0], _tempTree[0], { ancestor_ids }).then((res) => {
|
||||
that.$message.success(that.$t('deleteSuccess'))
|
||||
@@ -1063,18 +1121,20 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
handlePerm() {
|
||||
handlePerm(resourceName) {
|
||||
const _resource_name = resourceName ?? this.viewName
|
||||
|
||||
roleHasPermissionToGrant({
|
||||
app_id: 'cmdb',
|
||||
resource_type_name: 'RelationView',
|
||||
perm: 'grant',
|
||||
resource_name: this.$route.meta.title,
|
||||
resource_name: _resource_name,
|
||||
}).then((res) => {
|
||||
if (res.result) {
|
||||
searchResourceType({ page_size: 9999, app_id: 'cmdb' }).then((res) => {
|
||||
this.resource_type = { groups: res.groups, id2perms: res.id2perms }
|
||||
this.$nextTick(() => {
|
||||
this.$refs.cmdbGrant.open({ name: this.$route.meta.title, cmdbGrantType: 'relation_view' })
|
||||
this.$refs.cmdbGrant.open({ name: _resource_name, cmdbGrantType: 'relation_view' })
|
||||
})
|
||||
})
|
||||
} else {
|
||||
@@ -1100,7 +1160,7 @@ export default {
|
||||
},
|
||||
columnDrop() {
|
||||
this.$nextTick(() => {
|
||||
const xTable = this.$refs.xTable.getVxetableRef()
|
||||
const xTable = this.$refs?.xTable?.getVxetableRef?.()
|
||||
this.sortable = Sortable.create(
|
||||
xTable.$el.querySelector('.body--wrapper>.vxe-table--header .vxe-header--row'),
|
||||
{
|
||||
@@ -1282,7 +1342,7 @@ export default {
|
||||
async openBatchDownload() {
|
||||
this.$refs.batchDownload.open({
|
||||
preferenceAttrList: this.preferenceAttrList.filter((attr) => !attr?.is_reference),
|
||||
ciTypeName: this.$route.meta.name,
|
||||
ciTypeName: this.viewName,
|
||||
})
|
||||
},
|
||||
batchDownload({ filename, type, checkedKeys }) {
|
||||
@@ -1629,6 +1689,13 @@ export default {
|
||||
|
||||
openDetail(id, activeTabKey, ciDetailRelationKey) {
|
||||
this.$refs.detail.create(id, activeTabKey, ciDetailRelationKey)
|
||||
},
|
||||
|
||||
clickRelationViewMenu(id) {
|
||||
if (id) {
|
||||
localStorage.setItem(relationViewKeyStorage, id)
|
||||
this.reload()
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1649,17 +1716,61 @@ export default {
|
||||
overflow: auto;
|
||||
}
|
||||
.relation-views-left-header {
|
||||
border-left: 4px solid @primary-color;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
padding-left: 12px;
|
||||
margin-bottom: 12px;
|
||||
color: @text-color_1;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
cursor: default;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: @border-color-base;
|
||||
margin-bottom: 14px;
|
||||
|
||||
&-icon {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 22px;
|
||||
background-color: @primary-color;
|
||||
|
||||
i {
|
||||
font-size: 12px;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
&-name {
|
||||
margin-left: 9px;
|
||||
|
||||
span {
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
&-down {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 1px;
|
||||
background-color: @primary-color_3;
|
||||
cursor: pointer;
|
||||
margin-left: auto;
|
||||
|
||||
i {
|
||||
font-size: 18px;
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: @primary-color_4;
|
||||
}
|
||||
}
|
||||
}
|
||||
.ant-tree li {
|
||||
padding: 2px 0;
|
||||
@@ -1680,14 +1791,14 @@ export default {
|
||||
}
|
||||
.relation-views-left-input {
|
||||
margin-bottom: 12px;
|
||||
input {
|
||||
background-color: transparent;
|
||||
border-top: none;
|
||||
border-right: none;
|
||||
border-left: none;
|
||||
}
|
||||
.ant-input:focus {
|
||||
box-shadow: none;
|
||||
|
||||
.ant-input {
|
||||
background-color: #FFFFFF;
|
||||
border: solid 1px transparent;
|
||||
|
||||
&:hover, &:focus {
|
||||
border-color: @primary-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1703,4 +1814,75 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.relation-views-left-header-dropdown {
|
||||
background-color: #FFFFFF;
|
||||
|
||||
.relation-views-left-header-menu {
|
||||
box-shadow: none;
|
||||
max-height: 400px;
|
||||
min-height: 150px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
|
||||
&-item {
|
||||
width: 150px;
|
||||
overflow: hidden;
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
|
||||
&:hover {
|
||||
.relation-views-left-header-menu-grant {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-name {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
&-grant {
|
||||
margin-left: 8px;
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
display: none;
|
||||
margin-left: auto;
|
||||
color: @text-color_4;
|
||||
|
||||
&:hover {
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.relation-views-text-scroll {
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
& > span {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-wrap: nowrap;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
& > span {
|
||||
overflow: visible;
|
||||
animation: scroll-left 3s linear infinite;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes scroll-left {
|
||||
0% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -30,13 +30,13 @@
|
||||
>新增</a-button
|
||||
>
|
||||
</SearchForm>
|
||||
<vxe-table
|
||||
<ops-table
|
||||
ref="xTable"
|
||||
row-id="_id"
|
||||
:data="tableData"
|
||||
:height="tableHeight"
|
||||
highlight-hover-row
|
||||
:checkbox-config="{ reserve: true }"
|
||||
:checkbox-config="{ reserve: true, highlight: true, range: true }"
|
||||
@checkbox-change="onSelectChange"
|
||||
@checkbox-all="onSelectChange"
|
||||
show-overflow="tooltip"
|
||||
@@ -76,7 +76,7 @@
|
||||
<span v-if="col.value_type == '6' && row[col.field]">{{ JSON.stringify(row[col.field]) }}</span>
|
||||
</template>
|
||||
</vxe-table-column>
|
||||
</vxe-table>
|
||||
</ops-table>
|
||||
<a-pagination
|
||||
v-model="currentPage"
|
||||
size="small"
|
||||
@@ -216,7 +216,7 @@ export default {
|
||||
this.totalNumber = res.numfound
|
||||
this.columns = this.getColumns(res.result, this.preferenceAttrList)
|
||||
this.$nextTick(() => {
|
||||
const _table = this.$refs.xTable
|
||||
const _table = this.$refs.xTable?.getVxetableRef?.()
|
||||
if (_table) {
|
||||
_table.refreshColumn()
|
||||
}
|
||||
@@ -316,7 +316,11 @@ export default {
|
||||
|
||||
onSelectChange() {},
|
||||
handleClose() {
|
||||
this.$refs.xTable.clearCheckboxRow()
|
||||
const _table = this.$refs.xTable?.getVxetableRef?.()
|
||||
if (_table) {
|
||||
_table.clearCheckboxRow()
|
||||
}
|
||||
|
||||
this.currentPage = 1
|
||||
this.expression = ''
|
||||
this.isFocusExpression = false
|
||||
@@ -324,8 +328,10 @@ export default {
|
||||
this.showCreateBtn = true
|
||||
},
|
||||
async handleOk() {
|
||||
const selectRecordsCurrent = this.$refs.xTable.getCheckboxRecords()
|
||||
const selectRecordsReserved = this.$refs.xTable.getCheckboxReserveRecords()
|
||||
const _table = this.$refs.xTable?.getVxetableRef?.()
|
||||
const selectRecordsCurrent = _table?.getCheckboxRecords?.() || []
|
||||
const selectRecordsReserved = _table?.getCheckboxReserveRecords?.() || []
|
||||
|
||||
const ciIds = [...selectRecordsCurrent, ...selectRecordsReserved].map((record) => record._id)
|
||||
if (ciIds.length) {
|
||||
if (this.type === 'children') {
|
||||
|
@@ -1,367 +1,367 @@
|
||||
<template>
|
||||
<div
|
||||
:class="{
|
||||
'relation-views-node': true,
|
||||
'relation-views-node-checkbox': showCheckbox,
|
||||
}"
|
||||
@click="clickNode"
|
||||
>
|
||||
<span class="relation-views-node-switch">
|
||||
<a-icon v-if="!isLeaf" :type="switchIcon"></a-icon>
|
||||
</span>
|
||||
<span class="relation-views-node-content">
|
||||
<a-checkbox @click.stop="clickCheckbox" class="relation-views-node-checkbox" v-if="showCheckbox" />
|
||||
<template v-if="icon">
|
||||
<img
|
||||
v-if="icon.includes('$$') && icon.split('$$')[2]"
|
||||
:src="`/api/common-setting/v1/file/${icon.split('$$')[3]}`"
|
||||
:style="{ maxHeight: '14px', maxWidth: '14px' }"
|
||||
/>
|
||||
<ops-icon
|
||||
v-else-if="icon.includes('$$') && icon.split('$$')[0]"
|
||||
:style="{
|
||||
color: icon.split('$$')[1],
|
||||
fontSize: '14px',
|
||||
}"
|
||||
:type="icon.split('$$')[0]"
|
||||
/>
|
||||
<span class="relation-views-node-icon" v-else>{{ icon ? icon[0].toUpperCase() : 'i' }}</span>
|
||||
</template>
|
||||
<span
|
||||
class="relation-views-node-title"
|
||||
v-if="!isEditNodeName"
|
||||
:title="title"
|
||||
v-highlight="{ value: fullSearchValue, class: 'relation-views-node-title-highlight' }"
|
||||
>{{ title }}
|
||||
</span>
|
||||
<a-input
|
||||
ref="input"
|
||||
@blur="changeNodeName"
|
||||
@pressEnter="
|
||||
() => {
|
||||
$refs.input.blur()
|
||||
}
|
||||
"
|
||||
size="small"
|
||||
v-else
|
||||
v-model="editNodeName"
|
||||
:style="{ marginLeft: '5px' }"
|
||||
/>
|
||||
<span class="relation-views-node-number">{{ number }}</span>
|
||||
<a-dropdown overlayClassName="relation-views-node-dropdown" :overlayStyle="{ width: '200px' }">
|
||||
<a-menu slot="overlay" @click="({ key: menuKey }) => onContextMenuClick(this.treeKey, menuKey)">
|
||||
<template v-if="showBatchLevel === null">
|
||||
<a-divider orientation="left">{{ $t('cmdb.relation') }}</a-divider>
|
||||
<a-menu-item
|
||||
v-for="item in menuList"
|
||||
:key="item.id"
|
||||
><a-icon type="plus-circle" />{{ $t('add') }} {{ item.alias }}</a-menu-item
|
||||
>
|
||||
<a-menu-item
|
||||
v-if="showDelete"
|
||||
key="delete"
|
||||
><ops-icon type="icon-xianxing-delete" />{{
|
||||
$t('cmdb.serviceTree.deleteNode', { name: title })
|
||||
}}</a-menu-item
|
||||
>
|
||||
<a-divider orientation="left">{{ $t('cmdb.components.perm') }}</a-divider>
|
||||
<a-menu-item key="grant"><a-icon type="user-add" />{{ $t('grant') }}</a-menu-item>
|
||||
<a-menu-item key="revoke"><a-icon type="user-delete" />{{ $t('revoke') }}</a-menu-item>
|
||||
<a-menu-item key="view"><a-icon type="eye" />{{ $t('cmdb.serviceTree.view') }}</a-menu-item>
|
||||
<a-menu-divider />
|
||||
<a-menu-item
|
||||
key="editNodeName"
|
||||
><ops-icon type="icon-xianxing-edit" />{{ $t('cmdb.serviceTree.editNodeName') }}</a-menu-item
|
||||
>
|
||||
<a-menu-item key="batch"><ops-icon type="veops-copy" />{{ $t('cmdb.serviceTree.batch') }}</a-menu-item>
|
||||
</template>
|
||||
<template v-else>
|
||||
<a-menu-item
|
||||
:disabled="!batchTreeKey || !batchTreeKey.length"
|
||||
key="batchGrant"
|
||||
><a-icon type="user-add" />{{ $t('grant') }}</a-menu-item
|
||||
>
|
||||
<a-menu-item
|
||||
:disabled="!batchTreeKey || !batchTreeKey.length"
|
||||
key="batchRevoke"
|
||||
><a-icon type="user-delete" />{{ $t('revoke') }}</a-menu-item
|
||||
>
|
||||
<a-menu-divider />
|
||||
<template v-if="showBatchLevel > 0">
|
||||
<a-menu-item
|
||||
:disabled="!batchTreeKey || !batchTreeKey.length"
|
||||
key="batchDelete"
|
||||
><ops-icon type="icon-xianxing-delete" />{{ $t('cmdb.serviceTree.remove') }}</a-menu-item
|
||||
>
|
||||
<a-menu-divider />
|
||||
</template>
|
||||
<a-menu-item key="batchCancel"><a-icon type="close-circle" />{{ $t('cancel') }}</a-menu-item>
|
||||
</template>
|
||||
</a-menu>
|
||||
<a-icon class="relation-views-node-operation" type="ellipsis" />
|
||||
</a-dropdown>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { updateCI } from '../../../api/ci.js'
|
||||
import highlight from '@/directive/highlight'
|
||||
|
||||
export default {
|
||||
name: 'ContextMenu',
|
||||
directives: {
|
||||
highlight,
|
||||
},
|
||||
props: {
|
||||
treeNodeData: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
levels: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
currentViews: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
id2type: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
ciTypeIcons: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
showBatchLevel: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
batchTreeKey: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
fullSearchValue: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
switchIcon: 'caret-right',
|
||||
isEditNodeName: false,
|
||||
editNodeName: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
childLength() {
|
||||
return this.number
|
||||
},
|
||||
splitTreeKey() {
|
||||
return this.treeKey.split('@^@')
|
||||
},
|
||||
_tempTree() {
|
||||
return this.splitTreeKey[this.splitTreeKey.length - 1].split('%')
|
||||
},
|
||||
_typeIdIdx() {
|
||||
return this.levels.findIndex((level) => level[0] === Number(this._tempTree[1])) // 当前节点在levels中的index
|
||||
},
|
||||
showDelete() {
|
||||
if (this._typeIdIdx === 0) {
|
||||
// 如果是第一层节点,则不能删除
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
menuList() {
|
||||
let _menuList = []
|
||||
if (this._typeIdIdx > -1 && this._typeIdIdx < this.levels.length - 1) {
|
||||
// 不是叶子节点
|
||||
const id = Number(this.levels[this._typeIdIdx + 1])
|
||||
_menuList = [
|
||||
{
|
||||
id,
|
||||
alias: this.id2type[id].alias || this.id2type[id].name,
|
||||
},
|
||||
]
|
||||
} else {
|
||||
// 叶子节点
|
||||
_menuList = this.currentViews.node2show_types[this._tempTree[1]].map((item) => {
|
||||
return { id: item.id, alias: item.alias || item.name }
|
||||
})
|
||||
}
|
||||
return _menuList
|
||||
},
|
||||
icon() {
|
||||
const _split = this.treeKey.split('@^@')
|
||||
const currentNodeTypeId = _split[_split.length - 1].split('%')[1]
|
||||
return this.ciTypeIcons[Number(currentNodeTypeId)] ?? null
|
||||
},
|
||||
showCheckbox() {
|
||||
return this.showBatchLevel === this.treeKey.split('@^@').filter((item) => !!item).length - 1
|
||||
},
|
||||
title() {
|
||||
return this.treeNodeData.title
|
||||
},
|
||||
number() {
|
||||
return this.treeNodeData.number
|
||||
},
|
||||
treeKey() {
|
||||
return this.treeNodeData.key
|
||||
},
|
||||
isLeaf() {
|
||||
return this.treeNodeData.isLeaf
|
||||
},
|
||||
showName() {
|
||||
return this.treeNodeData.showName
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onContextMenuClick(treeKey, menuKey) {
|
||||
if (menuKey === 'editNodeName') {
|
||||
this.isEditNodeName = true
|
||||
this.editNodeName = this.title
|
||||
this.$nextTick(() => {
|
||||
this.$refs.input.focus()
|
||||
})
|
||||
return
|
||||
}
|
||||
this.$emit('onContextMenuClick', treeKey, menuKey)
|
||||
},
|
||||
clickNode() {
|
||||
this.$emit('onNodeClick', this.treeKey)
|
||||
this.switchIcon = this.switchIcon === 'caret-right' ? 'caret-down' : 'caret-right'
|
||||
},
|
||||
clickCheckbox() {
|
||||
this.$emit('clickCheckbox', this.treeKey)
|
||||
},
|
||||
changeNodeName(e) {
|
||||
const value = e.target.value
|
||||
if (value !== this.title) {
|
||||
const ci = this.treeKey
|
||||
.split('@^@')
|
||||
.slice(-1)[0]
|
||||
.split('%')
|
||||
const unique = Object.keys(JSON.parse(ci[2]))[0]
|
||||
const ciId = Number(ci[0])
|
||||
let editAttrName = unique
|
||||
if (this.showName) {
|
||||
editAttrName = this.showName
|
||||
}
|
||||
updateCI(ciId, { [editAttrName]: value }).then((res) => {
|
||||
this.$message.success(this.$t('updateSuccess'))
|
||||
this.$emit('updateTreeData', ciId, value)
|
||||
})
|
||||
}
|
||||
this.isEditNodeName = false
|
||||
this.editNodeName = ''
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.relation-views-node {
|
||||
width: 100%;
|
||||
display: inline-flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.relation-views-node-switch {
|
||||
display: inline-block;
|
||||
width: 15px;
|
||||
color: @text-color_5;
|
||||
i {
|
||||
opacity: 0;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
.relation-views-node-content {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
.relation-views-node-icon {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background-color: #d3d3d3;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
line-height: 16px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.relation-views-node-title {
|
||||
padding-left: 5px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
color: @text-color_1;
|
||||
}
|
||||
.relation-views-node-number {
|
||||
color: @text-color_4;
|
||||
font-size: 12px;
|
||||
margin: 0 5px;
|
||||
}
|
||||
.relation-views-node-operation {
|
||||
opacity: 0;
|
||||
width: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.relation-views-node-checkbox {
|
||||
> span {
|
||||
.relation-views-node-checkbox {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.relation-views-node-title {
|
||||
width: calc(100% - 42px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.relation-views-left .ant-tree:hover {
|
||||
.relation-views-node .relation-views-node-switch i {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.relation-views-node-title-highlight {
|
||||
color: @func-color_1;
|
||||
}
|
||||
.relation-views-left {
|
||||
ul:has(.relation-views-node-checkbox) > li > ul {
|
||||
margin-left: 26px;
|
||||
}
|
||||
ul:has(.relation-views-node-checkbox) {
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
.ant-tree-node-content-wrapper:hover {
|
||||
.relation-views-node-operation {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
.ant-tree li .ant-tree-node-content-wrapper.ant-tree-node-selected,
|
||||
.ant-tree li .ant-tree-node-content-wrapper:hover {
|
||||
background-color: @primary-color_3;
|
||||
}
|
||||
}
|
||||
|
||||
.relation-views-node-dropdown {
|
||||
.ant-divider {
|
||||
margin: 0;
|
||||
.ant-divider-inner-text {
|
||||
font-size: 12px;
|
||||
color: @text-color_3;
|
||||
}
|
||||
}
|
||||
.ant-dropdown-menu-item {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div
|
||||
:class="{
|
||||
'relation-views-node': true,
|
||||
'relation-views-node-checkbox': showCheckbox,
|
||||
}"
|
||||
@click="clickNode"
|
||||
>
|
||||
<span class="relation-views-node-switch">
|
||||
<a-icon v-if="!isLeaf" :type="switchIcon"></a-icon>
|
||||
</span>
|
||||
<span class="relation-views-node-content">
|
||||
<a-checkbox @click.stop="clickCheckbox" class="relation-views-node-checkbox" v-if="showCheckbox" />
|
||||
<template v-if="icon">
|
||||
<img
|
||||
v-if="icon.includes('$$') && icon.split('$$')[2]"
|
||||
:src="`/api/common-setting/v1/file/${icon.split('$$')[3]}`"
|
||||
:style="{ maxHeight: '14px', maxWidth: '14px' }"
|
||||
/>
|
||||
<ops-icon
|
||||
v-else-if="icon.includes('$$') && icon.split('$$')[0]"
|
||||
:style="{
|
||||
color: icon.split('$$')[1],
|
||||
fontSize: '14px',
|
||||
}"
|
||||
:type="icon.split('$$')[0]"
|
||||
/>
|
||||
<span class="relation-views-node-icon" v-else>{{ icon ? icon[0].toUpperCase() : 'i' }}</span>
|
||||
</template>
|
||||
<span
|
||||
class="relation-views-node-title"
|
||||
v-if="!isEditNodeName"
|
||||
:title="title"
|
||||
v-highlight="{ value: fullSearchValue, class: 'relation-views-node-title-highlight' }"
|
||||
>{{ title }}
|
||||
</span>
|
||||
<a-input
|
||||
ref="input"
|
||||
@blur="changeNodeName"
|
||||
@pressEnter="
|
||||
() => {
|
||||
$refs.input.blur()
|
||||
}
|
||||
"
|
||||
size="small"
|
||||
v-else
|
||||
v-model="editNodeName"
|
||||
:style="{ marginLeft: '5px' }"
|
||||
/>
|
||||
<span class="relation-views-node-number">{{ number }}</span>
|
||||
<a-dropdown overlayClassName="relation-views-node-dropdown" :overlayStyle="{ width: '200px' }">
|
||||
<a-menu slot="overlay" @click="({ key: menuKey }) => onContextMenuClick(this.treeKey, menuKey)">
|
||||
<template v-if="showBatchLevel === null">
|
||||
<a-divider orientation="left">{{ $t('cmdb.relation') }}</a-divider>
|
||||
<a-menu-item
|
||||
v-for="item in menuList"
|
||||
:key="item.id"
|
||||
><a-icon type="plus-circle" />{{ $t('add') }} {{ item.alias }}</a-menu-item
|
||||
>
|
||||
<a-menu-item
|
||||
v-if="showDelete"
|
||||
key="delete"
|
||||
><ops-icon type="icon-xianxing-delete" />{{
|
||||
$t('cmdb.serviceTree.deleteNode', { name: title })
|
||||
}}</a-menu-item
|
||||
>
|
||||
<a-divider orientation="left">{{ $t('cmdb.components.perm') }}</a-divider>
|
||||
<a-menu-item key="grant"><a-icon type="user-add" />{{ $t('grant') }}</a-menu-item>
|
||||
<a-menu-item key="revoke"><a-icon type="user-delete" />{{ $t('revoke') }}</a-menu-item>
|
||||
<a-menu-item key="view"><a-icon type="eye" />{{ $t('cmdb.serviceTree.view') }}</a-menu-item>
|
||||
<a-menu-divider />
|
||||
<a-menu-item
|
||||
key="editNodeName"
|
||||
><ops-icon type="icon-xianxing-edit" />{{ $t('cmdb.serviceTree.editNodeName') }}</a-menu-item
|
||||
>
|
||||
<a-menu-item key="batch"><ops-icon type="veops-copy" />{{ $t('cmdb.serviceTree.batch') }}</a-menu-item>
|
||||
</template>
|
||||
<template v-else>
|
||||
<a-menu-item
|
||||
:disabled="!batchTreeKey || !batchTreeKey.length"
|
||||
key="batchGrant"
|
||||
><a-icon type="user-add" />{{ $t('grant') }}</a-menu-item
|
||||
>
|
||||
<a-menu-item
|
||||
:disabled="!batchTreeKey || !batchTreeKey.length"
|
||||
key="batchRevoke"
|
||||
><a-icon type="user-delete" />{{ $t('revoke') }}</a-menu-item
|
||||
>
|
||||
<a-menu-divider />
|
||||
<template v-if="showBatchLevel > 0">
|
||||
<a-menu-item
|
||||
:disabled="!batchTreeKey || !batchTreeKey.length"
|
||||
key="batchDelete"
|
||||
><ops-icon type="icon-xianxing-delete" />{{ $t('cmdb.serviceTree.remove') }}</a-menu-item
|
||||
>
|
||||
<a-menu-divider />
|
||||
</template>
|
||||
<a-menu-item key="batchCancel"><a-icon type="close-circle" />{{ $t('cancel') }}</a-menu-item>
|
||||
</template>
|
||||
</a-menu>
|
||||
<a-icon class="relation-views-node-operation" type="ellipsis" />
|
||||
</a-dropdown>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { updateCI } from '../../../api/ci.js'
|
||||
import highlight from '@/directive/highlight'
|
||||
|
||||
export default {
|
||||
name: 'ContextMenu',
|
||||
directives: {
|
||||
highlight,
|
||||
},
|
||||
props: {
|
||||
treeNodeData: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
levels: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
currentViews: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
id2type: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
ciTypeIcons: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
showBatchLevel: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
batchTreeKey: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
fullSearchValue: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
switchIcon: 'caret-right',
|
||||
isEditNodeName: false,
|
||||
editNodeName: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
childLength() {
|
||||
return this.number
|
||||
},
|
||||
splitTreeKey() {
|
||||
return this.treeKey.split('@^@')
|
||||
},
|
||||
_tempTree() {
|
||||
return this.splitTreeKey[this.splitTreeKey.length - 1].split('%')
|
||||
},
|
||||
_typeIdIdx() {
|
||||
return this.levels.findIndex((level) => level[0] === Number(this._tempTree[1])) // 当前节点在levels中的index
|
||||
},
|
||||
showDelete() {
|
||||
if (this._typeIdIdx === 0) {
|
||||
// 如果是第一层节点,则不能删除
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
menuList() {
|
||||
let _menuList = []
|
||||
if (this._typeIdIdx > -1 && this._typeIdIdx < this.levels.length - 1) {
|
||||
// 不是叶子节点
|
||||
const id = Number(this.levels[this._typeIdIdx + 1])
|
||||
_menuList = [
|
||||
{
|
||||
id,
|
||||
alias: this.id2type[id].alias || this.id2type[id].name,
|
||||
},
|
||||
]
|
||||
} else {
|
||||
// 叶子节点
|
||||
_menuList = this.currentViews?.node2show_types?.[this._tempTree?.[1]]?.map?.((item) => {
|
||||
return { id: item.id, alias: item.alias || item.name }
|
||||
}) || []
|
||||
}
|
||||
return _menuList
|
||||
},
|
||||
icon() {
|
||||
const _split = this.treeKey.split('@^@')
|
||||
const currentNodeTypeId = _split[_split.length - 1].split('%')[1]
|
||||
return this.ciTypeIcons[Number(currentNodeTypeId)] ?? null
|
||||
},
|
||||
showCheckbox() {
|
||||
return this.showBatchLevel === this.treeKey.split('@^@').filter((item) => !!item).length - 1
|
||||
},
|
||||
title() {
|
||||
return this.treeNodeData.title
|
||||
},
|
||||
number() {
|
||||
return this.treeNodeData.number
|
||||
},
|
||||
treeKey() {
|
||||
return this.treeNodeData.key
|
||||
},
|
||||
isLeaf() {
|
||||
return this.treeNodeData.isLeaf
|
||||
},
|
||||
showName() {
|
||||
return this.treeNodeData.showName
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onContextMenuClick(treeKey, menuKey) {
|
||||
if (menuKey === 'editNodeName') {
|
||||
this.isEditNodeName = true
|
||||
this.editNodeName = this.title
|
||||
this.$nextTick(() => {
|
||||
this.$refs.input.focus()
|
||||
})
|
||||
return
|
||||
}
|
||||
this.$emit('onContextMenuClick', treeKey, menuKey)
|
||||
},
|
||||
clickNode() {
|
||||
this.$emit('onNodeClick', this.treeKey)
|
||||
this.switchIcon = this.switchIcon === 'caret-right' ? 'caret-down' : 'caret-right'
|
||||
},
|
||||
clickCheckbox() {
|
||||
this.$emit('clickCheckbox', this.treeKey)
|
||||
},
|
||||
changeNodeName(e) {
|
||||
const value = e.target.value
|
||||
if (value !== this.title) {
|
||||
const ci = this.treeKey
|
||||
.split('@^@')
|
||||
.slice(-1)[0]
|
||||
.split('%')
|
||||
const unique = Object.keys(JSON.parse(ci[2]))[0]
|
||||
const ciId = Number(ci[0])
|
||||
let editAttrName = unique
|
||||
if (this.showName) {
|
||||
editAttrName = this.showName
|
||||
}
|
||||
updateCI(ciId, { [editAttrName]: value }).then((res) => {
|
||||
this.$message.success(this.$t('updateSuccess'))
|
||||
this.$emit('updateTreeData', ciId, value)
|
||||
})
|
||||
}
|
||||
this.isEditNodeName = false
|
||||
this.editNodeName = ''
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.relation-views-node {
|
||||
width: 100%;
|
||||
display: inline-flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.relation-views-node-switch {
|
||||
display: inline-block;
|
||||
width: 15px;
|
||||
color: @text-color_5;
|
||||
i {
|
||||
opacity: 0;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
.relation-views-node-content {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
.relation-views-node-icon {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background-color: #d3d3d3;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
line-height: 16px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.relation-views-node-title {
|
||||
padding-left: 5px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
color: @text-color_1;
|
||||
}
|
||||
.relation-views-node-number {
|
||||
color: @text-color_4;
|
||||
font-size: 12px;
|
||||
margin: 0 5px;
|
||||
}
|
||||
.relation-views-node-operation {
|
||||
opacity: 0;
|
||||
width: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.relation-views-node-checkbox {
|
||||
> span {
|
||||
.relation-views-node-checkbox {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.relation-views-node-title {
|
||||
width: calc(100% - 42px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.relation-views-left .ant-tree:hover {
|
||||
.relation-views-node .relation-views-node-switch i {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.relation-views-node-title-highlight {
|
||||
color: @func-color_1;
|
||||
}
|
||||
.relation-views-left {
|
||||
ul:has(.relation-views-node-checkbox) > li > ul {
|
||||
margin-left: 26px;
|
||||
}
|
||||
ul:has(.relation-views-node-checkbox) {
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
.ant-tree-node-content-wrapper:hover {
|
||||
.relation-views-node-operation {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
.ant-tree li .ant-tree-node-content-wrapper.ant-tree-node-selected,
|
||||
.ant-tree li .ant-tree-node-content-wrapper:hover {
|
||||
background-color: @primary-color_3;
|
||||
}
|
||||
}
|
||||
|
||||
.relation-views-node-dropdown {
|
||||
.ant-divider {
|
||||
margin: 0;
|
||||
.ant-divider-inner-text {
|
||||
font-size: 12px;
|
||||
color: @text-color_3;
|
||||
}
|
||||
}
|
||||
.ant-dropdown-menu-item {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -13,12 +13,11 @@
|
||||
<div class="search-condition-control">
|
||||
<treeselect
|
||||
:value="sourceCIType"
|
||||
class="custom-treeselect custom-treeselect-bgcAndBorder filter-content-ciTypes"
|
||||
class="custom-treeselect custom-treeselect-white filter-content-ciTypes"
|
||||
:style="{
|
||||
width: '100%',
|
||||
zIndex: '1000',
|
||||
'--custom-height': '32px',
|
||||
'--custom-bg-color': '#FFF',
|
||||
'--custom-multiple-lineHeight': '32px',
|
||||
}"
|
||||
:multiple="false"
|
||||
@@ -699,14 +698,14 @@ export default {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background-color: #D9E4FA;
|
||||
background-color: @primary-color_4;
|
||||
|
||||
.search-condition-favor-name {
|
||||
color: #2F54EB;
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
.search-condition-favor-close {
|
||||
color: #2F54EB;
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -737,10 +736,10 @@ export default {
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: #D9E4FA;
|
||||
background-color: @primary-color_4;
|
||||
|
||||
.search-condition-hide-icon {
|
||||
color: #2F54EB;
|
||||
color: @primary-color_4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -656,15 +656,15 @@ export default {
|
||||
|
||||
&:hover {
|
||||
.relation-search-expand-handle {
|
||||
background-color: #D9E4FA;
|
||||
background-color: @primary-color_4;
|
||||
}
|
||||
|
||||
.relation-search-expand-icon {
|
||||
color: #2F54EB;
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
.relation-search-expand-text {
|
||||
color: #2F54EB;
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -180,7 +180,7 @@ export default {
|
||||
saveCondition(isSubmit) {
|
||||
this.$refs.conditionFilterRef.handleSubmit()
|
||||
this.$nextTick(() => {
|
||||
this.$emit('saveCondition', isSubmit)
|
||||
this.$emit('saveCondition', isSubmit, this.$parent.isColumnSearch ? 'column' : 'normal')
|
||||
this.visible = false
|
||||
})
|
||||
},
|
||||
|
@@ -327,7 +327,7 @@ export default {
|
||||
&-header {
|
||||
width: 100%;
|
||||
height: 75px;
|
||||
background-color: #EBF0F9;
|
||||
background-color: @primary-color_3;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
display: flex;
|
||||
@@ -342,7 +342,7 @@ export default {
|
||||
right: -20px;
|
||||
top: 0px;
|
||||
transform: rotate(40deg);
|
||||
background: rgba(248, 249, 253, 0.60);
|
||||
background-color: @primary-color_5;
|
||||
}
|
||||
|
||||
&-line-2 {
|
||||
@@ -352,7 +352,7 @@ export default {
|
||||
right: -110px;
|
||||
top: 0px;
|
||||
transform: rotate(40deg);
|
||||
background: rgba(248, 249, 253, 0.60);
|
||||
background-color: @primary-color_5;
|
||||
}
|
||||
|
||||
&-row {
|
||||
|
@@ -431,7 +431,7 @@ export default {
|
||||
}
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0px 2px 12px 0px rgba(147, 168, 223, 0.20);
|
||||
box-shadow: ~'0px 2px 12px 0px @{primary-color}15';
|
||||
|
||||
.list-card-collect {
|
||||
display: inline-block;
|
||||
|
@@ -1,29 +1,86 @@
|
||||
<template>
|
||||
<div :class="['search-input', classType ? 'search-input-' + classType : '']">
|
||||
<a-input
|
||||
:value="searchValue"
|
||||
class="search-input-component"
|
||||
:placeholder="$t('cmdb.ciType.searchInputTip')"
|
||||
@change="handleChangeSearchValue"
|
||||
@pressEnter="saveCondition(true)"
|
||||
>
|
||||
<a-icon
|
||||
class="search-input-component-icon"
|
||||
slot="prefix"
|
||||
type="search"
|
||||
@click="saveCondition(true)"
|
||||
/>
|
||||
</a-input>
|
||||
<FilterPopover
|
||||
ref="filterPpoverRef"
|
||||
:CITypeGroup="CITypeGroup"
|
||||
:allAttributesList="allAttributesList"
|
||||
:expression="expression"
|
||||
:selectCITypeIds="selectCITypeIds"
|
||||
@changeFilter="changeFilter"
|
||||
@updateAllAttributesList="updateAllAttributesList"
|
||||
@saveCondition="saveCondition"
|
||||
/>
|
||||
<div class="search-area">
|
||||
<a-input
|
||||
v-show="searchMode === SEARCH_MODE.NORMAL"
|
||||
:value="searchValue"
|
||||
class="search-input-component"
|
||||
:placeholder="$t('cmdb.ciType.searchInputTip')"
|
||||
@change="handleChangeSearchValue"
|
||||
@pressEnter="saveCondition(true)"
|
||||
>
|
||||
<a-icon
|
||||
class="search-icon"
|
||||
slot="prefix"
|
||||
type="search"
|
||||
@click="saveCondition(true)"
|
||||
/>
|
||||
</a-input>
|
||||
|
||||
<div
|
||||
v-show="searchMode === SEARCH_MODE.COLUMN"
|
||||
class="search-textarea-component"
|
||||
>
|
||||
<a-textarea
|
||||
:value="searchValue"
|
||||
:autosize="{
|
||||
minRows: 3,
|
||||
maxRows: 3,
|
||||
}"
|
||||
:placeholder="$t('cmdb.ciType.columnSearchInputTip')"
|
||||
@change="handleChangeSearchValue"
|
||||
/>
|
||||
<div class="search-textarea-icon-wrap">
|
||||
<a-icon
|
||||
class="search-icon"
|
||||
type="search"
|
||||
@click="saveCondition(true)"
|
||||
/>
|
||||
|
||||
<a-tooltip :title="$t('cmdb.ciType.columnSearchTip')">
|
||||
<a-icon
|
||||
type="info-circle"
|
||||
class="search-icon"
|
||||
/>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="operation-area">
|
||||
<FilterPopover
|
||||
ref="filterPpoverRef"
|
||||
:CITypeGroup="CITypeGroup"
|
||||
:allAttributesList="allAttributesList"
|
||||
:expression="expression"
|
||||
:selectCITypeIds="selectCITypeIds"
|
||||
@changeFilter="changeFilter"
|
||||
@updateAllAttributesList="updateAllAttributesList"
|
||||
@saveCondition="saveCondition"
|
||||
/>
|
||||
|
||||
<div class="search-mode-switch">
|
||||
<span
|
||||
v-for="(item) in searchModeList"
|
||||
:key="item.value"
|
||||
:class="['search-mode-switch-item', searchMode === item.value ? 'search-mode-switch-item-active' : '']"
|
||||
:style="{
|
||||
width: isZh ? '40px' : '65px'
|
||||
}"
|
||||
@click="updateSearchMode(item.value)"
|
||||
>
|
||||
{{ $t(item.label) }}
|
||||
</span>
|
||||
|
||||
<span
|
||||
class="search-mode-switch-slide"
|
||||
:style="{
|
||||
left: searchMode === SEARCH_MODE.COLUMN ? (isZh ? '44px' : '69px') : '4px',
|
||||
width: isZh ? '40px' : '65px'
|
||||
}"
|
||||
></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="copyText" class="expression-display">
|
||||
<span class="expression-display-text">{{ copyText }}</span>
|
||||
@@ -38,6 +95,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { SEARCH_MODE } from '../constants.js'
|
||||
import FilterPopover from './filterPopover.vue'
|
||||
|
||||
export default {
|
||||
@@ -69,12 +127,32 @@ export default {
|
||||
classType: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
searchMode: {
|
||||
type: String,
|
||||
default: SEARCH_MODE.NORMAL
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
return {
|
||||
SEARCH_MODE,
|
||||
searchModeList: [
|
||||
{
|
||||
value: SEARCH_MODE.NORMAL,
|
||||
label: 'cmdb.ciType.rowSearchMode'
|
||||
},
|
||||
{
|
||||
value: SEARCH_MODE.COLUMN,
|
||||
label: 'cmdb.ciType.columnSearchMode'
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isZh() {
|
||||
return this.$i18n.locale === 'zh'
|
||||
},
|
||||
|
||||
// 复制文字展示,与实际文本复制内容区别在于,未选择模型时不展示所有模型拼接数据
|
||||
copyText() {
|
||||
const regQ = /(?<=q=).+(?=&)|(?<=q=).+$/g
|
||||
@@ -88,7 +166,15 @@ export default {
|
||||
textArray.push(exp)
|
||||
}
|
||||
if (this.searchValue) {
|
||||
textArray.push(`*${this.searchValue}*`)
|
||||
if (
|
||||
this.searchMode === SEARCH_MODE.COLUMN &&
|
||||
this.searchValue.includes('\n')
|
||||
) {
|
||||
const values = this.searchValue.split('\n').filter(v => v.trim())
|
||||
textArray.push(`(${values.join(';')})`)
|
||||
} else {
|
||||
textArray.push(`*${this.searchValue}*`)
|
||||
}
|
||||
}
|
||||
|
||||
return textArray.length ? `q=${textArray.join(',')}` : ''
|
||||
@@ -125,7 +211,21 @@ export default {
|
||||
ciTypeIds.push(...ids)
|
||||
})
|
||||
}
|
||||
const copyText = `${ciTypeIds?.length ? `_type:(${ciTypeIds.join(';')})` : ''}${exp ? `,${exp}` : ''}${searchValue ? `,*${searchValue}*` : ''}`
|
||||
|
||||
let copySearchValue = ''
|
||||
if (searchValue) {
|
||||
if (
|
||||
this.searchMode === SEARCH_MODE.COLUMN &&
|
||||
this.searchValue.includes('\n')
|
||||
) {
|
||||
const values = searchValue.split('\n').filter(v => v.trim())
|
||||
copySearchValue = `,(${values.join(';')})`
|
||||
} else {
|
||||
copySearchValue = `,*${searchValue}*`
|
||||
}
|
||||
}
|
||||
|
||||
const copyText = `${ciTypeIds?.length ? `_type:(${ciTypeIds.join(';')})` : ''}${exp ? `,${exp}` : ''}${copySearchValue}`
|
||||
|
||||
this.$copyText(copyText)
|
||||
.then(() => {
|
||||
@@ -134,6 +234,10 @@ export default {
|
||||
.catch(() => {
|
||||
this.$message.error(this.$t('cmdb.ci.copyFailed'))
|
||||
})
|
||||
},
|
||||
|
||||
updateSearchMode(mode) {
|
||||
this.$emit('updateSearchMode', mode)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,51 +246,132 @@ export default {
|
||||
<style lang="less" scoped>
|
||||
.search-input {
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
|
||||
&-component {
|
||||
height: 100%;
|
||||
flex-grow: 1;
|
||||
background-color: #FFFFFF;
|
||||
border: none;
|
||||
font-size: 14px;
|
||||
border-radius: 48px;
|
||||
overflow: hidden;
|
||||
.search-area {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
|
||||
&-icon {
|
||||
color: #2F54EB;
|
||||
.search-input-component {
|
||||
height: 48px;
|
||||
line-height: 48px;
|
||||
border-radius: 48px;
|
||||
width: 100%;
|
||||
background-color: #FFFFFF;
|
||||
font-size: 14px;
|
||||
|
||||
&:hover {
|
||||
/deep/ .ant-input {
|
||||
background-color: @primary-color_5;
|
||||
}
|
||||
}
|
||||
|
||||
/deep/ .ant-input {
|
||||
border: none;
|
||||
height: 48px;
|
||||
line-height: 48px;
|
||||
border-radius: 48px;
|
||||
|
||||
&:focus {
|
||||
border: solid 1px @primary-color;
|
||||
background-color: #FFFFFF !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/deep/ & > input {
|
||||
height: 100%;
|
||||
margin-left: 10px;
|
||||
border: solid 1px transparent;
|
||||
box-shadow: none;
|
||||
.search-textarea-component {
|
||||
position: relative;
|
||||
|
||||
&:focus {
|
||||
border-color: @primary-color;
|
||||
.search-textarea-icon-wrap {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 6px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
/deep/ .ant-input {
|
||||
background-color: @primary-color_5;
|
||||
}
|
||||
}
|
||||
|
||||
/deep/ .ant-input {
|
||||
border: none;
|
||||
padding-left: 36px;
|
||||
resize: none;
|
||||
|
||||
&:focus {
|
||||
border: solid 1px @primary-color;
|
||||
background-color: #FFFFFF !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
color: @primary-color;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
&-after {
|
||||
height: 38px;
|
||||
justify-content: flex-start;
|
||||
.operation-area {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
height: 48px;
|
||||
transform: translateX(100%);
|
||||
|
||||
.search-input-component {
|
||||
max-width: 524px;
|
||||
.search-mode-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 32px;
|
||||
background-color: @primary-color_3;
|
||||
border-radius: 32px;
|
||||
position: relative;
|
||||
padding: 0 4px;
|
||||
margin-left: 14px;
|
||||
cursor: pointer;
|
||||
|
||||
&-item {
|
||||
height: 24px;
|
||||
width: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: @text-color_2;
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
|
||||
&-active {
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
&-slide {
|
||||
position: absolute;
|
||||
transition: left 0.2s;
|
||||
border-radius: 24px;
|
||||
background-color: #FFFFFF;
|
||||
height: 24px;
|
||||
top: 4px;
|
||||
width: 40px;
|
||||
z-index: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.expression-display {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 20px;
|
||||
max-width: 30%;
|
||||
max-width: 100%;
|
||||
width: fit-content;
|
||||
margin-top: 8px;
|
||||
|
||||
&-text {
|
||||
width: 100%;
|
||||
@@ -201,5 +386,11 @@ export default {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
&-after {
|
||||
.search-area {
|
||||
max-width: 420px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -0,0 +1,4 @@
|
||||
export const SEARCH_MODE = {
|
||||
NORMAL: 'normal',
|
||||
COLUMN: 'column'
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user