$ cnpm install @uyun/ec-strategy
作者:李茜
管理策略
(依赖metrics R16.4X)
<Strategy />
属性 | 说明 | 类型 | 默认值 |
---|---|---|---|
productName | 策略来源例如: 'Monitor' | string | - |
strategyType | 策略类型 , 'collection', 'trigger', 'complex' | string | ‘collection' |
editable | 策略是否可编辑 | bool | false |
treeData | 左侧资源树数据源, 参考左侧树数据格式 | array | [] |
bindRes | 是否展示关联资源按钮 | bool | false |
getStrategy | 自定义获取策略列表的接口, 参考自定义接口 | getStrategy | - |
copyOrAddStrategy | 自定义复制和添加策略接口,参考自定义接口 | copyOrAddStrategy | - |
getBindedRes | 自定义资源绑定列表,不同产品资源权限不同,需要自定义该接口时使用,参考自定义接口 | getBindRes | - |
tabsInfo | 是否展示tabs页,显示不同角色权限的策略,例如全局策略和我的策略, 参考tabsInfo定义 | object | - |
tabsArr | tabs页面的key列表 | array | - |
showDetail | 是否只展示策略详情 | bool | false |
showTrigger | 策略监控项为空时,是否展示规则 | bool | false |
rowSelection | - | ||
strategyId | 策略ID, 只展示策略详情时使用 | string | - |
classCode | 资源类型, 只展示策略详情时使用 | string | - |
[
{
name: "平台资源层",
code: "Platform Resource",
dataType: "layer",
children: [
{
name: "操作系统",
code: "os",
dataType: "layer",
children: [
{
name: "AIX",
code: "AIX",
dataType: "class",
children: []
},
...
],
...
},
...
],
...
}
]
当默认的数据源无法满足业务需求时,可自定义组件中的接口,需要注意请求参数的传递和确保返回正确的数据格式。由于数据量较大,所以返回的分页信息中不包含数据总数。
import Strategy from '@uyun/ec-strategy'
import { getUsers } from '@uyun/ec-strategy/lib/services/api'
...
<Strategy
getStrategy={params => {
return axios.get('/monitor/api/v2/strategy/query', {
// params 是页面中的分页、搜索等信息,
params: {
...params,
scope: 'global'
},
})
.then(res => {
console.log(res)
// data 是请求后获得的数据,
// 可根据情况将这个数组更改为组件要求的数据格式,
return res.data && res.data.data
})
}}
strategyType='collection' editable treeData={this.treeData}
/>
...
请求参数:
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
scope | 策略权限类型, 全局/我的 | string | - |
current | 当前页码 | int | 1 |
pageSize | 每页展示条数 | int | 10 |
searchName | 搜索内容 | string | '' |
classCode | 资源类型 | string | - |
返回数据格式:
参数 | 说明 | 类型 |
---|---|---|
total | 策略总数 | number |
list | 策略列表 | array |
list策略列表参数:
参数 | 说明 | 类型 |
---|---|---|
alias | 策略名称 | string |
description | 策略描述 | string |
relatedCount | 策略关联的资源数 | int |
edit | 策略是否可编辑 | bool |
canDel | 策略是否可删除 | bool |
classCode | 策略所属的资源类型 | string |
函数入参:
参数 | 说明 | 类型 |
---|---|---|
params | 接口请求参数 | object |
type | 策略操作类型 | stirng |
请求参数:
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
scope | 策略权限类型, 全局/我的 | string | - |
alias | 策略名称 | string | - |
description | 策略描述 | string | - |
classCode | 资源类型 | string | - |
id | 复制策略时,需要传递复制的策略Id | string | - |
[
{
key: 'global',
tab: '全局策略',
editable: false,
copy: true,
copyToTarget: [{
key: 'global',
name: '全局策略'
}, {
key: 'user',
name: '我的策略'
}]
}, {
key: 'user',
tab: '我的策略',
editable: true
},
...
]
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
tab | 策略角色名称 | string | - |
editable | 该角色下的策略是否可以编辑 | bool | - |
copy | 该角色下的策略是否可以复制,如editable为true, 默认可以复制 | bool | - |
showAuthorized | 是否可授权 | bool | - |
copyToTarget | 复制策略弹窗是否可以选择复制该策略到哪个角色策略列表中。参考copyToTarget格式定义 | array | - |
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
key | 策略角色类型, 全局/我的 | string | - |
name | 策略角色名称 | string | - |
Copyright 2013 - present © cnpmjs.org